Find all records within radius by coordinates between 2 tables

86 Views Asked by At

I have 2 tables: Oracle and Master. In Master table I have coordinates for each record, which were fetched using Geocoding API from Google. For Oracle I had only addresses, so I filled coordinates using the same API and some custom script (coordinates for matching records between 2 tables may slightly vary). My task is to match records between 2 tables. While I have no IDs or anything that would allow me to do that, I decided to go with coordinates, but some records (especially in big cities centers might be very close to each other).

First validation will be checking if both Lat and Lng match with 0.00001 precision, that should give me around 1-2m radius. Second validation will be checking for each record in Master table, what records from Oracle lie within 100m radius (in case nothing is found in first validation). In such cases it's gonna be a manual step to validate if whatever is found is a valid match).

I do all of that locally so I can play with column types and such, so all ideas are welcome.

Output: New column/columns created in Master table with references to Oracle records within radius. Not sure about the new column type to work with lists. I can add a new UUID column in Oracle and use these IDs as Foreign key.

I've heard of Haversine formula, but didn't manage to get it working for 2 tables.

0

There are 0 best solutions below