Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proximity search
Message
From
13/04/2010 13:00:24
 
 
To
13/04/2010 12:42:26
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:
01459970
Views:
30
>
>So, if I am at latHere and lonHere (consider lat and lon to be stored in degrees
>
>
>
>select .... where
>            lat between latHere - 1/111 * 20  and latHere + 1/111 * 20
>    and   lon between lonHere - 1/111 * 20 and lonHere + 1/111 * 20
>  and (calculatedDistance < 20 ) 
>
>
>You may add a bit to the range to be sure, like 2 km or so
>
>RangeAdd = 2/111
>
><pre>
>select .... where
>            lat between latHere - 1/111 * 20 - RangeAdd  and latHere + 1/111 * 20 +RangeAdd 
>    and   lon between lonHere - 1/111 * 20  - RangeAdd and lonHere + 1/111 * 20 + RangeAdd 
>  and (calculatedDistance < 20 ) 
>
>
>
Thanks, when I try this:
declare @CenterLat float=47.7795
declare @CenterLon float=-65.7191
declare @SearchDistance float=10000

select * 
from test where
latitude between @CenterLat - (1/111 * @SearchDistance)  and @CenterLat + (1/111 * @SearchDistance) and
longitude between @CenterLon - (1/111 * @SearchDistance) and @CenterLon + (1/111 * @SearchDistance)
It only returns one record however those two records in my table are only 12 to 16 km away. I have attached the table image.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform