<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Il giorno 28 marzo 2013 19:35, Groppo <span dir="ltr"><<a href="mailto:groppo8@gmail.com" target="_blank">groppo8@gmail.com</a>></span> ha scritto:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Il giorno 28 marzo 2013 17:54, emmexx <span dir="ltr"><<a href="mailto:emmexx@tiscalinet.it" target="_blank">emmexx@tiscalinet.it</a>></span> ha scritto:<div>

</div><br><div>È stato ha proposto di segnalare solo le entrate in rotatoria, senza turn_restriction, che hanno una strada laterale, per filtrare i casi più importanti tipo:<br></div></div></div></div></blockquote><div>... <br>

</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Nel tuo esempio, solo l'entrata che arriva dal parcheggio ha una laterale.<br>

<br></div><div>Lo script però avrebbe dovuto escluderla perché la laterale è una ciclabile, quindi... c'è qualcosa che non va (grazie per la segnalazione).<br></div></div></div></div></blockquote><br></div>Ho fatto delle modifiche. Le entrate che hanno come unica laterale una cycleway non dovrebbero più essere segnalate.<br>

<br><div>Ho escluso anche i casi in cui:</div><div>- imboccare l'entrata in rotatoria sia l'unica scelta possibile (<a href="http://osrm.at/2MV" target="_blank">http://osrm.at/2MV</a>)<br>

</div><div>- le laterali dell'entrata sono entranti, a senso unico.<br><br><a href="https://dl.dropbox.com/u/41550819/OSM/inversione_permessa.gpx">https://dl.dropbox.com/u/41550819/OSM/inversione_permessa.gpx</a><br>

</div><div><br></div><div>(~1260 segnalazioni)<br></div><div><br><br></div>Ciao,<br>Groppo<br><br>-- crea tabella con way entranti in rotatoria senza turn sul primo nodo<br>DROP TABLE IF EXISTS all_roundabout_entry_without_turn;<br>

CREATE TABLE all_roundabout_entry_without_turn AS<br>SELECT <a href="http://w2.id" target="_blank">w2.id</a> AS entry_id<br>FROM ways AS w1, ways AS w2, junctions AS j1, junctions AS j2<br>WHERE<br>w1.nodes[1] = j1.node_id AND<br>
w1.nodes[array_upper(w1.nodes, 1)] = w2.nodes[1] AND<br>
w2.nodes[array_upper(w2.nodes, 1)] = j2.node_id AND<br><a href="http://j1.id" target="_blank">j1.id</a> = <a href="http://j2.id" target="_blank">j2.id</a> AND<br>NOT w1.tags ? 'junction' AND<br>NOT w2.tags ? 'junction' AND<br>
w1.tags -> 'oneway' <> 'no' AND<br>
w2.tags -> 'oneway' <> 'no' AND<br>w2.nodes[1] NOT IN (SELECT member_id<br>FROM relation_members WHERE member_type = 'N');<br>CREATE INDEX ON all_roundabout_entry_without_turn (entry_id);<br>

ANALYZE all_roundabout_entry_without_turn;<br><br>-- crea tabella con nodi delle way entranti, tranne primo ed ultimo<br>DROP TABLE IF EXISTS all_roundabout_entry_without_turn_nodes;<br>CREATE TABLE all_roundabout_entry_without_turn_nodes AS<br>

SELECT unnest(w.nodes[2:array_upper(w.nodes, 1)-1]) AS nid, e.entry_id AS entryid<br>FROM all_roundabout_entry_without_turn AS e, ways AS w<br>WHERE <a href="http://w.id" target="_blank">w.id</a> = e.entry_id;<br>CREATE INDEX ON all_roundabout_entry_without_turn_nodes (nid, entryid);<br>

ANALYZE all_roundabout_entry_without_turn_nodes;<br><br>-- trova primo nodo delle way entranti che hanno nodi appartenenti a più way<br>-- laterali, non entranti ed a senso unico<br>DROP TABLE IF EXISTS turn_errors;<br>CREATE TABLE turn_errors AS<br>

SELECT w.nodes[1] AS id<br>FROM ways AS w<br>JOIN (<br>  SELECT e.entryid AS id<br>  FROM way_nodes, all_roundabout_entry_without_turn_nodes AS e, ways AS lat<br>  WHERE node_id = e.nid AND<br>  way_id = <a href="http://lat.id" target="_blank">lat.id</a> AND<br>

  lat.tags -> 'highway' NOT IN ('footway', 'path', 'cycleway') AND<br>  <a href="http://lat.id" target="_blank">lat.id</a> <> e.entryid AND<br>  CASE<br>    WHEN NOT lat.tags ? 'oneway'<br>

      THEN TRUE<br>    WHEN lat.tags -> 'oneway'='no'<br>      THEN TRUE<br>    WHEN lat.tags -> 'oneway'='yes'<br>      THEN sequence_id = 0<br>    WHEN lat.tags -> 'oneway' = '-1'<br>

      THEN sequence_id = array_upper(lat.nodes, 1) -1<br>  END<br>  GROUP BY e.entryid ORDER BY e.entryid<br>  ) AS wrong_entry ON (<a href="http://wrong_entry.id" target="_blank">wrong_entry.id</a> = <a href="http://w.id" target="_blank">w.id</a>);<br>

CREATE INDEX ON turn_errors (id);<br>ANALYZE turn_errors;<br><br>-- rimuovi casi in cui imboccare l'entrata sia l'unica scelta possibile<br>DROP TABLE IF EXISTS roundabout_entry_without_turn;<br>CREATE TABLE roundabout_entry_without_turn AS<br>

SELECT 'n'||<a href="http://n.id" target="_blank">n.id</a> AS osmid, 'no turn' AS desc, n.geom AS geometry<br>FROM nodes AS n<br>WHERE <a href="http://n.id" target="_blank">n.id</a> IN (SELECT wn.node_id<br>
FROM way_nodes AS wn<br>JOIN turn_errors AS error ON (<a href="http://error.id" target="_blank">error.id</a> = wn.node_id)<br>
GROUP BY wn.node_id<br>HAVING Count(wn.node_id) > 2);<br></div></div>