Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proximity search
Message
From
14/04/2010 03:22:34
 
 
To
14/04/2010 03:21:17
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:
01460117
Views:
24
>Maybe I should use LatitudePlusDistance/LongitudePlusDistance from http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-zipcode-latitude-longitude-pr

Try this simplified version and see if you could get something better:
DECLARE @CenterLat Float=47.7795
DECLARE @CenterLon Float=-65.7191
DECLARE @SearchDistance Float=250

SELECT Result.Latitude,Result.Longitude
 FROM (SELECT * FROM Test T
 CROSS APPLY (SELECT SIN(@CenterLat/57.2957795130823)*SIN(Latitude/57.2957795130823)+
 COS(@CenterLat/57.2957795130823)*COS(Latitude/57.2957795130823)*
 COS(Longitude/57.2957795130823-@CenterLon/57.2957795130823) AS Temp) Temp
 WHERE (Latitude>=@CenterLat-@SearchDistance/111.0 AND Latitude<=@CenterLat+@SearchDistance/111.0) AND
 (Longitude>=@CenterLon-@SearchDistance/111.0 AND Longitude<=@CenterLon+@SearchDistance/111.0)) Result
 WHERE 3958.75586574*ACOS(CASE WHEN Temp > 1 THEN 1 WHEN Temp < -1 THEN -1 ELSE Temp END)<=@SearchDistance
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
Reply
Map
View

Click here to load this message in the networking platform