<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=FR-BE link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US>Hello,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I am new in postgis environment and start
to discover this powerful tool.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I am facing problem with the data I have
and need to transform them.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I use a library to render maps based on “painter’s
algorithm”. (We are especially focused on roads transportation elements).<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>So to be more accurate I need to represent
road crossing properly with bridges above tunnels and not the opposite …<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I can match elevation points and road
elements being able to see an “above / below” information but there
is a big problem :<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>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.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>My only solution is to split road elements
into pieces which can have one and only one possible elevation.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I think I will need a function in order to
do this and .. I have never written any SQL function :’(<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The behavior I would reach is<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>From one multilinestring extract the line segment
that intersects my elevation point.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>e.g.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>POINT (2 2)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>MULTILINSTRING((0 0, 3 3, 6 6), (3 3, 3 4,
4 5))<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Returns would be<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>LINESTRING(0 0, 3 3)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>So if I write it in pseudo code, function
prototype should look like :<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>LINESTRING
get_matching_segment(MULTILINESTRING source, POINT needle)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>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.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Any tips about detailed existing functions’
documentation and the way to create custom SQL functions would be greatly
appreciated.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Thank you :-).<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Best regards.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Nicolas<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Gillet<o:p></o:p></span></p>

</div>

</body>

</html>