[geos-commits] [SCM] GEOS branch 3.7 updated. e95c65126c1685472283d3f7db45e063d13c015e

git at osgeo.org git at osgeo.org
Tue Sep 17 04:48:45 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, 3.7 has been updated
       via  e95c65126c1685472283d3f7db45e063d13c015e (commit)
      from  3c67085207e3223d6e020474d7dc16a056e6fd2b (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 e95c65126c1685472283d3f7db45e063d13c015e
Author: Daniel Baston <dbaston at gmail.com>
Date:   Tue Sep 17 07:48:32 2019 -0400

    Add file for new overlay perf test

diff --git a/tests/perf/capi/IntersectionPerfTest.cpp b/tests/perf/capi/IntersectionPerfTest.cpp
new file mode 100644
index 0000000..051edf7
--- /dev/null
+++ b/tests/perf/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.getTot() << std::endl;
+
+    GEOSSTRtree_destroy(tree);
+
+    for (auto& g : geoms) {
+        GEOSGeom_destroy(g);
+    }
+}

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

Summary of changes:
 tests/perf/capi/IntersectionPerfTest.cpp | 87 ++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 tests/perf/capi/IntersectionPerfTest.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list