Johannes -

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

for i, geom_i in enumerate(geoms):
    for j, geom_j in enumerate(geoms):
        if j > i:

            # Check bounding box first...
            result = geom_i.boundingBoxIntersects(geom_j)

            if result:

                # Bounding box intersects, check actual geometry...
                result = geom_i.intersects(geom_j)

            # Do something with result...


--
Med venlig hilsen / Kind regards

Bo Victor Thomsen


Den 06-04-2020 kl. 11:36 skrev Johannes Wildermuth:
Hello developers
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:
for i, geom in enumerate(geoms):
    for j, geom in enumerate(geoms):
        if j > i:
            //intersections
Is there a faster way? Perhaps with multithreading / rtree?
Regards
Johannes Wildermuth

_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to