Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proximity search
Message
From
13/04/2010 14:01:06
 
 
To
13/04/2010 13:49:18
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:
01459996
Views:
26
>>I get both of them
>>
>>	create cursor Coordinates ;
>>	(	co_pk			I, ;
>>		co_city			c(40), ;
>>		co_latitude		b(16), ;
>>		co_longitude	b(16), ;
>>		co_x			b(16), ;
>>		co_y			b(16), ;
>>		co_z			b(16) ;
>>	)
>>	
>>	insert into Coordinates ;
>>		( co_pk, co_city, co_latitude, co_longitude) ;
>>		values ;
>>		(1, 'Here', 47.7795, -65.7191 )
>>	
>>	insert into Coordinates ;
>>		( co_pk, co_city, co_latitude, co_longitude) ;
>>		values ;
>>		(2, 'There', 47.5993, -65.6506 )
>>		
>>	
>>	update Coordinates ;
>>		set	co_x	= cos(co_latitude*PI()/180) * cos(co_longitude*PI()/180), ;
>>			co_y	= cos(co_latitude*PI()/180) * sin(co_longitude*PI()/180), ;
>>			co_z	= sin(co_latitude*PI()/180)
>>	
>>		
>>	CenterLat =47.7795
>>	CenterLon = -65.7191
>>	SearchDistance = 1000
>>	
>>	select * ;
>>		from Coordinates ;
>>		where	( co_latitude between CenterLat - (1/111 * SearchDistance)  and CenterLat + (1/111 * SearchDistance) ) ;
>>			and	( co_longitude between CenterLon - (1/111 * SearchDistance)  and CenterLon + (1/111 * SearchDistance) )
>>
>
>There must be something I am missing here. This is as simple as it gets. I still get only one result:
>
>
>declare @CenterLat float=47.7795
>declare @CenterLon float=-65.7191
>declare @SearchDistance float=1000
>
>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))
>
Try using 1.0/111.0

or (I have also dropped some parentheses in order to avoid surprises
@CenterLat - 1/111 * @SearchDistance

also put SearchDistance before /111
select * from Test
 where(latitude between @CenterLat -  @SearchDistance/111.0  and  @CenterLat + @SearchDistance/111.0 ) and
 (longitude between @CenterLon - @SearchDistance/111.0 and  (@CenterLon + @SearchDistance/111.0) )
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform