diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in index d5dd9c4257..246c54eee2 100644 --- a/capi/geos_c.h.in +++ b/capi/geos_c.h.in @@ -210,7 +210,12 @@ enum GEOSGeomTypes { /** Multipolygon, a homogeneous collection of polygons */ GEOS_MULTIPOLYGON, /** Geometry collection, a heterogeneous collection of geometry */ - GEOS_GEOMETRYCOLLECTION + GEOS_GEOMETRYCOLLECTION, + GEOS_CIRCULARSTRING, + GEOS_COMPOUNDCURVE, + GEOS_CURVEPOLYGON, + GEOS_MULTICURVE, + GEOS_MULTISURFACE, }; /** diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp index 7109e0b722..6efc5f2f56 100644 --- a/capi/geos_ts_c.cpp +++ b/capi/geos_ts_c.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -41,12 +42,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -162,17 +165,21 @@ using geos::geom::CoordinateXY; using geos::geom::CoordinateXYM; using geos::geom::CoordinateXYZM; using geos::geom::CoordinateSequence; +using geos::geom::Curve; using geos::geom::Envelope; using geos::geom::Geometry; using geos::geom::GeometryCollection; using geos::geom::GeometryFactory; using geos::geom::LineString; using geos::geom::LinearRing; +using geos::geom::MultiCurve; using geos::geom::MultiLineString; using geos::geom::MultiPolygon; using geos::geom::Point; using geos::geom::Polygon; using geos::geom::PrecisionModel; +using geos::geom::SimpleCurve; +using geos::geom::Surface; using geos::io::WKTReader; using geos::io::WKTWriter; @@ -1048,8 +1055,7 @@ extern "C" { GEOSisRing_r(GEOSContextHandle_t extHandle, const Geometry* g) { return execute(extHandle, 2, [&]() { - // both LineString* and LinearRing* can cast to LineString* - const LineString* ls = dynamic_cast(g); + const Curve* ls = dynamic_cast(g); if(ls) { return ls->isRing(); } @@ -1692,6 +1698,8 @@ extern "C" { if (g->getGeometryTypeId() == geos::geom::GeometryTypeId::GEOS_POLYGON) { auto p = geos::detail::down_cast(g); p->orientRings(exteriorCW); + } else if (g->getGeometryTypeId() == geos::geom::GeometryTypeId::GEOS_CURVEPOLYGON) { + throw geos::util::UnsupportedOperationException("Curved geometries not supported."); } } @@ -1710,9 +1718,9 @@ extern "C" { GEOSGetNumInteriorRings_r(GEOSContextHandle_t extHandle, const Geometry* g1) { return execute(extHandle, -1, [&]() { - const Polygon* p = dynamic_cast(g1); + const Surface* p = dynamic_cast(g1); if(!p) { - throw IllegalArgumentException("Argument is not a Polygon"); + throw IllegalArgumentException("Argument is not a Surface"); } return static_cast(p->getNumInteriorRing()); }); @@ -1802,7 +1810,7 @@ extern "C" { GEOSisClosed_r(GEOSContextHandle_t extHandle, const Geometry* g1) { return execute(extHandle, 2, [&]() { - const LineString* ls = dynamic_cast(g1); + const Curve* ls = dynamic_cast(g1); if(ls) { return ls->isClosed(); } @@ -1812,7 +1820,12 @@ extern "C" { return mls->isClosed(); } - throw IllegalArgumentException("Argument is not a LineString or MultiLineString"); + const MultiCurve* mc = dynamic_cast(g1); + if(mc) { + return mc->isClosed(); + } + + throw IllegalArgumentException("Argument is not a Curve, MultiLineString, or MultiCurve"); }); } @@ -1840,9 +1853,9 @@ extern "C" { GEOSGeomGetNumPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1) { return execute(extHandle, -1, [&]() { - const LineString* ls = dynamic_cast(g1); + const SimpleCurve* ls = dynamic_cast(g1); if(!ls) { - throw IllegalArgumentException("Argument is not a LineString"); + throw IllegalArgumentException("Argument is not a SimpleCurve"); } return static_cast(ls->getNumPoints()); }); @@ -1926,9 +1939,9 @@ extern "C" { GEOSGetExteriorRing_r(GEOSContextHandle_t extHandle, const Geometry* g1) { return execute(extHandle, [&]() { - const Polygon* p = dynamic_cast(g1); + const Surface* p = dynamic_cast(g1); if(!p) { - throw IllegalArgumentException("Invalid argument (must be a Polygon)"); + throw IllegalArgumentException("Invalid argument (must be a Surface)"); } return p->getExteriorRing(); }); @@ -1942,9 +1955,9 @@ extern "C" { GEOSGetInteriorRingN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n) { return execute(extHandle, [&]() { - const Polygon* p = dynamic_cast(g1); + const Surface* p = dynamic_cast(g1); if(!p) { - throw IllegalArgumentException("Invalid argument (must be a Polygon)"); + throw IllegalArgumentException("Invalid argument (must be a Surface)"); } if(n < 0) { throw IllegalArgumentException("Index must be non-negative."); @@ -2813,7 +2826,7 @@ extern "C" { GEOSGeom_getCoordSeq_r(GEOSContextHandle_t extHandle, const Geometry* g) { return execute(extHandle, [&]() { - const LineString* ls = dynamic_cast(g); + const SimpleCurve* ls = dynamic_cast(g); if(ls) { return ls->getCoordinatesRO(); } diff --git a/include/geos/algorithm/hull/ConcaveHull.h b/include/geos/algorithm/hull/ConcaveHull.h index 1420e1f0a1..6201e21b5c 100644 --- a/include/geos/algorithm/hull/ConcaveHull.h +++ b/include/geos/algorithm/hull/ConcaveHull.h @@ -96,15 +96,7 @@ class GEOS_DLL ConcaveHull { public: - ConcaveHull(const Geometry* geom) - : inputGeometry(geom) - , maxEdgeLengthRatio(-1.0) - , alpha(-1) - , isHolesAllowed(false) - , criteriaType(PARAM_EDGE_LENGTH) - , maxSizeInHull(0.0) - , geomFactory(geom->getFactory()) - {}; + ConcaveHull(const Geometry* geom); /** * Computes the approximate edge length of diff --git a/include/geos/geom/CircularString.h b/include/geos/geom/CircularString.h index 5a87349546..e600092250 100644 --- a/include/geos/geom/CircularString.h +++ b/include/geos/geom/CircularString.h @@ -52,6 +52,10 @@ class GEOS_DLL CircularString : public SimpleCurve { throw util::UnsupportedOperationException("Cannot calculate length of CircularString"); } + bool hasCurvedComponents() const override { + return true; + } + }; diff --git a/include/geos/geom/CompoundCurve.h b/include/geos/geom/CompoundCurve.h index 7228a144bf..253e7dce23 100644 --- a/include/geos/geom/CompoundCurve.h +++ b/include/geos/geom/CompoundCurve.h @@ -92,6 +92,7 @@ class GEOS_DLL CompoundCurve : public Curve { int compareToSameClass(const Geometry* geom) const override; + bool hasCurvedComponents() const override; protected: CompoundCurve(std::vector>&&, diff --git a/include/geos/geom/Curve.h b/include/geos/geom/Curve.h index 520a4c299f..a8367c8175 100644 --- a/include/geos/geom/Curve.h +++ b/include/geos/geom/Curve.h @@ -36,6 +36,8 @@ class GEOS_DLL Curve : public Geometry { virtual bool isClosed() const = 0; + bool isRing() const; + using Geometry::apply_ro; using Geometry::apply_rw; diff --git a/include/geos/geom/CurvePolygon.h b/include/geos/geom/CurvePolygon.h index 9300df97ff..a030fc66bb 100644 --- a/include/geos/geom/CurvePolygon.h +++ b/include/geos/geom/CurvePolygon.h @@ -43,6 +43,8 @@ class GEOS_DLL CurvePolygon : public SurfaceImpl { double getArea() const override; + bool hasCurvedComponents() const override; + protected: using SurfaceImpl::SurfaceImpl; diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h index 488332c1cd..ead07c1b99 100644 --- a/include/geos/geom/Geometry.h +++ b/include/geos/geom/Geometry.h @@ -310,10 +310,14 @@ class GEOS_DLL Geometry { virtual std::string getGeometryType() const = 0; //Abstract /// Returns whether the Geometry type _may_ contain curved elements - virtual bool isCurvedType() const; + /// FIXME: this would be true for GeometryCollection ? + bool isCurvedType() const; static bool isCurvedType(GeometryTypeId); + /// Returns whether the Geometry contains curved components + virtual bool hasCurvedComponents() const; + /// Return an integer representation of this Geometry type virtual GeometryTypeId getGeometryTypeId() const = 0; //Abstract diff --git a/include/geos/geom/GeometryCollection.h b/include/geos/geom/GeometryCollection.h index 7e0428c1f5..ae9a441aaf 100644 --- a/include/geos/geom/GeometryCollection.h +++ b/include/geos/geom/GeometryCollection.h @@ -246,6 +246,8 @@ class GEOS_DLL GeometryCollection : public Geometry { int compareToSameClass(const Geometry* gc) const override; + bool hasCurvedComponents() const override; + }; } // namespace geos::geom diff --git a/include/geos/geom/MultiLineString.h b/include/geos/geom/MultiLineString.h index 47f2abaf9c..2b6cc76fdf 100644 --- a/include/geos/geom/MultiLineString.h +++ b/include/geos/geom/MultiLineString.h @@ -138,6 +138,11 @@ class GEOS_DLL MultiLineString: public GeometryCollection { return SORTINDEX_MULTILINESTRING; }; + bool hasCurvedComponents() const override + { + return false; + } + }; diff --git a/include/geos/geom/MultiPoint.h b/include/geos/geom/MultiPoint.h index 84863681e2..0e1d564d13 100644 --- a/include/geos/geom/MultiPoint.h +++ b/include/geos/geom/MultiPoint.h @@ -134,6 +134,11 @@ class GEOS_DLL MultiPoint: public GeometryCollection { return SORTINDEX_MULTIPOINT; }; + bool hasCurvedComponents() const override + { + return false; + } + }; #ifdef _MSC_VER diff --git a/include/geos/geom/MultiPolygon.h b/include/geos/geom/MultiPolygon.h index ab5b27d500..f4cca3a384 100644 --- a/include/geos/geom/MultiPolygon.h +++ b/include/geos/geom/MultiPolygon.h @@ -140,6 +140,11 @@ class GEOS_DLL MultiPolygon: public GeometryCollection { return SORTINDEX_MULTIPOLYGON; }; + bool hasCurvedComponents() const override + { + return false; + } + }; #ifdef _MSC_VER diff --git a/include/geos/geom/SimpleCurve.h b/include/geos/geom/SimpleCurve.h index 240b54170f..23c9467429 100644 --- a/include/geos/geom/SimpleCurve.h +++ b/include/geos/geom/SimpleCurve.h @@ -83,8 +83,6 @@ class GEOS_DLL SimpleCurve : public Curve { bool isClosed() const override; - bool isRing() const; - virtual bool isCoordinate(CoordinateXY& pt) const; bool equalsExact(const Geometry* other, double tolerance = 0) diff --git a/include/geos/operation/polygonize/Polygonizer.h b/include/geos/operation/polygonize/Polygonizer.h index 50fce1f7c8..1c21a3a343 100644 --- a/include/geos/operation/polygonize/Polygonizer.h +++ b/include/geos/operation/polygonize/Polygonizer.h @@ -192,16 +192,6 @@ class GEOS_DLL Polygonizer { */ void add(std::vector* geomList); - /** - * Add a geometry to the linework to be polygonized. - * May be called multiple times. - * Any dimension of Geometry may be added; - * the constituent linework will be extracted and used - * - * @param g a Geometry with linework to be polygonized - */ - void add(geom::Geometry* g); - /** * Add a geometry to the linework to be polygonized. * May be called multiple times. diff --git a/include/geos/triangulate/polygon/ConstrainedDelaunayTriangulator.h b/include/geos/triangulate/polygon/ConstrainedDelaunayTriangulator.h index c8cc8ac338..23c385d21e 100644 --- a/include/geos/triangulate/polygon/ConstrainedDelaunayTriangulator.h +++ b/include/geos/triangulate/polygon/ConstrainedDelaunayTriangulator.h @@ -55,7 +55,7 @@ class GEOS_DLL ConstrainedDelaunayTriangulator { const Geometry* inputGeom; const GeometryFactory* geomFact; - std::unique_ptr compute(); + std::unique_ptr compute() const; static std::unique_ptr toGeometry( const geom::GeometryFactory* geomFact, diff --git a/include/geos/util.h b/include/geos/util.h index bd2ff674db..04405b1e26 100644 --- a/include/geos/util.h +++ b/include/geos/util.h @@ -66,7 +66,7 @@ namespace util { template void ensureNotCurvedType(const T* geom) { - if (geom->isCurvedType()) { + if (geom->hasCurvedComponents()) { throw UnsupportedOperationException("Curved geometry types are not supported."); } } @@ -74,7 +74,7 @@ void ensureNotCurvedType(const T* geom) template void ensureNotCurvedType(const T& geom) { - if (geom.isCurvedType()) { + if (geom.hasCurvedComponents()) { throw UnsupportedOperationException("Curved geometry types are not supported."); } } diff --git a/src/algorithm/distance/DiscreteFrechetDistance.cpp b/src/algorithm/distance/DiscreteFrechetDistance.cpp index a54dd81462..03934def79 100644 --- a/src/algorithm/distance/DiscreteFrechetDistance.cpp +++ b/src/algorithm/distance/DiscreteFrechetDistance.cpp @@ -28,6 +28,8 @@ #include #include #include + +#include "geos/util.h" using namespace geos::geom; namespace geos { @@ -142,6 +144,9 @@ DiscreteFrechetDistance::compute( throw util::IllegalArgumentException("DiscreteFrechetDistance called with empty inputs."); } + util::ensureNotCurvedType(discreteGeom); + util::ensureNotCurvedType(geom); + auto lp = discreteGeom.getCoordinates(); auto lq = geom.getCoordinates(); std::size_t pSize, qSize; diff --git a/src/algorithm/distance/DiscreteHausdorffDistance.cpp b/src/algorithm/distance/DiscreteHausdorffDistance.cpp index cffc7b6a71..a02f0a6610 100644 --- a/src/algorithm/distance/DiscreteHausdorffDistance.cpp +++ b/src/algorithm/distance/DiscreteHausdorffDistance.cpp @@ -23,6 +23,8 @@ #include #include +#include "geos/util.h" + using namespace geos::geom; namespace geos { @@ -101,6 +103,9 @@ DiscreteHausdorffDistance::computeOrientedDistance( const geom::Geometry& geom, PointPairDistance& p_ptDist) { + util::ensureNotCurvedType(discreteGeom); + util::ensureNotCurvedType(geom); + // can't calculate distance with empty if (discreteGeom.isEmpty() || geom.isEmpty()) return; diff --git a/src/algorithm/hull/ConcaveHull.cpp b/src/algorithm/hull/ConcaveHull.cpp index bbee04badd..bf0ccfe6d6 100644 --- a/src/algorithm/hull/ConcaveHull.cpp +++ b/src/algorithm/hull/ConcaveHull.cpp @@ -28,6 +28,7 @@ #include #include #include +#include using geos::geom::Coordinate; @@ -48,6 +49,17 @@ namespace geos { namespace algorithm { // geos.algorithm namespace hull { // geos.algorithm.hulll +ConcaveHull::ConcaveHull(const Geometry* geom) + : inputGeometry(geom) + , maxEdgeLengthRatio(-1.0) + , alpha(-1) + , isHolesAllowed(false) + , criteriaType(PARAM_EDGE_LENGTH) + , maxSizeInHull(0.0) + , geomFactory(geom->getFactory()) +{ + util::ensureNotCurvedType(geom); +}; /* public static */ double diff --git a/src/algorithm/hull/ConcaveHullOfPolygons.cpp b/src/algorithm/hull/ConcaveHullOfPolygons.cpp index a774cf6f0f..e261762543 100644 --- a/src/algorithm/hull/ConcaveHullOfPolygons.cpp +++ b/src/algorithm/hull/ConcaveHullOfPolygons.cpp @@ -26,6 +26,8 @@ #include #include +#include "geos/util.h" + using geos::geom::Coordinate; using geos::geom::Geometry; @@ -111,6 +113,7 @@ ConcaveHullOfPolygons::ConcaveHullOfPolygons(const Geometry* geom) , isHolesAllowed(false) , isTight(false) { + util::ensureNotCurvedType(geom); if (! geom->isPolygonal()) { throw util::IllegalArgumentException("Input must be polygonal"); } diff --git a/src/coverage/CoverageRingEdges.cpp b/src/coverage/CoverageRingEdges.cpp index c334e47f59..f945c88490 100644 --- a/src/coverage/CoverageRingEdges.cpp +++ b/src/coverage/CoverageRingEdges.cpp @@ -71,6 +71,8 @@ CoverageRingEdges::build() std::map uniqueEdgeMap; for (const Geometry* geom : m_coverage) { for (std::size_t ipoly = 0; ipoly < geom->getNumGeometries(); ipoly++) { + util::ensureNotCurvedType(geom->getGeometryN(ipoly)); + const Polygon* poly = static_cast(geom->getGeometryN(ipoly)); //-- skip empty elements. Missing elements are copied in result diff --git a/src/coverage/CoverageValidator.cpp b/src/coverage/CoverageValidator.cpp index 719c7f134d..fedad7b498 100644 --- a/src/coverage/CoverageValidator.cpp +++ b/src/coverage/CoverageValidator.cpp @@ -74,6 +74,8 @@ CoverageValidator::validate() TemplateSTRtree index; std::vector> invalidLines; for (auto* geom : m_coverage) { + util::ensureNotCurvedType(geom); + index.insert(geom); invalidLines.emplace_back(nullptr); } diff --git a/src/geom/CompoundCurve.cpp b/src/geom/CompoundCurve.cpp index a5aa225526..f44f54876f 100644 --- a/src/geom/CompoundCurve.cpp +++ b/src/geom/CompoundCurve.cpp @@ -253,6 +253,15 @@ CompoundCurve::compareToSameClass(const Geometry* g) const return compare(curves, curve->curves); } +bool CompoundCurve::hasCurvedComponents() const { + for (const auto& curve : curves) { + if (curve->hasCurvedComponents()) { + return true; + } + } + return false; +} + void CompoundCurve::normalize() { diff --git a/src/geom/Curve.cpp b/src/geom/Curve.cpp index fd3013ec52..4bd3d02443 100644 --- a/src/geom/Curve.cpp +++ b/src/geom/Curve.cpp @@ -48,5 +48,12 @@ Curve::apply_ro(GeometryComponentFilter* filter) const filter->filter_ro(this); } +bool +Curve::isRing() const +{ + return isClosed() && isSimple(); +} + + } } \ No newline at end of file diff --git a/src/geom/CurvePolygon.cpp b/src/geom/CurvePolygon.cpp index 7afb1cb04e..74a5e943b7 100644 --- a/src/geom/CurvePolygon.cpp +++ b/src/geom/CurvePolygon.cpp @@ -56,6 +56,18 @@ namespace geom { throw util::UnsupportedOperationException(); } + bool CurvePolygon::hasCurvedComponents() const { + if (shell->hasCurvedComponents()) { + return true; + } + for (const auto& hole : holes) { + if (hole->hasCurvedComponents()) { + return true; + } + } + return false; + } + Geometry* CurvePolygon::cloneImpl() const { return new CurvePolygon(*this); diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp index c6c6f766d0..6c5b43c3bb 100644 --- a/src/geom/Geometry.cpp +++ b/src/geom/Geometry.cpp @@ -205,6 +205,8 @@ Geometry::getCentroid(CoordinateXY& ret) const std::unique_ptr Geometry::getInteriorPoint() const { + geos::util::ensureNotCurvedType(this); + Coordinate interiorPt; int dim = getDimension(); if(dim == 0) { @@ -815,6 +817,11 @@ Geometry::isCurvedType() const { return isCurvedType(getGeometryTypeId()); } +bool +Geometry::hasCurvedComponents() const { + return false; +} + } // namespace geos::geom } // namespace geos diff --git a/src/geom/GeometryCollection.cpp b/src/geom/GeometryCollection.cpp index 107b3b8bdf..096ca35268 100644 --- a/src/geom/GeometryCollection.cpp +++ b/src/geom/GeometryCollection.cpp @@ -333,6 +333,15 @@ GeometryCollection::compareToSameClass(const Geometry* g) const return compare(geometries, gc->geometries); } +bool GeometryCollection::hasCurvedComponents() const { + for (const auto& g : geometries) { + if (g->hasCurvedComponents()) { + return true; + } + } + return false; +} + const CoordinateXY* GeometryCollection::getCoordinate() const { diff --git a/src/geom/SimpleCurve.cpp b/src/geom/SimpleCurve.cpp index 471d48ff85..68c8414357 100644 --- a/src/geom/SimpleCurve.cpp +++ b/src/geom/SimpleCurve.cpp @@ -165,12 +165,6 @@ SimpleCurve::isClosed() const return points->front().equals2D(points->back()); } -bool -SimpleCurve::isRing() const -{ - return isClosed() && isSimple(); -} - std::unique_ptr SimpleCurve::getBoundary() const { diff --git a/src/geom/prep/PreparedLineString.cpp b/src/geom/prep/PreparedLineString.cpp index 819a42d6cb..7284905719 100644 --- a/src/geom/prep/PreparedLineString.cpp +++ b/src/geom/prep/PreparedLineString.cpp @@ -57,6 +57,8 @@ PreparedLineString::getIntersectionFinder() bool PreparedLineString::intersects(const geom::Geometry* g) const { + geos::util::ensureNotCurvedType(g); + if(! envelopesIntersect(g)) { return false; } diff --git a/src/geom/prep/PreparedPoint.cpp b/src/geom/prep/PreparedPoint.cpp index 8fa3f94f55..88aac78b3e 100644 --- a/src/geom/prep/PreparedPoint.cpp +++ b/src/geom/prep/PreparedPoint.cpp @@ -17,8 +17,11 @@ **********************************************************************/ +#include #include +#include "geos/util.h" + namespace geos { namespace geom { // geos.geom namespace prep { // geos.geom.prep @@ -26,6 +29,8 @@ namespace prep { // geos.geom.prep bool PreparedPoint::intersects(const geom::Geometry* g) const { + util::ensureNotCurvedType(g); + if(! envelopesIntersect(g)) { return false; } diff --git a/src/geom/prep/PreparedPolygon.cpp b/src/geom/prep/PreparedPolygon.cpp index 332c4798e3..c77b828a34 100644 --- a/src/geom/prep/PreparedPolygon.cpp +++ b/src/geom/prep/PreparedPolygon.cpp @@ -136,6 +136,8 @@ bool PreparedPolygon:: intersects(const geom::Geometry* g) const { + geos::util::ensureNotCurvedType(g); + // envelope test if(!envelopesIntersect(g)) { return false; diff --git a/src/geom/util/GeometryEditor.cpp b/src/geom/util/GeometryEditor.cpp index b2d66b9476..bbeaf98fb6 100644 --- a/src/geom/util/GeometryEditor.cpp +++ b/src/geom/util/GeometryEditor.cpp @@ -74,6 +74,8 @@ GeometryEditor::GeometryEditor(const GeometryFactory* newFactory) std::unique_ptr GeometryEditor::edit(const Geometry* geometry, GeometryEditorOperation* operation) { + geos::util::ensureNotCurvedType(geometry); + // if client did not supply a GeometryFactory, use the one from the input Geometry if(factory == nullptr) { factory = geometry->getFactory(); diff --git a/src/geomgraph/GeometryGraph.cpp b/src/geomgraph/GeometryGraph.cpp index b1b2e53f1a..5f47861ae7 100644 --- a/src/geomgraph/GeometryGraph.cpp +++ b/src/geomgraph/GeometryGraph.cpp @@ -169,6 +169,8 @@ void GeometryGraph::add(const Geometry* g) //throw (UnsupportedOperationException *) { + util::ensureNotCurvedType(g); + if(g->isEmpty()) { return; } diff --git a/src/io/GeoJSONWriter.cpp b/src/io/GeoJSONWriter.cpp index 154b8266d2..f174551059 100644 --- a/src/io/GeoJSONWriter.cpp +++ b/src/io/GeoJSONWriter.cpp @@ -30,6 +30,8 @@ #include #include +#include "geos/util.h" + #define GEOS_COMPILATION using namespace geos::geom; @@ -174,6 +176,8 @@ void GeoJSONWriter::encodeFeatureCollection(const geom::Geometry* g, geos_nlohma void GeoJSONWriter::encodeGeometry(const geom::Geometry* geometry, geos_nlohmann::ordered_json& j) { + util::ensureNotCurvedType(geometry); + auto type = geometry->getGeometryTypeId(); if (type == GEOS_POINT) { auto point = static_cast(geometry); diff --git a/src/io/WKBWriter.cpp b/src/io/WKBWriter.cpp index 43ad801a00..dd82b58b6a 100644 --- a/src/io/WKBWriter.cpp +++ b/src/io/WKBWriter.cpp @@ -36,6 +36,8 @@ #include #include +#include "geos/util.h" + #undef DEBUG_WKB_WRITER @@ -97,6 +99,8 @@ WKBWriter::writeHEX(const Geometry& g, std::ostream& os) void WKBWriter::write(const Geometry& g, std::ostream& os) { + util::ensureNotCurvedType(g); + OrdinateSet inputOrdinates = OrdinateSet::createXY(); inputOrdinates.setM(g.hasM()); inputOrdinates.setZ(g.hasZ()); diff --git a/src/noding/GeometryNoder.cpp b/src/noding/GeometryNoder.cpp index 144d1f306f..65a7c9941d 100644 --- a/src/noding/GeometryNoder.cpp +++ b/src/noding/GeometryNoder.cpp @@ -92,6 +92,7 @@ GeometryNoder::GeometryNoder(const geom::Geometry& g) : argGeom(g) { + util::ensureNotCurvedType(argGeom); } /* private */ diff --git a/src/operation/linemerge/LineMerger.cpp b/src/operation/linemerge/LineMerger.cpp index 8163c9a62a..1f90ca4ac3 100644 --- a/src/operation/linemerge/LineMerger.cpp +++ b/src/operation/linemerge/LineMerger.cpp @@ -94,6 +94,8 @@ struct LMGeometryComponentFilter: public GeometryComponentFilter { void LineMerger::add(const Geometry* geometry) { + util::ensureNotCurvedType(geometry); + LMGeometryComponentFilter lmgcf(this); geometry->apply_ro(&lmgcf); } diff --git a/src/operation/polygonize/Polygonizer.cpp b/src/operation/polygonize/Polygonizer.cpp index 1eb5241491..cc8abccb0a 100644 --- a/src/operation/polygonize/Polygonizer.cpp +++ b/src/operation/polygonize/Polygonizer.cpp @@ -103,20 +103,6 @@ Polygonizer::add(std::vector* geomList) } } -/* - * Add a geometry to the linework to be polygonized. - * May be called multiple times. - * Any dimension of Geometry may be added; - * the constituent linework will be extracted and used - * - * @param g a Geometry with linework to be polygonized - */ -void -Polygonizer::add(Geometry* g) -{ - g->apply_ro(&lineStringAdder); -} - /* * Add a geometry to the linework to be polygonized. * May be called multiple times. @@ -128,6 +114,7 @@ Polygonizer::add(Geometry* g) void Polygonizer::add(const Geometry* g) { + util::ensureNotCurvedType(g); g->apply_ro(&lineStringAdder); } diff --git a/src/triangulate/DelaunayTriangulationBuilder.cpp b/src/triangulate/DelaunayTriangulationBuilder.cpp index 424de2a131..70bb217a97 100644 --- a/src/triangulate/DelaunayTriangulationBuilder.cpp +++ b/src/triangulate/DelaunayTriangulationBuilder.cpp @@ -77,6 +77,8 @@ DelaunayTriangulationBuilder::DelaunayTriangulationBuilder() : void DelaunayTriangulationBuilder::setSites(const Geometry& geom) { + util::ensureNotCurvedType(geom); + // remove any duplicate points (they will cause the triangulation to fail) siteCoords = extractUniqueCoordinates(geom); } diff --git a/src/triangulate/VoronoiDiagramBuilder.cpp b/src/triangulate/VoronoiDiagramBuilder.cpp index d4b09c8c5d..29c05fee98 100644 --- a/src/triangulate/VoronoiDiagramBuilder.cpp +++ b/src/triangulate/VoronoiDiagramBuilder.cpp @@ -51,6 +51,7 @@ VoronoiDiagramBuilder::VoronoiDiagramBuilder() : void VoronoiDiagramBuilder::setSites(const geom::Geometry& geom) { + util::ensureNotCurvedType(geom); siteCoords = DelaunayTriangulationBuilder::extractUniqueCoordinates(geom); inputGeom = &geom; } diff --git a/src/triangulate/polygon/ConstrainedDelaunayTriangulator.cpp b/src/triangulate/polygon/ConstrainedDelaunayTriangulator.cpp index c52f855489..4788d3ba5f 100644 --- a/src/triangulate/polygon/ConstrainedDelaunayTriangulator.cpp +++ b/src/triangulate/polygon/ConstrainedDelaunayTriangulator.cpp @@ -39,8 +39,10 @@ ConstrainedDelaunayTriangulator::triangulate(const Geometry* geom) /* private */ std::unique_ptr -ConstrainedDelaunayTriangulator::compute() +ConstrainedDelaunayTriangulator::compute() const { + util::ensureNotCurvedType(inputGeom); + // short circuit empty input case if(inputGeom->isEmpty()) { auto gf = inputGeom->getFactory(); diff --git a/tests/unit/capi/GEOSBoundaryTest.cpp b/tests/unit/capi/GEOSBoundaryTest.cpp index 005ab388e4..d24bd558f3 100644 --- a/tests/unit/capi/GEOSBoundaryTest.cpp +++ b/tests/unit/capi/GEOSBoundaryTest.cpp @@ -30,6 +30,16 @@ void object::test<1>() ensure_equals(GEOSGetSRID(input_), GEOSGetSRID(result_)); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + result_ = GEOSBoundary(input_); + ensure(result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSBufferTest.cpp b/tests/unit/capi/GEOSBufferTest.cpp index e44d342e72..badf30684f 100644 --- a/tests/unit/capi/GEOSBufferTest.cpp +++ b/tests/unit/capi/GEOSBufferTest.cpp @@ -460,4 +460,15 @@ void object::test<25>() ensure_geometry_equals(geom3_, geom2_, 0.001); } +template<> +template<> +void object::test<26>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + result_ = GEOSBuffer(input_, 1, 8); + ensure(result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSBuildAreaTest.cpp b/tests/unit/capi/GEOSBuildAreaTest.cpp index c7f23ac4bc..012de41e40 100644 --- a/tests/unit/capi/GEOSBuildAreaTest.cpp +++ b/tests/unit/capi/GEOSBuildAreaTest.cpp @@ -38,4 +38,15 @@ void object::test<1>() ensure_geometry_equals(result_, expected_, 0); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("MULTICURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0) )"); + ensure(input_ != nullptr); + + result_ = GEOSBuildArea(input_); + ensure(result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSClipByRectTest.cpp b/tests/unit/capi/GEOSClipByRectTest.cpp index 0fcdb530df..13fde6f732 100644 --- a/tests/unit/capi/GEOSClipByRectTest.cpp +++ b/tests/unit/capi/GEOSClipByRectTest.cpp @@ -271,6 +271,17 @@ void object::test<16> } } +template<> +template<> +void object::test<17>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + result_ = GEOSClipByRect(input_, 0, 0, 1, 1); + ensure(result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp b/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp index 8de6baf542..57c6a0b9c1 100644 --- a/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp +++ b/tests/unit/capi/GEOSConcaveHullOfPolygonsTest.cpp @@ -52,6 +52,17 @@ void object::test<2>() ensure_geometry_equals(geom1_, expected_); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0) ))"); + ensure(input_ != nullptr); + + result_ = GEOSConcaveHullOfPolygons(input_, 0.7, false, false); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSConcaveHullTest.cpp b/tests/unit/capi/GEOSConcaveHullTest.cpp index 690ce54252..243161d31a 100644 --- a/tests/unit/capi/GEOSConcaveHullTest.cpp +++ b/tests/unit/capi/GEOSConcaveHullTest.cpp @@ -53,4 +53,15 @@ void object::test<2>() ensure_geometry_equals(result_, expected_); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + result_ = GEOSConcaveHull(input_, 0, 0); + ensure(result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp b/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp index 24687a6b86..2022b7f905 100644 --- a/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp +++ b/tests/unit/capi/GEOSConstrainedDelaunayTriangulationTest.cpp @@ -71,6 +71,17 @@ void object::test<3> ensure_geometry_equals(geom2_, geom3_); } +// CurvePolygon +template<> +template<> +void object::test<4>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0)))"); + ensure(input_ != nullptr); + + result_ = GEOSConstrainedDelaunayTriangulation(input_); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSContainsTest.cpp b/tests/unit/capi/GEOSContainsTest.cpp index 7dd017ff7e..2e570424d8 100644 --- a/tests/unit/capi/GEOSContainsTest.cpp +++ b/tests/unit/capi/GEOSContainsTest.cpp @@ -191,5 +191,19 @@ void object::test<5> } } +template<> +template<> +void object::test<6>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 0)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSContains(geom1_, geom2_), 2); +} + + } // namespace tut diff --git a/tests/unit/capi/GEOSConvexHullTest.cpp b/tests/unit/capi/GEOSConvexHullTest.cpp index 9b99c8cad4..e7c20ac0bd 100644 --- a/tests/unit/capi/GEOSConvexHullTest.cpp +++ b/tests/unit/capi/GEOSConvexHullTest.cpp @@ -42,5 +42,16 @@ void object::test<1> ensure_geometry_equals(result_, expected_); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + result_ = GEOSConvexHull(input_); + ensure(result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSCoverageIsValidTest.cpp b/tests/unit/capi/GEOSCoverageIsValidTest.cpp index 79d54d88aa..93868959db 100644 --- a/tests/unit/capi/GEOSCoverageIsValidTest.cpp +++ b/tests/unit/capi/GEOSCoverageIsValidTest.cpp @@ -88,6 +88,16 @@ template<> void object::test<2> ensure_geometry_equals(result_, expected_, 0.01); } +template<> +template<> void object::test<3> +() +{ + input_ = fromWKT("GEOMETRYCOLLECTION ( " + "CURVEPOLYGON (COMPOUNDCURVE ( CIRCULARSTRING (2 0, 1 1, 2 2), (2 2, 0 2, 0 0, 2 0))), " + "CURVEPOLYGON (COMPOUNDCURVE ( CIRCULARSTRING (2 2, 1 1, 2 0), (2 0, 4 0, 4 2, 2 2))))"); + ensure(input_); + ensure_equals("curved geometry not supported", GEOSCoverageIsValid(input_, 0, nullptr), 2); +} } // namespace tut diff --git a/tests/unit/capi/GEOSCoverageSimplifyTest.cpp b/tests/unit/capi/GEOSCoverageSimplifyTest.cpp index 830a58c476..812db7cc13 100644 --- a/tests/unit/capi/GEOSCoverageSimplifyTest.cpp +++ b/tests/unit/capi/GEOSCoverageSimplifyTest.cpp @@ -100,6 +100,18 @@ template<> void object::test<3> ensure_geometry_equals(result_, expected_, 0.1); } +template<> +template<> void object::test<4> +() +{ + input_ = fromWKT("GEOMETRYCOLLECTION ( " + "CURVEPOLYGON (COMPOUNDCURVE ( CIRCULARSTRING (2 0, 1 1, 2 2), (2 2, 0 2, 0 0, 2 0))), " + "CURVEPOLYGON (COMPOUNDCURVE ( CIRCULARSTRING (2 2, 1 1, 2 0), (2 0, 4 0, 4 2, 2 2))))"); + ensure(input_); + + result_ = GEOSCoverageSimplifyVW(input_, 0.1, false); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSCoverageUnionTest.cpp b/tests/unit/capi/GEOSCoverageUnionTest.cpp index 6b8a71e7a3..a9808c1042 100644 --- a/tests/unit/capi/GEOSCoverageUnionTest.cpp +++ b/tests/unit/capi/GEOSCoverageUnionTest.cpp @@ -10,13 +10,15 @@ #include #include +#include "capi_test_utils.h" + namespace tut { // // Test Group // // Common data used in test cases. -struct test_capicoverageunion_data { +struct test_capicoverageunion_data : public capitest::utility { static void notice(const char *fmt, ...) { std::fprintf(stdout, "NOTICE: "); @@ -103,6 +105,18 @@ void object::test<2> GEOSGeom_destroy_r(m_context, result); } +template<> +template<> void object::test<4> +() +{ + input_ = fromWKT("GEOMETRYCOLLECTION ( " + "CURVEPOLYGON (COMPOUNDCURVE ( CIRCULARSTRING (2 0, 1 1, 2 2), (2 2, 0 2, 0 0, 2 0))), " + "CURVEPOLYGON (COMPOUNDCURVE ( CIRCULARSTRING (2 2, 1 1, 2 0), (2 0, 4 0, 4 2, 2 2))))"); + ensure(input_); + + result_ = GEOSCoverageSimplifyVW(input_, 0.1, false); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSCoveredByTest.cpp b/tests/unit/capi/GEOSCoveredByTest.cpp index 6f9bfc947e..6982fb4966 100644 --- a/tests/unit/capi/GEOSCoveredByTest.cpp +++ b/tests/unit/capi/GEOSCoveredByTest.cpp @@ -32,5 +32,18 @@ void object::test<1>() ensure_equals(0, GEOSCoveredBy(geom3_, geom2_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("LINESTRING (5 3, 5 4)"); + geom2_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)))"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSCoveredBy(geom1_, geom2_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSCoversTest.cpp b/tests/unit/capi/GEOSCoversTest.cpp index ee976743a8..bdf5f3b087 100644 --- a/tests/unit/capi/GEOSCoversTest.cpp +++ b/tests/unit/capi/GEOSCoversTest.cpp @@ -32,5 +32,18 @@ void object::test<1>() ensure_equals(0, GEOSCovers(geom3_, geom2_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)))"); + geom2_ = fromWKT("LINESTRING (5 3, 5 4)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSCovers(geom1_, geom2_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSCrossesTest.cpp b/tests/unit/capi/GEOSCrossesTest.cpp index ab19caa9fc..12ba5f161a 100644 --- a/tests/unit/capi/GEOSCrossesTest.cpp +++ b/tests/unit/capi/GEOSCrossesTest.cpp @@ -32,5 +32,19 @@ void object::test<1>() ensure_equals(0, GEOSCrosses(geom3_, geom2_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSCrosses(geom1_, geom2_), 2); + ensure_equals("curved geometry not supported", GEOSCrosses(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp b/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp index a5568e59ea..0064d8073d 100644 --- a/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp +++ b/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp @@ -128,5 +128,16 @@ void object::test<6> "MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))"); } +template<> +template<> +void object::test<7>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0, 3 -1, 4 0)"); + ensure(input_); + + result_ = GEOSDelaunayTriangulation(input_, 0, 0); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSDensifyTest.cpp b/tests/unit/capi/GEOSDensifyTest.cpp index cd11e1cea3..97ede1605e 100644 --- a/tests/unit/capi/GEOSDensifyTest.cpp +++ b/tests/unit/capi/GEOSDensifyTest.cpp @@ -159,4 +159,14 @@ void object::test<9>() ensure("result expected to be NULL", result_ == nullptr); } +template<> +template<> +void object::test<10>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSDensify(input_, 0.1); + ensure("curved geometries not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSDifferenceTest.cpp b/tests/unit/capi/GEOSDifferenceTest.cpp index efaf1ad0d7..d1459e2acc 100644 --- a/tests/unit/capi/GEOSDifferenceTest.cpp +++ b/tests/unit/capi/GEOSDifferenceTest.cpp @@ -32,5 +32,19 @@ void object::test<1>() ensure_equals(GEOSGetSRID(geom1_), GEOSGetSRID(result_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + result_ = GEOSDifference(geom1_, geom2_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSDisjointSubsetUnionTest.cpp b/tests/unit/capi/GEOSDisjointSubsetUnionTest.cpp index 456b39ee9d..76e2a39923 100644 --- a/tests/unit/capi/GEOSDisjointSubsetUnionTest.cpp +++ b/tests/unit/capi/GEOSDisjointSubsetUnionTest.cpp @@ -46,6 +46,15 @@ void object::test<2>() ensure_geometry_equals(result_, expected_); } +template <> +template <> +void object::test<3>() { + input_ = fromWKT("MULTICURVE ((0 0, 1 1), CIRCULARSTRING (1 1, 2 0, 3 1), (5 5, 8 8))"); + ensure(input_); + + result_ = GEOSDisjointSubsetUnion(input_); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSDisjointTest.cpp b/tests/unit/capi/GEOSDisjointTest.cpp index cb8fde2a2e..f17faca3aa 100644 --- a/tests/unit/capi/GEOSDisjointTest.cpp +++ b/tests/unit/capi/GEOSDisjointTest.cpp @@ -28,5 +28,19 @@ void object::test<1>() ensure_equals(0, GEOSDisjoint(geom1_, geom3_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSDisjoint(geom1_, geom2_), 2); + ensure_equals("curved geometry not supported", GEOSDisjoint(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSDistanceTest.cpp b/tests/unit/capi/GEOSDistanceTest.cpp index 5bf03c90ba..0416532ef4 100644 --- a/tests/unit/capi/GEOSDistanceTest.cpp +++ b/tests/unit/capi/GEOSDistanceTest.cpp @@ -157,5 +157,20 @@ void object::test<5> ensure_equals(raised & FE_OVERFLOW, 0); } +template<> +template<> +void object::test<6>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 1.0001, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + double dist; + int ret = GEOSDistance(geom1_, geom2_, &dist); + ensure_equals("curved geometry not supported", ret, 0); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSDistanceWithinTest.cpp b/tests/unit/capi/GEOSDistanceWithinTest.cpp index a76aa05e98..567e431925 100644 --- a/tests/unit/capi/GEOSDistanceWithinTest.cpp +++ b/tests/unit/capi/GEOSDistanceWithinTest.cpp @@ -415,6 +415,19 @@ void object::test<31>() { ); } +template<> +template<> +void object::test<32>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 1.0001, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + char ret = GEOSDistanceWithin(geom1_, geom2_, 0.1); + ensure_equals("curved geometry not supported", ret, 2); +} diff --git a/tests/unit/capi/GEOSEqualsIdenticalTest.cpp b/tests/unit/capi/GEOSEqualsIdenticalTest.cpp index 4b0da52993..ea2b2a799e 100644 --- a/tests/unit/capi/GEOSEqualsIdenticalTest.cpp +++ b/tests/unit/capi/GEOSEqualsIdenticalTest.cpp @@ -212,5 +212,16 @@ void object::test<16> ensure_equals(GEOSEqualsIdentical(geom1_, geom2_), 1); } +template<> +template<> +void object::test<17> +() +{ + geom1_ = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + + ensure_equals(GEOSEqualsIdentical(geom1_, geom2_), 1); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSEqualsTest.cpp b/tests/unit/capi/GEOSEqualsTest.cpp index 793207f496..0164a3cede 100644 --- a/tests/unit/capi/GEOSEqualsTest.cpp +++ b/tests/unit/capi/GEOSEqualsTest.cpp @@ -134,5 +134,19 @@ void object::test<6> #endif +template<> +template<> +void object::test<7>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSEquals(geom1_, geom2_), 2); + ensure_equals("curved geometry not supported", GEOSEquals(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSFrechetDistanceTest.cpp b/tests/unit/capi/GEOSFrechetDistanceTest.cpp index 93c0f657e1..ad6215a284 100644 --- a/tests/unit/capi/GEOSFrechetDistanceTest.cpp +++ b/tests/unit/capi/GEOSFrechetDistanceTest.cpp @@ -92,4 +92,19 @@ void object::test<4> ensure(dist >= 0); // no crash } +template<> +template<> +void object::test<5>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 2, 2 2)"); + + ensure(geom1_); + ensure(geom2_); + + double dist; + ensure_equals("curved geometry not supported", GEOSFrechetDistance(geom1_, geom2_, &dist), 0); + ensure_equals("curved geometry not supported", GEOSFrechetDistance(geom2_, geom1_, &dist), 0); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGeomGeoJSONWriteTest.cpp b/tests/unit/capi/GEOSGeomGeoJSONWriteTest.cpp index 939ec6e5fb..23b2d68d1e 100644 --- a/tests/unit/capi/GEOSGeomGeoJSONWriteTest.cpp +++ b/tests/unit/capi/GEOSGeomGeoJSONWriteTest.cpp @@ -100,4 +100,17 @@ void object::test<3> "}"); test_geojson(wkt, expected, 4); } + +template<> +template<> +void object::test<4> +() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + char* geojson = GEOSGeoJSONWriter_writeGeometry(writer_, input_, 0); + ensure("curved geometry not supported", geojson == nullptr); +} + } diff --git a/tests/unit/capi/GEOSGeomGetNumPointsTest.cpp b/tests/unit/capi/GEOSGeomGetNumPointsTest.cpp index 7c9db7ae2b..80b7d24566 100644 --- a/tests/unit/capi/GEOSGeomGetNumPointsTest.cpp +++ b/tests/unit/capi/GEOSGeomGetNumPointsTest.cpp @@ -40,5 +40,13 @@ void object::test<3>() ensure_equals(GEOSGeomGetNumPoints(input_), -1); } +template<> +template<> +void object::test<4>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure_equals(GEOSGeomGetNumPoints(input_), 3); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGeomToHEX_bufTest.cpp b/tests/unit/capi/GEOSGeomToHEX_bufTest.cpp index fbd43b0a0f..f6d6c4e7c5 100644 --- a/tests/unit/capi/GEOSGeomToHEX_bufTest.cpp +++ b/tests/unit/capi/GEOSGeomToHEX_bufTest.cpp @@ -78,5 +78,7 @@ void object::test<3>() GEOS_finish_r(handle); } + + } // namespace tut diff --git a/tests/unit/capi/GEOSGeomTypeIdTest.cpp b/tests/unit/capi/GEOSGeomTypeIdTest.cpp index 65eed116a1..326796a253 100644 --- a/tests/unit/capi/GEOSGeomTypeIdTest.cpp +++ b/tests/unit/capi/GEOSGeomTypeIdTest.cpp @@ -24,9 +24,12 @@ void object::test<1>() ensure(nullptr != geom1_); geom2_ = fromWKT("LINESTRING (1 2, 3 4)"); ensure(nullptr != geom2_); + geom3_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(nullptr != geom3_); - ensure_equals(0, GEOSGeomTypeId(geom1_)); - ensure_equals(1, GEOSGeomTypeId(geom2_)); + ensure_equals(GEOS_POINT, GEOSGeomTypeId(geom1_)); + ensure_equals(GEOS_LINESTRING, GEOSGeomTypeId(geom2_)); + ensure_equals(GEOS_CIRCULARSTRING, GEOSGeomTypeId(geom3_)); } } // namespace tut diff --git a/tests/unit/capi/GEOSGeomTypeTest.cpp b/tests/unit/capi/GEOSGeomTypeTest.cpp index 14ba449f67..3f88c9431f 100644 --- a/tests/unit/capi/GEOSGeomTypeTest.cpp +++ b/tests/unit/capi/GEOSGeomTypeTest.cpp @@ -29,6 +29,11 @@ void object::test<1>() char* type2 = GEOSGeomType(geom2_); ensure_equals(std::string(type2), "LineString"); GEOSFree(type2); + + geom3_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 2)"); + char* type3 = GEOSGeomType(geom3_); + ensure_equals(std::string(type3), "CircularString"); + GEOSFree(type3); } } // namespace tut diff --git a/tests/unit/capi/GEOSGeom_cloneTest.cpp b/tests/unit/capi/GEOSGeom_cloneTest.cpp index 9948d5a0f4..3466a1b958 100644 --- a/tests/unit/capi/GEOSGeom_cloneTest.cpp +++ b/tests/unit/capi/GEOSGeom_cloneTest.cpp @@ -34,6 +34,16 @@ void object::test<1> ensure(GEOSGeom_getUserData(geom2_) == nullptr); // userData not transferred } +template<> +template<> +void object::test<2> +() +{ + input_ = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + result_ = GEOSGeom_clone(input_); + + ensure_equals(toWKT(result_), "CIRCULARSTRING (0 0, 1 1, 2 0)"); +} } // namespace tut diff --git a/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp b/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp index b2b531b36f..3d5c986141 100644 --- a/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp +++ b/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp @@ -65,6 +65,17 @@ void object::test<3> ensure_geometry_equals(geom3_, geom2_); } +template <> +template <> +void object::test<4>() { + input_ = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSGeom_extractUniquePoints(input_); + + ensure_geometry_equals(result_, "MULTIPOINT ((0 0), (1 1), (2 0))"); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp b/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp index bd84597881..e976d8ef39 100644 --- a/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp +++ b/tests/unit/capi/GEOSGeom_getCoordSeqTest.cpp @@ -57,5 +57,19 @@ void object::test<3>() ensure_equals(y, 8); } +template<> +template<> +void object::test<4>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + const GEOSCoordSequence* seq = GEOSGeom_getCoordSeq(input_); + + ensure(seq); + + unsigned int size; + ensure(GEOSCoordSeq_getSize(seq, &size)); + ensure_equals(size, 3u); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp index 8d0b0ce6fd..c3f41676be 100644 --- a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp +++ b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp @@ -21,14 +21,35 @@ template<> void object::test<1> () { - geom1_ = fromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))"); - ensure_equals(GEOSGeom_getCoordinateDimension(geom1_), 2); + input_ = fromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))"); + ensure_equals(GEOSGeom_getCoordinateDimension(input_), 2); +} + +template<> +template<> +void object::test<2> +() +{ + input_ = fromWKT("POINT (4 2 7)"); + ensure_equals(GEOSGeom_getCoordinateDimension(input_), 3); +} - geom2_ = fromWKT("POINT (4 2 7)"); - ensure_equals(GEOSGeom_getCoordinateDimension(geom2_), 3); +template<> +template<> +void object::test<3> +() +{ + input_ = fromWKT("LINESTRING (4 2 7 1, 8 2 9 5)"); + ensure_equals(GEOSGeom_getCoordinateDimension(input_), 4); +} - geom3_ = fromWKT("LINESTRING (4 2 7 1, 8 2 9 5)"); - ensure_equals(GEOSGeom_getCoordinateDimension(geom3_), 4); +template<> +template<> +void object::test<4> +() +{ + input_ = fromWKT("CIRCULARSTRING Z (0 0 0, 1 1 1, 2 0 2)"); + ensure_equals(GEOSGeom_getCoordinateDimension(input_), 3); } } // namespace tut diff --git a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp index c90e3e0ae6..5050f5d691 100644 --- a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp +++ b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp @@ -31,5 +31,13 @@ void object::test<1> ensure_equals(GEOSGeom_getDimensions(geom2_), 0); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure_equals(GEOSGeom_getDimensions(input_), 1); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGeom_transformXYTest.cpp b/tests/unit/capi/GEOSGeom_transformXYTest.cpp index f220a47f28..b2112ea36a 100644 --- a/tests/unit/capi/GEOSGeom_transformXYTest.cpp +++ b/tests/unit/capi/GEOSGeom_transformXYTest.cpp @@ -294,4 +294,15 @@ void object::test<13>() { GEOSGeom_destroy(out); } +template <> +template <> +void object::test<14>() { + input_ = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSGeom_transformXY(input_, SCALE_2_3, nullptr); + + ensure_equals(toWKT(result_), "CIRCULARSTRING (0 0, 2 3, 4 0)"); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGetCentroidTest.cpp b/tests/unit/capi/GEOSGetCentroidTest.cpp index 96b6334be0..f99c78f120 100644 --- a/tests/unit/capi/GEOSGetCentroidTest.cpp +++ b/tests/unit/capi/GEOSGetCentroidTest.cpp @@ -139,5 +139,16 @@ void object::test<5> } +template<> +template<> +void object::test<6>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0)))"); + ensure(input_ != nullptr); + + result_ = GEOSGetCentroid(input_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGetExteriorRingTest.cpp b/tests/unit/capi/GEOSGetExteriorRingTest.cpp index 0905b2e55f..c8012f90a7 100644 --- a/tests/unit/capi/GEOSGetExteriorRingTest.cpp +++ b/tests/unit/capi/GEOSGetExteriorRingTest.cpp @@ -41,4 +41,17 @@ namespace tut ensure(GEOSGetExteriorRing(geom1_) == nullptr); } + template<> + template<> + void object::test<3>() + { + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0)))"); + ensure(input_ != nullptr); + + const GEOSGeometry* extring = GEOSGetExteriorRing(input_); + ensure(extring); + + ensure_equals(toWKT(extring), "COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0))"); + } + } // namespace tut diff --git a/tests/unit/capi/GEOSGetGeometryNTest.cpp b/tests/unit/capi/GEOSGetGeometryNTest.cpp index 92665cbc16..bb8ac8d358 100644 --- a/tests/unit/capi/GEOSGetGeometryNTest.cpp +++ b/tests/unit/capi/GEOSGetGeometryNTest.cpp @@ -23,16 +23,27 @@ void object::test<1>() geom1_ = fromWKT("MULTIPOINT ((1 1), (2 2), (3 3))"); ensure(nullptr != geom1_); - GEOSGeometry* result = const_cast(GEOSGetGeometryN(geom1_, 0)); + const GEOSGeometry* result = GEOSGetGeometryN(geom1_, 0); ensure(nullptr != result); ensure_equals("POINT (1 1)", toWKT(result)); - result = const_cast(GEOSGetGeometryN(geom1_, 2)); + result = GEOSGetGeometryN(geom1_, 2); ensure(nullptr != result); ensure_equals("POINT (3 3)", toWKT(result)); ensure(GEOSGetGeometryN(geom1_, -1) == nullptr); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("MULTICURVE ((0 0, 1 1), CIRCULARSTRING (1 1, 2 0, 3 1))"); + ensure(input_); + + ensure_equals(toWKT(GEOSGetGeometryN(input_, 0)), "LINESTRING (0 0, 1 1)"); + ensure_equals(toWKT(GEOSGetGeometryN(input_, 1)), "CIRCULARSTRING (1 1, 2 0, 3 1)"); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSGetInteriorRingNTest.cpp b/tests/unit/capi/GEOSGetInteriorRingNTest.cpp index d54664d909..e9b50d60e9 100644 --- a/tests/unit/capi/GEOSGetInteriorRingNTest.cpp +++ b/tests/unit/capi/GEOSGetInteriorRingNTest.cpp @@ -42,5 +42,17 @@ namespace tut ensure(GEOSGetInteriorRingN(geom1_, 0) == nullptr); } + template<> + template<> + void object::test<3>() + { + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)), (8 8, 9 9, 9 8, 8 8))"); + ensure(input_ != nullptr); + + const GEOSGeometry* intring = GEOSGetInteriorRingN(input_, 0); + ensure(intring); + + ensure_equals(toWKT(intring), "LINESTRING (8 8, 9 9, 9 8, 8 8)"); + } } // namespace tut diff --git a/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp b/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp index 968868ea4f..70e647990b 100644 --- a/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp +++ b/tests/unit/capi/GEOSGetNumInteriorRingsTest.cpp @@ -38,5 +38,15 @@ void object::test<2>() GEOSGeom_destroy(input); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)), (8 8, 9 9, 9 8, 8 8))"); + ensure(input_ != nullptr); + + ensure_equals(GEOSGetNumInteriorRings(input_), 1); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSHasZMTest.cpp b/tests/unit/capi/GEOSHasZMTest.cpp index 346ca97d8d..13ea525b96 100644 --- a/tests/unit/capi/GEOSHasZMTest.cpp +++ b/tests/unit/capi/GEOSHasZMTest.cpp @@ -106,6 +106,15 @@ void object::test<9>() ensure_equals(GEOSHasM(input_), 1); } +template<> +template<> +void object::test<10>() +{ + input_ = fromWKT("CIRCULARSTRING M (0 0 0, 1 1 1, 2 0 2)"); + + ensure_equals(GEOSHasZ(input_), 0); + ensure_equals(GEOSHasM(input_), 1); +} } // namespace tut diff --git a/tests/unit/capi/GEOSHausdorffDistanceTest.cpp b/tests/unit/capi/GEOSHausdorffDistanceTest.cpp index 3cddf2424b..ead81cd93b 100644 --- a/tests/unit/capi/GEOSHausdorffDistanceTest.cpp +++ b/tests/unit/capi/GEOSHausdorffDistanceTest.cpp @@ -63,4 +63,19 @@ void object::test<2> ensure_distance(dist, 70., 1e-12); } +template<> +template<> +void object::test<3>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 2, 2 2)"); + + ensure(geom1_); + ensure(geom2_); + + double dist; + ensure_equals("curved geometry not supported", GEOSHausdorffDistance(geom1_, geom2_, &dist), 0); + ensure_equals("curved geometry not supported", GEOSHausdorffDistance(geom2_, geom1_, &dist), 0); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSIntersectionTest.cpp b/tests/unit/capi/GEOSIntersectionTest.cpp index 94d209e267..2377c609f4 100644 --- a/tests/unit/capi/GEOSIntersectionTest.cpp +++ b/tests/unit/capi/GEOSIntersectionTest.cpp @@ -143,6 +143,19 @@ void object::test<7> ensure(!std::fetestexcept(FE_INVALID)); } +template<> +template<> +void object::test<8>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + result_ = GEOSIntersection(geom1_, geom2_); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSIntersectsTest.cpp b/tests/unit/capi/GEOSIntersectsTest.cpp index bba2534458..395d2698ca 100644 --- a/tests/unit/capi/GEOSIntersectsTest.cpp +++ b/tests/unit/capi/GEOSIntersectsTest.cpp @@ -220,5 +220,19 @@ void object::test<10> ensure_equals(r2, 1); } +template<> +template<> +void object::test<11>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSIntersects(geom1_, geom2_), 2); + ensure_equals("curved geometry not supported", GEOSIntersects(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSLargestEmptyCircleTest.cpp b/tests/unit/capi/GEOSLargestEmptyCircleTest.cpp index aff84e2ec9..6b0e69a869 100644 --- a/tests/unit/capi/GEOSLargestEmptyCircleTest.cpp +++ b/tests/unit/capi/GEOSLargestEmptyCircleTest.cpp @@ -65,5 +65,32 @@ void object::test<2> ensure_geometry_equals_exact(result_, expected_, 0.0001); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("MULTICURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (0 3, 2 3))"); + ensure(input_); + + result_ = GEOSLargestEmptyCircle(input_, nullptr, 0.001); + + ensure("curved geometries not supported", result_ == nullptr); +} + +template<> +template<> +void object::test<4>() +{ + input_ = GEOSGeomFromWKT("MULTILINESTRING ((40 90, 90 60), (90 40, 40 10))"); + geom2_ = GEOSGeomFromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING(0 100, 50 150, 100 100), (100 100, 100 0, 0 0, 0 100)))"); + ensure(input_); + ensure(geom2_); + + result_ = GEOSLargestEmptyCircle(input_, geom2_, 0.001); + + ensure("curved geometries not supported", result_ == nullptr); +} + + } // namespace tut diff --git a/tests/unit/capi/GEOSLengthTest.cpp b/tests/unit/capi/GEOSLengthTest.cpp index fa22e2a7a4..66c2872d13 100644 --- a/tests/unit/capi/GEOSLengthTest.cpp +++ b/tests/unit/capi/GEOSLengthTest.cpp @@ -58,5 +58,17 @@ void object::test<3>() ensure_equals(length, 0); } +template<> +template<> +void object::test<4>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + double length = -1; + int ret = GEOSLength(input_, &length); + ensure_equals("error raised on curved geometry", ret, 0); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSLineMergeDirectedTest.cpp b/tests/unit/capi/GEOSLineMergeDirectedTest.cpp index 39a172ad17..bd5537d084 100644 --- a/tests/unit/capi/GEOSLineMergeDirectedTest.cpp +++ b/tests/unit/capi/GEOSLineMergeDirectedTest.cpp @@ -60,5 +60,18 @@ void object::test<2> GEOSGeom_destroy(expected); } + +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("MULTICURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 3 0))"); + ensure(input_); + + result_ = GEOSLineMergeDirected(input_); + + ensure("curved geometries not supported", result_ == nullptr); +} + } // namesplace tut diff --git a/tests/unit/capi/GEOSLineMergeTest.cpp b/tests/unit/capi/GEOSLineMergeTest.cpp index e744ed513d..d8c40c4e07 100644 --- a/tests/unit/capi/GEOSLineMergeTest.cpp +++ b/tests/unit/capi/GEOSLineMergeTest.cpp @@ -44,5 +44,17 @@ void object::test<1> GEOSGeom_destroy(expected); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("MULTICURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 3 0))"); + ensure(input_); + + result_ = GEOSLineMerge(input_); + + ensure("curved geometries not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSLineSubstringTest.cpp b/tests/unit/capi/GEOSLineSubstringTest.cpp index c759307929..24078c085c 100644 --- a/tests/unit/capi/GEOSLineSubstringTest.cpp +++ b/tests/unit/capi/GEOSLineSubstringTest.cpp @@ -119,6 +119,17 @@ void object::test<6> ensure_geometry_equals(result_, expected_); } +template<> +template<> +void object::test<7>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSLineSubstring(input_, 0.5, 0); + + ensure("curved geometries not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSMakeValidTest.cpp b/tests/unit/capi/GEOSMakeValidTest.cpp index c28d14606c..1c6071e94f 100644 --- a/tests/unit/capi/GEOSMakeValidTest.cpp +++ b/tests/unit/capi/GEOSMakeValidTest.cpp @@ -94,5 +94,16 @@ void object::test<4> ensure(GEOSEqualsExact(geom2_, expected_, 0.01)); } +template<> +template<> +void object::test<5>() +{ + // ring outside shell + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)), (10 10, 30 10, 30 30, 10 10))"); + ensure(input_); + + result_ = GEOSMakeValid(input_); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp b/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp index 60ef3f10bd..1ca8a79363 100644 --- a/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp +++ b/tests/unit/capi/GEOSMaximumInscribedCircleTest.cpp @@ -75,7 +75,16 @@ void object::test<2> // no crash } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 0 0)))"); + ensure(input_); + result_ = GEOSMaximumInscribedCircle(input_, 1); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp b/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp index 3bfd6326aa..5b7c1dff48 100644 --- a/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp +++ b/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp @@ -116,5 +116,19 @@ void object::test<4> ensure(fabs(radius) - 5.0 < 0.001); } +template<> +template<> +void object::test<5> +() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + GEOSGeometry* center; + double radius; + result_ = GEOSMinimumBoundingCircle(input_, &radius, ¢er); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSMinimumClearanceTest.cpp b/tests/unit/capi/GEOSMinimumClearanceTest.cpp index f683145da2..0e7f65e07f 100644 --- a/tests/unit/capi/GEOSMinimumClearanceTest.cpp +++ b/tests/unit/capi/GEOSMinimumClearanceTest.cpp @@ -120,4 +120,5 @@ void object::test<5> geos::DoubleInfinity); } + } // namespace tut diff --git a/tests/unit/capi/GEOSMinimumRotatedRectangleTest.cpp b/tests/unit/capi/GEOSMinimumRotatedRectangleTest.cpp index a71462d860..6782d20c2c 100644 --- a/tests/unit/capi/GEOSMinimumRotatedRectangleTest.cpp +++ b/tests/unit/capi/GEOSMinimumRotatedRectangleTest.cpp @@ -122,5 +122,16 @@ void object::test<7> "POLYGON ((1 2, 3 8, 9 6, 7 0, 1 2))"); } +template<> +template<> +void object::test<8> +() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSMinimumRotatedRectangle(input_); + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSMinimumWidthTest.cpp b/tests/unit/capi/GEOSMinimumWidthTest.cpp index bad070c101..57f935da8f 100644 --- a/tests/unit/capi/GEOSMinimumWidthTest.cpp +++ b/tests/unit/capi/GEOSMinimumWidthTest.cpp @@ -67,4 +67,16 @@ void object::test<2> GEOSGeom_destroy(output); } +template<> +template<> +void object::test<3> +() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSMinimumWidth(input_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSNodeTest.cpp b/tests/unit/capi/GEOSNodeTest.cpp index abda612bb9..9b11e1a15b 100644 --- a/tests/unit/capi/GEOSNodeTest.cpp +++ b/tests/unit/capi/GEOSNodeTest.cpp @@ -201,5 +201,17 @@ void object::test<8> GEOSFree(wkt_expected); } +template<> +template<> +void object::test<9>() +{ + input_ = fromWKT("MULTICURVE (CIRCULARSTRING (0 0, 1 1, 2 0), CIRCULARSTRING (0 1, 1 0, 2 1))"); + ensure(input_); + + result_ = GEOSNode(input_); + + ensure("curved geometries not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSOffsetCurveTest.cpp b/tests/unit/capi/GEOSOffsetCurveTest.cpp index d5ddfb8f67..b3414dc159 100644 --- a/tests/unit/capi/GEOSOffsetCurveTest.cpp +++ b/tests/unit/capi/GEOSOffsetCurveTest.cpp @@ -259,5 +259,17 @@ void object::test<12>() ); } +template<> +template<> +void object::test<13>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSOffsetCurve(input_, 1, 8, GEOSBUF_JOIN_ROUND, 0); + + ensure("curved geometries not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSOrientPolygonsTest.cpp b/tests/unit/capi/GEOSOrientPolygonsTest.cpp index 745ac1bc06..1b9a7a3d1d 100644 --- a/tests/unit/capi/GEOSOrientPolygonsTest.cpp +++ b/tests/unit/capi/GEOSOrientPolygonsTest.cpp @@ -90,5 +90,16 @@ void object::test<5>() ensure_equals(toWKT(geom1_), "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0)))))"); } +template<> +template<> +void object::test<6>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0)))"); + ensure(input_); + + auto ret = GEOSOrientPolygons(input_, 0); + ensure_equals("curved geometries not supported", ret, -1); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSOverlapsTest.cpp b/tests/unit/capi/GEOSOverlapsTest.cpp index 59cfa073ec..253bd762f3 100644 --- a/tests/unit/capi/GEOSOverlapsTest.cpp +++ b/tests/unit/capi/GEOSOverlapsTest.cpp @@ -35,5 +35,19 @@ void object::test<1>() ensure_equals(0, GEOSOverlaps(geom3_, geom2_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSOverlaps(geom1_, geom2_), 2); + ensure_equals("curved geometry not supported", GEOSOverlaps(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSPointOnSurfaceTest.cpp b/tests/unit/capi/GEOSPointOnSurfaceTest.cpp index 65f885e3dc..2675a3a7c6 100644 --- a/tests/unit/capi/GEOSPointOnSurfaceTest.cpp +++ b/tests/unit/capi/GEOSPointOnSurfaceTest.cpp @@ -224,5 +224,17 @@ void object::test<9> ensure_equals(std::string(wkt_), std::string("POINT (182755.892 141812.8789)")); } +template<> +template<> +void object::test<10> +() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE(CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0)))"); + ensure(input_); + + result_ = GEOSPointOnSurface(input_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSPolygonHullSimplifyTest.cpp b/tests/unit/capi/GEOSPolygonHullSimplifyTest.cpp index af98ebb300..43f426e046 100644 --- a/tests/unit/capi/GEOSPolygonHullSimplifyTest.cpp +++ b/tests/unit/capi/GEOSPolygonHullSimplifyTest.cpp @@ -93,6 +93,16 @@ void object::test<5>() ensure_geometry_equals(geom1_, expected_); } +template<> +template<> +void object::test<6>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 1 0.0001, 0 0)))"); + ensure(input_); + + result_ = GEOSPolygonHullSimplify(input_, 1, 0.8); + ensure("curved geometries not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSPolygonizeTest.cpp b/tests/unit/capi/GEOSPolygonizeTest.cpp index 695db3757c..c0c2eb5764 100644 --- a/tests/unit/capi/GEOSPolygonizeTest.cpp +++ b/tests/unit/capi/GEOSPolygonizeTest.cpp @@ -187,5 +187,28 @@ void object::test<6> GEOSGeom_destroy(expected_invalidRings); } +template<> +template<> +void object::test<7> +() +{ + constexpr int size = 2; + GEOSGeometry* geoms[size]; + geoms[0] = GEOSGeomFromWKT("LINESTRING (0 0, 2 0)"); + geoms[1] = GEOSGeomFromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + + for (auto& geom : geoms) { + ensure(geom != nullptr); + } + + GEOSGeometry* g = GEOSPolygonize(geoms, size); + + ensure("curved geometries not supported", g == nullptr); + + for(auto& input : geoms) { + GEOSGeom_destroy(input); + } +} + } // namespace tut diff --git a/tests/unit/capi/GEOSPreparedGeometryTest.cpp b/tests/unit/capi/GEOSPreparedGeometryTest.cpp index 5d324d55c5..4ee90cea51 100644 --- a/tests/unit/capi/GEOSPreparedGeometryTest.cpp +++ b/tests/unit/capi/GEOSPreparedGeometryTest.cpp @@ -441,5 +441,17 @@ void object::test<15> } +template<> +template<> +void object::test<16>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + + ensure(geom1_); + + prepGeom1_ = GEOSPrepare(geom1_); + ensure("curved geometries not supported", prepGeom1_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSRelatePatternTest.cpp b/tests/unit/capi/GEOSRelatePatternTest.cpp index ef8e24f6ec..1b6068749f 100644 --- a/tests/unit/capi/GEOSRelatePatternTest.cpp +++ b/tests/unit/capi/GEOSRelatePatternTest.cpp @@ -31,5 +31,19 @@ void object::test<1>() ensure_equals(1, GEOSRelatePattern(geom1_, geom3_, "*FF*FF212")); } +template<> +template<> +void object::test<11>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSRelatePattern(geom1_, geom2_, "0********"), 2); + ensure_equals("curved geometry not supported", GEOSRelatePattern(geom2_, geom1_, "0********"), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSRelateTest.cpp b/tests/unit/capi/GEOSRelateTest.cpp index 336c41f1e9..f531ee4ab3 100644 --- a/tests/unit/capi/GEOSRelateTest.cpp +++ b/tests/unit/capi/GEOSRelateTest.cpp @@ -30,5 +30,19 @@ void object::test<1>() GEOSFree(pattern); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure("curved geometry not supported", GEOSRelate(geom1_, geom2_) == nullptr); + ensure("curved geometry not supported", GEOSRelate(geom2_, geom1_) == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSRemoveRepeatedPointsTest.cpp b/tests/unit/capi/GEOSRemoveRepeatedPointsTest.cpp index 8d6c9c2c6a..1a0780b575 100644 --- a/tests/unit/capi/GEOSRemoveRepeatedPointsTest.cpp +++ b/tests/unit/capi/GEOSRemoveRepeatedPointsTest.cpp @@ -55,5 +55,16 @@ void object::test<2> ensure(result_ == nullptr); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0, 2 0, 2 0)"); + ensure(input_); + + result_ = GEOSRemoveRepeatedPoints(input_, 0); + + ensure("curved geometry not supported", result_ == nullptr); +} } // namespace tut diff --git a/tests/unit/capi/GEOSReverseTest.cpp b/tests/unit/capi/GEOSReverseTest.cpp index 5f5b8020d1..fae65d95f7 100644 --- a/tests/unit/capi/GEOSReverseTest.cpp +++ b/tests/unit/capi/GEOSReverseTest.cpp @@ -123,4 +123,12 @@ void object::test<8> testReverse("GEOMETRYCOLLECTION EMPTY", "GEOMETRYCOLLECTION EMPTY"); } +template<> +template<> +void object::test<9>() +{ + testReverse("CIRCULARSTRING (0 0, 1 1, 2 0)", + "CIRCULARSTRING (2 0, 1 1, 0 0)"); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSSharedPathsTest.cpp b/tests/unit/capi/GEOSSharedPathsTest.cpp index 0c16640bc8..db3b24fb9c 100644 --- a/tests/unit/capi/GEOSSharedPathsTest.cpp +++ b/tests/unit/capi/GEOSSharedPathsTest.cpp @@ -88,5 +88,19 @@ void object::test<3> ensure(!geom3_); } +template<> +template<> +void object::test<4>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + result_ = GEOSSharedPaths(geom1_, geom2_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSSimplifyTest.cpp b/tests/unit/capi/GEOSSimplifyTest.cpp index 1067bbb770..407589b8bb 100644 --- a/tests/unit/capi/GEOSSimplifyTest.cpp +++ b/tests/unit/capi/GEOSSimplifyTest.cpp @@ -44,5 +44,16 @@ void object::test<1> ensure(0 != GEOSisEmpty(geom2_)); } +template<> +template<> +void object::test<2>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + result_ = GEOSSimplify(input_, 2); + ensure(result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSSnapTest.cpp b/tests/unit/capi/GEOSSnapTest.cpp index 17d9da8f26..fba18f8e8c 100644 --- a/tests/unit/capi/GEOSSnapTest.cpp +++ b/tests/unit/capi/GEOSSnapTest.cpp @@ -209,5 +209,19 @@ void object::test<10> ensure_equals(out, "LINESTRING (-71.1257 42.2703, -71.1261 42.2703, -71.1261 42.2702, -71.1317 42.2509)"); } +template<> +template<> +void object::test<11>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 1.0001, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + result_ = GEOSSnap(geom1_, geom2_, 0.1); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSSymDifferenceTest.cpp b/tests/unit/capi/GEOSSymDifferenceTest.cpp index 34d2c07947..def092b684 100644 --- a/tests/unit/capi/GEOSSymDifferenceTest.cpp +++ b/tests/unit/capi/GEOSSymDifferenceTest.cpp @@ -29,5 +29,19 @@ void object::test<1>() ensure_equals("MULTILINESTRING ((50 150, 50 200), (50 50, 50 100))", toWKT(geom3_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + result_ = GEOSSymDifference(geom1_, geom2_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSTopologyPreserveSimplifyTest.cpp b/tests/unit/capi/GEOSTopologyPreserveSimplifyTest.cpp index 2df27d1a9b..ca84ed8992 100644 --- a/tests/unit/capi/GEOSTopologyPreserveSimplifyTest.cpp +++ b/tests/unit/capi/GEOSTopologyPreserveSimplifyTest.cpp @@ -52,5 +52,16 @@ void object::test<2> ensure_geometry_equals(result_, expected_); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0, 10 10, 20 0), (20 0, 10 0, 0 0)), (10 1, 11 1, 11 2, 10 1))"); + ensure(input_); + + result_ = GEOSTopologyPreserveSimplify(input_, 0.2); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSTouchesTest.cpp b/tests/unit/capi/GEOSTouchesTest.cpp index 79de79f629..df6722d5fb 100644 --- a/tests/unit/capi/GEOSTouchesTest.cpp +++ b/tests/unit/capi/GEOSTouchesTest.cpp @@ -35,5 +35,19 @@ void object::test<1>() ensure_equals(0, GEOSTouches(geom3_, geom2_)); } +template<> +template<> +void object::test<2>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSTouches(geom1_, geom2_), 2); + ensure_equals("curved geometry not supported", GEOSTouches(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSUnaryUnionTest.cpp b/tests/unit/capi/GEOSUnaryUnionTest.cpp index e164bbd39e..b33b07a2f3 100644 --- a/tests/unit/capi/GEOSUnaryUnionTest.cpp +++ b/tests/unit/capi/GEOSUnaryUnionTest.cpp @@ -218,6 +218,18 @@ void object::test<11> ensure_geometry_equals(result_, expected_); } +template<> +template<> +void object::test<12>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + + ensure(input_); + + result_ = GEOSUnaryUnion(input_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSUnionTest.cpp b/tests/unit/capi/GEOSUnionTest.cpp index 1053ec7a6d..68c90867b9 100644 --- a/tests/unit/capi/GEOSUnionTest.cpp +++ b/tests/unit/capi/GEOSUnionTest.cpp @@ -62,5 +62,19 @@ void object::test<2>() (void) result; // no crash } +template<> +template<> +void object::test<3>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 1)"); + + ensure(geom1_); + ensure(geom2_); + + result_ = GEOSUnion(geom1_, geom2_); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSVoronoiDiagramTest.cpp b/tests/unit/capi/GEOSVoronoiDiagramTest.cpp index c8843ac230..b379a49d04 100644 --- a/tests/unit/capi/GEOSVoronoiDiagramTest.cpp +++ b/tests/unit/capi/GEOSVoronoiDiagramTest.cpp @@ -175,4 +175,16 @@ void object::test<8> check_voronoi_ordered("LINESTRING (1 1, 2 2, 3 3)"); } +template<> +template<> +void object::test<9> +() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + result_ = GEOSVoronoiDiagram(input_, nullptr, 0, 0); + ensure("curved geometry not supported", result_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSWKBWriterTest.cpp b/tests/unit/capi/GEOSWKBWriterTest.cpp index 2f3e041d66..1bb95c8081 100644 --- a/tests/unit/capi/GEOSWKBWriterTest.cpp +++ b/tests/unit/capi/GEOSWKBWriterTest.cpp @@ -186,5 +186,18 @@ void object::test<9>() ensure_equals(hexstr, "010100008000000000000008400000000000002040000000000000F03F"); } +template<> +template<> +void object::test<10> +() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_); + + std::size_t hex_size = 0; + buf_ = GEOSWKBWriter_writeHEX(wkbwriter_, input_, &hex_size); + ensure("curved geometry not supported", buf_ == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSWithinTest.cpp b/tests/unit/capi/GEOSWithinTest.cpp index c6ee8ede01..703a9b86e6 100644 --- a/tests/unit/capi/GEOSWithinTest.cpp +++ b/tests/unit/capi/GEOSWithinTest.cpp @@ -88,5 +88,18 @@ void object::test<3> ensure_equals(int(r2), 1); } +template<> +template<> +void object::test<4>() +{ + geom1_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + geom2_ = fromWKT("LINESTRING (1 0, 2 0)"); + + ensure(geom1_); + ensure(geom2_); + + ensure_equals("curved geometry not supported", GEOSWithin(geom2_, geom1_), 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSisClosedTest.cpp b/tests/unit/capi/GEOSisClosedTest.cpp index c4becfdd79..656ec1ab15 100644 --- a/tests/unit/capi/GEOSisClosedTest.cpp +++ b/tests/unit/capi/GEOSisClosedTest.cpp @@ -36,7 +36,7 @@ void object::test<1> () { geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 1 0, 1 1)"); - int r = GEOSisClosed(geom1_); + char r = GEOSisClosed(geom1_); ensure_equals(r, 0); } @@ -46,7 +46,7 @@ void object::test<2> () { geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 1, 1 1, 0 0)"); - int r = GEOSisClosed(geom1_); + char r = GEOSisClosed(geom1_); ensure_equals(r, 1); } @@ -56,7 +56,7 @@ void object::test<3> () { geom1_ = GEOSGeomFromWKT("MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1))"); - int r = GEOSisClosed(geom1_); + char r = GEOSisClosed(geom1_); ensure_equals(r, 0); } @@ -66,7 +66,7 @@ void object::test<4> () { geom1_ = GEOSGeomFromWKT("MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1, 0 0))"); - int r = GEOSisClosed(geom1_); + char r = GEOSisClosed(geom1_); ensure_equals(r, 1); } @@ -76,8 +76,20 @@ void object::test<5> () { geom1_ = GEOSGeomFromWKT("POINT (1 1)"); - int r = GEOSisClosed(geom1_); + char r = GEOSisClosed(geom1_); ensure_equals(r, 2); } +template<> +template<> +void object::test<6> +() +{ + geom1_ = GEOSGeomFromWKT("COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0))"); + ensure(geom1_); + + char r = GEOSisClosed(geom1_); + ensure_equals(r, 1); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSisRingTest.cpp b/tests/unit/capi/GEOSisRingTest.cpp index 7337cd83eb..1d0b6da476 100644 --- a/tests/unit/capi/GEOSisRingTest.cpp +++ b/tests/unit/capi/GEOSisRingTest.cpp @@ -36,7 +36,7 @@ void object::test<1> () { geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 1 0, 1 1)"); - int r = GEOSisRing(geom1_); + char r = GEOSisRing(geom1_); ensure_equals(r, 0); } @@ -46,7 +46,7 @@ void object::test<2> () { geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 1 0, 1 1, 0 0)"); - int r = GEOSisRing(geom1_); + char r = GEOSisRing(geom1_); ensure_equals(r, 1); } @@ -56,7 +56,7 @@ void object::test<3> () { geom1_ = GEOSGeomFromWKT("POINT (1 1)"); - int r = GEOSisRing(geom1_); + char r = GEOSisRing(geom1_); ensure_equals(r, 0); } @@ -66,7 +66,7 @@ void object::test<4> () { geom1_ = GEOSGeomFromWKT("MULTILINESTRING ((0 0, 1 0, 1 1, 0 0))"); - int r = GEOSisRing(geom1_); + char r = GEOSisRing(geom1_); ensure_equals(r, 0); } @@ -76,9 +76,21 @@ void object::test<5> () { geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY"); - int r = GEOSisRing(geom1_); + char r = GEOSisRing(geom1_); ensure_equals(r, 0); } +template<> +template<> +void object::test<6> +() +{ + geom1_ = GEOSGeomFromWKT("COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 0 0))"); + ensure(geom1_); + + char r = GEOSisRing(geom1_); + ensure_equals("curved geometetries not supported", r, 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSisSimpleTest.cpp b/tests/unit/capi/GEOSisSimpleTest.cpp index b25930dd95..762bacdb8b 100644 --- a/tests/unit/capi/GEOSisSimpleTest.cpp +++ b/tests/unit/capi/GEOSisSimpleTest.cpp @@ -32,4 +32,15 @@ void object::test<2>() ensure_equals(0, GEOSisSimple(input_)); } +template<> +template<> +void object::test<3>() +{ + input_ = fromWKT("CIRCULARSTRING (0 0, 1 1, 2 0)"); + ensure(input_ != nullptr); + + char ret = GEOSisSimple(input_); + ensure_equals("error raised on curved geometry", ret, 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSisValidDetailTest.cpp b/tests/unit/capi/GEOSisValidDetailTest.cpp index cafa342f60..56d005268e 100644 --- a/tests/unit/capi/GEOSisValidDetailTest.cpp +++ b/tests/unit/capi/GEOSisValidDetailTest.cpp @@ -144,5 +144,16 @@ void object::test<6> ensure_equals(r, 0); // invalid } +template<> +template<> +void object::test<7>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 1 1)))"); + ensure(input_ != nullptr); + + char ret = GEOSisValidDetail(input_, 0, nullptr, nullptr); + ensure_equals("error raised on curved geometry", ret, 2); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSisValidReasonTest.cpp b/tests/unit/capi/GEOSisValidReasonTest.cpp index d253b7bfb9..fbd988e59a 100644 --- a/tests/unit/capi/GEOSisValidReasonTest.cpp +++ b/tests/unit/capi/GEOSisValidReasonTest.cpp @@ -57,6 +57,17 @@ void object::test<3>() GEOSFree(reason); } +template<> +template<> +void object::test<7>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 1 1)))"); + ensure(input_ != nullptr); + + char* reason = GEOSisValidReason(input_); + ensure(reason == nullptr); +} + } // namespace tut diff --git a/tests/unit/capi/GEOSisValidTest.cpp b/tests/unit/capi/GEOSisValidTest.cpp index a99684b79f..a71fc51501 100644 --- a/tests/unit/capi/GEOSisValidTest.cpp +++ b/tests/unit/capi/GEOSisValidTest.cpp @@ -64,4 +64,15 @@ void object::test<3>() ensure_equals(2, isvalid); } +template<> +template<> +void object::test<5>() +{ + input_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE( CIRCULARSTRING (0 0, 1 1, 2 0), (2 0, 1 1)))"); + ensure(input_ != nullptr); + + char ret = GEOSisValid(input_); + ensure_equals("error raised on curved geometry", ret, 2); +} + } // namespace tut diff --git a/tests/unit/capi/capi_test_utils.h b/tests/unit/capi/capi_test_utils.h index d6a9dc668e..ef6f6c07bb 100644 --- a/tests/unit/capi/capi_test_utils.h +++ b/tests/unit/capi/capi_test_utils.h @@ -82,7 +82,7 @@ namespace capitest { } std::string - toWKT(GEOSGeometry* g) + toWKT(const GEOSGeometry* g) { char* wkt = GEOSWKTWriter_write(wktw_, g); std::string ret(wkt);