« Return to Thread: Spatial query for the Nearest location given a lat and long?

Re: RE: Spatial query for the Nearest location given alat and long?

by Rick Zoolker :: Rate this Message:

Reply to Author | View in Thread

Looks like you got it.  FYI, ST_Point($longitude, $latitude) will work
slightly faster than using the GeomFromText().  Also, as Regina
mentioned, you won't be making use of any spatial indicies here, so
the query will run slower than what would be possible.

On 8/13/07, bdbeames <bdbeames@...> wrote:

>
> Results
>
> Ok, I think it is working.
>
> Here what I got for future reference
>
> Given a $latitude and $longitude point I query table_1 to find the
> closest/nearest location points.
>
> SELECT id, name,
>    distance_sphere(GeomFromText('POINT('|| $longitude ||' '|| $latitude
> ||')'),
>    GeomFromText('POINT('|| table_1.longitude ||' '|| table_1.latitude
> ||')')) as dist
> FROM table_1
> WHERE active = 't'
> ORDER BY dist LIMIT 5;
>
> Thanks again for all the help
> --
> View this message in context: http://www.nabble.com/Spatial-query-for-the-Nearest-location-given-a-lat-and-long--tf4253824.html#a12133535
> Sent from the PostGIS - User mailing list archive at Nabble.com.
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@...
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

 « Return to Thread: Spatial query for the Nearest location given a lat and long?