Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MATH - getting rows within a radius
Message
 
À
26/04/2007 15:32:08
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01219992
Message ID:
01220327
Vues:
18
>>I have a table of warrants with latitude and longitude, and I would like to be able to select all warrants within a given radius. I know I've seen this discussed before. Any of you math professors got a clue?
>
>hhmmmm, this calls for pythagoras...
>
>lets say your on position xPos and Ypos and your the location is at xDest and YDest, and your radius is nRad, I'd go for the following solution
>
>
SELECT * FROM Warrants WHERE SQRT((xPos - xDest) ^ 2 + (Ypos - yDest) ^ 2) =< nRad
>
>If its getting to slow you can think of adding additional for the benefit of rushmore like:
>
>
AND xdest BETWEEN xPos - nRad AND xPos + Rad AND yDest BETWEEN yPos - nRad AND yPos + nRad
>
>of course you need indexes on xDest and yDest
>
>Walter,

Thanks Walter, I'll give it a try.
John Harvey
Shelbynet.com

"I'm addicted to placebos. I could quit, but it wouldn't matter." Stephen Wright
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform