From dd34eedd7605d350811f614adcebe20cd15c3f11 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Sat, 7 Jan 2023 16:41:32 +0100 Subject: [PATCH] switch from Base.convert to GeoInterface.convert (#359) --- CHANGELOG.md | 2 ++ src/geointerface.jl | 15 +-------------- test/test_geometry.jl | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edc8707d..92043899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - breaking: Updated compat for GDAL.jl 1.5 and fixed tests for GDAL 3.6. These include changes to `gdalnearblack`, `fillunsetwithdefault!` and `gdalgetgeotransform`. +- breaking: Use `GeoInterface.convert` instead of `convert` to convert geometries from other + packages to ArchGDAL via the GeoInterface. Example: `GeoInterface.convert(AG.IGeometry, geom)` ## [0.9.4] - 2022-12-30 diff --git a/src/geointerface.jl b/src/geointerface.jl index 4fce6ec0..4a251ba3 100644 --- a/src/geointerface.jl +++ b/src/geointerface.jl @@ -278,20 +278,7 @@ let pointtypes = (wkbPoint, wkbPoint25D, wkbPointM, wkbPointZM), return toWKT(geom) end - function Base.convert(::Type{T}, geom::X) where {T<:IGeometry,X} - return Base.convert(T, GeoInterface.geomtrait(geom), geom) - end - function Base.convert( - ::Type{T}, - ::GeometryTraits, - geom::T, - ) where {T<:IGeometry} - return geom - end # fast fallthrough without conversion - function Base.convert(::Type{T}, ::Nothing, geom::T) where {T<:IGeometry} - return geom - end # fast fallthrough without conversion - function Base.convert( + function GeoInterface.convert( ::Type{T}, type::GeometryTraits, geom, diff --git a/test/test_geometry.jl b/test/test_geometry.jl index 04e652ea..03194b67 100644 --- a/test/test_geometry.jl +++ b/test/test_geometry.jl @@ -1005,7 +1005,7 @@ import GeoFormatTypes as GFT GI.getgeom(::GI.LineStringTrait, geom::MyLine, i) = MyPoint() geom = MyLine() - ag_geom = convert(AG.IGeometry, geom) + ag_geom = GI.convert(AG.IGeometry, geom) GI.coordinates(ag_geom) == [[1, 2], [1, 2]] end end