[geos-commits] [SCM] GEOS branch main-relate-ng updated. 5746c2afa30767843421ae661df5b45b6403f8f9

git at osgeo.org git at osgeo.org
Thu Aug 8 12:49:34 PDT 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main-relate-ng has been updated
       via  5746c2afa30767843421ae661df5b45b6403f8f9 (commit)
      from  8aae1cf6c1f3edc0076edb6fcba14f7dff898f22 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5746c2afa30767843421ae661df5b45b6403f8f9
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Thu Aug 8 12:49:15 2024 -0700

    Add touches to TopoPredicatePerfTest

diff --git a/benchmarks/geom/TopologyPredicatePerfTest.cpp b/benchmarks/geom/TopologyPredicatePerfTest.cpp
index 4af663769..571bcbc70 100644
--- a/benchmarks/geom/TopologyPredicatePerfTest.cpp
+++ b/benchmarks/geom/TopologyPredicatePerfTest.cpp
@@ -1,7 +1,7 @@
 /******************************************************
- *   Performance tests for spatial predicates
+ *   Performance tests for topological predicates
  * 
- * Usage: perf_prepared_polygon_intersects [ intersects | contains ]
+ * Usage: perf_topo_predicate [ intersects | contains ]
 ******************************************************/
 
 #include <geos/geom/util/SineStarFactory.h>
@@ -25,7 +25,9 @@ std::size_t NUM_LINES_PTS = 100;
 #define INTERSECTS 0
 #define CONTAINS 1
 #define COVERS 2
+#define TOUCHES 3
 
+std::string op{"intersects"};
 int predicateOp = INTERSECTS;
 
 int testRelateOpIntersects(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
@@ -55,6 +57,15 @@ int testRelateOpCovers(const Geometry& g, const std::vector<std::unique_ptr<Geom
     return count;
 }
 
+int testRelateOpTouches(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
+    int count = 0;
+    for (const auto& geom : geoms) {
+        auto im = g.relate(geom.get());
+        count += im->isTouches(g.getDimension(), geom.get()->getDimension());
+    }
+    return count;
+}
+
 int testGeometryIntersects(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
     int count = 0;
     for (const auto& geom : geoms) {
@@ -79,6 +90,14 @@ int testGeometryCovers(const Geometry& g, const std::vector<std::unique_ptr<Geom
     return count;
 }
 
+int testGeometryTouches(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
+    int count = 0;
+    for (const auto& geom : geoms) {
+        count += g.touches(geom.get());
+    }
+    return count;
+}
+
 int testPrepGeomIntersects(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
     int count = 0;
     auto prep = prep::PreparedGeometryFactory::prepare(&g);
@@ -133,10 +152,19 @@ int testRelateNGPreparedCovers(const Geometry& g, const std::vector<std::unique_
     return count;
 }
 
+int testRelateNGPreparedTouches(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms) {
+    int count = 0;
+    auto prep = geos::operation::relateng::RelateNG::prepare(&g);
+    for (const auto& line : geoms) {
+        count += prep->evaluate(line.get(), *geos::operation::relateng::RelatePredicate::touches());
+    }
+    return count;
+}
+
 template<typename F>
 double test(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geoms, const std::string& method, F&& fun, double baseTime)
 {
-    geos::util::Profile sw("PreparedPolygonIntersects");
+    geos::util::Profile sw("TopologuyPredicatePerf");
     sw.start();
 
     int count = 0;
@@ -153,8 +181,9 @@ double test(const Geometry& g, const std::vector<std::unique_ptr<Geometry>>& geo
         << count << "," << geoms[0]->getGeometryType() << "," 
         << geoms[0]->getNumPoints() << "," 
         << method << "," 
-        << tot << ","
-        << timesFaster 
+        << tot << ",";
+    std::cout << std::fixed << std::setprecision(1);
+    std::cout << timesFaster 
         << std::endl;
     return tot;
 }
@@ -177,22 +206,28 @@ void test(int dim, std::size_t npts) {
     double baseTime;
     switch (predicateOp) {
     case INTERSECTS:
-        baseTime = test(*target, geoms, "RelateOp intersects", testRelateOpIntersects, 0);
-        test(*target, geoms, "Geometry::intersects", testGeometryIntersects, baseTime);
-        test(*target, geoms, "PreparedGeom", testPrepGeomIntersects, baseTime);
-        test(*target, geoms, "RelateNGPrepared", testRelateNGPreparedIntersects, baseTime);
+        baseTime = test(*target, geoms, "RelateOp-intersects", testRelateOpIntersects, 0);
+        test(*target, geoms, "Geometry-intersects", testGeometryIntersects, baseTime);
+        test(*target, geoms, "PreparedGeom-intersects", testPrepGeomIntersects, baseTime);
+        test(*target, geoms, "RelateNGPrepared-intersects", testRelateNGPreparedIntersects, baseTime);
         break;
     case CONTAINS:
-        baseTime = test(*target, geoms, "RelateOp contains", testRelateOpIntersects, 0);
-        test(*target, geoms, "Geometry::contains", testGeometryIntersects, baseTime);
-        test(*target, geoms, "PreparedGeom contains", testPrepGeomContains, baseTime);
-        test(*target, geoms, "RelateNGPrepared contains", testRelateNGPreparedContains, baseTime);
+        baseTime = test(*target, geoms, "RelateOp-contains", testRelateOpIntersects, 0);
+        test(*target, geoms, "Geometry-contains", testGeometryIntersects, baseTime);
+        test(*target, geoms, "PreparedGeom-contains", testPrepGeomContains, baseTime);
+        test(*target, geoms, "RelateNGPrepared-contains", testRelateNGPreparedContains, baseTime);
         break;
     case COVERS:
-        baseTime = test(*target, geoms, "RelateOp covers", testRelateOpCovers, 0);
-        test(*target, geoms, "Geometry::covers", testGeometryCovers, baseTime);
-        test(*target, geoms, "PreparedGeom covers", testPrepGeomCovers, baseTime);
-        test(*target, geoms, "RelateNGPrepared covers", testRelateNGPreparedCovers, baseTime);
+        baseTime = test(*target, geoms, "RelateOp-covers", testRelateOpCovers, 0);
+        test(*target, geoms, "Geometry-covers", testGeometryCovers, baseTime);
+        test(*target, geoms, "PreparedGeom-covers", testPrepGeomCovers, baseTime);
+        test(*target, geoms, "RelateNGPrepared-covers", testRelateNGPreparedCovers, baseTime);
+        break;
+    case TOUCHES:
+        baseTime = test(*target, geoms, "RelateOp-touches", testRelateOpTouches, 0);
+        test(*target, geoms, "Geometry-touches", testGeometryTouches, baseTime);
+        test(*target, geoms, "RelateNGPrepared-touches", testRelateNGPreparedTouches, baseTime);
+        break;
     }
 }
 
@@ -209,15 +244,19 @@ void testAll(int dim)
 }
 
 int main(int argc, char** argv) {
-    predicateOp = INTERSECTS;
+    op = "intersects";
     if (argc >= 2) {
-        std::string op{argv[1]};
-        if (op == "contains") {
-            predicateOp = CONTAINS;
-        }
-        else if (op == "covers") {
-            predicateOp = COVERS;
-        }
+        op = argv[1];
+    }
+    predicateOp = INTERSECTS;
+    if (op == "contains") {
+        predicateOp = CONTAINS;
+    }
+    else if (op == "covers") {
+        predicateOp = COVERS;
+    }
+    else if (op == "touches") {
+        predicateOp = TOUCHES;
     }
 
     std::cout << "target_points,num_tests,num_hits,test_type,pts_in_test,method,time,factor" << std::endl;

-----------------------------------------------------------------------

Summary of changes:
 benchmarks/geom/TopologyPredicatePerfTest.cpp | 89 +++++++++++++++++++--------
 1 file changed, 64 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list