From 1ab5bfad5ed6888915bee646b5ad533068db0702 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Thu, 19 Jan 2023 12:50:00 +0530 Subject: [PATCH 1/2] Forward GeoInterface.centroid Noticed that this was missing, so decided to correct it. --- src/geointerface.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/geointerface.jl b/src/geointerface.jl index c8ebfd3a..260e4efe 100644 --- a/src/geointerface.jl +++ b/src/geointerface.jl @@ -272,6 +272,10 @@ let pointtypes = (wkbPoint, wkbPoint25D, wkbPointM, wkbPointZM), end end + function GeoInterface.centroid(::GeometryTraits, geom::AbstractGeometry) + return centroid(geom) + end + function GeoInterface.asbinary(::GeometryTraits, geom::AbstractGeometry) return toWKB(geom) end From d2a21e5ed695d4e8ac34b08af3390dc35af95e83 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Thu, 26 Jan 2023 17:08:11 +0530 Subject: [PATCH 2/2] Add tests for polygon and multipolygon within test_geometry.jl --- test/test_geometry.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_geometry.jl b/test/test_geometry.jl index fdb85c5a..e00ee1ee 100644 --- a/test/test_geometry.jl +++ b/test/test_geometry.jl @@ -4,7 +4,7 @@ import ArchGDAL as AG import GeoFormatTypes as GFT @testset "test_geometry.jl" begin - @testset "GeoInterface" begin + @testset "GeoInterface" begin AG.createpoint(100, 70) do point @test GI.geomtrait(point) == GI.PointTrait() @test GI.testgeometry(point) @@ -400,6 +400,9 @@ import GeoFormatTypes as GFT atol = 1e-6, ) @test AG.toWKT(geom) == "POLYGON ((1 4,2 5,3 6))" + @test_throws "Points of LinearRing do not form a closed linestring" GI.centroid(geom) + AG.closerings!(geom) + @test all(GI.coordinates(GI.centroid(geom)) .== (2, 5)) end AG.createpolygon( [1.0, 2.0, 3.0], @@ -542,6 +545,9 @@ import GeoFormatTypes as GFT "((0 0,0 4,4 4,4 0),(1 1,1 3,3 3,3 1))," * "((10 0,10 4,14 4,14 0),(11 1,11 3,13 3,13 1)))" end + @test_throws "Points of LinearRing do not form a closed linestring" GI.centroid(geom) + AG.closerings!(geom) + @test all(GI.coordinates(GI.centroid(geom)) .== (7, 2)) end @testset "circularstring" begin