[geos-commits] [SCM] GEOS branch master updated. 693c1aa855263198d42153da0d12f56b2b7a6991

git at osgeo.org git at osgeo.org
Wed Dec 9 13:28:57 PST 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  693c1aa855263198d42153da0d12f56b2b7a6991 (commit)
      from  cb186cda2f802094d5656f467b86c2b50f357576 (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 693c1aa855263198d42153da0d12f56b2b7a6991
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Dec 9 13:28:46 2020 -0800

    Correctly return isEmpty for hand-built empty points, closes #1049

diff --git a/src/geom/Point.cpp b/src/geom/Point.cpp
index 0b2e454..d439375 100644
--- a/src/geom/Point.cpp
+++ b/src/geom/Point.cpp
@@ -68,6 +68,8 @@ Point::Point(CoordinateSequence* newCoords, const GeometryFactory* factory)
     } else {
         empty2d = true;
     }
+
+
 }
 
 Point::Point(const Coordinate & c, const GeometryFactory* factory) :
@@ -103,7 +105,12 @@ Point::getNumPoints() const
 bool
 Point::isEmpty() const
 {
-    return empty2d || empty3d;
+    if (empty2d || empty3d) return true;
+    const Coordinate& c = coordinates.getAt(0);
+    if (std::isnan(c.x) && std::isnan(c.y))
+        return true;
+    else
+        return false;
 }
 
 bool
diff --git a/tests/unit/geom/PointTest.cpp b/tests/unit/geom/PointTest.cpp
index 3880eb8..d473cb5 100644
--- a/tests/unit/geom/PointTest.cpp
+++ b/tests/unit/geom/PointTest.cpp
@@ -12,6 +12,7 @@
 #include <geos/geom/PrecisionModel.h>
 #include <geos/io/WKTReader.h>
 #include <geos/util/IllegalArgumentException.h>
+#include <geos/constants.h>
 // std
 #include <memory>
 #include <string>
@@ -579,5 +580,25 @@ void object::test<45>
     ensure_equals(pt3->getCoordinateDimension(), 3);
 }
 
+
+
+// Test hand-build POINT(NaN NaN)
+template<>
+template<>
+void object::test<46>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+
+    CoordinateArraySequence* coords = new CoordinateArraySequence();
+    ensure(coords != nullptr);
+    coords->add(Coordinate(geos::DoubleNotANumber, geos::DoubleNotANumber));
+
+    PointAutoPtr point(factory_->createPoint(coords));
+    ensure("point->isEmpty()", point->isEmpty());
+    ensure("point->getCoordinateDimension() == 2", point->getCoordinateDimension() == 2);
+}
+
 } // namespace tut
 
diff --git a/tests/unit/io/WKTWriterTest.cpp b/tests/unit/io/WKTWriterTest.cpp
index db9d97d..1718fa5 100644
--- a/tests/unit/io/WKTWriterTest.cpp
+++ b/tests/unit/io/WKTWriterTest.cpp
@@ -8,8 +8,11 @@
 #include <geos/io/WKTWriter.h>
 #include <geos/geom/PrecisionModel.h>
 #include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Point.h>
 #include <geos/geom/Geometry.h>
 #include <geos/geom/GeometryCollection.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/CoordinateArraySequence.h>
 // std
 #include <sstream>
 #include <string>
@@ -182,5 +185,28 @@ void object::test<6>
     ensure_equals(result, std::string("MULTIPOINT (EMPTY, 1 2)"));
 }
 
+
+template<>
+template<>
+void object::test<7>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+    using geos::geom::Point;
+
+    PrecisionModel pm;
+    auto factory_ = GeometryFactory::create(&pm);
+    CoordinateArraySequence* coords = new CoordinateArraySequence();
+    ensure(coords != nullptr);
+
+    coords->add(Coordinate(geos::DoubleNotANumber, geos::DoubleNotANumber));
+    std::unique_ptr<Point> point(factory_->createPoint(coords));
+
+    std::string result = wktwriter.write(point.get());
+    ensure_equals(result, std::string("POINT EMPTY"));
+}
+
+
 } // namespace tut
 

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

Summary of changes:
 src/geom/Point.cpp              |  9 ++++++++-
 tests/unit/geom/PointTest.cpp   | 21 +++++++++++++++++++++
 tests/unit/io/WKTWriterTest.cpp | 26 ++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list