<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi<br/>
Thank you all for your quick answers.<br/>
Regards<br/>
Johannes</div>

<div> 
<div> 
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Montag, 06. April 2020 um 12:51 Uhr<br/>
<b>Von:</b> "Bo Victor Thomsen" <bo.victor.thomsen@gmail.com><br/>
<b>An:</b> qgis-developer@lists.osgeo.org<br/>
<b>Betreff:</b> Re: [QGIS-Developer] Intersections with Qgis</div>

<div name="quoted-content">
<p> </p>

<p>Johannes -</p>

<p>The actual intersection code can contain a pre-check of bounding box intersection. This will probably  decrease computation time significantly for the check:</p>

<p><tt>for i, geom_i in enumerate(geoms):</tt><br/>
<tt>    for j, geom_j in enumerate(geoms):</tt><br/>
<tt>        if j > i:</tt></p>

<p><tt>            # Check bounding box first...<br/>
            result = geom_i.boundingBoxIntersects(geom_j)<br/>
<br/>
            if result:<br/>
<br/>
                # Bounding box intersects, check actual geometry...<br/>
                result = </tt><tt>geom_i.intersects(geom_j)<br/>
<br/>
            # Do something with result...</tt></p>

<p> </p>

<pre class="moz-signature">--
Med venlig hilsen / Kind regards

Bo Victor Thomsen</pre>

<p>    </p>

<p> </p>

<div class="moz-cite-prefix">Den 06-04-2020 kl. 11:36 skrev Johannes Wildermuth:</div>

<blockquote>
<div style="font-family: Verdana;font-size: 12.0px;">
<div>Hello developers<br/>
I've been currently working on a python plugin in which I have to find all possible intersections on one layer. I want to improve the efficiency of this task. It roughly looks like this:<br/>
for i, geom in enumerate(geoms):<br/>
    for j, geom in enumerate(geoms):<br/>
        if j > i:<br/>
            //intersections<br/>
Is there a faster way? Perhaps with multithreading / rtree?<br/>
Regards<br/>
Johannes Wildermuth</div>
</div>
 

<fieldset class="mimeAttachmentHeader"> </fieldset>

<pre class="moz-quote-pre">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org" onclick="parent.window.location.href='mailto:QGIS-Developer@lists.osgeo.org'; return false;" target="_blank">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>

<pre class="moz-signature"> </pre>
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></div>
</div>
</div>
</div></div></body></html>