Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Equivalent of atn function
Message
From
13/04/2010 12:49:11
 
 
To
13/04/2010 06:32:22
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01459871
Message ID:
01459968
Views:
42
>I think you can replace 4*((4*atn(1/5))-(atn(1/239))) by PI()
>
>And if you store the Latitude and Longitude in radians, then it becomes
>
>SET XAxis = cos([TABLENAME].Latitude) * cos([TABLENAME].Longitude)
>
>
>likewise
>SET YAxis = cos([TABLENAME].Latitude) * sin([TABLENAME].Longitude)
>SET ZAxis = sin([TABLENAME].Latitude)
>
>
Thanks

I just want to verify that part. My code to replace those values are as follow:
UPDATE test SET XAxis = (cos(((PI())/180)*Latitude)*cos(((PI())/180)*Longitude))
UPDATE test SET XAxis = (cos(((PI())/180)*Latitude)*sin(((PI())/180)*Longitude))
UPDATE test SET ZAxis = (sin(((PI())/180)*Latitude))
Then, applying the related code would give the image attached:
declare @CenterLat float=47.7795
declare @CenterLon float=-65.7191
declare @EarthRadius float=6371 
declare @SearchDistance float=10000

declare @CntXAxis float
declare @CntYAxis float
declare @CntZAxis float

set @CntXAxis = cos(radians(@CenterLat)) * cos(radians(@CenterLon))
set @CntYAxis = cos(radians(@CenterLat)) * sin(radians(@CenterLon))
set @CntZAxis = sin(radians(@CenterLat))

select *,  ProxDistance = @EarthRadius * acos( XAxis*@CntXAxis + YAxis*@CntYAxis + ZAxis*@CntZAxis)
from test
where  @EarthRadius * acos( XAxis*@CntXAxis + YAxis*@CntYAxis + ZAxis*@CntZAxis) <= @SearchDistance
order by ProxDistance ASC
The code works, but the distance calculated is enormous. There is only about 12 to 16 km between those two coordinates.
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