[postgis-users] Extract a part of a linestring

Nicolas Gillet - MARKET-IP nicolas.gillet at market-ip.com
Tue Sep 29 05:25:26 PDT 2009


Hello,

 

I am new in postgis environment and start to discover this powerful tool.

 

I am facing problem with the data I have and need to transform them.

I use a library to render maps based on "painter's algorithm". (We are
especially focused on roads transportation elements).

 

So to be more accurate I need to represent road crossing properly with
bridges above tunnels and not the opposite .

 

I can match elevation points and road elements being able to see an "above /
below" information but there is a big problem :

One road element can match many elevation points because a long road element
can be once above and, a few meters further, below another road. It becomes
impossible to order them.

 

My only solution is to split road elements into pieces which can have one
and only one possible elevation.

 

I think I will need a function in order to do this and .. I have never
written any SQL function :'(

 

The behavior I would reach is

>From one multilinestring extract the line segment that intersects my
elevation point.

 

e.g.

POINT (2 2)

MULTILINSTRING((0 0, 3 3, 6 6), (3 3, 3 4, 4 5))

Returns would be

LINESTRING(0 0, 3 3)

 

So if I write it in pseudo code, function prototype should look like :

LINESTRING get_matching_segment(MULTILINESTRING source, POINT needle)

 

I found something about how to split a MULTI* geometry (GeometryN(geometry,
index)), getting points inside a geometry (PointN(geometry, index) or
getting a part of a geometry (Line_SubString(geometry, double, double)), .
but I can't find a way to put them together to get what I want.

 

Any tips about detailed existing functions' documentation and the way to
create custom SQL functions would be greatly appreciated.

 

Thank you :-).

 

Best regards.

 

Nicolas

Gillet

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090929/772e6caa/attachment.html>


More information about the postgis-users mailing list