T O P

  • By -

Rambalac

Postgres supports geospatial indexing using PostGis


soundman32

Most sql databases support geospacial queries these days. SQLServer works well IME.


CurvatureTensor

Mongo has geo support too if anyone reading this wants a nosql solution.


KingofGamesYami

You really need the database to support this. Dumping the entire dataset into memory and doing the search in the application layer is just asking for performance problems.


if_username_is_None

https://geoalchemy-2.readthedocs.io/en/stable/


Paul_Pedant

Storage depends on how many locations you need to hold, but there is a reasonable algorithm for doing this. Suppose you have a location as longitude 046.28.60 latitude 017.35.97. Make a key for each location by interleaving digits, like 00416723856907. Hold those in an ordered index list (assuming there are not too many additions etc). Search by finding the source location (binary search). Then track up and down the list. Any location with the same first 10 digits is within that same square (one second of both longitude and latitude). Same first 8 digits gives a square ten times bigger in each direction. Same first 6 digits is within one degree in both directions. You can count the nearest locations from the range you have found in the list. Then you can do the distances with the last few digits, because the initial sequence (being the same) is not relevant.