[postgis-users] segmentize lines with order

2014-02-24 Thread Pedro Costa
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

Re: [postgis-users] segmentize lines with order

2014-02-24 Thread Stephen Woodbridge
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

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Rémi Cura
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 po

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Pedro Costa
Hi Stephen, Thanks, I was searching some function to change draw order of lines but i cannot remembered the postgis function name. Now I'm trying to do a stored procedure to put the lines in the same order. Anybody knows some code example that do something like this? I have little experience w

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Pedro Costa
Hi Rémi, Thanks for your awnser. My problem is that the draw order isn't equal in all lines so the path of st_dumppoints sometimes return ascend order and another times descend. I need to make a loop to make a reverse... Em 25-02-2014 08:33, Rémi Cura escreveu: Hey, I don't understand your p

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Rémi Cura
You can use http://postgis.refractions.net/docs/ST_Reverse.html Or simply ORDER BY DESC for your path Cheers, Rémi-C 2014-02-25 11:49 GMT+01:00 Pedro Costa : > Hi Rémi, > > Thanks for your awnser. > My problem is that the draw order isn't equal in all lines so the path of > st_dumppoints som

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Pedro Costa
thanks Remi. I'm tying to make a stored procedure to use st_reverse when draw order is wrong. Now, my difficult is in writing the loop. I can't find something like that to guide me... Em 25-02-2014 11:11, Rémi Cura escreveu: You can use http://postgis.refractions.net/docs/ST_Reverse.html Or

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Rémi Cura
You don't need a stored procedure, you can simply use pure sql with the CASE WHEN ... THEN .. WHEN .. THEN .. .. END. doc : http://www.postgresql.org/docs/9.3/static/functions-conditional.html If you still need plpgsql : http://www.postgresql.org/docs/9.3/static/plpgsql-control-structures.html#PL

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Pedro Costa
I was trying CASE before but i doesn't know how to access 'next line start point'. Example: SELECT CASE WHEN (ST_Intersects(ST_EndPoint(geom),(SELECT ST_StartPoint(geom) FROM lines WHERE seq = seq+1))) <--- I need to get next line geom THEN 1 ELSE 0 END AS revers

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Rémi Cura
I still don't understand what you are trying to do, if you want to access the next row of a querry, you need to order the row . So what does "next line" mean? How is this information stored? It is possible to access other rows using windows function : http://www.postgresql.org/docs/9.3/static/func

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Pedro Costa
With next line I mean next ' line geom' . I need to verify if endPoint of line 1 is the same as start point of line 2. My problem is when I have a lot of lines with 'draw order wrong'. See ss atached, i need to reverse line 2, 3 and 4. Do you undestand me now? Or not :-)? My query: SELECT

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Stephen Woodbridge
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. -S

Re: [postgis-users] segmentize lines with order

2014-02-25 Thread Rémi Cura
OK, first you may try this trick , which will be way faster to write : _get all start point of lines and all end points (without duplicates) _merge all the lines into one (I'm guessing they are all connected, and don't form loop) _cut the merged line with the points . The trick is that the merge

Re: [postgis-users] segmentize lines with order

2014-02-26 Thread Pedro Costa
Thanks guys, Remi, I'm already tried the second trick and doesn't work because when I break the lines I get the original draw order. But the second trick help me a lot because I do not know 'lag'. After play with that function I have success: http://pastebin.com/eC4PGq3Q I have no sure if can

Re: [postgis-users] segmentize lines with order

2014-02-26 Thread Rémi Cura
Cool, glad it works :-) Cheers, Rémi-C 2014-02-26 13:08 GMT+01:00 Pedro Costa : > Thanks guys, > Remi, I'm already tried the second trick and doesn't work because when I > break the lines I get the original draw order. > But the second trick help me a lot because I do not know 'lag'. After pla