From 9790398ec0ce8b16d89142465164da1782e470c0 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sat, 29 Apr 2023 17:18:49 +0200 Subject: [PATCH 1/3] remove incorrect x y z implementations and test --- src/geo_interface.jl | 5 +---- test/test_geo_interface.jl | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/geo_interface.jl b/src/geo_interface.jl index 80c85e6..e74caa7 100644 --- a/src/geo_interface.jl +++ b/src/geo_interface.jl @@ -53,10 +53,6 @@ GeoInterface.getgeom(t::AbstractGeometryTrait, geom::PreparedGeometry, i) = GeoInterface.getgeom(t, geom.ownedby, i) GeoInterface.getgeom(t::AbstractPointTrait, geom::PreparedGeometry, i) = 0 -GeoInterface.x(::AbstractPointTrait, geom::AbstractGeometry) = getX(geom.ptr, 1, get_context(geom)) -GeoInterface.y(::AbstractPointTrait, geom::AbstractGeometry) = getY(geom.ptr, 1, get_context(geom)) -GeoInterface.z(::AbstractPointTrait, geom::AbstractGeometry) = getZ(geom.ptr, 1, get_context(geom)) - GeoInterface.ncoord(::AbstractGeometryTrait, geom::AbstractGeometry) = isEmpty(geom) ? 0 : getCoordinateDimension(geom) GeoInterface.getcoord(::AbstractGeometryTrait, geom::AbstractGeometry, i) = @@ -67,6 +63,7 @@ GeoInterface.ncoord(t::AbstractGeometryTrait, geom::PreparedGeometry) = GeoInterface.getcoord(t::AbstractGeometryTrait, geom::PreparedGeometry, i) = GeoInterface.getcoord(t, geom.ownedby, i) +# FIXME this doesn't work for 3d geoms, Z is missing function GeoInterface.extent(::AbstractGeometryTrait, geom::AbstractGeometry) # minx, miny, maxx, maxy = getExtent(geom) env = envelope(geom) diff --git a/test/test_geo_interface.jl b/test/test_geo_interface.jl index 5d23f91..1ae8530 100644 --- a/test/test_geo_interface.jl +++ b/test/test_geo_interface.jl @@ -4,6 +4,8 @@ const LG = LibGEOS @testset "Geo interface" begin pt = LibGEOS.Point(1.0, 2.0) + @test GeoInterface.x(pt) == 1.0 + @test GeoInterface.y(pt) == 2.0 @test GeoInterface.coordinates(pt) ≈ [1, 2] atol = 1e-5 @test GeoInterface.geomtrait(pt) == PointTrait() @test GeoInterface.ncoord(pt) == 2 @@ -12,8 +14,20 @@ const LG = LibGEOS @test GeoInterface.extent(pt) == Extent(X = (1.0, 1.0), Y = (2.0, 2.0)) plot(pt) + pt = LibGEOS.Point(1.0, 2.0, 3.0) + @test GeoInterface.x(pt) == 1.0 + @test GeoInterface.y(pt) == 2.0 + @test GeoInterface.z(pt) == 3.0 + @test GeoInterface.coordinates(pt) ≈ [1, 2, 3] atol = 1e-5 + @test GeoInterface.ncoord(pt) == 3 + @test GeoInterface.getcoord(pt, 3) ≈ 3.0 + @test GeoInterface.testgeometry(pt) + # This doesn't return the Z extent + @tehst_broken GeoInterface.extent(pt) == Extent(X = (1.0, 1.0), Y=(2.0, 2.0), Z=(3.0, 3.0)) + plot(pt) + pt = LibGEOS.Point(1, 2) - @test GeoInterface.coordinates(pt) ≈ [1, 2] atol = 1e-5 + @atest GeoInterface.coordinates(pt) ≈ [1, 2] atol = 1e-5 @test GeoInterface.geomtrait(pt) == PointTrait() @test GeoInterface.testgeometry(pt) From 4ab6219fa7a603a280fea27c64de89e7e61812d2 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sat, 29 Apr 2023 17:28:11 +0200 Subject: [PATCH 2/3] fix typo --- test/test_geo_interface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_geo_interface.jl b/test/test_geo_interface.jl index 1ae8530..40bc5a8 100644 --- a/test/test_geo_interface.jl +++ b/test/test_geo_interface.jl @@ -23,7 +23,7 @@ const LG = LibGEOS @test GeoInterface.getcoord(pt, 3) ≈ 3.0 @test GeoInterface.testgeometry(pt) # This doesn't return the Z extent - @tehst_broken GeoInterface.extent(pt) == Extent(X = (1.0, 1.0), Y=(2.0, 2.0), Z=(3.0, 3.0)) + @test_broken GeoInterface.extent(pt) == Extent(X = (1.0, 1.0), Y=(2.0, 2.0), Z=(3.0, 3.0)) plot(pt) pt = LibGEOS.Point(1, 2) From f9a46a2dbdb7f3cc8cfab13f6c0b8594b35ce604 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Sat, 29 Apr 2023 19:43:10 +0200 Subject: [PATCH 3/3] a typo --- test/test_geo_interface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_geo_interface.jl b/test/test_geo_interface.jl index 40bc5a8..c09a128 100644 --- a/test/test_geo_interface.jl +++ b/test/test_geo_interface.jl @@ -27,7 +27,7 @@ const LG = LibGEOS plot(pt) pt = LibGEOS.Point(1, 2) - @atest GeoInterface.coordinates(pt) ≈ [1, 2] atol = 1e-5 + @test GeoInterface.coordinates(pt) ≈ [1, 2] atol = 1e-5 @test GeoInterface.geomtrait(pt) == PointTrait() @test GeoInterface.testgeometry(pt)