<div dir="ltr">This is the query I have so far:<div><div>WITH RECURSIVE flow(gid, geom) AS (</div><div>    SELECT e.gid, e.geom FROM electric_line e WHERE e.gid = 3312</div><div>  UNION ALL</div><div>    SELECT n.gid, n.geom</div><div>    FROM electric_line n, flow f</div><div>    WHERE ST_DWithin(ST_EndPoint(f.geom),ST_StartPoint(n.geom),0.01)</div><div>  )</div><div>UPDATE electric_line SET geom = ST_Reverse(electric_line.geom) FROM flow WHERE electric_line.gid = flow.gid;</div></div><div><br></div><div>Is it possible to add an If statement that would only update if the EndPoint is not StartPoint of the next the line?</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 13, 2016 at 8:37 AM Leknín Řepánek <<a href="mailto:godzilalalala@gmail.com">godzilalalala@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ST_EndPoint, ST_StartPoint, ST_Reverse.<br>
<br>
On Tue, Sep 13, 2016 at 12:31:07PM +0000, Jonatan Malaver wrote:<br>
> Hello,<br>
><br>
>    I'm trying to come up with a query that would check the direction of a line.<br>
> If the end point is not the start point of the next line to update the line by<br>
> reversing that line. Can anyone give me pointers on how to do it?<br>
><br>
> Thanks,<br>
> Jon<br>
<br>
> _______________________________________________<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" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
<br>
_______________________________________________<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" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div>