[geos-commits] [SCM] GEOS branch master updated. dfb6d579ad64e769770653987ff9e50d52f2087a

git at osgeo.org git at osgeo.org
Mon Sep 14 09:36:28 PDT 2020


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  dfb6d579ad64e769770653987ff9e50d52f2087a (commit)
       via  a32d1b5caff914cc7c0d38a31cbf1f16517ec324 (commit)
       via  4633d4960a2ad15043f932cc8951209ba49d21a2 (commit)
      from  208a6f5090deac573597f54471b0651f91ae415f (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 dfb6d579ad64e769770653987ff9e50d52f2087a
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Aug 24 14:06:17 2020 +0200

    Add OverlayNG in HeuristicOverlay, kept disabled

diff --git a/src/geom/HeuristicOverlay.cpp b/src/geom/HeuristicOverlay.cpp
index ed7eace..c1fd19b 100644
--- a/src/geom/HeuristicOverlay.cpp
+++ b/src/geom/HeuristicOverlay.cpp
@@ -45,11 +45,9 @@
  *
  **********************************************************************/
 
-#define GEOS_DEBUG_HEURISTICOVERLAY 1
-#define GEOS_DEBUG_HEURISTICOVERLAY_PRINT_INVALID 1
-
 #include <geos/geom/HeuristicOverlay.h>
 #include <geos/operation/overlay/OverlayOp.h>
+#include <geos/operation/overlayng/OverlayNG.h>
 #include <geos/operation/overlayng/OverlayNGSnapIfNeeded.h>
 
 #include <geos/simplify/TopologyPreservingSimplifier.h>
@@ -72,6 +70,9 @@
 
 #include <geos/operation/overlay/snap/GeometrySnapper.h>
 
+#define GEOS_DEBUG_HEURISTICOVERLAY 1
+#define GEOS_DEBUG_HEURISTICOVERLAY_PRINT_INVALID 0
+
 
 #ifdef GEOS_DEBUG_HEURISTICOVERLAY
 # include <iostream>
@@ -92,6 +93,20 @@
  */
 #define GEOS_CHECK_ORIGINAL_RESULT_VALIDITY 0
 
+/*
+ * Define this to use OverlayNG policy with fixed precision
+ */
+#ifndef USE_FIXED_PRECISION_OVERLAYNG
+# define USE_FIXED_PRECISION_OVERLAYNG 0
+#endif
+
+/*
+ * Define this to use OverlayNG policy with whatever precision
+ */
+#ifndef USE_OVERLAYNG_SNAPIFNEEDED
+# define USE_OVERLAYNG_SNAPIFNEEDED 0
+#endif
+
 
 /*
  * Define this to use PrecisionReduction policy
@@ -163,6 +178,7 @@
 #define GEOS_CHECK_SNAPPINGOP_VALIDITY 0
 
 using geos::operation::overlay::OverlayOp;
+using geos::operation::overlayng::OverlayNG;
 
 namespace geos {
 namespace geom { // geos::geom
@@ -470,6 +486,7 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
 
 #endif // USE_SNAPPING_POLICY }
 
+
 // {
 #if USE_PRECISION_REDUCTION_POLICY
 
@@ -489,7 +506,8 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
                   << std::endl;
 #endif
 
-        double maxScale = 1e16;
+        double maxScale = 1e16; // TODO: compute from input
+        double minScale = 1; // TODO: compute from input
 
         // Don't use a scale bigger than the input one
         if(g0scale && static_cast<double>(g0scale) < maxScale) {
@@ -500,7 +518,7 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
         }
 
 
-        for(double scale = maxScale; scale >= 1; scale /= 10) {
+        for(double scale = maxScale; scale >= minScale; scale /= 10) {
             PrecisionModel pm(scale);
             GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
 #if GEOS_DEBUG_HEURISTICOVERLAY
@@ -558,6 +576,74 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
 #endif
 // USE_PRECISION_REDUCTION_POLICY }
 
+// {
+#if USE_FIXED_PRECISION_OVERLAYNG
+
+
+    // Try OverlayNG with fixed precision
+    try {
+        long unsigned int g0scale =
+            static_cast<long unsigned int>(g0->getFactory()->getPrecisionModel()->getScale());
+        long unsigned int g1scale =
+            static_cast<long unsigned int>(g1->getFactory()->getPrecisionModel()->getScale());
+
+#if GEOS_DEBUG_HEURISTICOVERLAY
+        std::cerr << "Original input scales are: "
+                  << g0scale
+                  << " and "
+                  << g1scale
+                  << std::endl;
+#endif
+
+        double maxScale = 1e16; // TODO: compute from input
+        double minScale = 1e10; // TODO: compute from input
+
+        // Don't use a scale bigger than the input one
+        if(g0scale && static_cast<double>(g0scale) < maxScale) {
+            maxScale = static_cast<double>(g0scale);
+        }
+        if(g1scale && static_cast<double>(g1scale) < maxScale) {
+            maxScale = static_cast<double>(g1scale);
+        }
+
+
+        for(double scale = maxScale; scale >= minScale; scale /= 10) {
+            PrecisionModel pm(scale);
+#if GEOS_DEBUG_HEURISTICOVERLAY
+            std::cerr << "Trying with precision scale " << scale << std::endl;
+#endif
+
+            try {
+                ret = OverlayNG::overlay(g0, g1, opCode, &pm);
+
+#if GEOS_DEBUG_HEURISTICOVERLAY
+                std::cerr << "Attempt with fixedNG scale " << scale << " succeeded" << std::endl;
+#endif
+                return ret;
+            }
+            catch(const geos::util::TopologyException& ex) {
+#if GEOS_DEBUG_HEURISTICOVERLAY
+                std::cerr << "fixedNG with scale (" << scale << "): "
+                          << ex.what() << std::endl;
+#endif
+                if(scale == 1) {
+                    throw ex;
+                }
+            }
+
+        }
+
+    }
+    catch(const geos::util::TopologyException& ex) {
+#if GEOS_DEBUG_HEURISTICOVERLAY
+        std::cerr << "Reduced: " << ex.what() << std::endl;
+#endif
+        ::geos::ignore_unused_variable_warning(ex);
+    }
+
+#endif
+// USE_FIXED_PRECISION_OVERLAYNG }
+
 
 // {
 #if USE_TP_SIMPLIFY_POLICY
@@ -606,6 +692,9 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
 // USE_TP_SIMPLIFY_POLICY }
 
 
+// {
+#if USE_OVERLAYNG_SNAPIFNEEDED
+
 #if GEOS_DEBUG_HEURISTICOVERLAY
     std::cerr << "Trying with OverlayNGSnapIfNeeded" << std::endl;
 #endif
@@ -625,6 +714,7 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
         std::cerr << "OverlayNGSnapIfNeeded: " << ex.what() << std::endl;
 #endif
     }
+#endif // USE_OVERLAYNG_SNAPIFNEEDED }
 
 
 #if GEOS_DEBUG_HEURISTICOVERLAY

commit a32d1b5caff914cc7c0d38a31cbf1f16517ec324
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Aug 21 14:33:54 2020 +0200

    Rename BinaryOp to HeuristicOverlay
    
    This is in preparation of using OverlayNG as a possible fallback
    heuristic.

diff --git a/capi/geos_c.cpp b/capi/geos_c.cpp
index d5d79a4..17a2fb2 100644
--- a/capi/geos_c.cpp
+++ b/capi/geos_c.cpp
@@ -21,10 +21,6 @@
 #include <geos/io/WKBReader.h>
 #include <geos/io/WKTWriter.h>
 #include <geos/io/WKBWriter.h>
-#include <geos/operation/overlay/OverlayOp.h>
-#include <geos/operation/union/CascadedPolygonUnion.h>
-#include <geos/algorithm/distance/DiscreteHausdorffDistance.h>
-#include <geos/algorithm/distance/DiscreteFrechetDistance.h>
 #include <geos/util/Interrupt.h>
 
 #include <stdexcept>
@@ -76,9 +72,6 @@ using geos::io::WKBWriter;
 
 using geos::index::strtree::STRtree;
 
-using geos::operation::overlay::OverlayOp;
-using geos::operation::overlay::overlayOp;
-using geos::operation::geounion::CascadedPolygonUnion;
 
 typedef std::unique_ptr<Geometry> GeomPtr;
 
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 7557459..a6d6fde 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -63,11 +63,10 @@
 #include <geos/operation/distance/IndexedFacetDistance.h>
 #include <geos/operation/linemerge/LineMerger.h>
 #include <geos/operation/overlay/OverlayOp.h>
-#include <geos/operation/overlayng/OverlayNG.h>
-#include <geos/operation/overlayng/OverlayNGSnapIfNeeded.h>
 #include <geos/operation/overlay/snap/GeometrySnapper.h>
 #include <geos/operation/overlayng/PrecisionReducer.h>
 #include <geos/operation/overlayng/OverlayNG.h>
+#include <geos/operation/overlayng/OverlayNGSnapIfNeeded.h>
 #include <geos/operation/intersection/Rectangle.h>
 #include <geos/operation/intersection/RectangleIntersection.h>
 #include <geos/operation/polygonize/Polygonizer.h>
@@ -141,6 +140,7 @@ using geos::geom::LinearRing;
 using geos::geom::MultiLineString;
 using geos::geom::MultiPolygon;
 using geos::geom::Polygon;
+using geos::geom::PrecisionModel;
 using geos::geom::CoordinateSequence;
 using geos::geom::GeometryCollection;
 using geos::geom::GeometryFactory;
@@ -150,19 +150,19 @@ using geos::io::WKTWriter;
 using geos::io::WKBReader;
 using geos::io::WKBWriter;
 
-using geos::geom::PrecisionModel;
-using geos::operation::overlay::OverlayOp;
+using geos::algorithm::distance::DiscreteFrechetDistance;
+using geos::algorithm::distance::DiscreteHausdorffDistance;
+
+using geos::operation::buffer::BufferBuilder;
+using geos::operation::buffer::BufferParameters;
+using geos::operation::distance::IndexedFacetDistance;
+using geos::operation::geounion::CascadedPolygonUnion;
 using geos::operation::overlayng::OverlayNG;
 using geos::operation::overlayng::OverlayNGSnapIfNeeded;
-using geos::operation::overlay::overlayOp;
-using geos::operation::geounion::CascadedPolygonUnion;
-using geos::operation::distance::IndexedFacetDistance;
-using geos::operation::buffer::BufferParameters;
-using geos::operation::buffer::BufferBuilder;
+
 using geos::precision::GeometryPrecisionReducer;
+
 using geos::util::IllegalArgumentException;
-using geos::algorithm::distance::DiscreteHausdorffDistance;
-using geos::algorithm::distance::DiscreteFrechetDistance;
 
 typedef std::unique_ptr<Geometry> GeomPtr;
 
diff --git a/include/geos/geom/HeuristicOverlay.h b/include/geos/geom/HeuristicOverlay.h
new file mode 100644
index 0000000..ae3e057
--- /dev/null
+++ b/include/geos/geom/HeuristicOverlay.h
@@ -0,0 +1,36 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2013-2020 Sandro Santilli <strk at kbt.io>
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * 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: ORIGINAL WORK
+ *
+ **********************************************************************/
+
+#ifndef GEOS_GEOM_HEURISTICOVERLAY_H
+#define GEOS_GEOM_HEURISTICOVERLAY_H
+
+#include <memory> // for unique_ptr
+
+namespace geos {
+namespace geom { // geos::geom
+
+class Geometry;
+
+std::unique_ptr<Geometry>
+HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode);
+
+} // namespace geos::geom
+} // namespace geos
+
+#endif // GEOS_GEOM_HEURISTICOVERLAY_H
diff --git a/include/geos/geom/Makefile.am b/include/geos/geom/Makefile.am
index 3397ae6..d7afb62 100644
--- a/include/geos/geom/Makefile.am
+++ b/include/geos/geom/Makefile.am
@@ -10,7 +10,7 @@ SUBDIRS = \
 geosdir = $(includedir)/geos/geom
 
 geos_HEADERS = \
-    BinaryOp.h \
+    HeuristicOverlay.h \
     CoordinateArraySequenceFactory.h \
     CoordinateArraySequenceFactory.inl \
     CoordinateArraySequence.h \
diff --git a/include/geos/operation/overlay/OverlayOp.h b/include/geos/operation/overlay/OverlayOp.h
index a2f5f6a..3f34525 100644
--- a/include/geos/operation/overlay/OverlayOp.h
+++ b/include/geos/operation/overlay/OverlayOp.h
@@ -400,27 +400,6 @@ private:
 
 };
 
-/** \brief
- * OverlayOp::overlayOp Adapter for use with geom::BinaryOp
- */
-struct overlayOp {
-
-    OverlayOp::OpCode opCode;
-
-    overlayOp(OverlayOp::OpCode code)
-        :
-        opCode(code)
-    {}
-
-    geom::Geometry*
-    operator()(const geom::Geometry* g0,
-               const geom::Geometry* g1)
-    {
-        return OverlayOp::overlayOp(g0, g1, opCode);
-    }
-
-};
-
 } // namespace geos::operation::overlay
 } // namespace geos::operation
 } // namespace geos
diff --git a/include/geos/operation/union/UnaryUnionOp.h b/include/geos/operation/union/UnaryUnionOp.h
index e6d9900..049cf80 100644
--- a/include/geos/operation/union/UnaryUnionOp.h
+++ b/include/geos/operation/union/UnaryUnionOp.h
@@ -24,7 +24,7 @@
 
 #include <geos/export.h>
 #include <geos/geom/GeometryFactory.h>
-#include <geos/geom/BinaryOp.h>
+#include <geos/geom/HeuristicOverlay.h>
 #include <geos/geom/Point.h>
 #include <geos/geom/LineString.h>
 #include <geos/geom/Polygon.h>
diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp
index 6701897..6a1075a 100644
--- a/src/geom/Geometry.cpp
+++ b/src/geom/Geometry.cpp
@@ -18,7 +18,7 @@
  *
  **********************************************************************/
 
-#include <geos/geom/BinaryOp.h>
+#include <geos/geom/HeuristicOverlay.h>
 #include <geos/geom/Geometry.h>
 #include <geos/geom/GeometryFactory.h>
 #include <geos/geom/PrecisionModel.h>
@@ -554,7 +554,7 @@ Geometry::intersection(const Geometry* other) const
 #ifdef USE_OVERLAYNG
     return operation::overlayng::OverlayNGSnapIfNeeded::Intersection(this, other);
 #else
-    return BinaryOp(this, other, overlayOp(OverlayOp::opINTERSECTION));
+    return HeuristicOverlay(this, other, OverlayOp::opINTERSECTION);
 #endif
 }
 
@@ -612,7 +612,7 @@ Geometry::Union(const Geometry* other) const
 #ifdef USE_OVERLAYNG
     return operation::overlayng::OverlayNGSnapIfNeeded::Union(this, other);
 #else
-    return BinaryOp(this, other, overlayOp(OverlayOp::opUNION));
+    return HeuristicOverlay(this, other, OverlayOp::opUNION);
 #endif
 }
 
@@ -643,7 +643,7 @@ Geometry::difference(const Geometry* other) const
 #ifdef USE_OVERLAYNG
     return operation::overlayng::OverlayNGSnapIfNeeded::Difference(this, other);
 #else
-    return BinaryOp(this, other, overlayOp(OverlayOp::opDIFFERENCE));
+    return HeuristicOverlay(this, other, OverlayOp::opDIFFERENCE);
 #endif
 }
 
@@ -697,7 +697,7 @@ Geometry::symDifference(const Geometry* other) const
 #ifdef USE_OVERLAYNG
     return operation::overlayng::OverlayNGSnapIfNeeded::SymDifference(this, other);
 #else
-    return BinaryOp(this, other, overlayOp(OverlayOp::opSYMDIFFERENCE));
+    return HeuristicOverlay(this, other, OverlayOp::opSYMDIFFERENCE);
 #endif
 
 }
diff --git a/include/geos/geom/BinaryOp.h b/src/geom/HeuristicOverlay.cpp
similarity index 85%
rename from include/geos/geom/BinaryOp.h
rename to src/geom/HeuristicOverlay.cpp
index 3a385e3..ed7eace 100644
--- a/include/geos/geom/BinaryOp.h
+++ b/src/geom/HeuristicOverlay.cpp
@@ -3,7 +3,7 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.osgeo.org
  *
- * Copyright (C) 2013 Sandro Santilli <strk at kbt.io>
+ * Copyright (C) 2013-2020 Sandro Santilli <strk at kbt.io>
  * Copyright (C) 2006 Refractions Research Inc.
  *
  * This is free software; you can redistribute and/or modify it under
@@ -43,11 +43,22 @@
  * See USE_TP_SIMPLIFY_POLICY, USE_PRECISION_REDUCTION_POLICY and
  * USE_SNAPPING_POLICY macros below.
  *
- *
  **********************************************************************/
 
-#ifndef GEOS_GEOM_BINARYOP_H
-#define GEOS_GEOM_BINARYOP_H
+#define GEOS_DEBUG_HEURISTICOVERLAY 1
+#define GEOS_DEBUG_HEURISTICOVERLAY_PRINT_INVALID 1
+
+#include <geos/geom/HeuristicOverlay.h>
+#include <geos/operation/overlay/OverlayOp.h>
+#include <geos/operation/overlayng/OverlayNGSnapIfNeeded.h>
+
+#include <geos/simplify/TopologyPreservingSimplifier.h>
+#include <geos/operation/IsSimpleOp.h>
+#include <geos/operation/valid/IsValidOp.h>
+#include <geos/operation/valid/TopologyValidationError.h>
+#include <geos/util/TopologyException.h>
+#include <geos/util.h>
+
 
 #include <geos/algorithm/BoundaryNodeRule.h>
 #include <geos/geom/Geometry.h>
@@ -61,19 +72,8 @@
 
 #include <geos/operation/overlay/snap/GeometrySnapper.h>
 
-#include <geos/simplify/TopologyPreservingSimplifier.h>
-#include <geos/operation/IsSimpleOp.h>
-#include <geos/operation/valid/IsValidOp.h>
-#include <geos/operation/valid/TopologyValidationError.h>
-#include <geos/util/TopologyException.h>
-#include <geos/util.h>
-
-#include <memory> // for unique_ptr
 
-//#define GEOS_DEBUG_BINARYOP 1
-#define GEOS_DEBUG_BINARYOP_PRINT_INVALID 1
-
-#ifdef GEOS_DEBUG_BINARYOP
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY
 # include <iostream>
 # include <iomanip>
 # include <sstream>
@@ -162,6 +162,7 @@
  */
 #define GEOS_CHECK_SNAPPINGOP_VALIDITY 0
 
+using geos::operation::overlay::OverlayOp;
 
 namespace geos {
 namespace geom { // geos::geom
@@ -186,13 +187,13 @@ check_valid(const Geometry& g, const std::string& label, bool doThrow = false, b
         if(! ivo.isValid()) {
             using operation::valid::TopologyValidationError;
             TopologyValidationError* err = ivo.getValidationError();
-#ifdef GEOS_DEBUG_BINARYOP
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY
             std::cerr << label << " is INVALID: "
                       << err->toString()
                       << " (" << std::setprecision(20)
                       << err->getCoordinate() << ")"
                       << std::endl
-#ifdef GEOS_DEBUG_BINARYOP_PRINT_INVALID
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY_PRINT_INVALID
                       << "<A>" << std::endl
                       << g.toString()
                       << std::endl
@@ -221,7 +222,7 @@ inline std::unique_ptr<Geometry>
 fix_self_intersections(std::unique_ptr<Geometry> g, const std::string& label)
 {
     ::geos::ignore_unused_variable_warning(label);
-#ifdef GEOS_DEBUG_BINARYOP
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY
     std::cerr << label << " fix_self_intersection (UnaryUnion)" << std::endl;
 #endif
 
@@ -246,18 +247,18 @@ fix_self_intersections(std::unique_ptr<Geometry> g, const std::string& label)
     switch(err->getErrorType()) {
     case TopologyValidationError::eRingSelfIntersection:
     case TopologyValidationError::eTooFewPoints: // collapsed lines
-#ifdef GEOS_DEBUG_BINARYOP
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << label << " ATTEMPT_TO_FIX: " << err->getErrorType() << ": " << *g << std::endl;
 #endif
         g = g->Union();
-#ifdef GEOS_DEBUG_BINARYOP
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << label << " ATTEMPT_TO_FIX succeeded.. " << std::endl;
 #endif
         return g;
     case TopologyValidationError::eSelfIntersection:
     // this one is within a single component, won't be fixed
     default:
-#ifdef GEOS_DEBUG_BINARYOP
+#ifdef GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << label << " invalidity is: " << err->getErrorType() << std::endl;
 #endif
         return g;
@@ -266,13 +267,12 @@ fix_self_intersections(std::unique_ptr<Geometry> g, const std::string& label)
 
 
 /// \brief
-/// Apply a binary operation to the given geometries
+/// Apply an overlay operation to the given geometries
 /// after snapping them to each other after common-bits
 /// removal.
 ///
-template <class BinOp>
 std::unique_ptr<Geometry>
-SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
+SnapOp(const Geometry* g0, const Geometry* g1, int opCode)
 {
     typedef std::unique_ptr<Geometry> GeomPtr;
 
@@ -282,7 +282,7 @@ SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     // Snap tolerance must be computed on the original
     // (not commonbits-removed) geoms
     double snapTolerance = GeometrySnapper::computeOverlaySnapTolerance(*g0, *g1);
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
     std::cerr << std::setprecision(20) << "Computed snap tolerance: " << snapTolerance << std::endl;
 #endif
 
@@ -292,7 +292,7 @@ SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     geos::precision::CommonBitsRemover cbr;
     cbr.add(g0);
     cbr.add(g1);
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
     std::cerr << "Computed common bits: " << cbr.getCommonCoordinate() << std::endl;
 #endif
 
@@ -302,7 +302,7 @@ SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     GeomPtr rG1 = g1->clone();
     cbr.removeCommonBits(rG1.get());
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
     check_valid(*rG0, "CBR: removed-bits geom 0");
     check_valid(*rG1, "CBR: removed-bits geom 1");
 #endif
@@ -324,10 +324,10 @@ SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     GeomPtr snapG1(snapper1.snapTo(*snapG0, snapTolerance));
     //snapG1 = fix_self_intersections(snapG1, "SNAP: snapped geom 1");
 
-    // Run the binary op
-    GeomPtr result(_Op(snapG0.get(), snapG1.get()));
+    // Run the overlay op
+    GeomPtr result(OverlayOp::overlayOp(snapG0.get(), snapG1.get(), OverlayOp::OpCode(opCode)));
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
     check_valid(*result, "SNAP: result (before common-bits addition");
 #endif
 
@@ -343,9 +343,9 @@ SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     return result;
 }
 
-template <class BinOp>
+
 std::unique_ptr<Geometry>
-BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
+HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)
 {
     typedef std::unique_ptr<Geometry> GeomPtr;
 
@@ -355,23 +355,23 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 #ifdef USE_ORIGINAL_INPUT
     // Try with original input
     try {
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Trying with original input." << std::endl;
 #endif
-        ret.reset(_Op(g0, g1));
+        ret.reset(OverlayOp::overlayOp(g0, g1, OverlayOp::OpCode(opCode)));
 
 #if GEOS_CHECK_ORIGINAL_RESULT_VALIDITY
         check_valid(*ret, "Overlay result between original inputs", true, true);
 #endif
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Attempt with original input succeeded" << std::endl;
 #endif
         return ret;
     }
     catch(const geos::util::TopologyException& ex) {
         origException = ex;
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Original exception: " << ex.what() << std::endl;
 #endif
     }
@@ -393,7 +393,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
         GeomPtr rG1;
         precision::CommonBitsRemover cbr;
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Trying with Common Bits Remover (CBR)" << std::endl;
 #endif
 
@@ -406,14 +406,14 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
         rG1 = g1->clone();
         cbr.removeCommonBits(rG1.get());
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         check_valid(*rG0, "CBR: geom 0 (after common-bits removal)");
         check_valid(*rG1, "CBR: geom 1 (after common-bits removal)");
 #endif
 
-        ret.reset(_Op(rG0.get(), rG1.get()));
+        ret.reset(OverlayOp::overlayOp(rG0.get(), rG1.get(), OverlayOp::OpCode(opCode)));
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         check_valid(*ret, "CBR: result (before common-bits addition)");
 #endif
 
@@ -423,7 +423,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
         check_valid(*ret, "CBR: result (after common-bits addition)", true);
 #endif
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Attempt with CBR succeeded" << std::endl;
 #endif
 
@@ -431,7 +431,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     }
     catch(const geos::util::TopologyException& ex) {
         ::geos::ignore_unused_variable_warning(ex);
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "CBR: " << ex.what() << std::endl;
 #endif
     }
@@ -446,16 +446,16 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 // {
 #if USE_SNAPPING_POLICY
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
     std::cerr << "Trying with snapping " << std::endl;
 #endif
 
     try {
-        ret = SnapOp(g0, g1, _Op);
+        ret = SnapOp(g0, g1, opCode);
 #if GEOS_CHECK_SNAPPINGOP_VALIDITY
         check_valid(*ret, "SNAP: result", true, true);
 #endif
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "SnapOp succeeded" << std::endl;
 #endif
         return ret;
@@ -463,7 +463,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
     }
     catch(const geos::util::TopologyException& ex) {
         ::geos::ignore_unused_variable_warning(ex);
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "SNAP: " << ex.what() << std::endl;
 #endif
     }
@@ -481,7 +481,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
         long unsigned int g1scale =
             static_cast<long unsigned int>(g1->getFactory()->getPrecisionModel()->getScale());
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Original input scales are: "
                   << g0scale
                   << " and "
@@ -503,7 +503,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
         for(double scale = maxScale; scale >= 1; scale /= 10) {
             PrecisionModel pm(scale);
             GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
             std::cerr << "Trying with scale " << scale << std::endl;
 #endif
 
@@ -511,13 +511,13 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
             GeomPtr rG0(reducer.reduce(*g0));
             GeomPtr rG1(reducer.reduce(*g1));
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
             check_valid(*rG0, "PR: geom 0 (after precision reduction)");
             check_valid(*rG1, "PR: geom 1 (after precision reduction)");
 #endif
 
             try {
-                ret.reset(_Op(rG0.get(), rG1.get()));
+                ret.reset(OverlayOp::overlayOp(rG0.get(), rG1.get(), OverlayOp::OpCode(opCode)));
                 // restore original precision (least precision between inputs)
                 if(g0->getFactory()->getPrecisionModel()->compareTo(g1->getFactory()->getPrecisionModel()) < 0) {
                     ret.reset(g0->getFactory()->createGeometry(ret.get()));
@@ -530,13 +530,13 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
                 check_valid(*ret, "PR: result (after restore of original precision)", true);
 #endif
 
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
                 std::cerr << "Attempt with scale " << scale << " succeeded" << std::endl;
 #endif
                 return ret;
             }
             catch(const geos::util::TopologyException& ex) {
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
                 std::cerr << "Reduced with scale (" << scale << "): "
                           << ex.what() << std::endl;
 #endif
@@ -549,7 +549,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 
     }
     catch(const geos::util::TopologyException& ex) {
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Reduced: " << ex.what() << std::endl;
 #endif
         ::geos::ignore_unused_variable_warning(ex);
@@ -559,9 +559,6 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 // USE_PRECISION_REDUCTION_POLICY }
 
 
-
-
-
 // {
 #if USE_TP_SIMPLIFY_POLICY
 
@@ -573,7 +570,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
         double tolStep = 0.01;
 
         for(double tol = minTolerance; tol <= maxTolerance; tol += tolStep) {
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
             std::cerr << "Trying simplifying with tolerance " << tol << std::endl;
 #endif
 
@@ -581,14 +578,14 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
             GeomPtr rG1(simplify::TopologyPreservingSimplifier::simplify(g1, tol));
 
             try {
-                ret.reset(_Op(rG0.get(), rG1.get()));
+                ret.reset(OverlayOp::overlayOp(rG0.get(), rG1.get(), geos::operation::overlay::OverlayOp::OpCode(opCode)));
                 return ret;
             }
             catch(const geos::util::TopologyException& ex) {
                 if(tol >= maxTolerance) {
                     throw ex;
                 }
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
                 std::cerr << "Simplified with tolerance (" << tol << "): "
                           << ex.what() << std::endl;
 #endif
@@ -600,7 +597,7 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 
     }
     catch(const geos::util::TopologyException& ex) {
-#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_HEURISTICOVERLAY
         std::cerr << "Simplified: " << ex.what() << std::endl;
 #endif
     }
@@ -608,7 +605,29 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 #endif
 // USE_TP_SIMPLIFY_POLICY }
 
-#if GEOS_DEBUG_BINARYOP
+
+#if GEOS_DEBUG_HEURISTICOVERLAY
+    std::cerr << "Trying with OverlayNGSnapIfNeeded" << std::endl;
+#endif
+
+    try {
+        ret = operation::overlayng::OverlayNGSnapIfNeeded::Overlay(g0, g1, opCode);
+
+#if GEOS_DEBUG_HEURISTICOVERLAY
+        std::cerr << "Attempt with OverlayNGSnapIfNeeded succeeded" << std::endl;
+#endif
+
+        return ret;
+    }
+    catch(const geos::util::TopologyException& ex) {
+        ::geos::ignore_unused_variable_warning(ex);
+#if GEOS_DEBUG_HEURISTICOVERLAY
+        std::cerr << "OverlayNGSnapIfNeeded: " << ex.what() << std::endl;
+#endif
+    }
+
+
+#if GEOS_DEBUG_HEURISTICOVERLAY
     std::cerr << "No attempts worked to union " << std::endl;
     std::cerr << "Input geometries:" << std::endl
               << "<A>" << std::endl
@@ -625,5 +644,3 @@ BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 
 } // namespace geos::geom
 } // namespace geos
-
-#endif // GEOS_GEOM_BINARYOP_H
diff --git a/src/geom/Makefile.am b/src/geom/Makefile.am
index fc49614..245fd4e 100644
--- a/src/geom/Makefile.am
+++ b/src/geom/Makefile.am
@@ -22,6 +22,7 @@ libgeom_la_SOURCES = \
     GeometryCollection.cpp \
     GeometryComponentFilter.cpp \
     GeometryFactory.cpp \
+    HeuristicOverlay.cpp \
     IntersectionMatrix.cpp \
     LinearRing.cpp \
     LineSegment.cpp \
diff --git a/src/operation/union/CascadedPolygonUnion.cpp b/src/operation/union/CascadedPolygonUnion.cpp
index d28c212..6d1d9bf 100644
--- a/src/operation/union/CascadedPolygonUnion.cpp
+++ b/src/operation/union/CascadedPolygonUnion.cpp
@@ -21,7 +21,7 @@
 #include <geos/operation/union/CascadedPolygonUnion.h>
 #include <geos/operation/union/OverlapUnion.h>
 #include <geos/operation/overlay/OverlayOp.h>
-#include <geos/geom/BinaryOp.h>
+#include <geos/geom/HeuristicOverlay.h>
 #include <geos/geom/Dimension.h>
 #include <geos/geom/Geometry.h>
 #include <geos/geom/GeometryFactory.h>
@@ -305,7 +305,7 @@ ClassicUnionStrategy::Union(const geom::Geometry* g0, const geom::Geometry* g1)
 {
     try {
         // return SnapIfNeededOverlayOp.union(g0, g1);
-        return geom::BinaryOp(g0, g1, overlay::overlayOp(OverlayOp::opUNION));
+        return geom::HeuristicOverlay(g0, g1, overlay::OverlayOp::opUNION);
     }
     catch (const util::TopologyException &ex) {
         // union-by-buffer only works for polygons
diff --git a/src/operation/valid/MakeValid.cpp b/src/operation/valid/MakeValid.cpp
index 8807432..afe29db 100644
--- a/src/operation/valid/MakeValid.cpp
+++ b/src/operation/valid/MakeValid.cpp
@@ -25,7 +25,7 @@
 #include <geos/operation/overlay/OverlayOp.h>
 #include <geos/operation/polygonize/BuildArea.h>
 #include <geos/operation/union/UnaryUnionOp.h>
-#include <geos/geom/BinaryOp.h>
+#include <geos/geom/HeuristicOverlay.h>
 #include <geos/geom/Geometry.h>
 #include <geos/geom/GeometryCollection.h>
 #include <geos/geom/GeometryFactory.h>
@@ -60,19 +60,19 @@ namespace valid { // geos.operation.valid
 static std::unique_ptr<geom::Geometry>
 makeValidSymDifference(const geom::Geometry* g0, const geom::Geometry* g1)
 {
-    return BinaryOp(g0, g1, overlayOp(OverlayOp::opSYMDIFFERENCE));
+    return HeuristicOverlay(g0, g1, OverlayOp::opSYMDIFFERENCE);
 }
 
 static std::unique_ptr<geom::Geometry>
 makeValidDifference(const geom::Geometry* g0, const geom::Geometry* g1)
 {
-    return BinaryOp(g0, g1, overlayOp(OverlayOp::opDIFFERENCE));
+    return HeuristicOverlay(g0, g1, OverlayOp::opDIFFERENCE);
 }
 
 static std::unique_ptr<geom::Geometry>
 makeValidUnion(const geom::Geometry* g0, const geom::Geometry* g1)
 {
-    return BinaryOp(g0, g1, overlayOp(OverlayOp::opUNION));
+    return HeuristicOverlay(g0, g1, OverlayOp::opUNION);
 }
 
 /*
diff --git a/tests/xmltester/BufferResultMatcher.cpp b/tests/xmltester/BufferResultMatcher.cpp
index 8e17a56..96ff030 100644
--- a/tests/xmltester/BufferResultMatcher.cpp
+++ b/tests/xmltester/BufferResultMatcher.cpp
@@ -19,7 +19,7 @@
 #include "BufferResultMatcher.h"
 
 #include <geos/geom/Geometry.h>
-#include <geos/geom/BinaryOp.h>
+#include <geos/geom/HeuristicOverlay.h>
 #include <geos/operation/overlay/OverlayOp.h>
 #include <geos/algorithm/distance/DiscreteHausdorffDistance.h>
 
@@ -68,11 +68,11 @@ BufferResultMatcher::isSymDiffAreaInTolerance(
     typedef std::unique_ptr<geom::Geometry> GeomPtr;
 
     using namespace operation::overlay;
-    using geos::geom::BinaryOp;
+    using geos::geom::HeuristicOverlay;
 
     double area = expectedBuffer.getArea();
-    GeomPtr diff = BinaryOp(&actualBuffer, &expectedBuffer,
-                            overlayOp(OverlayOp::opSYMDIFFERENCE));
+    GeomPtr diff = HeuristicOverlay(&actualBuffer, &expectedBuffer,
+                            OverlayOp::opSYMDIFFERENCE);
 
     double areaDiff = diff->getArea();
 
diff --git a/tests/xmltester/SingleSidedBufferResultMatcher.cpp b/tests/xmltester/SingleSidedBufferResultMatcher.cpp
index c3a1f92..9e51218 100644
--- a/tests/xmltester/SingleSidedBufferResultMatcher.cpp
+++ b/tests/xmltester/SingleSidedBufferResultMatcher.cpp
@@ -19,7 +19,7 @@
 #include "SingleSidedBufferResultMatcher.h"
 
 #include <geos/geom/Geometry.h>
-#include <geos/geom/BinaryOp.h>
+#include <geos/geom/HeuristicOverlay.h>
 #include <geos/operation/overlay/OverlayOp.h>
 #include <geos/algorithm/distance/DiscreteHausdorffDistance.h>
 
diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index 552524e..d9567dc 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -2393,7 +2393,7 @@ main(int argC, char* argV[])
  *         error on load of requested tests.
  *
  * Revision 1.32  2006/04/14 14:57:15  strk
- * XMLTester binary ops invoked using the new BinaryOp template function.
+ * XMLTester binary ops invoked using the new HeuristicOverlay template function.
  *
  * Revision 1.31  2006/04/07 13:26:38  strk
  * Use of unique_ptr<> to prevent confusing leaks in tester

commit 4633d4960a2ad15043f932cc8951209ba49d21a2
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Aug 24 14:05:15 2020 +0200

    OID are not needed by modern QGIS anymore

diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index 8fcf23d..552524e 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -410,7 +410,7 @@ XMLTester::run(const std::string& source)
                   //       The 'WITH OIDS' parameter is supported back to
                   //       PostgreSQL 7.2, so if you run an older version
                   //       rebuild with the next line commented out.
-                  << " WITH OIDS"
+                  //<< " WITH OIDS"
 
                   << ";" << std::endl;
     }

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

Summary of changes:
 capi/geos_c.cpp                                    |   7 -
 capi/geos_ts_c.cpp                                 |  22 +-
 .../{GeometryCollection.inl => HeuristicOverlay.h} |  27 +--
 include/geos/geom/Makefile.am                      |   2 +-
 include/geos/operation/overlay/OverlayOp.h         |  21 --
 include/geos/operation/union/UnaryUnionOp.h        |   2 +-
 src/geom/Geometry.cpp                              |  10 +-
 .../BinaryOp.h => src/geom/HeuristicOverlay.cpp    | 231 +++++++++++++++------
 src/geom/Makefile.am                               |   1 +
 src/operation/union/CascadedPolygonUnion.cpp       |   4 +-
 src/operation/valid/MakeValid.cpp                  |   8 +-
 tests/xmltester/BufferResultMatcher.cpp            |   8 +-
 tests/xmltester/SingleSidedBufferResultMatcher.cpp |   2 +-
 tests/xmltester/XMLTester.cpp                      |   4 +-
 14 files changed, 210 insertions(+), 139 deletions(-)
 copy include/geos/geom/{GeometryCollection.inl => HeuristicOverlay.h} (60%)
 rename include/geos/geom/BinaryOp.h => src/geom/HeuristicOverlay.cpp (75%)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list