[geos-commits] r3460 - in branches/3.3: . src/geom tests/unit tests/unit/geom/Geometry

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Aug 20 16:52:21 EDT 2011


Author: strk
Date: 2011-08-20 13:52:21 -0700 (Sat, 20 Aug 2011)
New Revision: 3460

Added:
   branches/3.3/tests/unit/geom/Geometry/clone.cpp
Modified:
   branches/3.3/NEWS
   branches/3.3/src/geom/GeometryCollection.cpp
   branches/3.3/src/geom/LineString.cpp
   branches/3.3/src/geom/Point.cpp
   branches/3.3/src/geom/Polygon.cpp
   branches/3.3/tests/unit/Makefile.am
Log:
Fix Geometry::clone() to copy SRID. Closes ticket #464.


Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS	2011-08-19 10:47:38 UTC (rev 3459)
+++ branches/3.3/NEWS	2011-08-20 20:52:21 UTC (rev 3460)
@@ -8,6 +8,7 @@
   - Fix for SOLARIS build 
   - Fix EMPTY result from GEOSOffsetCurve with distance 0 (#454)
   - Fix out of source builds
+  - Fix Geometry::clone to copy SRID (#464)
 
 Changes in 3.3.0
 2011-05-30

Modified: branches/3.3/src/geom/GeometryCollection.cpp
===================================================================
--- branches/3.3/src/geom/GeometryCollection.cpp	2011-08-19 10:47:38 UTC (rev 3459)
+++ branches/3.3/src/geom/GeometryCollection.cpp	2011-08-20 20:52:21 UTC (rev 3460)
@@ -45,7 +45,7 @@
 /*protected*/
 GeometryCollection::GeometryCollection(const GeometryCollection &gc)
 	:
-	Geometry(gc.getFactory())
+	Geometry(gc)
 {
 	size_t ngeoms=gc.geometries->size();
 

Modified: branches/3.3/src/geom/LineString.cpp
===================================================================
--- branches/3.3/src/geom/LineString.cpp	2011-08-19 10:47:38 UTC (rev 3459)
+++ branches/3.3/src/geom/LineString.cpp	2011-08-20 20:52:21 UTC (rev 3460)
@@ -49,7 +49,7 @@
 /*protected*/
 LineString::LineString(const LineString &ls)
 	:
-	Geometry(ls.getFactory()),
+	Geometry(ls),
 	points(ls.points->clone())
 {
 	//points=ls.points->clone();

Modified: branches/3.3/src/geom/Point.cpp
===================================================================
--- branches/3.3/src/geom/Point.cpp	2011-08-19 10:47:38 UTC (rev 3459)
+++ branches/3.3/src/geom/Point.cpp	2011-08-20 20:52:21 UTC (rev 3460)
@@ -62,7 +62,7 @@
 /*protected*/
 Point::Point(const Point &p)
 	:
-	Geometry(p.getFactory()),
+	Geometry(p),
 	coordinates(p.coordinates->clone())
 {
 }

Modified: branches/3.3/src/geom/Polygon.cpp
===================================================================
--- branches/3.3/src/geom/Polygon.cpp	2011-08-19 10:47:38 UTC (rev 3459)
+++ branches/3.3/src/geom/Polygon.cpp	2011-08-20 20:52:21 UTC (rev 3460)
@@ -53,7 +53,7 @@
 /*protected*/
 Polygon::Polygon(const Polygon &p)
 	:
-	Geometry(p.getFactory())
+	Geometry(p)
 {
 	shell=new LinearRing(*p.shell);
 	size_t nholes=p.holes->size();

Modified: branches/3.3/tests/unit/Makefile.am
===================================================================
--- branches/3.3/tests/unit/Makefile.am	2011-08-19 10:47:38 UTC (rev 3459)
+++ branches/3.3/tests/unit/Makefile.am	2011-08-20 20:52:21 UTC (rev 3460)
@@ -47,8 +47,9 @@
 	geom/CoordinateTest.cpp \
 	geom/DimensionTest.cpp \
 	geom/EnvelopeTest.cpp \
+	geom/Geometry/clone.cpp \
+	geom/Geometry/coversTest.cpp \
 	geom/Geometry/isRectangleTest.cpp \
-	geom/Geometry/coversTest.cpp \
 	geom/GeometryFactoryTest.cpp \
 	geom/IntersectionMatrixTest.cpp \
 	geom/LinearRingTest.cpp \

Added: branches/3.3/tests/unit/geom/Geometry/clone.cpp
===================================================================
--- branches/3.3/tests/unit/geom/Geometry/clone.cpp	                        (rev 0)
+++ branches/3.3/tests/unit/geom/Geometry/clone.cpp	2011-08-20 20:52:21 UTC (rev 3460)
@@ -0,0 +1,152 @@
+// $Id$
+// 
+// Test Suite for Geometry's clone() 
+
+// 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_geometry_clone_data
+{
+	typedef std::auto_ptr<geos::geom::Geometry> GeomAutoPtr;
+	geos::geom::GeometryFactory factory;
+	geos::io::WKTReader reader;
+
+	test_geometry_clone_data()
+	    : reader(&factory)
+	{}
+};
+
+typedef test_group<test_geometry_clone_data> group;
+typedef group::object object;
+
+group test_geometry_clone_data("geos::geom::Geometry::clone");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>()
+{
+	GeomAutoPtr g1(reader.read(
+		"POINT (0 100)"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+
+}
+
+template<>
+template<>
+void object::test<2>()
+{
+	GeomAutoPtr g1(reader.read(
+		"LINESTRING (0 0, 0 100, 100 100, 100 0)"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+
+}
+
+template<>
+template<>
+void object::test<3>()
+{
+	GeomAutoPtr g1(reader.read(
+		"POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+
+}
+
+template<>
+template<>
+void object::test<4>()
+{
+	GeomAutoPtr g1(reader.read(
+		"MULTIPOINT (0 100, 5 6)"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+
+}
+
+template<>
+template<>
+void object::test<5>()
+{
+	GeomAutoPtr g1(reader.read(
+		"MULTILINESTRING ((0 0, 0 100, 100 100, 100 0), (15 25, 25 52))"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+
+}
+
+template<>
+template<>
+void object::test<6>()
+{
+	GeomAutoPtr g1(reader.read(
+		"MULTIPOLYGON (((0 0, 0 100, 100 100, 100 0, 0 0)))"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+}
+
+template<>
+template<>
+void object::test<7>()
+{
+	GeomAutoPtr g1(reader.read(
+		"GEOMETRYCOLLECTION(MULTIPOLYGON (((0 0, 0 100, 100 100, 100 0, 0 0))),POINT(3 4))"
+	));
+	g1->setSRID(66);
+	GeomAutoPtr g2(g1->clone());
+	ensure( g1->equalsExact(g2.get()) );
+	ensure_equals( g1->getSRID(), 66 );
+	ensure_equals( g1->getSRID(), g2->getSRID() );
+}
+
+
+} // namespace tut
+



More information about the geos-commits mailing list