diff --git a/src/geo_interface.jl b/src/geo_interface.jl index 0ea8c6d..c7104cc 100644 --- a/src/geo_interface.jl +++ b/src/geo_interface.jl @@ -32,6 +32,8 @@ GeoInterface.ngeom(::AbstractPointTrait, geom::Point) = 0 GeoInterface.ngeom(::AbstractPointTrait, geom::PreparedGeometry) = 0 GI.is3d(::AbstractGeometryTrait, geom::AbstractGeometry) = hasZ(geom) +GI.getexterior(::AbstractPolygonTrait, geom::Polygon) = exteriorRing(geom) +GI.gethole(::AbstractPolygonTrait, geom::Polygon, n) = interiorRing(geom, n) function GeoInterface.getgeom( ::AbstractGeometryCollectionTrait, @@ -41,6 +43,7 @@ function GeoInterface.getgeom( getGeometry(geom, i) end GeoInterface.getgeom(::MultiPointTrait, geom::MultiPoint, i) = getGeometry(geom, i)::Point +GeoInterface.getgeom(::MultiPointTrait, geom::MultiPoint) = getGeometry(geom, i)::Point GeoInterface.getgeom(::MultiLineStringTrait, geom::MultiLineString, i) = getGeometry(geom, i)::LineString GeoInterface.getgeom(::MultiPolygonTrait, geom::MultiPolygon, i) = @@ -51,14 +54,14 @@ function GeoInterface.getgeom(::AbstractGeometryTrait, geom::Union{LineString,Li _get_tuple_point(geom, seq, ref, i) end function GeoInterface.getgeom(::AbstractGeometryTrait, geom::Union{LineString,LinearRing}) - n = GeoInterface.ngeom(geom) - seq = getCoordSeq(geom::Union{LineString, LinearRing}) + context = get_global_context() + seq = getCoordSeq(geom, context) + n = getSize(seq, context) # Faster thatn `GI.ngeom(geom)` when we already have `seq` ref = Ref{Float64}() - return (_get_tuple_point(geom, seq, ref, i) for i in 1:n) + return (_get_tuple_point(geom, seq, ref, i, context) for i in 1:n) end -function _get_tuple_point(geom, seq, ref, i) - context = get_global_context() +function _get_tuple_point(geom, seq, ref, i, context = get_global_context()) if GeoInterface.is3d(geom) GC.@preserve ref begin GEOSCoordSeq_getX_r(context, seq, i - 1, ref)