From 79e2f592d8040125212a308161b316ca5d74a3c6 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Fri, 27 Dec 2024 21:37:24 +0530 Subject: [PATCH 1/2] update to use Extents interface rather than old GI --- src/geointerface.jl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/geointerface.jl b/src/geointerface.jl index dc61b45..f99ccb8 100644 --- a/src/geointerface.jl +++ b/src/geointerface.jl @@ -57,12 +57,8 @@ GI.getfeature(::GI.FeatureCollectionTrait, fc::AbstractFeatureCollection, i::Int GI.nfeature(::GI.FeatureCollectionTrait, fc::AbstractFeatureCollection) = length(fc) # Any GeoJSON Object -GI.extent(::GI.FeatureTrait, x::GeoJSONT{2}) = _extent2(x) -GI.extent(::GI.FeatureCollectionTrait, x::GeoJSONT{2}) = _extent2(x) -GI.extent(::GI.AbstractGeometryTrait, x::GeoJSONT{2}) = _extent2(x) -GI.extent(::GI.FeatureTrait, x::GeoJSONT{3}) = _extent3(x) -GI.extent(::GI.FeatureCollectionTrait, x::GeoJSONT{3}) = _extent3(x) -GI.extent(::GI.AbstractGeometryTrait, x::GeoJSONT{3}) = _extent3(x) +GI.Extents.extent(x::GeoJSONT{2}) = _extent2(x) +GI.Extents.extent(x::GeoJSONT{3}) = _extent3(x) function _extent3(x) bb = bbox(x) From 2301c3dc6c07a6877cd86e552eca83bef58510b6 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 14 Jan 2025 10:59:10 -0500 Subject: [PATCH 2/2] Add tests for extents where `bbox` does not exist --- test/runtests.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index c864d86..e36e139 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -321,6 +321,14 @@ include("geojson_samples.jl") end end + @testset "Extents" begin + # First, test that `Extents.extent` returns nothing for a geometry with no bbox + feature = GeoJSON.read(Samples.b) + @test isnothing(GI.Extents.extent(feature)) + # Next, test that `GI.extent` returns the correct extent for a geometry with a bbox + @test GI.extent(feature) == mapreduce(GI.extent, GI.Extents.union, GI.getpoint(feature.geometry)) + end + @testset "GeoInterface tests" begin @test all(GI.testgeometry, GeoJSON.read.(Samples.geometries)) @test all(GI.testfeature, GeoJSON.read.(Samples.features))