From f039844c28e711fc535e7f1e6aed99a3e3a69a41 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sat, 29 Apr 2023 23:59:26 +0200 Subject: [PATCH 01/14] fix calc extent type stability --- src/fallbacks.jl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fallbacks.jl b/src/fallbacks.jl index 30d9901..f92cba3 100644 --- a/src/fallbacks.jl +++ b/src/fallbacks.jl @@ -115,7 +115,18 @@ function calc_extent(t::AbstractPointTrait, geom) names = coordnames(geom) return Extent(NamedTuple{names}(zip(coords, coords))) end -calc_extent(t::AbstractGeometryTrait, geom) = reduce(Extents.union, (extent(f) for f in getgeom(t, geom))) +function calc_extent(t::AbstractGeometryTrait, geom) + points = getpoint(t, geom) + X = extrema(p -> x(p), points) + Y = extrema(p -> y(p), points) + if is3d(geom) + Z = extrema(p -> z(p), points) + Extent(; X, Y, Z) + else + Extent(; X, Y) + end +end +calc_extent(t::GeometryCollectionTrait, geom) = reduce(Extents.union, (extent(f) for f in getgeom(t, geom))) function calc_extent(::AbstractFeatureTrait, feature) geom = geometry(feature) isnothing(geom) ? nothing : extent(geom) From 955dd3eb6168426cab9006b2cb7b16a57ccf959c Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sun, 30 Apr 2023 00:04:39 +0200 Subject: [PATCH 02/14] optimise point extent --- src/fallbacks.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fallbacks.jl b/src/fallbacks.jl index f92cba3..4dbdbe6 100644 --- a/src/fallbacks.jl +++ b/src/fallbacks.jl @@ -111,9 +111,14 @@ coordinates(t::AbstractFeatureCollectionTrait, fc) = [coordinates(f) for f in ge extent(::AbstractTrait, x) = Extents.extent(x) function calc_extent(t::AbstractPointTrait, geom) - coords = collect(getcoord(t, geom)) - names = coordnames(geom) - return Extent(NamedTuple{names}(zip(coords, coords))) + x = x(t, geom) + y = y(t, geom) + if is3d(geom) + z = z(t, geom) + return Extent(; X=(x, x), Y=(y, y), Z=(z, z)) + else + return Extent(; X=(x, x), Y=(y, y)) + end end function calc_extent(t::AbstractGeometryTrait, geom) points = getpoint(t, geom) From e5847cda86493fcec42ec27863c5489a9dd94380 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sun, 30 Apr 2023 00:18:14 +0200 Subject: [PATCH 03/14] add ncoord to test objects --- test/test_primitives.jl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/test_primitives.jl b/test/test_primitives.jl index 7f87bb5..398361c 100644 --- a/test/test_primitives.jl +++ b/test/test_primitives.jl @@ -35,42 +35,49 @@ GeoInterface.isgeometry(::MyCurve) = true GeoInterface.geomtrait(::MyCurve) = LineStringTrait() GeoInterface.ngeom(::LineStringTrait, geom::MyCurve) = 2 GeoInterface.getgeom(::LineStringTrait, geom::MyCurve, i) = MyPoint() +GeoInterface.ncoord(t::LineStringTrait, geom::MyCurve) = 2 -GeoInterface.ncoord(t::PolygonTrait, geom::MyPolygon) = 2 GeoInterface.isgeometry(::MyPolygon) = true GeoInterface.geomtrait(::MyPolygon) = PolygonTrait() GeoInterface.ngeom(::PolygonTrait, geom::MyPolygon) = 2 GeoInterface.getgeom(::PolygonTrait, geom::MyPolygon, i) = MyCurve() +GeoInterface.ncoord(t::PolygonTrait, geom::MyPolygon) = 2 GeoInterface.isgeometry(::MyTriangle) = true GeoInterface.geomtrait(::MyTriangle) = TriangleTrait() GeoInterface.ngeom(::TriangleTrait, geom::MyTriangle) = 3 GeoInterface.getgeom(::TriangleTrait, geom::MyTriangle, i) = MyCurve() +GeoInterface.ncoord(t::TriangleTrait, geom::MyTriangle) = 2 GeoInterface.isgeometry(::MyMultiPoint) = true GeoInterface.geomtrait(::MyMultiPoint) = MultiPointTrait() GeoInterface.ngeom(::MultiPointTrait, geom::MyMultiPoint) = 2 GeoInterface.getgeom(::MultiPointTrait, geom::MyMultiPoint, i) = MyPoint() +GeoInterface.ncoord(t::MultiPointTrait, geom::MyMultiPoint) = 2 GeoInterface.isgeometry(::MyMultiCurve) = true GeoInterface.geomtrait(::MyMultiCurve) = MultiCurveTrait() GeoInterface.ngeom(::MultiCurveTrait, geom::MyMultiCurve) = 2 GeoInterface.getgeom(::MultiCurveTrait, geom::MyMultiCurve, i) = MyCurve() +GeoInterface.ncoord(t::MultiCurveTrait, geom::MyMultiCurve) = 2 GeoInterface.isgeometry(::MyMultiPolygon) = true GeoInterface.geomtrait(::MyMultiPolygon) = MultiPolygonTrait() GeoInterface.ngeom(::MultiPolygonTrait, geom::MyMultiPolygon) = 2 GeoInterface.getgeom(::MultiPolygonTrait, geom::MyMultiPolygon, i) = MyPolygon() +GeoInterface.ncoord(t::MultiPolygonTrait, geom::MyMultiPolygon) = 2 GeoInterface.isgeometry(::MyTIN) = true GeoInterface.geomtrait(::MyTIN) = PolyhedralSurfaceTrait() GeoInterface.ngeom(::PolyhedralSurfaceTrait, geom::MyTIN) = 2 GeoInterface.getgeom(::PolyhedralSurfaceTrait, geom::MyTIN, i) = MyTriangle() +GeoInterface.ncoord(t::PolyhedralSurfaceTrait, geom::MyTIN) = 2 GeoInterface.isgeometry(::MyCollection) = true GeoInterface.geomtrait(::MyCollection) = GeometryCollectionTrait() GeoInterface.ngeom(::GeometryCollectionTrait, geom::MyCollection) = 2 GeoInterface.getgeom(::GeometryCollectionTrait, geom::MyCollection, i) = MyCurve() +GeoInterface.ncoord(t::GeometryCollectionTrait, geom::MyCollection) = 2 GeoInterface.isfeature(::Type{<:MyFeature}) = true GeoInterface.trait(feature::MyFeature) = FeatureTrait() @@ -117,6 +124,7 @@ GeoInterface.getfeature(::FeatureCollectionTrait, fc::MyFeatureCollection, i::In @test testgeometry(geom) @test GeoInterface.npoint(geom) == 2 # defaults to ngeom + @test GeoInterface.ncoord(geom) == 2 @test GeoInterface.coordinates(geom) == [[1, 2], [1, 2]] points = GeoInterface.getpoint(geom) point = GeoInterface.getpoint(geom, 1) @@ -139,6 +147,7 @@ GeoInterface.getfeature(::FeatureCollectionTrait, fc::MyFeatureCollection, i::In @test GeoInterface.nring(geom) == 2 @test GeoInterface.nhole(geom) == 1 + @test GeoInterface.ncoord(geom) == 2 @test GeoInterface.coordinates(geom) == [[[1, 2], [1, 2]], [[1, 2], [1, 2]]] lines = GeoInterface.getring(geom) line = GeoInterface.getring(geom, 1) @@ -162,6 +171,7 @@ GeoInterface.getfeature(::FeatureCollectionTrait, fc::MyFeatureCollection, i::In @test testgeometry(geom) @test GeoInterface.npoint(geom) == 2 + @test GeoInterface.ncoord(geom) == 2 points = GeoInterface.getpoint(geom) point = GeoInterface.getpoint(geom, 1) @test GeoInterface.coordinates(geom) == [[1, 2], [1, 2]] @@ -174,6 +184,7 @@ GeoInterface.getfeature(::FeatureCollectionTrait, fc::MyFeatureCollection, i::In geom = MyMultiCurve() @test testgeometry(geom) + @test GeoInterface.ncoord(geom) == 2 @test GeoInterface.nlinestring(geom) == 2 lines = GeoInterface.getlinestring(geom) line = GeoInterface.getlinestring(geom, 1) @@ -186,6 +197,7 @@ GeoInterface.getfeature(::FeatureCollectionTrait, fc::MyFeatureCollection, i::In @test testgeometry(geom) @test GeoInterface.npolygon(geom) == 2 + @test GeoInterface.ncoord(geom) == 2 polygons = GeoInterface.getpolygon(geom) polygon = GeoInterface.getpolygon(geom, 1) @test GeoInterface.coordinates(geom) == [[[[1, 2], [1, 2]], [[1, 2], [1, 2]]], [[[1, 2], [1, 2]], [[1, 2], [1, 2]]]] @@ -209,6 +221,7 @@ GeoInterface.getfeature(::FeatureCollectionTrait, fc::MyFeatureCollection, i::In @test testgeometry(geom) @test GeoInterface.ngeom(geom) == 2 + @test GeoInterface.ncoord(geom) == 2 geoms = GeoInterface.getgeom(geom) thing = GeoInterface.getgeom(geom, 1) @test GeoInterface.coordinates(geom) == [[[1, 2], [1, 2]], [[1, 2], [1, 2]]] From 8f26310e109b041cf84d323f91432fa416f158f2 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sun, 30 Apr 2023 00:20:51 +0200 Subject: [PATCH 04/14] qualify xyz --- src/fallbacks.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fallbacks.jl b/src/fallbacks.jl index 4dbdbe6..52fb171 100644 --- a/src/fallbacks.jl +++ b/src/fallbacks.jl @@ -111,10 +111,10 @@ coordinates(t::AbstractFeatureCollectionTrait, fc) = [coordinates(f) for f in ge extent(::AbstractTrait, x) = Extents.extent(x) function calc_extent(t::AbstractPointTrait, geom) - x = x(t, geom) - y = y(t, geom) + x = GeoInterface.x(t, geom) + y = GeoInterface.y(t, geom) if is3d(geom) - z = z(t, geom) + z = GeoInterface.z(t, geom) return Extent(; X=(x, x), Y=(y, y), Z=(z, z)) else return Extent(; X=(x, x), Y=(y, y)) From 6cd4790486e5e93d279b05c347f2dc330e57ceef Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sat, 29 Jul 2023 23:31:36 +0200 Subject: [PATCH 05/14] test 3d extents --- GeoInterfaceMakie/src/GeoInterfaceMakie.jl | 2 ++ GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl | 3 ++- test/test_primitives.jl | 1 + test/test_wrappers.jl | 5 +++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/GeoInterfaceMakie/src/GeoInterfaceMakie.jl b/GeoInterfaceMakie/src/GeoInterfaceMakie.jl index cceb33d..5718a2c 100644 --- a/GeoInterfaceMakie/src/GeoInterfaceMakie.jl +++ b/GeoInterfaceMakie/src/GeoInterfaceMakie.jl @@ -118,4 +118,6 @@ end # Features and Feature collections # https://github.com/JuliaGeo/GeoInterface.jl/pull/72#issue-1406325596 +@enable GeoInterface.Wrappers.WrapperGeometry + end diff --git a/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl b/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl index 4f714b0..86a06e6 100644 --- a/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl +++ b/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl @@ -139,7 +139,6 @@ function _coordvecs(::GI.MultiPolygonTrait, geom) end end - _coordvec(n) = Array{Float64}(undef, n) function _geom2coordvecs!(xs, ys, geom) @@ -158,4 +157,6 @@ function _geom2coordvecs!(xs, ys, zs, geom) return xs, ys, zs end +@enable_geo_plots GeoInterface.Wrappers.WrapperGeometry + end diff --git a/test/test_primitives.jl b/test/test_primitives.jl index 398361c..d9b93fa 100644 --- a/test/test_primitives.jl +++ b/test/test_primitives.jl @@ -331,6 +331,7 @@ end @test GeoInterface.y(geom) == 2 @test_throws ArgumentError GeoInterface.z(geom) @test_throws ArgumentError GeoInterface.m(geom) + @test GeoInterface.extent(geom) == Extents.Extent(X=(1, 1), Y=(2, 2)) geom = [1, 2, 3] @test testgeometry(geom) @test collect(GeoInterface.getcoord(geom)) == geom diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index 14e71de..d31f306 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -143,6 +143,11 @@ polygon_crs = GI.Polygon(polygon; crs=EPSG(4326)) @test parent(polygon_crs) === parent(polygon) @test GI.crs(polygon_crs) === EPSG(4326) +linearring3d = GI.LinearRing([(1, 2, 3), (3, 4, 5), (5, 6, 7), (1, 2, 3)]) +polygon3d = GI.Polygon([linearring3d, linearring3d]) +@test GI.is3d(polygon3d) +@test GI.extent(polygon3d) == Extents.Extent(X=(1, 5), Y=(2, 6), Z=(3, 7)) + # MultiPoint multipoint = GI.MultiPoint([(1, 2), (3, 4), (3, 2), (1, 4), (7, 8), (9, 10)]) @test multipoint == GI.MultiPoint(multipoint) From 076168730cb515ff57acf87e571780f7ec26ea60 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sun, 30 Jul 2023 00:48:31 +0200 Subject: [PATCH 06/14] add missing extents point wrapper method --- src/wrappers.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wrappers.jl b/src/wrappers.jl index a1ec3e4..6873ef9 100644 --- a/src/wrappers.jl +++ b/src/wrappers.jl @@ -308,6 +308,7 @@ ncoord(trait::PointTrait, geom::Point) = ncoord(trait, parent(geom)) getcoord(trait::PointTrait, geom::Point, i::Integer) = getcoord(trait, parent(geom), i) convert(::Type{Point}, ::PointTrait, geom) = Point(geom) convert(::Type{Point}, ::PointTrait, geom::Point) = geom +extent(trait::PointTrait, geom::Point) = extent(trait, parent(geom)) x(trait::PointTrait, geom::Point) = x(trait, parent(geom)) y(trait::PointTrait, geom::Point) = y(trait, parent(geom)) From a185bb16a9cf1170d186db75d3360c1295cdcfcb Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sun, 30 Jul 2023 01:06:23 +0200 Subject: [PATCH 07/14] test all wrapper extents --- test/test_wrappers.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index d31f306..0c9fb73 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -7,6 +7,7 @@ point = GI.Point(1, 2) GI.getcoord(point, 1) @test !GI.ismeasured(point) @test !GI.is3d(point) +@test GI.extent(point) == Extent(X=(1, 1), Y=(2, 2)) @test point == GI.Point(point) @test (GI.x(point), GI.y(point)) == (1, 2) @test_throws ArgumentError GI.z(point) @@ -25,6 +26,7 @@ pointz = GI.Point(1, 2, 3) @test (GI.x(pointz), GI.y(pointz), GI.z(pointz)) == (1, 2, 3) @test GI.testgeometry(pointz) @test GI.convert(GI, pointz) === pointz +@test GI.extent(pointz) == Extents.Extent(X=(1, 1), Y=(2, 2), Z=(3, 3)) # 3D measured point pointzm = GI.Point(; X=1, Y=2, Z=3, M=4) @@ -101,6 +103,8 @@ line = GI.Line([(1, 2), (3, 4)]) @test GI.getgeom(line, 1) === (1, 2) @test GI.getgeom(line) == [(1, 2), (3, 4)] @test GI.testgeometry(line) +@test !GI.is3d(line) +@test GI.extent(line) == Extent(X=(1, 3), Y=(2, 4)) @test_throws ArgumentError GI.Line(point) @test_throws ArgumentError GI.Line([(1, 2)]) @test_throws ArgumentError GI.Line([line, line]) @@ -114,6 +118,8 @@ linestring = GI.LineString([(1, 2), (3, 4)]) @test GI.getgeom(linestring, 1) === (1, 2) @test GI.getgeom(linestring) == [(1, 2), (3, 4)] @test GI.testgeometry(linestring) +@test !GI.is3d(linestring) +@test GI.extent(linestring) == Extent(X=(1, 3), Y=(2, 4)) @test_throws ArgumentError GI.LineString([(1, 2)]) linestring_crs = GI.LineString(linestring; crs=EPSG(4326)) @test parent(linestring_crs) === parent(linestring) @@ -125,6 +131,8 @@ linearring = GI.LinearRing([(1, 2), (3, 4), (5, 6), (1, 2)]) @test GI.getgeom(linearring, 1) === (1, 2) @test GI.getgeom(linearring) == [(1, 2), (3, 4), (5, 6), (1, 2)] @test GI.testgeometry(linearring) +@test !GI.is3d(linearring) +@test GI.extent(linearring) == Extent(X=(1, 5), Y=(2, 6)) @test_throws ArgumentError GI.LinearRing([(1, 2)]) linearring_crs = GI.LinearRing(linearring; crs=EPSG(4326)) @test parent(linearring_crs) === parent(linearring) @@ -137,6 +145,8 @@ polygon = GI.Polygon([linearring, linearring]) @test collect(GI.getgeom(polygon)) == [linearring, linearring] @test collect(GI.getpoint(polygon)) == vcat(collect(GI.getpoint(linearring)), collect(GI.getpoint(linearring))) @test GI.testgeometry(polygon) +@test !GI.is3d(polygon) +@test GI.extent(polygon) == Extent(X=(1, 5), Y=(2, 6)) @test GI.convert(GI, MyPolygon()) isa GI.Polygon @test GI.convert(GI, polygon) === polygon polygon_crs = GI.Polygon(polygon; crs=EPSG(4326)) @@ -152,6 +162,8 @@ polygon3d = GI.Polygon([linearring3d, linearring3d]) multipoint = GI.MultiPoint([(1, 2), (3, 4), (3, 2), (1, 4), (7, 8), (9, 10)]) @test multipoint == GI.MultiPoint(multipoint) @test GI.getgeom(multipoint, 1) === (1, 2) +@test !GI.is3d(multipoint) +@test GI.extent(multipoint) == Extent(X=(1, 9), Y=(2, 10)) @test_throws ArgumentError GI.MultiPoint([[(1, 2), (3, 4), (3, 2), (1, 4), (7, 8), (9, 10)]]) @test GI.testgeometry(multipoint) multipoint_crs = GI.MultiPoint(multipoint; crs=EPSG(4326)) @@ -164,6 +176,8 @@ collection = GI.GeometryCollection(geoms) @test collection == GI.GeometryCollection(collection) @test GI.getgeom(collection) == geoms @test GI.testgeometry(collection) +@test !GI.is3d(collection) +@test GI.extent(collection) == reduce(Extents.union, map(GI.extent, geoms)) collection_crs = GI.GeometryCollection(collection; crs=EPSG(4326)) @test parent(collection_crs) == parent(collection) @test GI.crs(collection_crs) === EPSG(4326) @@ -173,6 +187,8 @@ multicurve = GI.MultiCurve([linestring, linearring]) @test collect(GI.getpoint(multicurve)) == vcat(collect(GI.getpoint(linestring)), collect(GI.getpoint(linearring))) @test multicurve == GI.MultiCurve(multicurve) @test GI.getgeom(multicurve, 1) === linestring +@test !GI.is3d(multicurve) +@test GI.extent(multicurve) == Extent(X=(1, 5), Y=(2, 6)) @test_throws ArgumentError GI.MultiCurve([pointz, polygon]) @test GI.testgeometry(multicurve) multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) @@ -183,6 +199,8 @@ multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) multipolygon = GI.MultiPolygon([polygon]) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon +@test !GI.is3d(multipolygon) +@test GI.extent(multipolygon) == Extent(X=(1, 5), Y=(2, 6)) @test collect(GI.getpoint(multipolygon)) == collect(GI.getpoint(polygon)) @test_throws ArgumentError GI.MultiPolygon([[[[(1, 2), (3, 4), (3, 2), (1, 4)]]]]) @test GI.testgeometry(multipolygon) @@ -193,6 +211,8 @@ multipolygon_crs = GI.MultiPolygon(multipolygon; crs=EPSG(4326)) # PolyhedralSurface polyhedralsurface = GI.PolyhedralSurface([polygon, polygon]) @test polyhedralsurface == GI.PolyhedralSurface(polyhedralsurface) +@test !GI.is3d(polyhedralsurface) +@test GI.extent(polyhedralsurface) == Extent(X=(1, 5), Y=(2, 6)) @test GI.getgeom(polyhedralsurface, 1) === polygon @test collect(GI.getgeom(polyhedralsurface)) == [polygon, polygon] @test GI.getgeom(polyhedralsurface, 1) == polygon From e5f8fe8f4998d11d4dd0cf93d02d6b2a49005620 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Mon, 31 Jul 2023 23:51:05 +0200 Subject: [PATCH 08/14] update tests --- test/test_wrappers.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index 0c9fb73..115bf92 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -119,7 +119,7 @@ linestring = GI.LineString([(1, 2), (3, 4)]) @test GI.getgeom(linestring) == [(1, 2), (3, 4)] @test GI.testgeometry(linestring) @test !GI.is3d(linestring) -@test GI.extent(linestring) == Extent(X=(1, 3), Y=(2, 4)) +@test @inferred(GI.extent(linestring)) == Extent(X=(1, 3), Y=(2, 4)) @test_throws ArgumentError GI.LineString([(1, 2)]) linestring_crs = GI.LineString(linestring; crs=EPSG(4326)) @test parent(linestring_crs) === parent(linestring) @@ -132,7 +132,7 @@ linearring = GI.LinearRing([(1, 2), (3, 4), (5, 6), (1, 2)]) @test GI.getgeom(linearring) == [(1, 2), (3, 4), (5, 6), (1, 2)] @test GI.testgeometry(linearring) @test !GI.is3d(linearring) -@test GI.extent(linearring) == Extent(X=(1, 5), Y=(2, 6)) +@test @inferred(GI.extent(linearring)) == Extent(X=(1, 5), Y=(2, 6)) @test_throws ArgumentError GI.LinearRing([(1, 2)]) linearring_crs = GI.LinearRing(linearring; crs=EPSG(4326)) @test parent(linearring_crs) === parent(linearring) @@ -146,7 +146,7 @@ polygon = GI.Polygon([linearring, linearring]) @test collect(GI.getpoint(polygon)) == vcat(collect(GI.getpoint(linearring)), collect(GI.getpoint(linearring))) @test GI.testgeometry(polygon) @test !GI.is3d(polygon) -@test GI.extent(polygon) == Extent(X=(1, 5), Y=(2, 6)) +@test @inferred(GI.extent(polygon)) == Extent(X=(1, 5), Y=(2, 6)) @test GI.convert(GI, MyPolygon()) isa GI.Polygon @test GI.convert(GI, polygon) === polygon polygon_crs = GI.Polygon(polygon; crs=EPSG(4326)) @@ -163,7 +163,7 @@ multipoint = GI.MultiPoint([(1, 2), (3, 4), (3, 2), (1, 4), (7, 8), (9, 10)]) @test multipoint == GI.MultiPoint(multipoint) @test GI.getgeom(multipoint, 1) === (1, 2) @test !GI.is3d(multipoint) -@test GI.extent(multipoint) == Extent(X=(1, 9), Y=(2, 10)) +@test @inferred(GI.extent(multipoint)) == Extent(X=(1, 9), Y=(2, 10)) @test_throws ArgumentError GI.MultiPoint([[(1, 2), (3, 4), (3, 2), (1, 4), (7, 8), (9, 10)]]) @test GI.testgeometry(multipoint) multipoint_crs = GI.MultiPoint(multipoint; crs=EPSG(4326)) @@ -200,6 +200,7 @@ multipolygon = GI.MultiPolygon([polygon]) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon @test !GI.is3d(multipolygon) +# MultiPolygon extent does not infer, maybe due to nesting @test GI.extent(multipolygon) == Extent(X=(1, 5), Y=(2, 6)) @test collect(GI.getpoint(multipolygon)) == collect(GI.getpoint(polygon)) @test_throws ArgumentError GI.MultiPolygon([[[[(1, 2), (3, 4), (3, 2), (1, 4)]]]]) @@ -212,7 +213,7 @@ multipolygon_crs = GI.MultiPolygon(multipolygon; crs=EPSG(4326)) polyhedralsurface = GI.PolyhedralSurface([polygon, polygon]) @test polyhedralsurface == GI.PolyhedralSurface(polyhedralsurface) @test !GI.is3d(polyhedralsurface) -@test GI.extent(polyhedralsurface) == Extent(X=(1, 5), Y=(2, 6)) +@test @inferred(GI.extent(polyhedralsurface)) == Extent(X=(1, 5), Y=(2, 6)) @test GI.getgeom(polyhedralsurface, 1) === polygon @test collect(GI.getgeom(polyhedralsurface)) == [polygon, polygon] @test GI.getgeom(polyhedralsurface, 1) == polygon From 2824bb13d4e351a6ddb2e412f9ce0a8ff49a22ab Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 1 Aug 2023 00:05:30 +0200 Subject: [PATCH 09/14] f --- test/test_wrappers.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index 115bf92..501705f 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -195,11 +195,13 @@ multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) @test parent(multicurve_crs) == parent(multicurve) @test GI.crs(multicurve_crs) === EPSG(4326) + # MultiPolygon multipolygon = GI.MultiPolygon([polygon]) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon @test !GI.is3d(multipolygon) +@show GI.extent(multipolygon) # MultiPolygon extent does not infer, maybe due to nesting @test GI.extent(multipolygon) == Extent(X=(1, 5), Y=(2, 6)) @test collect(GI.getpoint(multipolygon)) == collect(GI.getpoint(polygon)) From c20cc068a3faa904bf4efd909055990d1e1756ba Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 1 Aug 2023 00:27:50 +0200 Subject: [PATCH 10/14] show --- test/test_wrappers.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index 501705f..e77e847 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -198,6 +198,8 @@ multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) # MultiPolygon multipolygon = GI.MultiPolygon([polygon]) +@show polygon +@show GI.getgeom(polygon, 1) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon @test !GI.is3d(multipolygon) From 8e9ebc4f79c0e4da4416a6e9feb8afbcc5b66707 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 1 Aug 2023 00:53:22 +0200 Subject: [PATCH 11/14] f --- test/test_wrappers.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index e77e847..7b5c92d 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -198,12 +198,11 @@ multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) # MultiPolygon multipolygon = GI.MultiPolygon([polygon]) -@show polygon -@show GI.getgeom(polygon, 1) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon @test !GI.is3d(multipolygon) -@show GI.extent(multipolygon) +@show polygon +@show GI.getgeom(polygon, 1) # MultiPolygon extent does not infer, maybe due to nesting @test GI.extent(multipolygon) == Extent(X=(1, 5), Y=(2, 6)) @test collect(GI.getpoint(multipolygon)) == collect(GI.getpoint(polygon)) From f9f19f77e7047a0ae276bbcf6e885f9ad4223faf Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 1 Aug 2023 01:23:21 +0200 Subject: [PATCH 12/14] f --- test/test_wrappers.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index 7b5c92d..6ea9b5f 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -197,11 +197,12 @@ multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) # MultiPolygon -multipolygon = GI.MultiPolygon([polygon]) +multipolygon = GI.MultiPolygon(GI.Polygon([linearring, linearring])) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon @test !GI.is3d(multipolygon) @show polygon +@show polygon @show GI.getgeom(polygon, 1) # MultiPolygon extent does not infer, maybe due to nesting @test GI.extent(multipolygon) == Extent(X=(1, 5), Y=(2, 6)) From 549e0ab01ba0439d7c6018fb4b7fc16b613998c9 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 1 Aug 2023 01:40:16 +0200 Subject: [PATCH 13/14] f --- test/test_wrappers.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_wrappers.jl b/test/test_wrappers.jl index 6ea9b5f..9487b93 100644 --- a/test/test_wrappers.jl +++ b/test/test_wrappers.jl @@ -197,12 +197,12 @@ multicurve_crs = GI.MultiCurve(multicurve; crs=EPSG(4326)) # MultiPolygon -multipolygon = GI.MultiPolygon(GI.Polygon([linearring, linearring])) +polygon = GI.Polygon([linearring, linearring]) +multipolygon = GI.MultiPolygon([polygon]) @test multipolygon == GI.MultiPolygon(multipolygon) @test GI.getgeom(multipolygon, 1) === polygon @test !GI.is3d(multipolygon) @show polygon -@show polygon @show GI.getgeom(polygon, 1) # MultiPolygon extent does not infer, maybe due to nesting @test GI.extent(multipolygon) == Extent(X=(1, 5), Y=(2, 6)) From b813824e9e04815eb4edc43917f39726b00ccae2 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 4 Aug 2023 15:53:44 +0200 Subject: [PATCH 14/14] remove accidental liines --- GeoInterfaceMakie/src/GeoInterfaceMakie.jl | 2 -- GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/GeoInterfaceMakie/src/GeoInterfaceMakie.jl b/GeoInterfaceMakie/src/GeoInterfaceMakie.jl index 5718a2c..cceb33d 100644 --- a/GeoInterfaceMakie/src/GeoInterfaceMakie.jl +++ b/GeoInterfaceMakie/src/GeoInterfaceMakie.jl @@ -118,6 +118,4 @@ end # Features and Feature collections # https://github.com/JuliaGeo/GeoInterface.jl/pull/72#issue-1406325596 -@enable GeoInterface.Wrappers.WrapperGeometry - end diff --git a/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl b/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl index 86a06e6..4f714b0 100644 --- a/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl +++ b/GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl @@ -139,6 +139,7 @@ function _coordvecs(::GI.MultiPolygonTrait, geom) end end + _coordvec(n) = Array{Float64}(undef, n) function _geom2coordvecs!(xs, ys, geom) @@ -157,6 +158,4 @@ function _geom2coordvecs!(xs, ys, zs, geom) return xs, ys, zs end -@enable_geo_plots GeoInterface.Wrappers.WrapperGeometry - end