<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">Would be much easier to send your graph to python <a href="https://networkx.github.io/">networkx</a><br></div><div class="gmail_default" style="font-family:monospace,monospace">If you have plpython, this is <a href="https://github.com/Remi-C/PPPP_utilities/blob/69fcb68fb27ba4120426b457950699b89453abf3/postgres/rc_connected_components.sql#L368">immediate</a> (line 368)<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br>I found it painful  to work on graph in pgsql (or pgrouting, besides the excellent already written functions),<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">much easier with dedicated tools.<br><br><br></div><div class="gmail_default" style="font-family:monospace,monospace">If you really really want to use pgsql,<br></div><div class="gmail_default" style="font-family:monospace,monospace">you can use pure SQL with a  recursive CTE,<br></div><div class="gmail_default" style="font-family:monospace,monospace">as in <a href="https://github.com/postgis/postgis/blob/3beb3f82ba78cb98478637f380070839472c8fb3/topology/sql/query/GetRingEdges.sql.in">postgis </a><a href="https://github.com/postgis/postgis/blob/3beb3f82ba78cb98478637f380070839472c8fb3/topology/sql/export/TopoJSON.sql.in">topology.</a><br><br></div><div class="gmail_default" style="font-family:monospace,monospace">I find it hard to test and debug though<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Cheers,<br></div><div class="gmail_default" style="font-family:monospace,monospace">Rémi-C<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-07-13 4:17 GMT+02:00 Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Opened an enhancement request to pgrouting:<br>
<a href="https://github.com/pgRouting/pgrouting/issues/625" rel="noreferrer" target="_blank">https://github.com/pgRouting/pgrouting/issues/625</a><div class="HOEnZb"><div class="h5"><br>
<br>
On 7/12/2016 9:56 PM, Stephen Woodbridge wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sounds like you want a "graph" based on the road network topology like<br>
what is used in pgRouting. Then given the graph do a depth first<br>
traversal of the topology, labeling the edges as you go.<br>
<br>
If you build the graph topology (not the postgis topology), the you can<br>
probably write a recursive query to do the traversal and labeling. I<br>
think I would probably write a pgsql function(s) to traverse the graph<br>
and label the edges.<br>
<br>
Unfortunately, pgRouting does not have depth first search function built<br>
into it, hence the need to code one in pgsql.<br>
<br>
-Steve<br>
<br>
On 7/12/2016 5:16 PM, Dan Jacobson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to go down the (all unnamed) roads in my future mountain<br>
community assigning house numbers every 50 meters.<br>
<br>
   50-100   170-200<br>
    /         /<br>
1  / 107 147 /  213<br>
+-+---+---+-+----+--240--main-road--<br>
2 48   \   168<br>
        \<br>
      120-140<br>
<br>
I stay on my main road, but whenever encountering a fork, first go<br>
down it.<br>
"Depth first pre-order ordered labeled rooted binary tree traversal<br>
but with central path"?<br>
<a href="http://math.stackexchange.com/questions/1856814/binary-tree-traversal-with-fixed-final-node" rel="noreferrer" target="_blank">http://math.stackexchange.com/questions/1856814/binary-tree-traversal-with-fixed-final-node</a><br>
<br>
<br>
OK for PostGIS, given a few linestrings, I suppose I first (somehow)<br>
connect them to form a network, then ride my virtual car down it. And<br>
whenever my odometer reaches another 50m, make a mark on the centerline.<br>
(Assume a strict binary tree (mountain roads with no 4-way junctions))<br>
At each road junction I first choose a side road, and if already on a<br>
side road, first choose the left road, before choosing the right road.<br>
When backtracking turn off my odometer, until finally back on to my main<br>
road.<br>
<br>
Holy smokes, sounds tough. Can I do this with PostGIS or should I go<br>
back to GRASS or what?<br>
<br>
(I am thinking instead of using ST_OffsetCurve (previous project, thanks<br>
Sandro) to put odd on the left even on the right, down the centerline<br>
I'll just put odd numbers at 25, 75m, padded "1 ", and even at 50, 100m<br>
reverse padded " 2".) These points and their labels are what I want<br>
for output.<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>
</blockquote>
<br>
<br>
---<br>
This email has been checked for viruses by Avast antivirus software.<br>
<a href="https://www.avast.com/antivirus" rel="noreferrer" target="_blank">https://www.avast.com/antivirus</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><br>
</blockquote>
<br>
<br>
---<br>
This email has been checked for viruses by Avast antivirus software.<br>
<a href="https://www.avast.com/antivirus" rel="noreferrer" target="_blank">https://www.avast.com/antivirus</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></div></div></blockquote></div><br></div>