Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proximity search
Message
From
14/04/2010 03:01:13
 
 
To
14/04/2010 00:57:58
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:
01460113
Views:
43
Michel,

A start

There's a problem with the SearchDistance mapping range for 5,000 km brussels, ie LongMin and LongMax - I do not know why. If I apply min/max and a range of 5,000 km it does not work (tried even 7000)

For small distance tests - no problem
declare @City table
(	ci_Id	int,
	ci_desc	varchar(60),
	ci_pos geography 
	)

insert into @City (ci_Id, ci_desc, ci_pos)
select 1, 'Here', geography::Point(47.77950, -65.7191, 4326)
union all
select 2, 'There', geography::Point(47.5993, -65.6506, 4326)
union all
select 3, 'Brussels', geography::Point(50.00 + 50./60. + 0/3600., 4.0 + 20./60. + 0/3600, 4326)


select * from @City

declare @CenterLat float=47.7795
declare @CenterLon float=-65.7191
declare @SearchDistance float=5000

-- http://en.wikipedia.org/wiki/Latitude_and_longitude
declare @LatitudinalDegreeKm  float = 110.9
declare @LongitudinalDegreeKm  float = 111.3

declare @LatMin float = @CenterLat - @SearchDistance/@LatitudinalDegreeKm
declare @LatMax float = @CenterLat + @SearchDistance/@LatitudinalDegreeKm

declare @LongMin float = @CenterLon - @SearchDistance/@LongitudinalDegreeKm
declare @LongMax float = @CenterLon + @SearchDistance/@LongitudinalDegreeKm

declare @Here geography = geography::Point(@CenterLat, @CenterLon, 4326)



/*
select *, 
		ci_pos.Lat as Latitude,
		ci_pos.Long	as Longitude,
		@Here.STDistance(ci_pos)/1000.0 as distanceKm
		from @City
*/
select *, 
		@Here.STDistance(ci_pos)/1000.0 as distanceKm,
		ci_pos.Lat as Latitude, 
		ci_pos.Long as Longitude,
		@LatMin as lat_min,
		@LatMax as lat_max,
		@LongMin as long_min, 
		@LongMax as long_max
		from @City 

select *, 
		@Here.STDistance(ci_pos)/1000.0 as distanceKm,
		ci_pos.Lat as Latitude, 
		ci_pos.Long as Longitude,
		@LatMin as lat_min,
		@LatMax as lat_max,
		@LongMin as long_min, 
		@LongMax as long_max
		from @City 
	where	(	ci_pos.Lat between @LatMin and @LatMax )
		and	(	ci_pos.Long between @LongMin and @LongMax) 
		and	( @Here.STDistance(ci_pos)/1000.0 <= @SearchDistance )
	

	
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform