[geos-commits] [SCM] GEOS branch master updated. 4701553c4b8554f4f1e15d7119780ec5fa1c3cc5

git at osgeo.org git at osgeo.org
Mon Sep 16 18:44:12 PDT 2019


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, master has been updated
       via  4701553c4b8554f4f1e15d7119780ec5fa1c3cc5 (commit)
      from  6bac4f45e94f8e18409803b17eb306dd94fa065a (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 4701553c4b8554f4f1e15d7119780ec5fa1c3cc5
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Sep 16 14:38:35 2019 -0400

    Add overlay perf test

diff --git a/benchmarks/capi/CMakeLists.txt b/benchmarks/capi/CMakeLists.txt
index 4fdf0e3..5f37deb 100644
--- a/benchmarks/capi/CMakeLists.txt
+++ b/benchmarks/capi/CMakeLists.txt
@@ -18,4 +18,7 @@ target_include_directories(perf_memleak_mp_prep
 target_link_libraries(perf_memleak_mp_prep PRIVATE geos_c)
 
 add_executable(perf_geospreparedcontains GEOSPreparedContainsPerfTest.cpp)
-target_link_libraries(perf_geospreparedcontains PRIVATE geos geos_c)
\ No newline at end of file
+target_link_libraries(perf_geospreparedcontains PRIVATE geos geos_c)
+
+add_executable(perf_intersection IntersectionPerfTest.cpp)
+target_link_libraries(perf_intersection PRIVATE geos geos_c)
diff --git a/benchmarks/capi/IntersectionPerfTest.cpp b/benchmarks/capi/IntersectionPerfTest.cpp
new file mode 100644
index 0000000..3617fbe
--- /dev/null
+++ b/benchmarks/capi/IntersectionPerfTest.cpp
@@ -0,0 +1,87 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2019 Daniel Baston <dbaston at gmail.com>
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ **********************************************************************/
+
+#include <geos/profiler.h>
+#include <geos_c.h>
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+int main(int argc, char** argv) {
+    if (argc != 2 && argc != 3) {
+        std::cout << "perf_intersection reads geometries from a WKT file and" << std::endl;
+        std::cout << "inserts them into an STR-tree. For each input geometry, it" << std::endl;
+        std::cout << "queries the tree to find all intersecting geometries and" << std::endl;
+        std::cout << "then computes their intersection." << std::endl;
+        std::cout << std::endl;
+        std::cout << "Usage: perf_intersection [wktfile] [n]" << std::endl;
+        return 0;
+    }
+
+    initGEOS(nullptr, nullptr);
+
+    std::string fname{argv[1]};
+
+    long max_geoms;
+    if (argc == 3) {
+        max_geoms = std::atol(argv[2]);
+        std::cout << "Reading up to " << max_geoms << " geometries from " << fname << std::endl;
+    } else {
+        std::cout << "Reading geometries from " << fname << std::endl;
+        max_geoms = -1;
+    }
+
+    std::vector<GEOSGeometry*> geoms;
+
+    std::ifstream f(fname);
+    std::string line;
+    long i = 0;
+    while(std::getline(f, line) && i < max_geoms) {
+        geoms.push_back(GEOSGeomFromWKT(line.c_str()));
+        i++;
+    }
+    f.close();
+
+    std::cout << "Read " << geoms.size() << " geometries." << std::endl;
+
+    GEOSSTRtree* tree = GEOSSTRtree_create(10);
+
+    for (const auto& g : geoms) {
+        GEOSSTRtree_insert(tree, g, g);
+    }
+
+    geos::util::Profile sw("Intersection");
+    sw.start();
+
+    for (const auto& g : geoms) {
+        GEOSSTRtree_query(tree, g, [](void* g2v, void* g1v) {
+            GEOSGeometry* g1 = (GEOSGeometry*) g1v;
+            GEOSGeometry* g2 = (GEOSGeometry*) g2v;
+            if (GEOSIntersects(g1, g2) == 1) {
+                GEOSGeometry* g3 = GEOSIntersection(g1, g2);
+                GEOSGeom_destroy(g3);
+            }
+        }, g);
+    }
+
+    sw.stop();
+    std::cout << sw.getTotFormatted() << std::endl;
+
+    GEOSSTRtree_destroy(tree);
+
+    for (auto& g : geoms) {
+        GEOSGeom_destroy(g);
+    }
+}

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

Summary of changes:
 benchmarks/capi/CMakeLists.txt           |  5 +-
 benchmarks/capi/IntersectionPerfTest.cpp | 87 ++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 benchmarks/capi/IntersectionPerfTest.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list