diff --git a/src/LibGEOS.jl b/src/LibGEOS.jl index 4c8d7f0..57fd395 100644 --- a/src/LibGEOS.jl +++ b/src/LibGEOS.jl @@ -70,6 +70,7 @@ export Point, hasZ, isClosed, isValid, + interiorRing, interiorRings, exteriorRing, numGeometries, diff --git a/src/geos_operations.jl b/src/geos_operations.jl index f9a64ac..b228906 100644 --- a/src/geos_operations.jl +++ b/src/geos_operations.jl @@ -241,7 +241,7 @@ getGeometries(obj::Geometry, context::GEOSContext = _context) = # Converts Geometry to normal form (or canonical form). normalize!(obj::Geometry) = normalize!(obj.ptr) -interiorRing(obj::Polygon, n::Integer) = interiorRing(obj.ptr, n) +interiorRing(obj::Polygon, n::Integer) = LinearRing(interiorRing(obj.ptr, n)) interiorRings(obj::Polygon) = map(LinearRing, interiorRings(obj.ptr)) exteriorRing(obj::Polygon) = LinearRing(exteriorRing(obj.ptr)) diff --git a/test/test_geos_operations.jl b/test/test_geos_operations.jl index 2f5ac1d..4aa2499 100644 --- a/test/test_geos_operations.jl +++ b/test/test_geos_operations.jl @@ -349,6 +349,19 @@ end # Geometry info # ----- + @testset "Polygon ring(s)" begin + poly = readgeom( + "POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))", + ) + @test LibGEOS.getCoordinates(LibGEOS.getCoordSeq(exteriorRing(poly).ptr)) == + Vector{Float64}[[35, 10], [45, 45], [15, 40], [10, 20], [35, 10]] + @test length(interiorRings(poly)) == 1 + @test LibGEOS.getCoordinates(LibGEOS.getCoordSeq(interiorRing(poly, 1).ptr)) == + Vector{Float64}[[20, 30], [35, 35], [30, 20], [20, 30]] + @test_throws ErrorException interiorRing(poly, 0) + @test_throws ErrorException interiorRing(poly, 2) + end + @testset "numGeometries" begin @test numGeometries(readgeom("POINT(2 2)")) == 1 @test numGeometries(readgeom("MULTIPOINT(0 0, 5 0, 10 0)")) == 3