Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proximity search
Message
De
14/04/2010 06:59:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/04/2010 03:01:13
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01459851
Message ID:
01460124
Vues:
26
>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 )
>	
>
>	
>
Spatial methods work but an area within a fixed distance from a point is not a rectangular area. Instead try STBuffer(). ie:
DECLARE @area geography;
SET @area = @Here.STBuffer( @SearchDistance * 1000 );

select *, 
		@Here.STDistance(ci_pos)/1000.0 as distanceKm,
		ci_pos.Lat as Latitude, 
		ci_pos.Long as Longitude
		from @City 
	where	@area.STIntersects( ci_pos ) = 1;
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform