Thursday, 18 May 2017

How to get lat/lng coordinates from GEOMETRY('POINT') with Sequelize?

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?



via Robert

No comments:

Post a Comment