Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proximity search
Message
From
13/04/2010 05:48:57
 
 
To
13/04/2010 05:14:16
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01459851
Message ID:
01459896
Views:
42
>>>>>There's also this http://geocoder.ibegin.com/downloads.php
>>>>>
>>>>>US zip codes with longitudes and latitudes
>>>>
>>>>Thank you, this is useful.
>>>>
>>>>I have a class that calculates the distance based on two sets of coordinates. However, I am still curious to know how they do it to calculate so fast that x number of records correspond to a 50 km radius, from a specific location, taking from a 10,000 records table.
>>>
>>>Some things come to mind
>>>
>>>(1) They may also store the lattitude in radians to speed up the calculation
>>>(2) They may have a table that stores all the distances (and update it within a trigger if the coordinates of a city are changed/added)
>>>eg 10,000 cities would be a table of 10,000 * 10,000 / 2 records = 50,000,000 records
>>
>>Calculating the exact distance for every possible 'destination' seems like overkill?
>
>I don't know. Michel was wondering why it was fast.
>
>Of course you can 'heuristically' limit the candidates based on latitude and longitude
>
>But then, if there are only 10,000 cities, I wonder which will be the fastest method - I expect the 'overkill' will

Might depend on what Michel actually wants to do with this. Most likely only expecting a small result set (e.g. 'gas stations within 50 miles' type of thing). And if, for example, you're trying to estimate driving distance then a great circle route may not be more accurate than a cruder approximation....
But it sounds as if Michel doesn't have a problem with performance anyway....

>
>>If this is for the U.S. and only targets within a certain radius are required you could get a rough selection based simply on latitude and longitude.
>>There's pretty much a direct correlation for latitude (110 miles per degree) and given that the the U.S only extends from about 45-25 degrees it will always be between say 80-100 miles per degree of longitude. So grab the max by allowing an extra 20% on longitude then do the exact calculation on that result set? Not having the meridian pass through the country makes it easier as well.....
Previous
Reply
Map
View

Click here to load this message in the networking platform