简体   繁体   中英

Match Postgis SRID with Redis' spherical model?

I'm using Postgres (with PostGIS) and I have geometry columns which have the SRID of 4326. In my stack, Redis is acting as a cache and holds the location data using it's geo functionality , specifically, let's say I have a location in Postgres like so:

INSERT INTO locations(geom) VALUES(ST_GeomFromText('POINT(40.7547 -73.9614)', 4326)) RETURNING 'id';

Then the object gets added to Redis:

redis> GEOADD someId -73.9614 40.7547

The question is, because Redis uses a totally spherical model of the globe, is it beneficial to use a similarly spherical model SRID for postgres? I found EPSG:4047 which is a sphere.

Are there time, accuracy, or other benefits or pitfalls I'm not seeing?

Keep the data in EPSG:4326, if all computations are to be done in the Redis environment it won't matter; you cannot pass in spatial reference information, and Redis seems to assume the WGS84 based (Spherical) Web Mercator projection ('seems' because they state to use a wrongly assigned and deprecated EPSG code for it...), at least for their indexing implementation.

The distance calculation via Haversines is unaffected by changing between those reference systems (and the CRS that Redis uses); the formulae work independent from any spatial reference other than the spherical radius.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM