<div dir="ltr">Yep, <div>would need some wrapping to output right path :-) </div><div><br></div><div>I'd really like to have more functions in PostGis...</div><div><br></div><div>I'm not going to do it yet, working on a SnapToLine function.</div>
<div><br></div><div>Cheers,</div><div>Rémi-C</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/30 Nicolas Ribot <span dir="ltr"><<a href="mailto:nicolas.ribot@gmail.com" target="_blank">nicolas.ribot@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
To dump (multi)polygons boundaries, you can use:<br>
st_exteriorRing((st_dumpRings((st_dump(geom)).geom)).geom)<br>
<br>
I returns one linestring for each boundary, taking holes into account.<br>
<span class="HOEnZb"><font color="#888888"><br>
Nicolas<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 30 October 2013 14:34, Rémi Cura <<a href="mailto:remi.cura@gmail.com">remi.cura@gmail.com</a>> wrote:<br>
> Hey,<br>
> here is the function, safe for geometry collection and multilinestring as<br>
> well.<br>
> It mimics ST_DumpPoints.<br>
><br>
> It doesn't work on polygon as we would first need a method STDumpLines.<br>
><br>
><br>
> Origine of segments is preserved inside the path when multi.<br>
> Could it be added to core ?<br>
> Shall I add a ticket?<br>
><br>
> Cheers,<br>
> Rémi-C<br>
><br>
> /////////////////////////////////<br>
><br>
> DROP FUNCTION IF EXISTS public.DumpSegments(line geometry ) ;<br>
> CREATE OR REPLACE FUNCTION public.DumpSegments(_line geometry)<br>
> RETURNS SETOF geometry_dump<br>
> AS<br>
> $BODY$<br>
> --this function breaks a line into minimal segments and return it<br>
> DECLARE<br>
> _r record;<br>
> BEGIN<br>
><br>
> FOR _r in SELECT ST_Dump(ST_CollectionExtract (_line,2)) AS dp<br>
> LOOP<br>
> RETURN QUERY WITH line AS(<br>
> SELECT --ST_GeomFromText('LINESTRING(12 1, 13 1, 14 2, 15 4)') AS line<br>
> (_r.dp).path AS gpath, (_r.dp).geom AS line<br>
> ),<br>
> dump AS(<br>
> SELECT gpath[1] AS gpath, (ST_DumpPoints(line)) as dp<br>
> FROM line<br>
> ),<br>
> segments AS (<br>
> SELECT CASE WHEN gpath IS NULL THEN ARRAY[(dp).path[1]-1] ELSE ARRAY[gpath,<br>
> (dp).path[1]-1] END AS path,ST_MakeLine( lag((dp).geom , 1, NULL) OVER<br>
> (ORDER BY  (dp).path),(dp).geom) AS geom<br>
> FROM dump<br>
> )<br>
> SELECT path,geom<br>
> FROM segments<br>
> WHEre geom  IS NOT NULL;<br>
> END LOOP;--loop if multi linestring<br>
> RETURN;<br>
> END;<br>
> $BODY$<br>
>  LANGUAGE plpgsql  IMMUTABLE STRICT;<br>
><br>
><br>
> SELECT public.DumpSegments(line2)<br>
> FROM ST_GeomFromText('MULTILINESTRING((12 1, 13 1, 14 2, 15 4),(1 1, 2 2,3<br>
> 3))') AS line1,ST_GeomFromText( 'LINESTRING(12 1, 13 1, 14 2, 15 4)') AS<br>
> line2<br>
><br>
><br>
><br>
><br>
> //////////////////////////////////////<br>
><br>
><br>
><br>
><br>
> 2013/10/30 Rémi Cura <<a href="mailto:remi.cura@gmail.com">remi.cura@gmail.com</a>><br>
>><br>
>> Thanks,<br>
>> wanted to do it the clean way (geos accelerated maybe?),<br>
>><br>
>> but not so much a big deal, I'll go you way.<br>
>><br>
>> Cheers,<br>
>> Rémi-C<br>
>><br>
>><br>
>> 2013/10/30 Nicolas Ribot <<a href="mailto:nicolas.ribot@gmail.com">nicolas.ribot@gmail.com</a>><br>
>>><br>
>>> Hi,<br>
>>><br>
>>> I don't think such a function exists in postgis.<br>
>>> (To achieve that, I usually dump line points and create new<br>
>>> linestrings with vertices n, n+1)<br>
>>><br>
>>> Nicolas<br>
>>><br>
>>> On 30 October 2013 10:59, Rémi Cura <<a href="mailto:remi.cura@gmail.com">remi.cura@gmail.com</a>> wrote:<br>
>>> > Hey,<br>
>>> > is somebodyers aware of a function breaking a linestring into a set of<br>
>>> > segments (mathematical meaning),<br>
>>> > without introducing new points?<br>
>>> ><br>
>>> > Cheers,<br>
>>> ><br>
>>> ><br>
>>> > Rémi-C<br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > postgis-users mailing list<br>
>>> > <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
>>> > <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
>>> _______________________________________________<br>
>>> postgis-users mailing list<br>
>>> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
>>> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
>><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div>