[geos-commits] r3461 - in trunk: src/geom tests/unit
tests/unit/geom/Geometry
svn_geos at osgeo.org
svn_geos at osgeo.org
Sat Aug 20 17:02:57 EDT 2011
Author: strk
Date: 2011-08-20 14:02:57 -0700 (Sat, 20 Aug 2011)
New Revision: 3461
Added:
trunk/tests/unit/geom/Geometry/clone.cpp
Modified:
trunk/src/geom/GeometryCollection.cpp
trunk/src/geom/LineString.cpp
trunk/src/geom/Point.cpp
trunk/src/geom/Polygon.cpp
trunk/tests/unit/Makefile.am
Log:
Forward port fix for #464 (Geometry.clone SRID copy)
Modified: trunk/src/geom/GeometryCollection.cpp
===================================================================
--- trunk/src/geom/GeometryCollection.cpp 2011-08-20 20:52:21 UTC (rev 3460)
+++ trunk/src/geom/GeometryCollection.cpp 2011-08-20 21:02:57 UTC (rev 3461)
@@ -45,7 +45,7 @@
/*protected*/
GeometryCollection::GeometryCollection(const GeometryCollection &gc)
:
- Geometry(gc.getFactory())
+ Geometry(gc)
{
size_t ngeoms=gc.geometries->size();
Modified: trunk/src/geom/LineString.cpp
===================================================================
--- trunk/src/geom/LineString.cpp 2011-08-20 20:52:21 UTC (rev 3460)
+++ trunk/src/geom/LineString.cpp 2011-08-20 21:02:57 UTC (rev 3461)
@@ -49,7 +49,7 @@
/*protected*/
LineString::LineString(const LineString &ls)
:
- Geometry(ls.getFactory()),
+ Geometry(ls),
points(ls.points->clone())
{
//points=ls.points->clone();
Modified: trunk/src/geom/Point.cpp
===================================================================
--- trunk/src/geom/Point.cpp 2011-08-20 20:52:21 UTC (rev 3460)
+++ trunk/src/geom/Point.cpp 2011-08-20 21:02:57 UTC (rev 3461)
@@ -62,7 +62,7 @@
/*protected*/
Point::Point(const Point &p)
:
- Geometry(p.getFactory()),
+ Geometry(p),
coordinates(p.coordinates->clone())
{
}
Modified: trunk/src/geom/Polygon.cpp
===================================================================
--- trunk/src/geom/Polygon.cpp 2011-08-20 20:52:21 UTC (rev 3460)
+++ trunk/src/geom/Polygon.cpp 2011-08-20 21:02:57 UTC (rev 3461)
@@ -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: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am 2011-08-20 20:52:21 UTC (rev 3460)
+++ trunk/tests/unit/Makefile.am 2011-08-20 21:02:57 UTC (rev 3461)
@@ -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: trunk/tests/unit/geom/Geometry/clone.cpp
===================================================================
--- trunk/tests/unit/geom/Geometry/clone.cpp (rev 0)
+++ trunk/tests/unit/geom/Geometry/clone.cpp 2011-08-20 21:02:57 UTC (rev 3461)
@@ -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