[postgis-users] identfying a nearest point

Supunmali Ahangama supunmali7 at gmail.com
Fri Apr 24 04:31:57 PDT 2009



Daniel Kastl-2 wrote:
> 
> Hi,
>> This is the SQL I tried with:
>>
>> select v.*, c.gid 
>> from vertices_tmp v, customer_location c 
>> where c.gid=1 and 
>> st_expand(setsrid(((select the_geom from customer_location where
>> gid=1)),4326), 10000000) && setsrid(v.the_geom,4326)
>> order by distance(setsrid((select the_geom from customer_location where
>> gid=1),4326),setsrid(v.the_geom,4326))
>> asc limit 1; 
>>
>>   
> Without having tested this "100000000" looks very suspicious.
> This value is in the same projection as your geometry is set: 4326
> 4326 is in degree, so you could try it with 0.1 for example.
> 
> Daniel
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 


No, it does not work. It doesnt show anything when used 0.1 as radius.

and I tried this just considering distance (full table scan):

select v.*, c.gid 
from vertices_tmp v, customer_location c 
where c.gid=1
order by distance(setsrid((select the_geom from customer_location where
gid=1),4326),setsrid(v.the_geom,4326)) asc 
limit 1;  
 
This SQL do not consider the radius, it just consider the distance and scan
the table fully; but it still gives the same answer (which is incorrect). 
Please provide me with some suggestions.
-- 
View this message in context: http://www.nabble.com/identfying-a-nearest-point-tp23193816p23214605.html
Sent from the PostGIS - User mailing list archive at Nabble.com.




More information about the postgis-users mailing list