Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proximity search
Message
From
14/04/2010 00:50:21
 
 
To
14/04/2010 00:45:48
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:
01460110
Views:
22
>Below the script
>I also attached the output
>
>As to the big distances you get - I see that your calculated XAxis is wrong in the table. The values are almost identical to your YAxis
>
>Also, what I suspected is right. Be careful with the expressions
>This one inserts the right numbers
>
>select 3, 'Brussels', 50.00 + 50./60. + 0./3600.0, 4.0 + 20.0/60.0 + 0.0/3600.0
>
>If I take the dots away as in
>
select 3, 'Brussels', 50.00 + 50/60 + 0/3600, 4.0 + 20/60 + 0/3600
>Then 50.0 and 4.0 get inserted
>
>Which means that 50/60 is evaluated as an integer as both 50 and 60 are integers
>
>
>
>declare @City table
>(	ci_Id	int,
>	ci_desc	varchar(60),
>	ci_latitude	float,
>	ci_longitude	float,
>	ci_x	float,
>	ci_y	float,
>	ci_z	float
>	)
>
>insert into @City (ci_Id, ci_desc, ci_latitude, ci_longitude)
>select 1, 'Here', 47.77950, -65.7191
>union all
>select 2, 'There', 47.5993, -65.6506
>union all
>select 3, 'Brussels', 50.00 + 50./60. + 0./3600.0, 4.0 + 20.0/60.0 + 0.0/3600.0
>
>update @City
>	set ci_x = cos(radians(ci_latitude)) * cos(radians(ci_longitude)), 
>		ci_y = cos(radians(ci_latitude)) * sin(radians(ci_longitude)),
>		ci_z = sin(radians(ci_latitude))
>
>select * from @City
>
>declare @CenterLat float=47.7795
>declare @CenterLon float=-65.7191
>declare @SearchDistance float=250
>declare @EarthRadius float=6371 
>
>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))
>
>-- all distances
>select *, 
>		calculatedDistance = @EarthRadius * acos( ci_x*@CntXAxis + ci_y*@CntYAxis + ci_z*@CntZAxis)
>		from @City
>		
>select test2.*
>	from (
>		select *,
>			calculatedDistance = @EarthRadius * acos( ci_x*@CntXAxis + ci_y*@CntYAxis + ci_z*@CntZAxis)
>			from @City
>			where	(ci_latitude between @CenterLat - @SearchDistance/111.0 and @CenterLat + @SearchDistance/111.0)
>				and	(ci_longitude between @CenterLon - @SearchDistance/111.0 and @CenterLon + @SearchDistance/111.0)
>		) Test2 
>	where (calculatedDistance <= @SearchDistance)
>	 
>	
>
Thanks, this is all correct. There were issues about the . and the formula. As you might have seen by now, we have resolved all this today. There was a lot of great ideas and documentation provided. I was able to fine tune all this and I am now working in building it all in a class.
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