|
31 | 31 | #include <geos/coverage/CoverageValidator.h>
|
32 | 32 | #include <geos/coverage/CoverageSimplifier.h>
|
33 | 33 | #include <geos/coverage/CoverageUnion.h>
|
| 34 | +#include <geos/geom/CircularString.h> |
| 35 | +#include <geos/geom/CompoundCurve.h> |
34 | 36 | #include <geos/geom/Coordinate.h>
|
35 | 37 | #include <geos/geom/CoordinateSequence.h>
|
36 | 38 | #include <geos/geom/Curve.h>
|
| 39 | +#include <geos/geom/CurvePolygon.h> |
37 | 40 | #include <geos/geom/Envelope.h>
|
38 | 41 | #include <geos/geom/Geometry.h>
|
39 | 42 | #include <geos/geom/GeometryCollection.h>
|
|
46 | 49 | #include <geos/geom/MultiLineString.h>
|
47 | 50 | #include <geos/geom/MultiPoint.h>
|
48 | 51 | #include <geos/geom/MultiPolygon.h>
|
| 52 | +#include <geos/geom/MultiSurface.h> |
49 | 53 | #include <geos/geom/Point.h>
|
50 | 54 | #include <geos/geom/Polygon.h>
|
51 | 55 | #include <geos/geom/PrecisionModel.h>
|
@@ -2078,6 +2082,12 @@ extern "C" {
|
2078 | 2082 | case GEOS_MULTIPOLYGON:
|
2079 | 2083 | g = gf->createMultiPolygon(std::move(vgeoms));
|
2080 | 2084 | break;
|
| 2085 | + case GEOS_MULTICURVE: |
| 2086 | + g = gf->createMultiCurve(std::move(vgeoms)); |
| 2087 | + break; |
| 2088 | + case GEOS_MULTISURFACE: |
| 2089 | + g = gf->createMultiSurface(std::move(vgeoms)); |
| 2090 | + break; |
2081 | 2091 | default:
|
2082 | 2092 | handle->ERROR_MESSAGE("Unsupported type request for GEOSGeom_createCollection_r");
|
2083 | 2093 | }
|
@@ -2991,6 +3001,113 @@ extern "C" {
|
2991 | 3001 | });
|
2992 | 3002 | }
|
2993 | 3003 |
|
| 3004 | + Geometry* |
| 3005 | + GEOSGeom_createCircularString_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs) |
| 3006 | + { |
| 3007 | + return execute(extHandle, [&]() { |
| 3008 | + GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle); |
| 3009 | + const GeometryFactory* gf = handle->geomFactory; |
| 3010 | + |
| 3011 | + return gf->createCircularString(std::unique_ptr<CoordinateSequence>(cs)).release(); |
| 3012 | + }); |
| 3013 | + } |
| 3014 | + |
| 3015 | + Geometry* |
| 3016 | + GEOSGeom_createEmptyCircularString_r(GEOSContextHandle_t extHandle) |
| 3017 | + { |
| 3018 | + return execute(extHandle, [&]() { |
| 3019 | + GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle); |
| 3020 | + const GeometryFactory* gf = handle->geomFactory; |
| 3021 | + |
| 3022 | + return gf->createCircularString(false, false).release(); |
| 3023 | + }); |
| 3024 | + } |
| 3025 | + |
| 3026 | + Geometry* |
| 3027 | + GEOSGeom_createCompoundCurve_r(GEOSContextHandle_t extHandle, Geometry** geoms, unsigned int ngeoms) |
| 3028 | + { |
| 3029 | + return execute(extHandle, [&]() -> Geometry* { |
| 3030 | + GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle); |
| 3031 | + const GeometryFactory* gf = handle->geomFactory; |
| 3032 | + |
| 3033 | + bool invalid_input = false; |
| 3034 | + std::vector<std::unique_ptr<SimpleCurve>> geom_vec(ngeoms); |
| 3035 | + for (std::size_t i = 0; i < ngeoms; i++) { |
| 3036 | + if (SimpleCurve* c = dynamic_cast<SimpleCurve*>(geoms[i])) { |
| 3037 | + geom_vec[i].reset(c); |
| 3038 | + } else { |
| 3039 | + delete geoms[i]; |
| 3040 | + invalid_input = true; |
| 3041 | + } |
| 3042 | + } |
| 3043 | + |
| 3044 | + if (invalid_input) { |
| 3045 | + throw IllegalArgumentException("Input is not a SimpleCurve"); |
| 3046 | + } |
| 3047 | + |
| 3048 | + return gf->createCompoundCurve(std::move(geom_vec)).release(); |
| 3049 | + }); |
| 3050 | + } |
| 3051 | + |
| 3052 | + Geometry* |
| 3053 | + GEOSGeom_createEmptyCompoundCurve_r(GEOSContextHandle_t extHandle) |
| 3054 | + { |
| 3055 | + return execute(extHandle, [&]() { |
| 3056 | + GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle); |
| 3057 | + const GeometryFactory* gf = handle->geomFactory; |
| 3058 | + |
| 3059 | + return gf->createCompoundCurve().release(); |
| 3060 | + }); |
| 3061 | + } |
| 3062 | + |
| 3063 | + Geometry* |
| 3064 | + GEOSGeom_createCurvePolygon_r(GEOSContextHandle_t extHandle, Geometry* p_shell, Geometry** p_holes, unsigned int nholes) |
| 3065 | + { |
| 3066 | + return execute(extHandle, [&]() { |
| 3067 | + GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle); |
| 3068 | + const GeometryFactory* gf = handle->geomFactory; |
| 3069 | + bool good_holes = true, good_shell = true; |
| 3070 | + |
| 3071 | + std::unique_ptr<Curve> shell; |
| 3072 | + std::vector<std::unique_ptr<Curve>> holes(nholes); |
| 3073 | + |
| 3074 | + if (Curve* c = dynamic_cast<Curve*>(p_shell)) { |
| 3075 | + shell.reset(c); |
| 3076 | + } else { |
| 3077 | + good_shell = false; |
| 3078 | + delete p_shell; |
| 3079 | + } |
| 3080 | + |
| 3081 | + for (std::size_t i = 0; i < nholes; i++) { |
| 3082 | + if (Curve* c = dynamic_cast<Curve*>(p_holes[i])) { |
| 3083 | + holes[i].reset(c); |
| 3084 | + } else { |
| 3085 | + good_shell = false; |
| 3086 | + delete p_holes[i]; |
| 3087 | + } |
| 3088 | + } |
| 3089 | + |
| 3090 | + if (good_shell && good_holes) { |
| 3091 | + return gf->createCurvePolygon(std::move(shell), std::move(holes)).release(); |
| 3092 | + } else if (!good_shell) { |
| 3093 | + throw IllegalArgumentException("Shell is not a Curve"); |
| 3094 | + } else { |
| 3095 | + throw IllegalArgumentException("Hole is not a Curve"); |
| 3096 | + } |
| 3097 | + }); |
| 3098 | + } |
| 3099 | + |
| 3100 | + |
| 3101 | + Geometry* |
| 3102 | + GEOSGeom_createEmptyCurvePolygon_r(GEOSContextHandle_t extHandle) |
| 3103 | + { |
| 3104 | + return execute(extHandle, [&]() { |
| 3105 | + GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle); |
| 3106 | + const GeometryFactory* gf = handle->geomFactory; |
| 3107 | + return gf->createCurvePolygon(false, false).release(); |
| 3108 | + }); |
| 3109 | + } |
| 3110 | + |
2994 | 3111 | Geometry*
|
2995 | 3112 | GEOSGeom_clone_r(GEOSContextHandle_t extHandle, const Geometry* g)
|
2996 | 3113 | {
|
|
0 commit comments