I have used
RGEO_FACTORY = RGeo::Geographic.simple_mercator_factory
RGEO_FACTORY.point(lon, lat).projection
But now I want to use sql to implement it. And I have the point(geometry) in the postgis database.
How should I do ?
I have used
RGEO_FACTORY = RGeo::Geographic.simple_mercator_factory
RGEO_FACTORY.point(lon, lat).projection
But now I want to use sql to implement it. And I have the point(geometry) in the postgis database.
How should I do ?
RGeo simple mercator factory docs state that it uses SRID 4326 to store points and SRID 3785 for projections. PostGIS has ST_Transform for that. Here's a nice tutorial covering the topic. Suppose you store your geom field in 'nodes' table and it's in SRID 4326, then you can use ST_Transform to get the same projection as RGeo simple mercator. Use ST_SRID to learn which is your geom field's srid:
If you try to convert geom to the same srid, it doesn't change: