[postgis-users] Nearest line from a point
Aurélien FILEZ
kinju59 at gmail.com
Sat Aug 20 06:29:51 PDT 2011
Thank you very much :)
On Sat, Aug 20, 2011 at 2:36 PM, Charles Galpin <cgalpin at lhsw.com> wrote:
> I assume you mean it takes a long time? The key is to create a buffer
> around the point that is as big as you feel necessary to make a match, and
> then in your where clause only match lines that intersect this. That way the
> index is used to limit the number of candidates to get the distance for.
> Something like
>
> where line && st_expand(myPoint, bufferSizeInYourProjectionUnits)
>
> hth
> charles
>
> On Aug 20, 2011, at 4:56 AM, Aurélien FILEZ wrote:
>
> > Hi,
> >
> > I have two tables, one which define lines (ST_LineString) and a point
> (St_Points).
> >
> > I'm searching to get the nearest line from this point.
> >
> > My first solution was to use this type of query :
> > SELECT
> > id,
> > St_Distance(line, myPoint) d
> > FROM
> > my_lines_tables
> > ORDER BY d ASC LIMIT 1
> >
> > But it's very long. Is there is another way to make this ?
> >
> > Thank you all,
> > Kin
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110820/a2844e29/attachment.html>
More information about the postgis-users
mailing list