<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</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><tt><br>
</tt><tt>
for j, geom_j in enumerate(geoms):</tt><tt><br>
</tt><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...<br>
</tt></p>
<p> <br>
</p>
<pre class="moz-signature" cols="72">--
Med venlig hilsen / Kind regards
Bo Victor Thomsen</pre>
<p> </p>
<p><br>
</p>
<div class="moz-cite-prefix">Den 06-04-2020 kl. 11:36 skrev Johannes
Wildermuth:<br>
</div>
<blockquote type="cite"
cite="mid:trinity-bb73d125-1f88-444d-b383-213bfd1e6401-1586165812521@3c-app-gmx-bap71">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">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">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>
<pre class="moz-signature" cols="72">
</pre>
</body>
</html>