2

I'm looking for a way to detect if 2 points are "near enough" each other for a match, and hopefully, if the range could be specified in metric system (each item may have different ranges, but there would be no change once it has been inserted).

I have already used Distance before for things like this, though the amount of data was significantly less, now I'm afraid it would be too slow for what I need.

Using simple logic, I thought about the fastest way to calculate that would be to do half the calculation already on the table, since one of the points has a constant range and location (neither can be changed later, worst case scenario, range can be changed, but then only need to update circle area), I could instead save it as a Circle format.

I'm not really sure, But as I looked more on it I reached a conclusion that usual GIS functions use the Cartesian Coordinate System for its calculations, which could work fine under a certain limited area, but because I would be working with GPS coordinates, I'm afraid that the farther away from points 0°,0°, the bigger the error margin may be too big (The radius could be from a few meters to a few Kms) and but I'm not sure if there are functions for Geographic Coordinates, or if anyone knows a way to draw a "deformed circle" accordingly based on the base latitude point.

3
  • What software are you using or is this a coded solution (in which case, which language)? The answer will depend on it. Commented Sep 1, 2017 at 12:54
  • I want to put this directly into the database, it has not been decided yet, I was considering PostgreSQL, but if a NoSQL DB does it better, I could try to implement it there too.
    – ssj4maiko
    Commented Sep 1, 2017 at 12:56
  • I would think PostgreSQL/PostGIS extension would work. Enable PostGIS extension on your database, add geometry column to table, write query that buffers two records, and checks to see if their buffers intersect or not.
    – artwork21
    Commented Sep 1, 2017 at 13:00

1 Answer 1

3

If you are using PostGIS as per your comments, then read this. It will tell you the best function to use in your case for speed. ST_DWithin will use geography data types and so can calculate on a spheroid for greater accuracy with long distance.

1
  • Can't test right now, but from the description I reading, it does seem to do what I want, and it works directly with points and metric system. so no need to convert anything. Thanks for the heads up!
    – ssj4maiko
    Commented Sep 1, 2017 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.