I have an MS SQL database that contains a table with latitude/longitude positions of some devices. These positions are stored in a GEOGRAPHY field. Now I want to get these positions from my node app with Sequelize.
Here's my sequelize model definition:
db.define('StationLocation', {
StationId: { type: Sequelize.INTEGER },
Position: { type: Sequelize.GEOMETRY('POINT') }
}
)
And here's what I currently get:
{
"id":4,
"StationId":1,
"Position":{
"type":"Buffer",
"data":[
230,
16,
0,
0,
1,
12,
25,
159,
112,
57,
112,
200,
73,
64,
0,
0,
0,
128,
184,
247,
26,
64
]
}
}
How can I convert this to latitude and longitude values? Is Sequelize able to do this?
Update: In the example above, the position is this:
Latitude: 51.565924816122966
Longitude: 6.741914749145508
Here's my query:
StationLocation
.findAll({ raw: true })
.then(function(allStationLocations) {
console.dir(allStationLocations[0].coordinates); // Just for debugging
res.send(JSON.stringify(allStationLocations));
});
This translates to this SQL statement:
SELECT [id], [StationId], [Position] FROM [StationLocations] AS [StationLocation];