[geos-commits] r4153 - trunk/tests/unit/operation/overlay
svn_geos at osgeo.org
svn_geos at osgeo.org
Mon Feb 29 09:59:06 PST 2016
Author: mloskot
Date: 2016-02-29 09:59:06 -0800 (Mon, 29 Feb 2016)
New Revision: 4153
Added:
trunk/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
Log:
Add basic test for geos::operation::OverlayOp with UNION.
Test union of four segments (linestrings) of a suqare.
Added: trunk/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
===================================================================
--- trunk/tests/unit/operation/overlay/OverlayOpUnionTest.cpp (rev 0)
+++ trunk/tests/unit/operation/overlay/OverlayOpUnionTest.cpp 2016-02-29 17:59:06 UTC (rev 4153)
@@ -0,0 +1,64 @@
+//
+// Test Suite for geos::operation::OverlayOp class for UNION
+
+#include <tut.hpp>
+// geos
+#include <geos/operation/overlay/OverlayOp.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/PrecisionModel.h>
+#include <geos/io/WKBReader.h>
+#include <geos/io/WKTReader.h>
+// std
+#include <string>
+#include <memory>
+
+using namespace geos::geom;
+using namespace geos::operation;
+
+namespace tut
+{
+ //
+ // Test Group
+ //
+
+ struct test_overlayopunion_data
+ {
+ typedef geos::geom::Geometry::AutoPtr GeometryPtr;
+ typedef geos::geom::GeometryFactory GeometryFactory;
+ typedef geos::geom::GeometryFactory::unique_ptr GeometryFactoryPtr;
+ };
+
+ typedef test_group<test_overlayopunion_data> group;
+ typedef group::object object;
+
+ group test_issimpleop_group("geos::operation::OverlayOp::UNION");
+
+ //
+ // Test Cases
+ //
+
+ // 1 - Union four segments of a square
+ template<>
+ template<>
+ void object::test<1>()
+ {
+ // Arrange
+ geos::geom::PrecisionModel pm(1e+13);
+ GeometryFactoryPtr factory = geos::geom::GeometryFactory::create(&pm);
+ geos::io::WKTReader reader(*factory);
+ GeometryPtr line1(reader.read("LINESTRING(0 0, 0 5)"));
+ GeometryPtr line2(reader.read("LINESTRING(0 5, 5 5)"));
+ GeometryPtr line3(reader.read("LINESTRING(5 5, 5 0)"));
+ GeometryPtr line4(reader.read("LINESTRING(5 0, 0 0)"));
+
+ // Act: union segments incrementally
+ GeometryPtr lines12(line1->Union(line2.get()));
+ GeometryPtr lines123(lines12->Union(line3.get()));
+ GeometryPtr lines1234(lines123->Union(line4.get()));
+
+ // Assert
+ ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+ }
+
+} // namespace tut
More information about the geos-commits
mailing list