Graphql-engine: Updating postgres geometry column has weird results. Not writing correct coordinates

Created on 28 Sep 2020  路  2Comments  路  Source: hasura/graphql-engine

I have a table with both geography and geometry types. I use google to fetch lat and long and enrich the columns when a user creates a location. When I write to geometry and geography, geography returns a different coordinate than provided in variables.

Expected result is correct lat and long updated in correct column.

Not expected. Random locations populated in my database.

Any insight appreciated!

image

Most helpful comment

GeoJSON describes an order for coordinates: they should go, in order: [longitude, latitude, elevation]

Geography is a spatial data type used to represent a feature in geodetic coordinate systems.

Geometric data types represent two-dimensional spatial objects

You are sending a mutation to Hasura with the coordinate in the wrong order [latitude, longitude]. Since your longitude value is not valid in the geodetic coordinate system. The value is saved wrong in the database.

For the geometric type it is saving the way you are sending since the geometric type is just a two-dimensional spatial object and has nothing to do with the geodetic coordinate system.

All 2 comments

GeoJSON describes an order for coordinates: they should go, in order: [longitude, latitude, elevation]

Geography is a spatial data type used to represent a feature in geodetic coordinate systems.

Geometric data types represent two-dimensional spatial objects

You are sending a mutation to Hasura with the coordinate in the wrong order [latitude, longitude]. Since your longitude value is not valid in the geodetic coordinate system. The value is saved wrong in the database.

For the geometric type it is saving the way you are sending since the geometric type is just a two-dimensional spatial object and has nothing to do with the geodetic coordinate system.

Thanks @leoalves for clearing that up!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rikinsk-zz picture rikinsk-zz  路  3Comments

revskill10 picture revskill10  路  3Comments

sachaarbonel picture sachaarbonel  路  3Comments

jjangga0214 picture jjangga0214  路  3Comments

marionschleifer picture marionschleifer  路  3Comments