Reputation: 87
I a working on GPS location where i need to convert latitude and longitude in corresponding address. I have a database of all latitude and longitude(more than 1,50,000 data) with its actual landmark i.e. address in one master table.
We have installed GPS device on many vehicles which is moving across all geographic location. Every 2 minute this device sends the actual position in term of latitude and longitude, i get this latitude and longitude and maps to our Master table and check near by which landmark from our master table. For doing this calculation i do some mathematical operation to add some delta value to latitude and longitude get from vehicle and then find the nearest search from my master table, once we find we show vehicle is 5 KM from XYZ location, we get XYZ location from master table which is nearest point.
This program basically takes lot of time to calculate the location, since we have 10,000 GPS devices installed on Vehicle and every device send GPS data in 2 minute, so you may imagine how much data we do get.
Could you please help me to fix this issue and make it very scalable and fast.
Thanks in advance.
Upvotes: 0
Views: 130
Reputation: 9170
How about using a GIS layer on your db? Something like PostGIS adds a new layer to sql with just that kind of functinality. From an FAQ:
3.7. What is the best way to find all objects within a radius of another object?
To use the database most efficiently, it is best to do radius queries which combine the radius test with a bounding box test: the bounding box test uses the spatial index, giving fast access to a subset of data which the radius test is then applied to.
The ST_DWithin(geometry, geometry, distance) function is a handy way of performing an indexed distance search. It works by creating a search rectangle large enough to enclose the distance radius, then performing an exact distance search on the indexed subset of results.
For example, to find all objects with 100 meters of POINT(1000 1000) the following query would work well:
SELECT * FROM geotable WHERE ST_DWithin(geocolumn, 'POINT(1000 1000)', 100.0);
Upvotes: 1