[postgis-users] match line with road segment

Luigi Castro Cardeles luigi.cardeles at gmail.com
Fri Jul 18 07:03:55 PDT 2008


hi,

just a suggestion: you should try a check to identify the line segment that
don't lies in the road.

ST_PointN(geometry,integer) you can iterate and create the line segments.
then you can run a ST_Contains to check if your road segment matches route
segment.
you should save the information of the line segment after and before the
ST_Contains fails.
with that information you can find the vertice and them interpolate to
create him.

best regards,

Luigi Castro Cardeles

2008/7/18 searchelite <searchelite at gmail.com>:

>
>
> searchelite wrote:
> >
> >
> >
> > Obe, Regina     DND\MIS wrote:
> >>
> >> Now you do your make line.  But you'll have to take into consideration
> >> what Paolo Rizzi said afterward.  Not sure the easiest way to do that.
> >>
> >> So basically your process should look something like the below where
> >> trip_id is some fied that uniquely identifies each trip.  The below
> snaps
> >> each point to closest road segment and then makes a line for each trip.
> >> It assumes the pt.gid is in the order of time travel.  If you have a
> >> datetime field for each point, use that instead of the pt.gid.
> >>
> >>  SELECT trip_id, ST_MakeLine(snapped_point) As trip_route
> >> (SELECT
> >> pt_id,
> >> ln_id,
> >>
> >> ST_Line_Interpolate_Point(
> >>  ln_geom,
> >>  ST_Line_Locate_Point(ln_geom, pt_geom)
> >>  ) As snapped_point,
> >> travel_id
> >>
> >> FROM
> >> (
> >> SELECT DISTINCT ON (pt.gid)
> >>  ln.the_geom AS ln_geom,
> >>  pt.the_geom AS pt_geom,
> >>  ln.id AS ln_id,
> >>  pt.gid AS pt_id,pt.trip_id
> >> FROM
> >> gps_points pt INNER JOIN
> >> road_table ln
> >> ON
> >> ST_DWithin(pt.the_geom, ln.the_geom, 10.0)
> >> ORDER BY
> >> pt.gid,ST_Distance(ln.the_geom, pt.the_geom)
> >> ) AS subquery ORDER BY trip_id, pt_id) As snapped_points
> >> GROUP BY travel_id;
> >>
> >> Hope that helps,
> >> Regina
> >>
> >>
> >
> >
> > thanks a lot for the reply...i'll try the code you give me first thing
> > tomorrow...:-)
> >
> >
>
> basically, the code you gave me just create a line from snapped points
> right? what about matching the route with the road? I want to make the
> route
> like the illustration below
>
> http://www.nabble.com/file/p18522213/untitled.jpg
>
>
> thank you
>
>
>
> --
> View this message in context:
> http://www.nabble.com/match-line-with-road-segment-tp18479996p18522213.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
>
> _______________________________________________
> 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/20080718/b6ff3994/attachment.html>


More information about the postgis-users mailing list