[postgis-users] segmentize lines with order

Stephen Woodbridge woodbri at swoodbridge.com
Tue Feb 25 06:20:26 PST 2014


If you have an ordered collection of linestrings like the output of 
pgRouting that all touch end to end but some have the direction reversed 
and you can to convert that into an ordered list of coordinates, then 
you have to find and reverse the strings that are oriented the wrong 
direction.

-Steve

On 2/25/2014 3:33 AM, Rémi Cura wrote:
> Hey,
> I don't understand your problem.
>
> If you have multilinestring, you need to break it to linestring with an
> id per multilinestring.
> If you have linestring, you just need to keep an id for each line and an
> id per point (given in path).
>
> Then you have several option to generate a ordered set of point (use the
> ORDER BY and the row_number() postgres function).
>
> If you give some detailled example maybe we could help better.
>
> Cheers,
> Rémi-C
>
>
> 2014-02-24 19:27 GMT+01:00 Stephen Woodbridge <woodbri at swoodbridge.com
> <mailto:woodbri at swoodbridge.com>>:
>
>     On 2/24/2014 11:33 AM, Pedro Costa wrote:
>
>         Hi guys,
>
>         I'm trying to use lines from postgis to google maps android.
>         To do that, I'm converting the lines to points with
>         St_DumpPoints and,
>         in gmaps, I make the lines. My problem is that I cannot create a
>         correct
>         sequence to order the points in android and so i get wrong lines
>         (see ss
>         atached). I'm already try to use st_dumpPoints path column and
>         generate
>         a serial but doesn't result.
>
>         Anybody knows a solution to resolve that?
>
>
>     You probably need to write function that re-orients you lines before
>     you dump them to points. The algorithm is like this:
>
>     1. for the first edge, if the start point match the the start or end
>     of the 2nd edge, if it does then st_reverse() the first edge.
>
>     2. for the rest of the edges, if the edge point of the current edge
>     matches the end point of the last edge, then st_reverse() the
>     current edge.
>
>     You might be able to st_union all the edges into one large edge and
>     that should create a new reorder edge.
>
>     No you can dump them and the order will be correct.
>
>     -Steve
>     _________________________________________________
>     postgis-users mailing list
>     postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org>
>     http://lists.osgeo.org/cgi-__bin/mailman/listinfo/postgis-__users
>     <http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users>
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list