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

git at osgeo.org git at osgeo.org
Fri Oct 18 15:17:35 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  b363b501d5ceeecee3eba51277adecf975308174 (commit)
      from  6b64a820d18365fc2170cd6f36d8256c4f806ec3 (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 b363b501d5ceeecee3eba51277adecf975308174
Author: Daniel Baston <dbaston at gmail.com>
Date:   Fri Oct 18 18:16:49 2019 -0400

    Backport perf tests to 3.7

diff --git a/tests/perf/algorithm/CMakeLists.txt b/tests/perf/algorithm/CMakeLists.txt
new file mode 100644
index 0000000..8b0ab39
--- /dev/null
+++ b/tests/perf/algorithm/CMakeLists.txt
@@ -0,0 +1,23 @@
+#################################################################################
+#
+# CMake configuration for GEOS perf/algorithm tests
+#
+# Copyright (C) 2017 Mateusz Loskot <mateusz at loskot.net>
+#
+# 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.
+#
+#################################################################################
+
+add_executable(perf_voronoi VoronoiPerfTest.cpp)
+target_link_libraries(perf_voronoi geos)
+
+add_test(perf_voronoi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perf_voronoi)
+
+add_executable(perf_unaryunion_segments UnaryUnionSegmentsPerfTest.cpp)
+target_link_libraries(perf_unaryunion_segments geos)
+
+add_executable(perf_interiorpoint_area InteriorPointAreaPerfTest.cpp)
+target_link_libraries(perf_interiorpoint_area geos)
diff --git a/tests/perf/algorithm/InteriorPointAreaPerfTest.cpp b/tests/perf/algorithm/InteriorPointAreaPerfTest.cpp
new file mode 100644
index 0000000..7dc7d40
--- /dev/null
+++ b/tests/perf/algorithm/InteriorPointAreaPerfTest.cpp
@@ -0,0 +1,138 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2011  Sandro Santilli <strk at kbt.io>
+ *
+ * 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.
+ *
+ **********************************************************************
+ *
+ * Last port: perf/operation/predicate/RectangleIntersectsPerfTest.java r378 (JTS-1.12)
+ *
+ **********************************************************************/
+
+
+#include <geos/geom/PrecisionModel.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/util/GeometricShapeFactory.h>
+#include <geos/precision/SimpleGeometryPrecisionReducer.h>
+#include <geos/geom/util/SineStarFactory.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/Polygon.h>
+#include <geos/geom/Point.h>
+#include <geos/profiler.h>
+#include <iostream>
+#include <vector>
+#include <cmath>
+#include <sstream>
+#include <memory>
+
+using namespace geos::geom;
+using namespace geos::io;
+using namespace std;
+
+class InteriorPointAreaPerfTest {
+public:
+    InteriorPointAreaPerfTest()
+        :
+        pm(),
+        fact(GeometryFactory::create(&pm, 0))
+    {
+        showHeader();
+    }
+
+    void
+    test(int nPts)
+    {
+        Coordinate origin(ORG_X, ORG_Y);
+        std::unique_ptr<geos::geom::Polygon> sinePoly =
+            createSineStar(origin, SIZE, nPts);
+
+        /**
+         * Make the geometry "crinkly" by rounding off the points.
+         * This defeats the  MonotoneChain optimization in the full relate
+         * algorithm, and provides a more realistic test.
+         */
+        using geos::precision::SimpleGeometryPrecisionReducer;
+        double scale = nPts / SIZE;
+        PrecisionModel p_pm(scale);
+        SimpleGeometryPrecisionReducer reducer(&p_pm);
+        std::unique_ptr<Geometry> sinePolyCrinkly(reducer.reduce(sinePoly.get()));
+        sinePoly.reset();
+
+        //cout << sinePolyCrinkly->toText() << endl;
+
+        test(*sinePolyCrinkly);
+    }
+
+    const double ORG_X = 100.0;
+    const double ORG_Y = 100.0;
+    const double SIZE = 100.0;
+    const int N_ARMS = 20;
+    const double ARM_RATIO = 0.3;
+    const int N_ITER = 100;
+
+private:
+    PrecisionModel pm;
+    GeometryFactory::Ptr fact;
+
+    void
+    showHeader() {
+        cout << "Interior Point Area perf test" << endl;
+        cout << "# Iterations: " << N_ITER << endl;
+        cout << "SineStar: origin: ("
+                << ORG_X << ", " << ORG_Y
+                << ")  size: " << SIZE
+                << "  # arms: " << N_ARMS
+                << "  arm ratio: " << ARM_RATIO
+                << endl;
+    }
+
+    void
+    test(geos::geom::Geometry& poly)
+    {
+        geos::util::Profile sw("");
+        sw.start();
+
+        for(int i = 0; i < N_ITER; i++) {
+            std::unique_ptr<geos::geom::Point> pt( poly.getInteriorPoint() );
+        }
+
+        sw.stop();
+        cout << poly.getNumPoints() << " points: " << sw.getTot() << endl;
+    }
+
+    std::unique_ptr<geos::geom::Polygon>
+    createSineStar(const Coordinate& origin,
+                   double size, int nPts)
+    {
+        using geos::geom::util::SineStarFactory;
+
+        SineStarFactory gsf(fact.get());
+        gsf.setCentre(origin);
+        gsf.setSize(size);
+        gsf.setNumPoints(nPts);
+        gsf.setArmLengthRatio( ARM_RATIO );
+        gsf.setNumArms( N_ARMS );
+        std::unique_ptr<geos::geom::Polygon> poly = gsf.createSineStar();
+        return poly;
+    }
+};
+
+int
+main()
+{
+    InteriorPointAreaPerfTest tester;
+
+    tester.test(100);
+    tester.test(1000);
+    tester.test(10000);
+    tester.test(100000);
+    tester.test(1000000);
+}
+
diff --git a/tests/perf/algorithm/UnaryUnionSegmentsPerfTest.cpp b/tests/perf/algorithm/UnaryUnionSegmentsPerfTest.cpp
new file mode 100644
index 0000000..19099c6
--- /dev/null
+++ b/tests/perf/algorithm/UnaryUnionSegmentsPerfTest.cpp
@@ -0,0 +1,72 @@
+/**********************************************************************
+ *
+ * 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/triangulate/DelaunayTriangulationBuilder.h>
+#include <geos/triangulate/VoronoiDiagramBuilder.h>
+#include <geos/geom/CoordinateArraySequence.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/LineString.h>
+#include <geos/profiler.h>
+
+#include <algorithm>
+#include <random>
+#include <vector>
+#include <memory>
+
+class SegmentUnaryUnionPerfTest {
+
+public:
+    void test(size_t num_lines) {
+        using namespace geos::geom;
+
+        std::default_random_engine e(12345);
+        std::uniform_real_distribution<> dis(0, 100);
+
+        std::vector<Geometry*>* lines = new std::vector<Geometry*>();
+
+        for (size_t i = 0; i < num_lines; i++) {
+            CoordinateArraySequence* cas = new CoordinateArraySequence(2, 2);
+            cas->setAt(Coordinate(dis(e), dis(e)), 0);
+            cas->setAt(Coordinate(dis(e), dis(e)), 1);
+
+            Geometry* line = gfact->createLineString(cas);
+            lines->push_back(line);
+        }
+
+        auto g = gfact->createMultiLineString(lines);
+
+        auto sw = profiler->get("union");
+        sw->start();
+
+        g->Union();
+
+        sw->stop();
+
+        std::cout << *sw << std::endl;
+    }
+private:
+    decltype(geos::geom::GeometryFactory::create()) gfact = geos::geom::GeometryFactory::create();
+    geos::util::Profiler* profiler = geos::util::Profiler::instance();
+};
+
+int main(int argc, char** argv) {
+    SegmentUnaryUnionPerfTest tester;
+
+    auto num_lines = std::atol(argv[1]);
+    auto num_reps = argc > 2 ? std::atol(argv[2]) : 1;
+
+    for (int i = 0; i < num_reps; i++) {
+        tester.test(num_lines);
+    }
+}
diff --git a/tests/perf/algorithm/VoronoiPerfTest.cpp b/tests/perf/algorithm/VoronoiPerfTest.cpp
new file mode 100644
index 0000000..ab6e9dc
--- /dev/null
+++ b/tests/perf/algorithm/VoronoiPerfTest.cpp
@@ -0,0 +1,93 @@
+/**********************************************************************
+ *
+ * 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/triangulate/DelaunayTriangulationBuilder.h>
+#include <geos/triangulate/VoronoiDiagramBuilder.h>
+#include <geos/geom/CoordinateArraySequence.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/LineString.h>
+#include <geos/profiler.h>
+
+#include <algorithm>
+#include <random>
+#include <vector>
+#include <memory>
+
+class VoronoiPerfTest {
+
+public:
+    void test(size_t num_points) {
+        using namespace geos::geom;
+
+        std::default_random_engine e(12345);
+        std::uniform_real_distribution<> dis(0, 100);
+
+        std::unique_ptr<std::vector<Coordinate>> coords(new std::vector<Coordinate>(num_points));
+        std::generate(coords->begin(), coords->end(), [&dis, &e]() {
+            return Coordinate(dis(e), dis(e));
+        });
+        CoordinateArraySequence seq(coords.release());
+        Geometry* geom = gfact->createLineString(seq.clone());
+
+        voronoi(seq);
+        voronoi(*geom);
+
+        delaunay(seq);
+        delaunay(*geom);
+
+        std::cout << std::endl;
+    }
+private:
+    decltype(geos::geom::GeometryFactory::create()) gfact = geos::geom::GeometryFactory::create();
+    geos::util::Profiler* profiler = geos::util::Profiler::instance();
+
+    template<typename T>
+    void voronoi(const T & sites) {
+        auto sw = profiler->get(std::string("Voronoi from ") + typeid(T).name());
+        sw->start();
+
+        geos::triangulate::VoronoiDiagramBuilder vdb;
+        vdb.setSites(sites);
+
+        auto result = vdb.getDiagram(*gfact);
+
+        sw->stop();
+        std::cout << sw->name << ": " << result->getNumGeometries() << ": " << *sw << std::endl;
+    }
+
+    template<typename T>
+    void delaunay(const T & seq) {
+        auto sw = profiler->get(std::string("Delaunay from ") + typeid(T).name());
+        sw->start();
+
+        geos::triangulate::DelaunayTriangulationBuilder dtb;
+        dtb.setSites(seq);
+
+        auto result = dtb.getTriangles(*gfact);
+
+        sw->stop();
+        std::cout << sw->name << ": " << result->getNumGeometries() << ": " << *sw << std::endl;
+    }
+};
+
+int main() {
+    VoronoiPerfTest tester;
+
+    //tester.test(100);
+    //tester.test(1000);
+    //tester.test(10000);
+    for (auto i = 0; i < 5; i++) {
+        tester.test(100000);
+    }
+}
\ No newline at end of file
diff --git a/tests/perf/capi/CMakeLists.txt b/tests/perf/capi/CMakeLists.txt
index 9019629..7d92704 100644
--- a/tests/perf/capi/CMakeLists.txt
+++ b/tests/perf/capi/CMakeLists.txt
@@ -22,3 +22,5 @@ add_test(perf_memleak_mp_prep ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perf_memleak_mp_
 add_executable(perf_intersection IntersectionPerfTest.cpp)
 target_link_libraries(perf_intersection geos_c)
 
+add_executable(perf_geospreparedcontains GEOSPreparedContainsPerfTest.cpp)
+target_link_libraries(perf_geospreparedcontains geos_c)
diff --git a/tests/perf/capi/GEOSPreparedContainsPerfTest.cpp b/tests/perf/capi/GEOSPreparedContainsPerfTest.cpp
new file mode 100644
index 0000000..8b75a05
--- /dev/null
+++ b/tests/perf/capi/GEOSPreparedContainsPerfTest.cpp
@@ -0,0 +1,115 @@
+/**********************************************************************
+ *
+ * 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 <geos/geom/Coordinate.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Polygon.h>
+#include <geos/geom/util/SineStarFactory.h>
+
+#include <algorithm>
+#include <random>
+#include <vector>
+#include <memory>
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+class GEOSPreparedContainsPerfTest {
+
+public:
+    void test(const GEOSGeometry* g, size_t num_points) {
+        using namespace geos::geom;
+
+        double xmin, xmax, ymin, ymax;
+
+        GEOSGeom_getXMin(g, &xmin);
+        GEOSGeom_getXMax(g, &xmax);
+        GEOSGeom_getYMin(g, &ymin);
+        GEOSGeom_getYMax(g, &ymax);
+
+        std::default_random_engine e(12345);
+        std::uniform_real_distribution<> xdist(xmin, xmax);
+        std::uniform_real_distribution<> ydist(ymin, ymax);
+
+        std::vector<Coordinate> coords(num_points);
+        std::generate(coords.begin(), coords.end(), [&xdist, &ydist, &e]() {
+            return Coordinate(xdist(e), ydist(e));
+        });
+
+        geos::util::Profile sw("GEOSPreparedContains");
+        sw.start();
+
+        size_t hits = 0;
+        auto prep = GEOSPrepare(g);
+        for (const auto& c : coords) {
+            auto seq = GEOSCoordSeq_create(1, 2);
+            GEOSCoordSeq_setX(seq, 0, c.x);
+            GEOSCoordSeq_setY(seq, 0, c.y);
+
+            auto pt = GEOSGeom_createPoint(seq);
+
+            if (GEOSPreparedContains(prep, pt)) {
+                hits++;
+            }
+
+            GEOSGeom_destroy(pt);
+        }
+
+        GEOSPreparedGeom_destroy(prep);
+
+        sw.stop();
+
+        std::cout << sw.name << ": " << hits << " hits from " << num_points << " points in " <<  sw.getTot() << std::endl;
+
+    }
+};
+
+int main(int argc, char** argv) {
+    if (argc != 3) {
+        std::cout << "perf_geospreparedcontins performs a specified number of point-in-polygon tests" << std::endl;
+        std::cout << "on randomly generated points from the bounding box of a single geometry provided" << std::endl;
+        std::cout << "in a file as WKT." << std::endl;
+        std::cout << std::endl;
+        std::cout << "Usage: perf_geospreparedcontins [wktfile] [n]" << std::endl;
+        return 0;
+    }
+
+    GEOSPreparedContainsPerfTest tester;
+
+    int n = std::atoi(argv[2]);
+    std::cout << "Performing " << n << " point-in-polygon tests." << std::endl;
+
+    std::string fname{argv[1]};
+    std::cout << "Reading shape from " << fname << std::endl;
+
+    std::ifstream f(fname);
+    std::stringstream buff;
+    buff << f.rdbuf();
+    f.close();
+
+    std::string wkt = buff.str();
+    buff.clear();
+
+    initGEOS(nullptr, nullptr);
+    GEOSGeometry* g = GEOSGeomFromWKT(wkt.c_str());
+    wkt.clear();
+
+    tester.test(g, n);
+
+    GEOSGeom_destroy(g);
+}

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

Summary of changes:
 tests/perf/algorithm/CMakeLists.txt                |  23 ++++
 tests/perf/algorithm/InteriorPointAreaPerfTest.cpp | 138 +++++++++++++++++++++
 .../perf/algorithm/UnaryUnionSegmentsPerfTest.cpp  |  72 +++++++++++
 tests/perf/algorithm/VoronoiPerfTest.cpp           |  93 ++++++++++++++
 tests/perf/capi/CMakeLists.txt                     |   2 +
 tests/perf/capi/GEOSPreparedContainsPerfTest.cpp   | 115 +++++++++++++++++
 6 files changed, 443 insertions(+)
 create mode 100644 tests/perf/algorithm/CMakeLists.txt
 create mode 100644 tests/perf/algorithm/InteriorPointAreaPerfTest.cpp
 create mode 100644 tests/perf/algorithm/UnaryUnionSegmentsPerfTest.cpp
 create mode 100644 tests/perf/algorithm/VoronoiPerfTest.cpp
 create mode 100644 tests/perf/capi/GEOSPreparedContainsPerfTest.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list