<div dir="ltr"><div><div>Ciao Andrea,<br><br>grazie della risposta sollecita: nella tua select c'era un errore, una parentesi tonda in più, la versione sintatticamente corretta è questa<br><br>SELECT <br>    lc1.lc_name AS "Tuscan Local Council",<br>
    c1.county_name AS "Tuscan County",<br>    lc2.lc_name AS "Neighbour LC",<br>    c2.county_name AS County,<br>    r2.region_name AS Region<br>FROM <br>    local_councils AS lc1,<br>    local_councils AS lc2<br>
    JOIN counties AS c1 ON (c1.county_id = lc1.county_id)<br>    JOIN counties AS c2 ON (c2.county_id = lc2.county_id)<br>    JOIN regions AS r1 ON (r1.region_id = c1.region_id)<br>    JOIN regions AS r2 ON (r2.region_id = c2.region_id)<br>
WHERE <br>    r1.region_name LIKE 'toscana'<br>    AND r1.region_id <> r2.region_id<br>    AND ST_Touches(lc1.geometry, lc2.geometry)<br>    AND lc2.ROWID IN (<br>        SELECT ROWID FROM SpatialIndex<br>        WHERE f_table_name='MAIN=local_councils' AND search_frame=lc1.geometry<br>
    )<br>ORDER BY c1.county_name, lc1.lc_name;<br><br></div>Ora non dà più errore anche se al momento mi restituisce un insieme vuoto ..... riproverò.<br><br></div> Grazie<br><br><div><div><br><br></div></div></div><div class="gmail_extra">
<br clear="all"><div>Cesare Gerbino<br><br><a href="http://cesaregerbino.wordpress.com/" target="_blank">http://cesaregerbino.wordpress.com/</a><br><a href="http://www.facebook.com/cesare.gerbino" target="_blank">http://www.facebook.com/cesare.gerbino</a><br>
<a href="http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl" target="_blank">http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl</a><br><a href="https://twitter.com/CesareGerbino" target="_blank">https://twitter.com/CesareGerbino</a><br>
<a href="http://www.linkedin.com/pub/cesare-gerbino/56/494/77b" target="_blank">http://www.linkedin.com/pub/cesare-gerbino/56/494/77b</a><br><br></div>
<br><br><div class="gmail_quote">Il giorno 05 gennaio 2014 11:24, Andrea Peri <span dir="ltr"><<a href="mailto:aperi2007@gmail.com" target="_blank">aperi2007@gmail.com</a>></span> ha scritto:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><div><div><div>Premesso che la query in questione sembra scritta per far casino :)<br></div>Infatti usa due volte la medesima tabella local_councils e quindi un utente che deve imparare non capisce se nell'indice deve fare riferimento alla prima o alla seconda tabella (sono entrambe le stesse!).<br>

<br></div>Premesso anche che non ho il tempo di provarla, io credo che questa dovrebbe essere quella corretta.<br></div>Eventualmente si tratta di cambiare da lc1.geometry a lc2.geometry.<br><br></div>Questa è la tua query originale, opportunamente indentata per evidenziarne la struttura:<div>
<div class="h5"><br>
<br>SELECT <br>    lc1.lc_name AS "Tuscan Local Council",<br>    c1.county_name AS "Tuscan County",<br>    lc2.lc_name AS "Neighbour LC",<br>    c2.county_name AS County,<br>    r2.region_name AS Region<br>

FROM <br>    local_councils AS lc1,<br>    local_councils AS lc2 <br>    JOIN counties AS c1 ON (c1.county_id = lc1.county_id)<br>    JOIN counties AS c2 ON (c2.county_id = lc2.county_id)<br>    JOIN regions AS r1 ON (r1.region_id = c1.region_id)<br>

    JOIN regions AS r2 ON (r2.region_id = c2.region_id)<br>WHERE <br>    r1.region_name LIKE 'toscana'<br>    AND r1.region_id <> r2.region_id<br>    AND ST_Touches(lc1.geometry, lc2.geometry)<br>    AND lc2.ROWID IN (<br>

        SELECT pkid FROM idx_local_councils_geometry<br>        WHERE pkid MATCH RTreeIntersects(<br>            MbrMinX(lc1.geometry),<br>            MbrMinY(lc1.geometry),<br>            MbrMaxX(lc1.geometry),<br>            MbrMaxY(lc1.geometry)<br>

        )<br>    )<br>ORDER BY c1.county_name, lc1.lc_name;<br><br><br></div></div></div>Questa altra è come io proverei a tradformarla per usare le ultime novita' di spatialite.<br>Ovviamente si parla di un db generato con la medesima ultima versione di SL.<div class="im">
<br>
<br>SELECT <br>    lc1.lc_name AS "Tuscan Local Council",<br>    c1.county_name AS "Tuscan County",<br>    lc2.lc_name AS "Neighbour LC",<br>    c2.county_name AS County,<br>    r2.region_name AS Region<br>

FROM <br>    local_councils AS lc1,<br>    local_councils AS lc2 <br>    JOIN counties AS c1 ON (c1.county_id = lc1.county_id)<br>    JOIN counties AS c2 ON (c2.county_id = lc2.county_id)<br>    JOIN regions AS r1 ON (r1.region_id = c1.region_id)<br>

    JOIN regions AS r2 ON (r2.region_id = c2.region_id)<br>WHERE <br>    r1.region_name LIKE 'toscana'<br>    AND r1.region_id <> r2.region_id<br>    AND ST_Touches(lc1.geometry, lc2.geometry)<br>    AND lc2.ROWID IN (<br>
</div>
        SELECT ROWID FROM SpatialIndex<br>        WHERE f_table_name='MAIN=local_councils' AND search_frame=lc1.geometry<br>    )<br>)<br>ORDER BY c1.county_name, lc1.lc_name;<br><br><br></div>se invece che nel medesimo db la tabella è in un db allegato, allora fai:<br>

        WHERE f_table_name='DB=allegato.local_councils' AND search_frame=lc1.geometry<br><br><div><div><br></div><div>Saluti,<br></div><div><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

Il giorno 05 gennaio 2014 11:08, cesare gerbino <span dir="ltr"><<a href="mailto:cesaregerbino@gmail.com" target="_blank">cesaregerbino@gmail.com</a>></span> ha scritto:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<div dir="ltr"><div><div><div><div>Ciao a tutti,<br><br></div>ho ripreso per approfondire una cosa SpatialLite Cookbook e sto usando l'ultima versione di spatialite_gui.<br><br></div>Provando ad eseguire la ricetta 12 "Dintorni" che è quella che mi interesserebbe ho notato che provando ad eseguirla ottengo un errore che è il seguente:<br>


<br>SQL error: no such function: RTreeIntersects<br><br></div>Cercando un po nella rete sembra che sia dovuto al fatto che la funzione in questione sia "deprecata" se non ho inteso male.<br><br></div>Vista quindi la select riportata nel manuale ......<br>


<div><br>SELECT lc1.lc_name AS "Tuscan Local Council",<br>c1.county_name AS "Tuscan County",<br>lc2.lc_name AS "Neighbour LC",<br>c2.county_name AS County,<br>r2.region_name AS Region<br>FROM local_councils AS lc1,<br>


local_councils AS lc2<br>JOIN counties AS c1<br>ON (c1.county_id = lc1.county_id)<br>JOIN counties AS c2<br>ON (c2.county_id = lc2.county_id)<br>JOIN regions AS r1<br>ON (r1.region_id = c1.region_id)<br>JOIN regions AS r2<br>


ON (r2.region_id = c2.region_id)<br>WHERE r1.region_name LIKE 'toscana'<br>AND r1.region_id <> r2.region_id<br>AND ST_Touches(lc1.geometry, lc2.geometry)<br>AND lc2.ROWID IN (<br>SELECT pkid<br>FROM idx_local_councils_geometry<br>


WHERE pkid MATCH RTreeIntersects(<br>MbrMinX(lc1.geometry),<br>MbrMinY(lc1.geometry),<br>MbrMaxX(lc1.geometry),<br>MbrMaxY(lc1.geometry)))<br>ORDER BY c1.county_name, lc1.lc_name;<br><br></div><div>come posso modificarla per ottenere lo stesso risultato?<br>


<br></div><div>Grazie mille anticipatamente<br><br></div><div> Cesare<br></div><div><br><div><div><div><div><div><div><br clear="all"><div><div>Cesare Gerbino<br><br><a href="http://cesaregerbino.wordpress.com/" target="_blank">http://cesaregerbino.wordpress.com/</a><br>


<a href="http://www.facebook.com/cesare.gerbino" target="_blank">http://www.facebook.com/cesare.gerbino</a><br><a href="http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl" target="_blank">http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl</a><br>


<a href="https://twitter.com/CesareGerbino" target="_blank">https://twitter.com/CesareGerbino</a><br><a href="http://www.linkedin.com/pub/cesare-gerbino/56/494/77b" target="_blank">http://www.linkedin.com/pub/cesare-gerbino/56/494/77b</a><br>


<br></div>
</div></div></div></div></div></div></div></div></div>
<br></div></div>_______________________________________________<br>
<a href="mailto:Gfoss@lists.gfoss.it" target="_blank">Gfoss@lists.gfoss.it</a><br>
<a href="http://lists.gfoss.it/cgi-bin/mailman/listinfo/gfoss" target="_blank">http://lists.gfoss.it/cgi-bin/mailman/listinfo/gfoss</a><br>
Questa e' una lista di discussione pubblica aperta a tutti.<br>
I messaggi di questa lista non hanno relazione diretta con le posizioni dell'Associazione GFOSS.it.<br>
666 iscritti al 22.7.2013<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br>-----------------<br>Andrea Peri<br>. . . . . . . . . <br>
qwerty àèìòù<br>-----------------<br>
</font></span></div>
</blockquote></div><br></div>