I am looking for a way to join all lines that are connected, have the same direction, i.e. start point of one is end point of the other, and share some common attributes. In fact, I want to connect oneway streets having an common start/end point and the same oneway direction. I found a way to identify pairs of lines that fulfill these condition:
select a.osm_id, a.name,a.oneway, b.osm_id, b.name,b.oneway, from planet_osm_line a, planet_osm_line b WHERE (st_startpoint(a.way)=st_endpoint(b.way) or st_endpoint(a.way)=st_startpoint(b.way)) and a.oneway=b.oneway ;
I am now looking for a way to merge the geometries of these lines.