rgeo / activerecord-postgis-adapter

ActiveRecord connection adapter for PostGIS, based on postgresql and rgeo
Other
873 stars 240 forks source link

4326 vs Planar performance #370

Closed joshfester closed 2 years ago

joshfester commented 2 years ago

Sorry if this is the wrong place to ask. I haven't been able to find any info.

Say I'm only calculating distances between two points that are within a maximum ~25 mile radius (to show a user that a store is X miles away). Would using a flat coordinate system be accurate enough? Are there any performance implications using 4326?

EDIT: I found this in the rgeo docs and it looks like I should probably use a flat system. Is that still true with postgis?

keithdoggett commented 2 years ago

Hi @joshfester if you're only doing point-to-point operations then the performance hit of using geographic data types should be negligible and it may be easier to work with since everything will be in lat/lng so you won't have to worry about transforming coordinates.

Since your points are fairly close, a projected coordinate system would definitely work as well, but unless you start working with geometry types other than points, using geographic types will likely be fine.

joshfester commented 2 years ago

Ah thank you so much!! That is super helpful. I will go with a geography type 👍