[geos-commits] r4000 - in branches/3.4: . src/geom tests/unit tests/unit/geom tests/unit/geom/Geometry
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue Sep 9 07:36:35 PDT 2014
Author: strk
Date: 2014-09-09 07:36:35 -0700 (Tue, 09 Sep 2014)
New Revision: 4000
Added:
branches/3.4/tests/unit/geom/Geometry/equalsTest.cpp
Modified:
branches/3.4/NEWS
branches/3.4/src/geom/Envelope.cpp
branches/3.4/src/geom/Geometry.cpp
branches/3.4/tests/unit/Makefile.am
branches/3.4/tests/unit/geom/EnvelopeTest.cpp
branches/3.4/tests/unit/geom/PointTest.cpp
Log:
Fix Empty to Empty equals response (#703)
Modified: branches/3.4/NEWS
===================================================================
--- branches/3.4/NEWS 2014-09-09 14:35:51 UTC (rev 3999)
+++ branches/3.4/NEWS 2014-09-09 14:36:35 UTC (rev 4000)
@@ -2,6 +2,7 @@
YYYY-MM-DD
- Bug fixes / improvements
+ - Fix Empty to Empty equals (#703)
- Fix build on OpenBSD (#700)
- Fix build on HP-UX 11.23 (#664)
- Throw a ParseException on missing chars from HEXWKB string (#675)
Modified: branches/3.4/src/geom/Envelope.cpp
===================================================================
--- branches/3.4/src/geom/Envelope.cpp 2014-09-09 14:35:51 UTC (rev 3999)
+++ branches/3.4/src/geom/Envelope.cpp 2014-09-09 14:36:35 UTC (rev 4000)
@@ -325,7 +325,7 @@
bool
Envelope::equals(const Envelope* other) const
{
- if (isNull() || other->isNull()) { return false; }
+ if (isNull()) return other->isNull();
return other->getMinX() == minx &&
other->getMaxX() == maxx &&
other->getMinY() == miny &&
Modified: branches/3.4/src/geom/Geometry.cpp
===================================================================
--- branches/3.4/src/geom/Geometry.cpp 2014-09-09 14:35:51 UTC (rev 3999)
+++ branches/3.4/src/geom/Geometry.cpp 2014-09-09 14:36:35 UTC (rev 4000)
@@ -435,6 +435,10 @@
if (! getEnvelopeInternal()->equals(g->getEnvelopeInternal()))
return false;
#endif
+
+ if (isEmpty()) return g->isEmpty();
+ else if (g->isEmpty()) return isEmpty();
+
auto_ptr<IntersectionMatrix> im ( relate(g) );
bool res=im->isEquals(getDimension(), g->getDimension());
return res;
Modified: branches/3.4/tests/unit/Makefile.am
===================================================================
--- branches/3.4/tests/unit/Makefile.am 2014-09-09 14:35:51 UTC (rev 3999)
+++ branches/3.4/tests/unit/Makefile.am 2014-09-09 14:36:35 UTC (rev 4000)
@@ -49,6 +49,7 @@
geom/EnvelopeTest.cpp \
geom/Geometry/clone.cpp \
geom/Geometry/coversTest.cpp \
+ geom/Geometry/equalsTest.cpp \
geom/Geometry/isRectangleTest.cpp \
geom/GeometryFactoryTest.cpp \
geom/IntersectionMatrixTest.cpp \
Modified: branches/3.4/tests/unit/geom/EnvelopeTest.cpp
===================================================================
--- branches/3.4/tests/unit/geom/EnvelopeTest.cpp 2014-09-09 14:35:51 UTC (rev 3999)
+++ branches/3.4/tests/unit/geom/EnvelopeTest.cpp 2014-09-09 14:36:35 UTC (rev 4000)
@@ -102,6 +102,9 @@
ensure( !zero2.isNull() );
ensure( !box.isNull() );
+ /* See http://trac.osgeo.org/geos/ticket/703 */
+ ensure( empty.equals( &empty ) );
+
ensure( !empty.equals( &zero ) );
ensure( !zero.equals( &empty ) );
Added: branches/3.4/tests/unit/geom/Geometry/equalsTest.cpp
===================================================================
--- branches/3.4/tests/unit/geom/Geometry/equalsTest.cpp (rev 0)
+++ branches/3.4/tests/unit/geom/Geometry/equalsTest.cpp 2014-09-09 14:36:35 UTC (rev 4000)
@@ -0,0 +1,68 @@
+//
+// Test Suite for Geometry's equals() function
+
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/Polygon.h>
+#include <geos/io/WKTReader.h>
+// std
+#include <memory>
+#include <string>
+
+namespace tut {
+
+//
+// Test Group
+//
+
+struct test_equals_data
+{
+ typedef std::auto_ptr<geos::geom::Geometry> GeomAutoPtr;
+ geos::geom::GeometryFactory factory;
+ geos::io::WKTReader reader;
+
+ test_equals_data()
+ : reader(&factory)
+ {}
+};
+
+typedef test_group<test_equals_data> group;
+typedef group::object object;
+
+group test_equals_data("geos::geom::Geometry::equals");
+
+//
+// Test Cases
+//
+
+// Empty equals empty
+// See http://trac.osgeo.org/geos/ticket/703
+
+template<> template<> void object::test<1>() {
+
+ GeomAutoPtr g1(reader.read("POINT EMPTY"));
+ ensure( g1->equals(g1.get()) );
+
+ GeomAutoPtr g2(reader.read("LINESTRING EMPTY"));
+ ensure( g2->equals(g2.get()) );
+ ensure( g2->equals(g1.get()) );
+
+ GeomAutoPtr g3(reader.read("POLYGON EMPTY"));
+ ensure( g3->equals(g3.get()) );
+ ensure( g3->equals(g2.get()) );
+ ensure( g3->equals(g1.get()) );
+
+ GeomAutoPtr g4(reader.read("GEOMETRYCOLLECTION EMPTY"));
+ ensure( g4->equals(g4.get()) );
+ ensure( g4->equals(g3.get()) );
+ ensure( g4->equals(g2.get()) );
+ ensure( g4->equals(g1.get()) );
+
+}
+
+
+} // namespace tut
+
Modified: branches/3.4/tests/unit/geom/PointTest.cpp
===================================================================
--- branches/3.4/tests/unit/geom/PointTest.cpp 2014-09-09 14:35:51 UTC (rev 3999)
+++ branches/3.4/tests/unit/geom/PointTest.cpp 2014-09-09 14:36:35 UTC (rev 4000)
@@ -371,7 +371,7 @@
{
GeometryAutoPtr geo(empty_point_->clone());
- ensure( !empty_point_->equals(geo.get()) );
+ ensure( empty_point_->equals(geo.get()) );
}
// Test of equals() for non-empty Point (1.234,5.678)
More information about the geos-commits
mailing list