[geos-commits] [SCM] GEOS branch main updated. 5dc668b7f2ca3beb9d188b9dfc6f8f3e4935894a
git at osgeo.org
git at osgeo.org
Mon Jun 17 19:32:33 PDT 2024
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, main has been updated
via 5dc668b7f2ca3beb9d188b9dfc6f8f3e4935894a (commit)
from 2aa98200475266fb63e132f806f82c00c8665c6c (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 5dc668b7f2ca3beb9d188b9dfc6f8f3e4935894a
Author: Dan Baston <dbaston at gmail.com>
Date: Mon Jun 17 22:32:12 2024 -0400
WKBReader: Support curved geometry types (#1106)
diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h
index 342d0cf6b..3661bf886 100644
--- a/include/geos/geom/Geometry.h
+++ b/include/geos/geom/Geometry.h
@@ -70,7 +70,7 @@ namespace geos { // geos
namespace geom { // geos::geom
/// Geometry types
-enum GeometryTypeId {
+enum GeometryTypeId : int {
/// a point
GEOS_POINT,
/// a linestring
diff --git a/include/geos/geom/GeometryTypeName.h b/include/geos/geom/GeometryTypeName.h
new file mode 100644
index 000000000..9807e5a24
--- /dev/null
+++ b/include/geos/geom/GeometryTypeName.h
@@ -0,0 +1,110 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2024 ISciences, LLC
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ **********************************************************************/
+
+#pragma once
+
+namespace geos {
+namespace geom {
+
+class Curve;
+class CurvePolygon;
+class GeometryCollection;
+class LineString;
+class LinearRing;
+class MultiCurve;
+class MultiLineString;
+class MultiPoint;
+class MultiPolygon;
+class MultiSurface;
+class Point;
+class Polygon;
+class SimpleCurve;
+class Surface;
+
+// These structures allow templates to have compile-time access to a type's human-readable name.
+template<typename T>
+struct GeometryTypeName {};
+
+template<>
+struct GeometryTypeName<geom::Curve> {
+ static constexpr const char* name = "Curve";
+};
+
+template<>
+struct GeometryTypeName<geom::CurvePolygon> {
+ static constexpr const char* name = "CurvePolygon";
+};
+
+template<>
+struct GeometryTypeName<geom::GeometryCollection> {
+ static constexpr const char* name = "GeometryCollection";
+};
+
+template<>
+struct GeometryTypeName<geom::LineString> {
+ static constexpr const char* name = "LineString";
+};
+
+template<>
+struct GeometryTypeName<geom::LinearRing> {
+ static constexpr const char* name = "LinearRing";
+};
+
+template<>
+struct GeometryTypeName<geom::MultiCurve> {
+ static constexpr const char* name = "MultiCurve";
+};
+
+template<>
+struct GeometryTypeName<geom::MultiLineString> {
+ static constexpr const char* name = "MultiLineString";
+};
+
+template<>
+struct GeometryTypeName<geom::MultiPoint> {
+ static constexpr const char* name = "MultiPoint";
+};
+
+template<>
+struct GeometryTypeName<geom::MultiPolygon> {
+ static constexpr const char* name = "MultiPolygon";
+};
+
+template<>
+struct GeometryTypeName<geom::MultiSurface> {
+ static constexpr const char* name = "MultiSurface";
+};
+
+template<>
+struct GeometryTypeName<geom::Point> {
+ static constexpr const char* name = "Point";
+};
+
+template<>
+struct GeometryTypeName<geom::Polygon> {
+ static constexpr const char* name = "Polygon";
+};
+
+template<>
+struct GeometryTypeName<geom::SimpleCurve> {
+ static constexpr const char* name = "SimpleCurve";
+};
+
+template<>
+struct GeometryTypeName<geom::Surface> {
+ static constexpr const char* name = "Surface";
+};
+
+}
+}
diff --git a/include/geos/io/WKBReader.h b/include/geos/io/WKBReader.h
index c050f26ac..008f32865 100644
--- a/include/geos/io/WKBReader.h
+++ b/include/geos/io/WKBReader.h
@@ -20,7 +20,8 @@
#pragma once
#include <geos/export.h>
-
+#include <geos/geom/Geometry.h>
+#include <geos/geom/GeometryTypeName.h>
#include <geos/io/ByteOrderDataInStream.h> // for composition
#include <iosfwd> // ostream, istream
@@ -28,8 +29,6 @@
// #include <vector>
#include <array>
-#define BAD_GEOM_TYPE_MSG "Bad geometry type encountered in"
-
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
@@ -41,17 +40,24 @@ namespace geom {
class GeometryFactory;
class Coordinate;
+class CircularString;
+class CompoundCurve;
+class CurvePolygon;
class Geometry;
+enum GeometryTypeId : int;
class GeometryCollection;
class Point;
class LineString;
class LinearRing;
class Polygon;
+class MultiCurve;
class MultiPoint;
class MultiLineString;
class MultiPolygon;
+class MultiSurface;
class PrecisionModel;
class CoordinateSequence;
+class SimpleCurve;
} // namespace geom
} // namespace geos
@@ -148,22 +154,42 @@ private:
std::unique_ptr<geom::LinearRing> readLinearRing();
+ std::unique_ptr<geom::CircularString> readCircularString();
+
+ std::unique_ptr<geom::CompoundCurve> readCompoundCurve();
+
std::unique_ptr<geom::Polygon> readPolygon();
+ std::unique_ptr<geom::CurvePolygon> readCurvePolygon();
+
std::unique_ptr<geom::MultiPoint> readMultiPoint();
std::unique_ptr<geom::MultiLineString> readMultiLineString();
+ std::unique_ptr<geom::MultiCurve> readMultiCurve();
+
std::unique_ptr<geom::MultiPolygon> readMultiPolygon();
+ std::unique_ptr<geom::MultiSurface> readMultiSurface();
+
std::unique_ptr<geom::GeometryCollection> readGeometryCollection();
std::unique_ptr<geom::CoordinateSequence> readCoordinateSequence(unsigned int); // throws IOException
- void minMemSize(int geomType, uint64_t size);
+ void minMemSize(geom::GeometryTypeId geomType, uint64_t size) const;
void readCoordinate(); // throws IOException
+ template<typename T>
+ std::unique_ptr<T> readChild()
+ {
+ auto g = readGeometry();
+ if (dynamic_cast<const T*>(g.get())) {
+ return std::unique_ptr<T>(static_cast<T*>(g.release()));
+ }
+ throw io::ParseException(std::string("Expected ") + geom::GeometryTypeName<T>::name + " but got " + g->getGeometryType());
+ }
+
// Declare type as noncopyable
WKBReader(const WKBReader& other) = delete;
WKBReader& operator=(const WKBReader& rhs) = delete;
diff --git a/src/io/WKBReader.cpp b/src/io/WKBReader.cpp
index 0aa9c38e9..5410ab0c7 100644
--- a/src/io/WKBReader.cpp
+++ b/src/io/WKBReader.cpp
@@ -20,15 +20,21 @@
#include <geos/io/WKBConstants.h>
#include <geos/io/ByteOrderValues.h>
#include <geos/io/ParseException.h>
+#include <geos/geom/CircularString.h>
+#include <geos/geom/CompoundCurve.h>
+#include <geos/geom/CurvePolygon.h>
+#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/Point.h>
#include <geos/geom/LinearRing.h>
#include <geos/geom/LineString.h>
#include <geos/geom/Polygon.h>
+#include <geos/geom/MultiCurve.h>
#include <geos/geom/MultiPoint.h>
#include <geos/geom/MultiLineString.h>
#include <geos/geom/MultiPolygon.h>
+#include <geos/geom/MultiSurface.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/util.h>
@@ -58,6 +64,7 @@ WKBReader::WKBReader()
: WKBReader(*(GeometryFactory::getDefaultInstance()))
{}
+
void
WKBReader::setFixStructure(bool doFixStructure)
{
@@ -178,7 +185,7 @@ WKBReader::readHEX(std::istream& is)
}
void
-WKBReader::minMemSize(int geomType, uint64_t size)
+WKBReader::minMemSize(geom::GeometryTypeId geomType, uint64_t size) const
{
uint64_t minSize = 0;
constexpr uint64_t minCoordSize = 2 * sizeof(double);
@@ -191,18 +198,24 @@ WKBReader::minMemSize(int geomType, uint64_t size)
switch(geomType) {
case GEOS_LINESTRING:
case GEOS_LINEARRING:
+ case GEOS_CIRCULARSTRING:
+ case GEOS_COMPOUNDCURVE:
+ case GEOS_POINT:
minSize = size * minCoordSize;
break;
case GEOS_POLYGON:
+ case GEOS_CURVEPOLYGON:
minSize = size * minRingSize;
break;
case GEOS_MULTIPOINT:
minSize = size * minPtSize;
break;
case GEOS_MULTILINESTRING:
+ case GEOS_MULTICURVE:
minSize = size * minLineSize;
break;
case GEOS_MULTIPOLYGON:
+ case GEOS_MULTISURFACE:
minSize = size * minPolySize;
break;
case GEOS_GEOMETRYCOLLECTION:
@@ -309,9 +322,18 @@ WKBReader::readGeometry()
case WKBConstants::wkbLineString :
result = readLineString();
break;
+ case WKBConstants::wkbCircularString :
+ result = readCircularString();
+ break;
+ case WKBConstants::wkbCompoundCurve :
+ result = readCompoundCurve();
+ break;
case WKBConstants::wkbPolygon :
result = readPolygon();
break;
+ case WKBConstants::wkbCurvePolygon :
+ result = readCurvePolygon();
+ break;
case WKBConstants::wkbMultiPoint :
result = readMultiPoint();
break;
@@ -324,6 +346,12 @@ WKBReader::readGeometry()
case WKBConstants::wkbGeometryCollection :
result = readGeometryCollection();
break;
+ case WKBConstants::wkbMultiCurve :
+ result = readMultiCurve();
+ break;
+ case WKBConstants::wkbMultiSurface :
+ result = readMultiSurface();
+ break;
default:
std::stringstream err;
err << "Unknown WKB type " << geometryType;
@@ -376,6 +404,30 @@ WKBReader::readLinearRing()
return factory.createLinearRing(std::move(pts));
}
+std::unique_ptr<CircularString>
+WKBReader::readCircularString()
+{
+ uint32_t size = dis.readUnsigned();
+ minMemSize(GEOS_CIRCULARSTRING, size);
+ auto pts = readCoordinateSequence(size);
+ return factory.createCircularString(std::move(pts));
+}
+
+std::unique_ptr<CompoundCurve>
+WKBReader::readCompoundCurve()
+{
+ auto numCurves = dis.readUnsigned();
+ minMemSize(GEOS_COMPOUNDCURVE, numCurves);
+
+ std::vector<std::unique_ptr<SimpleCurve>> curves(numCurves);
+
+ for (std::uint32_t i = 0; i < numCurves; i++) {
+ curves[i] = readChild<SimpleCurve>();
+ }
+
+ return factory.createCompoundCurve(std::move(curves));
+}
+
std::unique_ptr<Polygon>
WKBReader::readPolygon()
{
@@ -402,9 +454,38 @@ WKBReader::readPolygon()
return factory.createPolygon(std::move(shell), std::move(holes));
}
+
return factory.createPolygon(std::move(shell));
}
+std::unique_ptr<CurvePolygon>
+WKBReader::readCurvePolygon()
+{
+ uint32_t numRings = dis.readUnsigned();
+ minMemSize(GEOS_POLYGON, numRings);
+
+#if DEBUG_WKB_READER
+ std::size_t << "WKB numRings: " << numRings << std::endl;
+#endif
+
+ if (numRings == 0) {
+ return factory.createCurvePolygon(hasZ, hasM);
+ }
+
+ auto shell = readChild<Curve>();
+
+ if(numRings > 1) {
+ std::vector<std::unique_ptr<Curve>> holes(numRings - 1);
+ for(uint32_t i = 0; i < numRings - 1; i++) {
+ holes[i] = readChild<Curve>();
+ }
+
+ return factory.createCurvePolygon(std::move(shell), std::move(holes));
+ }
+
+ return factory.createCurvePolygon(std::move(shell));
+}
+
std::unique_ptr<MultiPoint>
WKBReader::readMultiPoint()
{
@@ -413,12 +494,7 @@ WKBReader::readMultiPoint()
std::vector<std::unique_ptr<Geometry>> geoms(numGeoms);
for(uint32_t i = 0; i < numGeoms; i++) {
- geoms[i] = readGeometry();
- if(!dynamic_cast<Point*>(geoms[i].get())) {
- std::stringstream err;
- err << BAD_GEOM_TYPE_MSG << " MultiPoint";
- throw ParseException(err.str());
- }
+ geoms[i] = readChild<Point>();
}
return factory.createMultiPoint(std::move(geoms));
@@ -432,12 +508,7 @@ WKBReader::readMultiLineString()
std::vector<std::unique_ptr<Geometry>> geoms(numGeoms);
for(uint32_t i = 0; i < numGeoms; i++) {
- geoms[i] = readGeometry();
- if(!dynamic_cast<LineString*>(geoms[i].get())) {
- std::stringstream err;
- err << BAD_GEOM_TYPE_MSG << " LineString";
- throw ParseException(err.str());
- }
+ geoms[i] = readChild<LineString>();
}
return factory.createMultiLineString(std::move(geoms));
@@ -451,17 +522,40 @@ WKBReader::readMultiPolygon()
std::vector<std::unique_ptr<Geometry>> geoms(numGeoms);
for(uint32_t i = 0; i < numGeoms; i++) {
- geoms[i] = readGeometry();
- if(!dynamic_cast<Polygon*>(geoms[i].get())) {
- std::stringstream err;
- err << BAD_GEOM_TYPE_MSG << " Polygon";
- throw ParseException(err.str());
- }
+ geoms[i] = readChild<Polygon>();
}
return factory.createMultiPolygon(std::move(geoms));
}
+std::unique_ptr<MultiCurve>
+WKBReader::readMultiCurve()
+{
+ uint32_t numGeoms = dis.readUnsigned();
+ minMemSize(GEOS_MULTICURVE, numGeoms);
+ std::vector<std::unique_ptr<Curve>> geoms(numGeoms);
+
+ for(uint32_t i = 0; i < numGeoms; i++) {
+ geoms[i] = readChild<Curve>();
+ }
+
+ return factory.createMultiCurve(std::move(geoms));
+}
+
+std::unique_ptr<MultiSurface>
+WKBReader::readMultiSurface()
+{
+ uint32_t numGeoms = dis.readUnsigned();
+ minMemSize(GEOS_MULTISURFACE, numGeoms);
+ std::vector<std::unique_ptr<Surface>> geoms(numGeoms);
+
+ for(uint32_t i = 0; i < numGeoms; i++) {
+ geoms[i] = readChild<Surface>();
+ }
+
+ return factory.createMultiSurface(std::move(geoms));
+}
+
std::unique_ptr<GeometryCollection>
WKBReader::readGeometryCollection()
{
diff --git a/tests/unit/io/WKBReaderTest.cpp b/tests/unit/io/WKBReaderTest.cpp
index 1485b6262..6628351a8 100644
--- a/tests/unit/io/WKBReaderTest.cpp
+++ b/tests/unit/io/WKBReaderTest.cpp
@@ -12,6 +12,8 @@
#include <geos/io/WKBConstants.h>
#include <geos/io/WKBWriter.h>
#include <geos/io/WKTReader.h>
+#include <geos/geom/CompoundCurve.h>
+#include <geos/geom/CurvePolygon.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Geometry.h>
@@ -741,5 +743,100 @@ void object::test<30>
);
}
+// CircularString
+template<>
+template<>
+void object::test<31>
+()
+{
+ // CIRCULARSTRING(1 3,2 4,3 1)
+ auto g = readHex("010800000003000000000000000000F03F0000000000000840000000000000004000000000000010400000000000000840000000000000F03F");
+
+ ensure_equals(g->getGeometryTypeId(), geos::geom::GEOS_CIRCULARSTRING);
+ ensure_equals(g->getNumPoints(), 3u);
+}
+
+// CompoundCurve
+template<>
+template<>
+void object::test<32>
+()
+{
+ // SRID=5646;COMPOUNDCURVE(CIRCULARSTRING(1 3,2 4,3 1),(3 1,0 0))
+ auto g = readHex("01090000200E16000002000000010800000003000000000000000000F03F0000000000000840000000000000004000000000000010400000000000000840000000000000F03F0102000000020000000000000000000840000000000000F03F00000000000000000000000000000000");
+
+ ensure_equals(g->getGeometryTypeId(), geos::geom::GEOS_COMPOUNDCURVE);
+ ensure_equals(g->getSRID(), 5646);
+
+ const auto* cc = static_cast<const geos::geom::CompoundCurve*>(g.get());
+ ensure_equals(cc->getNumCurves(), 2u);
+ ensure_equals(cc->getCurveN(0)->getGeometryTypeId(), geos::geom::GEOS_CIRCULARSTRING);
+ ensure_equals(cc->getCurveN(0)->getNumPoints(), 3u);
+
+ ensure_equals(cc->getCurveN(1)->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+ ensure_equals(cc->getCurveN(1)->getNumPoints(), 2u);
+}
+
+// CurvePolygon
+template<>
+template<>
+void object::test<33>
+()
+{
+ // SRID=5646;CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,2 0,2 1,2 3,4 3),(4 3,4 5,1 4,0 0)),
+ // CIRCULARSTRING(1.7 1,1.4 0.4,1.6 0.4,1.6 0.5,1.7 1))
+ auto g = readHex("010A0000200E1600000200000001090000000200000001080000000500000000000000000000000000000000000000000000000000004000000000000000000000000000000040000000000000F03F00000000000000400000000000000840000000000000104000000000000008400102000000040000000000000000001040000000000000084000000000000010400000000000001440000000000000F03F000000000000104000000000000000000000000000000000010800000005000000333333333333FB3F000000000000F03F666666666666F63F9A9999999999D93F9A9999999999F93F9A9999999999D93F9A9999999999F93F000000000000E03F333333333333FB3F000000000000F03F");
+
+ ensure_equals(g->getGeometryTypeId(), geos::geom::GEOS_CURVEPOLYGON);
+ ensure_equals(g->getSRID(), 5646);
+
+ const auto* cp = static_cast<const geos::geom::CurvePolygon*>(g.get());
+ ensure_equals(cp->getExteriorRing()->getGeometryTypeId(), geos::geom::GEOS_COMPOUNDCURVE);
+ ensure_equals(cp->getNumInteriorRing(), 1u);
+ ensure_equals(cp->getInteriorRingN(0)->getGeometryTypeId(), geos::geom::GEOS_CIRCULARSTRING);
+}
+
+// MultiCurve
+template<>
+template<>
+void object::test<34>
+()
+{
+ // MULTICURVE((0 0,5 5),
+ // COMPOUNDCURVE((-1 -1,0 0),CIRCULARSTRING(0 0,1 1,2 0)),
+ // CIRCULARSTRING(4 0,4 4,8 4))
+ auto g = readHex("010B000000030000000102000000020000000000000000000000000000000000000000000000000014400000000000001440010900000002000000010200000002000000000000000000F0BF000000000000F0BF0000000000000000000000000000000001080000000300000000000000000000000000000000000000000000000000F03F000000000000F03F00000000000000400000000000000000010800000003000000000000000000104000000000000000000000000000001040000000000000104000000000000020400000000000001040");
+ ensure_equals(g->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ ensure_equals(g->getNumGeometries(), 3u);
+ ensure_equals(g->getGeometryN(0)->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+ ensure_equals(g->getGeometryN(1)->getGeometryTypeId(), geos::geom::GEOS_COMPOUNDCURVE);
+ ensure_equals(g->getGeometryN(2)->getGeometryTypeId(), geos::geom::GEOS_CIRCULARSTRING);
+}
+
+// MultiSurface
+template<>
+template<>
+void object::test<35>
+()
+{
+ // MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 0,4 0,4 4,0 4,0 0),(1 1,3 3,3 1,1 1)),
+ // ((10 10,14 12,11 10,10 10),(11 11,11.5 11,11 11.5,11 11))
+ auto g = readHex("010C00000002000000010A000000020000000108000000050000000000000000000000000000000000000000000000000010400000000000000000000000000000104000000000000010400000000000000000000000000000104000000000000000000000000000000000010200000004000000000000000000F03F000000000000F03F000000000000084000000000000008400000000000000840000000000000F03F000000000000F03F000000000000F03F01030000000200000004000000000000000000244000000000000024400000000000002C40000000000000284000000000000026400000000000002440000000000000244000000000000024400400000000000000000026400000000000002640000000000000274000000000000026400000000000002640000000000000274000000000000026400000000000002640");
+ ensure_equals(g->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
+ ensure_equals(g->getNumGeometries(), 2u);
+ ensure_equals(g->getGeometryN(0)->getGeometryTypeId(), geos::geom::GEOS_CURVEPOLYGON);
+ ensure_equals(g->getGeometryN(1)->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+}
+
+// Invalid CompoundCurve with Point as a member
+template<>
+template<>
+void object::test<36>
+()
+{
+ testParseError("01090000200E160000010000000101000000000000000000F03F000000000000F03F",
+ "ParseException: Expected SimpleCurve but got Point");
+}
+
} // namespace tut
diff --git a/tests/unit/io/WKTReaderTest.cpp b/tests/unit/io/WKTReaderTest.cpp
index 8873141f9..59e5f1b25 100644
--- a/tests/unit/io/WKTReaderTest.cpp
+++ b/tests/unit/io/WKTReaderTest.cpp
@@ -473,96 +473,4 @@ void object::test<24>
ensure_equals(geom->getNumGeometries(), 3u);
}
-// Read a CircularString
-template<>
-template<>
-void object::test<25>
-()
-{
- auto geom = wktreader.read("CIRCULARSTRING (0 0, 1 1, 2 0)");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_CIRCULARSTRING);
- ensure_equals(geom->getNumPoints(), 3u);
-}
-
-// Read a CompoundCurve
-template<>
-template<>
-void object::test<26>
-()
-{
- auto geom = wktreader.read("COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1 0), (1 0, 0 1))");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_COMPOUNDCURVE);
- ensure_equals(geom->getNumPoints(), 5u);
-
- // explicit form
- auto geom2 = wktreader.read("COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1 0), LINESTRING (1 0, 0 1))");
- ensure(geom->equalsIdentical(geom2.get()));
-}
-
-// Read a CurvePolygon whose components are simple curves
-template<>
-template<>
-void object::test<27>
-()
-{
- auto geom = wktreader.read("CURVEPOLYGON( CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 3 3, 3 1, 1 1) )");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_CURVEPOLYGON);
-}
-
-// Read a CurvePolygon whose components include compound curves
-template<>
-template<>
-void object::test<28>
-()
-{
- auto geom = wktreader.read("CURVEPOLYGON( COMPOUNDCURVE( CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3), (4 3, 4 5, 1 4, 0 0)), CIRCULARSTRING(1.7 1, 1.4 0.4, 1.6 0.4, 1.6 0.5, 1.7 1) )");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_CURVEPOLYGON);
-}
-
-// Read a MultiCurve
-template<>
-template<>
-void object::test<29>
-()
-{
- auto geom = wktreader.read("MULTICURVE( (0 0, 5 5), CIRCULARSTRING(4 0, 4 4, 8 4))");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
-
- // explicit form
- auto geom2 = wktreader.read("MULTICURVE( LINESTRING(0 0, 5 5), CIRCULARSTRING(4 0, 4 4, 8 4))");
- ensure(geom->equalsIdentical(geom2.get()));
-}
-
-// Read a MultiCurve whose elements contain CompoundCurves
-template<>
-template<>
-void object::test<30>
-()
-{
- auto geom = wktreader.read("MULTICURVE( (0 0, 5 5), COMPOUNDCURVE( (0 0, 1 1), CIRCULARSTRING (0 0, 1 1, 2 0)), CIRCULARSTRING(4 0, 4 4, 8 4))");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
-}
-
-// Read a MultiSurface
-template<>
-template<>
-void object::test<31>
-()
-{
- auto geom = wktreader.read("MULTISURFACE( CURVEPOLYGON( CIRCULARSTRING( 0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 3 3, 3 1, 1 1)), ((10 10, 14 12, 11 10, 10 10), (11 11, 11.5 11, 11 11.5, 11 11)))");
-
- ensure_equals(geom->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
-
- // explicit form
- auto geom2 = wktreader.read("MULTISURFACE( CURVEPOLYGON( CIRCULARSTRING( 0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 3 3, 3 1, 1 1)), POLYGON ((10 10, 14 12, 11 10, 10 10), (11 11, 11.5 11, 11 11.5, 11 11)))");
- ensure(geom->equalsIdentical(geom2.get()));
-}
-
-
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
include/geos/geom/Geometry.h | 2 +-
include/geos/geom/GeometryTypeName.h | 110 +++++++++++++++++++++++++++++
include/geos/io/WKBReader.h | 34 +++++++--
src/io/WKBReader.cpp | 132 ++++++++++++++++++++++++++++++-----
tests/unit/io/WKBReaderTest.cpp | 97 +++++++++++++++++++++++++
tests/unit/io/WKTReaderTest.cpp | 92 ------------------------
6 files changed, 351 insertions(+), 116 deletions(-)
create mode 100644 include/geos/geom/GeometryTypeName.h
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list