From eb7e25b64e2507f2c050e2ef8402331cc3703278 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Mon, 1 Jan 2024 23:19:49 +0100 Subject: [PATCH] f --- src/geo_interface.jl | 2 ++ src/geos_functions.jl | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/geo_interface.jl b/src/geo_interface.jl index ac180e9..0ea8c6d 100644 --- a/src/geo_interface.jl +++ b/src/geo_interface.jl @@ -31,6 +31,8 @@ GeoInterface.ngeom(t::AbstractGeometryTrait, geom::PreparedGeometry) = GeoInterface.ngeom(::AbstractPointTrait, geom::Point) = 0 GeoInterface.ngeom(::AbstractPointTrait, geom::PreparedGeometry) = 0 +GI.is3d(::AbstractGeometryTrait, geom::AbstractGeometry) = hasZ(geom) + function GeoInterface.getgeom( ::AbstractGeometryCollectionTrait, geom::AbstractMultiGeometry, diff --git a/src/geos_functions.jl b/src/geos_functions.jl index 14e7334..8556ba1 100644 --- a/src/geos_functions.jl +++ b/src/geos_functions.jl @@ -97,7 +97,7 @@ function cloneCoordSeq(ptr::GEOSCoordSeq, context::GEOSContext = get_global_cont end function destroyCoordSeq(ptr::GEOSCoordSeq, context::GEOSContext = get_global_context()) - result = GEOSCoordSeq_destroy_r(context, ptr) + o if result == C_NULL error("LibGEOS: Error in GEOSCoordSeq_destroy") end @@ -1304,9 +1304,7 @@ Numbering is one-based. For a simple geometry, returns a copy of the input. """ function getGeometry(obj::Geometry, n::Integer, context::GEOSContext = get_context(obj)) - n in 1:numGeometries(obj, context) || error( - "GEOSGetGeometryN: $(numGeometries(obj, context)) sub-geometries in geom, therefore n should be in 1:$(numGeometries(obj, context))", - ) + n in 1:numGeometries(obj, context) || _no_n_geom(obj, context, n) result = GEOSGetGeometryN_r(context, obj, n - 1) if result == C_NULL error("LibGEOS: Error in GEOSGetGeometryN") @@ -1314,6 +1312,9 @@ function getGeometry(obj::Geometry, n::Integer, context::GEOSContext = get_conte geomFromGEOS(cloneGeom(result, context), context) end +@noinline _no_n_geom_error(obj, context, n) = + erroe("GEOSGetGeometryN: $(numGeometries(obj, context)) sub-geometries in geom, therefore n: $n should be in 1:$(numGeometries(obj, context))",) + """ getGeometries(obj::Geometry, context::GEOSContext = get_context(obj))