[geos-commits] [SCM] GEOS branch master updated. 6ca3f4c20514e2b8b80e57d09da924297b6a6dd1

git at osgeo.org git at osgeo.org
Thu Dec 27 17:48:31 PST 2018


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  6ca3f4c20514e2b8b80e57d09da924297b6a6dd1 (commit)
       via  33c1e7bc78dbfffcaf9a05744e49b76d91d21d2f (commit)
      from  1866159c644fb5c74f13f0714ebaba8e5c3e65ff (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 6ca3f4c20514e2b8b80e57d09da924297b6a6dd1
Merge: 1866159 33c1e7b
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Dec 27 20:48:03 2018 -0500

    Merge remote-tracking branch 'sir-sigurd/geometry-item-srid'

diff --cc tests/unit/geom/GeometryCollectionTest.cpp
index 89860f7,b906ba1..d49a230
--- a/tests/unit/geom/GeometryCollectionTest.cpp
+++ b/tests/unit/geom/GeometryCollectionTest.cpp
@@@ -1,56 -1,56 +1,83 @@@
  //
  // Test Suite for geos::geom::GeometryCollection class.
  
 -// tut
  #include <tut/tut.hpp>
  #include <utility.h>
 -// geos
 -#include <geos/geom/GeometryFactory.h>
 -#include <geos/geom/GeometryCollection.h>
 -// std
 -#include <vector>
 -
 -namespace tut
 -{
 +
 +
 +namespace tut {
- //
- // Test Group
- //
+ 	//
+ 	// Test Group
+ 	//
+ 
+ 	// Common data used by tests
 -	struct test_geometrycollection_data {};
++	struct test_geometry_collection_data {
++		typedef geos::geom::GeometryFactory GeometryFactory;
++
++		geos::geom::PrecisionModel pm_;
++		GeometryFactory::Ptr factory_;
+ 
 -	typedef test_group<test_geometrycollection_data> group;
++		test_geometry_collection_data()
++			: pm_(1000), factory_(GeometryFactory::create(&pm_, 0))
++		{
++		}
++	};
++
++	typedef test_group<test_geometry_collection_data> group;
+ 	typedef group::object object;
  
- // Common data used by tests
- struct test_geometry_collection_data {
-     typedef geos::geom::GeometryFactory GeometryFactory;
 -	group test_geometrycollection_group("geos::geom::GeometryCollection");
++	group test_geometry_collection_group("geos::geom::GeometryCollection");
  
-     geos::geom::PrecisionModel pm_;
-     GeometryFactory::Ptr factory_;
+ 	//
+ 	// Test Cases
+ 	//
  
-     test_geometry_collection_data()
-         : pm_(1000), factory_(GeometryFactory::create(&pm_, 0))
++#if 0
++
++	// Test of user's constructor to build empty Point
++	template<>
++    template<>
++    void object::test<1>()
 +    {
-     }
- };
++        GeometryPtr empty_point = factory_->createPoint();
++        ensure( empty_point != nullptr );
 +
- typedef test_group<test_geometry_collection_data> group;
- typedef group::object object;
++        geos::geom::Coordinate coord(1, 2);
++        GeometryPtr point = factory_->createPoint(coord);
++        ensure( point != nullptr );
 +
- group test_geometry_collection_group("geos::geom::GeometryCollection");
++        std::vector<GeometryPtr> geoms{empty_point, point};
++        GeometryColPtr col = factory_->createGeometryCollection(geoms);
++        ensure( col != nullptr );
 +
- //
- // Test Cases
- //
++        ensure( col->getCoordinate() != nullptr );
++        ensure_equals( col->getCoordinate()->x, 1 );
++        ensure_equals( col->getCoordinate()->y, 2 );
++    }
 +
- // Test of user's constructor to build empty Point
- template<>
- template<>
- void object::test<1>()
- {
-     GeometryPtr empty_point = factory_->createPoint();
-     ensure( empty_point != nullptr );
+ 	// Test of default constructor
+ 	template<>
+ 	template<>
 -	void object::test<1>()
++	void object::test<2>()
+ 	{
 -		using geos::geom::GeometryFactory;
+ 		geos::geom::PrecisionModel pm;
+ 		auto gf = GeometryFactory::create(&pm, 1);
+ 		auto g = gf->createEmptyGeometry();
  
-     geos::geom::Coordinate coord(1, 2);
-     GeometryPtr point = factory_->createPoint(coord);
-     ensure( point != nullptr );
+ 		g->setSRID(0);
+ 		std::vector<decltype(g)> v = {g};
+ 		auto geom_col = gf->createGeometryCollection(v);
+ 		ensure_equals(geom_col->getGeometryN(0)->getSRID(), 1);
  
-     std::vector<GeometryPtr> geoms{empty_point, point};
-     GeometryColPtr col = factory_->createGeometryCollection(geoms);
-     ensure( col != nullptr );
+ 		geom_col->setSRID(2);
+ 		ensure_equals(geom_col->getGeometryN(0)->getSRID(), 2);
  
-     ensure( col->getCoordinate() != nullptr );
-     ensure_equals( col->getCoordinate()->x, 1 );
-     ensure_equals( col->getCoordinate()->y, 2 );
- }
+ 		auto clone = geom_col->clone();
+ 		ensure_equals(clone->getGeometryN(0)->getSRID(), 2);
  
+ 		// FREE MEMORY
+ 		gf->destroyGeometry(geom_col);
+ 		gf->destroyGeometry(clone);
+ 	}
++#endif
  } // namespace tut

commit 33c1e7bc78dbfffcaf9a05744e49b76d91d21d2f
Author: Sergey Fedoseev <fedoseev.sergey at gmail.com>
Date:   Sun Sep 16 18:07:06 2018 +0500

    Fix #924: Geometries returned by getGeometryN() now have the same SRID as collection.

diff --git a/include/geos/geom/GeometryCollection.h b/include/geos/geom/GeometryCollection.h
index c255ecf..7832d26 100644
--- a/include/geos/geom/GeometryCollection.h
+++ b/include/geos/geom/GeometryCollection.h
@@ -78,6 +78,8 @@ public:
 
 	~GeometryCollection() override;
 
+	void setSRID(int) override;
+
 	/**
 	 * \brief
 	 * Collects all coordinates of all subgeometries into a
diff --git a/src/geom/GeometryCollection.cpp b/src/geom/GeometryCollection.cpp
index 3ead8fa..d893d9e 100644
--- a/src/geom/GeometryCollection.cpp
+++ b/src/geom/GeometryCollection.cpp
@@ -53,8 +53,6 @@ GeometryCollection::GeometryCollection(const GeometryCollection &gc)
 	for(size_t i=0; i<ngeoms; ++i)
 	{
 		(*geometries)[i]=(*gc.geometries)[i]->clone();
-    // Drop SRID from inner geoms
-		(*geometries)[i]->setSRID(0);
 	}
 }
 
@@ -72,11 +70,21 @@ GeometryCollection::GeometryCollection(vector<Geometry *> *newGeoms, const Geome
 	}
 	geometries=newGeoms;
 
-  // Drop SRID from inner geoms
+	// Set SRID for inner geoms
 	size_t ngeoms=geometries->size();
 	for(size_t i=0; i<ngeoms; ++i)
 	{
-		(*geometries)[i]->setSRID(0);
+		(*geometries)[i]->setSRID(getSRID());
+	}
+}
+
+void
+GeometryCollection::setSRID(int newSRID)
+{
+	Geometry::setSRID(newSRID);
+	for (size_t i = 0; i < geometries->size(); i++)
+	{
+		(*geometries)[i]->setSRID(newSRID);
 	}
 }
 
diff --git a/src/io/WKBWriter.cpp b/src/io/WKBWriter.cpp
index dbc0d4c..f9bd7ff 100644
--- a/src/io/WKBWriter.cpp
+++ b/src/io/WKBWriter.cpp
@@ -203,6 +203,8 @@ WKBWriter::writeGeometryCollection(const GeometryCollection &g,
 
 	auto ngeoms = g.getNumGeometries();
 	writeInt(static_cast<int>(ngeoms));
+	auto orig_includeSRID = includeSRID;
+	includeSRID = false;
 
 	assert(outStream);
 	for (std::size_t i=0; i<ngeoms; i++)
@@ -212,6 +214,7 @@ WKBWriter::writeGeometryCollection(const GeometryCollection &g,
 
 		write(*elem, *outStream);
 	}
+	includeSRID = orig_includeSRID;
 }
 
 void
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 8f02cc4..bcfaf6e 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -58,6 +58,7 @@ geos_unit_SOURCES = \
 	geom/CoordinateTest.cpp \
 	geom/DimensionTest.cpp \
 	geom/EnvelopeTest.cpp \
+	geom/GeometryCollectionTest.cpp \
 	geom/Geometry/clone.cpp \
 	geom/Geometry/coversTest.cpp \
 	geom/Geometry/equalsTest.cpp \
diff --git a/tests/unit/geom/GeometryCollectionTest.cpp b/tests/unit/geom/GeometryCollectionTest.cpp
new file mode 100644
index 0000000..b906ba1
--- /dev/null
+++ b/tests/unit/geom/GeometryCollectionTest.cpp
@@ -0,0 +1,56 @@
+//
+// Test Suite for geos::geom::GeometryCollection class.
+
+// tut
+#include <tut/tut.hpp>
+#include <utility.h>
+// geos
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/GeometryCollection.h>
+// std
+#include <vector>
+
+namespace tut
+{
+	//
+	// Test Group
+	//
+
+	// Common data used by tests
+	struct test_geometrycollection_data {};
+
+	typedef test_group<test_geometrycollection_data> group;
+	typedef group::object object;
+
+	group test_geometrycollection_group("geos::geom::GeometryCollection");
+
+	//
+	// Test Cases
+	//
+
+	// Test of default constructor
+	template<>
+	template<>
+	void object::test<1>()
+	{
+		using geos::geom::GeometryFactory;
+		geos::geom::PrecisionModel pm;
+		auto gf = GeometryFactory::create(&pm, 1);
+		auto g = gf->createEmptyGeometry();
+
+		g->setSRID(0);
+		std::vector<decltype(g)> v = {g};
+		auto geom_col = gf->createGeometryCollection(v);
+		ensure_equals(geom_col->getGeometryN(0)->getSRID(), 1);
+
+		geom_col->setSRID(2);
+		ensure_equals(geom_col->getGeometryN(0)->getSRID(), 2);
+
+		auto clone = geom_col->clone();
+		ensure_equals(clone->getGeometryN(0)->getSRID(), 2);
+
+		// FREE MEMORY
+		gf->destroyGeometry(geom_col);
+		gf->destroyGeometry(clone);
+	}
+} // namespace tut

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

Summary of changes:
 include/geos/geom/GeometryCollection.h     |  2 +
 src/geom/GeometryCollection.cpp            | 16 +++--
 src/io/WKBWriter.cpp                       |  3 +
 tests/unit/Makefile.am                     |  2 +-
 tests/unit/geom/GeometryCollectionTest.cpp | 97 +++++++++++++++++++-----------
 5 files changed, 80 insertions(+), 40 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list