Reputation: 312
I have a Postgres database with PostGIS running. I'm using Node.js and Sequelize to work with the data within the database. On one of my tables I have a geometry column that is returning weird results.
Normally when I query a geometry column with sequelize I get something along these lines:
{
type: 'Point',
coordinates: [ 33.48051135141372, -111.92908778058047 ]
}
But for some reason when I log the results from this column I get the following string:
01010000004D20CF54F80241409C8C9B8BAE9E5DC0
On other tables I'm getting the expected result. But for some reason with this specific table/column I'm unable to parse the latitude and longitude from the data returned.
Can anyone explain why I might be getting this instead of the normal JSON above?
Upvotes: 3
Views: 895
Reputation: 17836
Coordinates must be expressed as longitude
first, then latitude
.
Your input is expressed as lat
-long
, and so it is out of bounds. Try swapping the coordinates.
Using postgis directly, you can display the textual representation of the geometry:
select st_asText('01010000004D20CF54F80241409C8C9B8BAE9E5DC0');
st_astext
------------------------------------------
POINT(34.023203469406 -118.479403402237)
which does confirm that the coordinates are in the wrong order.
Upvotes: 0