<div dir="ltr">the reason being is that I do a network analysis by running the following function:<div><div>WITH RECURSIVE flow(gid, geom) AS (</div><div>    SELECT e.gid, e.geom FROM electric_line e, transformers t WHERE ST_Distance(t.geom,ST_StartPoint(e.geom)) <= 0.01 AND t.gid=$1</div><div>  UNION ALL</div><div>    SELECT n.gid, n.geom</div><div>    FROM electric_line n, flow f</div><div>    WHERE ST_Distance(ST_EndPoint(f.geom),ST_StartPoint(n.geom)) <= 0.01</div><div>  )</div></div><div>The problem I have is that some of the lines direction are in reversed. I'm trying to correct them with referenced to the first line. Otherwise, I will end up changing hundreds of lines manually.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 13, 2016 at 11:12 AM James Keener <<a href="mailto:jim@jimkeener.com">jim@jimkeener.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Depends on what you mean by direction. If you want to grab the start and end points (st_startpoint and st_endpoint) and check their x and y (st_x and st_y) for some condition (both less at the end?) Then update the record with the value of st_reverse.<br>
<br>
I guess my other question is why it matters.<br>
<br>
Jim<br><br><div class="gmail_quote"></div></div><div><div class="gmail_quote">On September 13, 2016 8:31:07 AM EDT, Jonatan Malaver <<a href="mailto:jon.malaver@shrewsburyma.gov" target="_blank">jon.malaver@shrewsburyma.gov</a>> wrote:</div></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hello,<div><br></div><div>   I'm trying to come up with a query that would check the direction of a line. If the end point is not the start point of the next line to update the line by reversing that line. Can anyone give me pointers on how to do it?</div><div><br></div><div>Thanks,</div><div>Jon</div></div>
<p style="margin-top:2.5em;margin-bottom:1em;border-bottom:1px solid #000"></p></blockquote></div></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre><br>postgis-users mailing list<br><a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a></pre></blockquote></div></div><div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</div></blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Thanks,</span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black"><br></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Jonatan Malaver<u></u><u></u></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Assistant Engineer of Electrical and Cable Operations<u></u><u></u></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Shrewsbury Electric & Cable Operations<u></u><u></u></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">100 Maple Avenue<u></u><u></u></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Shrewsbury, MA 01545<u></u><u></u></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Office: (508) 841-8610<u></u><u></u></span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black">Fax: (508) 842-9267</span></p><p style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:calibri,sans-serif"><span style="color:black"><a href="mailto:jon.malaver@shrewsburyma.gov">jon.malaver@shrewsburyma.gov</a></span></p></div></div>