From b4ad832b0018322340a7d1c35ca11a85b3d4e189 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 16 Sep 2025 16:40:03 +0200 Subject: [PATCH 1/2] Add coordtype implementation for GeometryBasics types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented GeoInterface.coordtype for GeometryBasics geometry types. GeometryBasics encodes the coordinate type T in the type parameters of Point{Dim,T}, AbstractGeometry{Dim,T}, Simplex{Dim,T,N}, and Mesh{Dim,T,E,V}. Added version guard for compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- ext/GeometryBasicsGeoInterfaceExt.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ext/GeometryBasicsGeoInterfaceExt.jl b/ext/GeometryBasicsGeoInterfaceExt.jl index ed5da70b..2af1a2a9 100644 --- a/ext/GeometryBasicsGeoInterfaceExt.jl +++ b/ext/GeometryBasicsGeoInterfaceExt.jl @@ -159,4 +159,13 @@ function _collect_with_type(::Type{PT}, geom) where {PT <: Point{2}} return [PT(GeoInterface.x(p), GeoInterface.y(p)) for p in getgeom(geom)] end +# coordtype implementation - GeometryBasics encodes coordinate type in eltype +if :coordtype in names(GeoInterface; all = true) + # For types with coordinate type T as a type parameter + GeoInterface.coordtype(::GeoInterface.AbstractGeometryTrait, geom::Point{Dim,T}) where {Dim,T} = T + GeoInterface.coordtype(::GeoInterface.AbstractGeometryTrait, geom::AbstractGeometry{Dim,T}) where {Dim,T} = T + GeoInterface.coordtype(::GeoInterface.AbstractGeometryTrait, geom::Simplex{Dim,T,N}) where {Dim,T,N} = T + GeoInterface.coordtype(::GeoInterface.PolyhedralSurfaceTrait, geom::Mesh{Dim,T,E,V}) where {Dim,T,E,V} = T +end + end From b22b8aec643467b0599657533bb397f6a85eacc7 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Fri, 19 Sep 2025 08:44:03 +0200 Subject: [PATCH 2/2] use isdefined instead --- ext/GeometryBasicsGeoInterfaceExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/GeometryBasicsGeoInterfaceExt.jl b/ext/GeometryBasicsGeoInterfaceExt.jl index 2af1a2a9..8464acd3 100644 --- a/ext/GeometryBasicsGeoInterfaceExt.jl +++ b/ext/GeometryBasicsGeoInterfaceExt.jl @@ -160,7 +160,7 @@ function _collect_with_type(::Type{PT}, geom) where {PT <: Point{2}} end # coordtype implementation - GeometryBasics encodes coordinate type in eltype -if :coordtype in names(GeoInterface; all = true) +if isdefined(GeoInterface, :coordtype) # For types with coordinate type T as a type parameter GeoInterface.coordtype(::GeoInterface.AbstractGeometryTrait, geom::Point{Dim,T}) where {Dim,T} = T GeoInterface.coordtype(::GeoInterface.AbstractGeometryTrait, geom::AbstractGeometry{Dim,T}) where {Dim,T} = T