[postgis-users] MultiLineString element to LineStrings

Steffen Macke sdteffen at gmail.com
Sat Jun 3 01:08:16 PDT 2006


Hi,

>         MultiLineString((x1 y1, x2 y2, ..... ,xn yn))
>
> I need to be able to operate most of the time on a small portion of the road
> based on some queries, e.g., get road segments that are within a certain
> range of a point. By segment, I mean a line connecting two consecutive
> points.

Depending on what you need exactly, the following might work:

line_substring(geometryn('MULTILINESTRING((1 1,0 0))',1),0,0.5)

The measures 0 and 0.5 can be obtained e.g. through line_locate_point().
0 is the beginning of the line.
0.5 is the middle of the line
1 is the end of the line.

If you would like to always use the vertices of the line (without
interpolation),
you should look at the NumPoints() and PointN() functions.

The PostgreSQL function generate_series() will allow you to loop over
several points
in an SQL statement. If that is not sufficient, you may have to create an PL/SQL
function.

Regards,

Steffen



More information about the postgis-users mailing list