Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proximity search
Message
De
13/04/2010 03:35:30
 
 
À
13/04/2010 03:14:47
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01459851
Message ID:
01459876
Vues:
37
>>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
>
>I am looking at this right now:
>
>http://msdn.microsoft.com/en-us/library/ms980211.aspx
>
>As for point 2, in order to know a distance, we need two set of coordinates. So, this can only be known when the user do the search. So, basically, calculation applies at search time only. In the page I have added here, there is a SQL Server code to do this so I am trying it now. But, the more records there is, the more time it will take.

So they precalculate Xaxis, Yaxis and Zaxis for each location

As to point (2) it's possible if you have a table

FK_city1
FK_City2
Distance


The query is then simply:
select  * 
   from DistanceTable 
    where (FK_Where_I_Am in (FK_city1, FK_city2))
     and (Distance < = 50.0)
The result needs to be joined
- with the city table on FK_City2 if (FK_Where_I_Am == FK_city1), and
- with  the city table on FK_City1 if (FK_Where_I_Am == FK_city2)
Can be done with a union
select * 
   from DistanceTable
    join CityTable on (pk_City = FK_City2)
    where ( FK_city1 = FK_Where_I_Am )
     and (Distance < = 50.0)
union all
select * 
   from DistanceTable
    join CityTable on (pk_City = FK_City1)
    where ( FK_city2 = FK_Where_I_Am )
     and (Distance < = 50.0)
Of course, you never store the distance from a city to itself

You need to find a way to store the distance between two cities only once
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform