Skip to content

Commit

Permalink
resolve 8 method ambiguities
Browse files Browse the repository at this point in the history
As found by Aqua. These come from GeoInterface fallbacks, and are all similar to:
```
Ambiguity #4
ngeom(::GeoInterface.AbstractGeometryTrait, geom::LibGEOS.Polygon)
     @ LibGEOS D:\visser_mn\.julia\dev\LibGEOS\src\geo_interface.jl:26
ngeom(::GeoInterface.AbstractPointTrait, geom)
     @ GeoInterface d:\visser_mn\.julia\packages\GeoInterface\J298z\src\fallbacks.jl:22

Possible fix, define
  ngeom(::GeoInterface.AbstractPointTrait, ::LibGEOS.Polygon)
```
  • Loading branch information
visr committed Jul 24, 2022
1 parent ee7f4f3 commit a0df6fc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/geo_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,38 @@ GeoInterface.geomtrait(geom::PreparedGeometry) = GeoInterface.geomtrait(geom.own

GeoInterface.ngeom(::AbstractGeometryTrait, geom::AbstractGeometry) =
isEmpty(geom.ptr) ? 0 : numGeometries(geom.ptr)
GeoInterface.ngeom(::AbstractPointTrait, geom::AbstractGeometry) = 0

function GeoInterface.getgeom(::AbstractGeometryTrait, geom::AbstractGeometry, i)
clone = getGeometry(geom.ptr, i)
id = geomTypeId(clone) + 1
0 < id <= length(geomtypes) || error("Unknown geometry type id $id")
geomtypes[id](clone)
end

GeoInterface.getgeom(::AbstractPointTrait, geom::AbstractGeometry, i) = nothing
GeoInterface.ngeom(::AbstractGeometryTrait, geom::Union{LineString,LinearRing}) =
numPoints(geom.ptr)
GeoInterface.ngeom(t::AbstractPointTrait, geom::Union{LineString,LinearRing}) = 0
GeoInterface.getgeom(::AbstractGeometryTrait, geom::Union{LineString,LinearRing}, i) =
Point(getPoint(geom.ptr, i))
GeoInterface.getgeom(::AbstractPointTrait, geom::Union{LineString,LinearRing}, i) = nothing

GeoInterface.ngeom(::AbstractGeometryTrait, geom::Polygon) = numInteriorRings(geom.ptr) + 1
GeoInterface.ngeom(::AbstractPointTrait, geom::Polygon) = 0
function GeoInterface.getgeom(::AbstractGeometryTrait, geom::Polygon, i)
if i == 1
LinearRing(exteriorRing(geom.ptr))
else
LinearRing(interiorRing(geom.ptr, i - 1))
end
end
GeoInterface.getgeom(::AbstractPointTrait, geom::Polygon, i) = nothing

GeoInterface.ngeom(t::AbstractGeometryTrait, geom::PreparedGeometry) = GeoInterface.ngeom(t, geom.ownedby)
GeoInterface.ngeom(t::AbstractPointTrait, geom::PreparedGeometry) = 0
GeoInterface.getgeom(t::AbstractGeometryTrait, geom::PreparedGeometry, i) = GeoInterface.getgeom(t, geom.ownedby, i)
GeoInterface.getgeom(t::AbstractPointTrait, geom::PreparedGeometry, i) = 0

GeoInterface.ncoord(::AbstractGeometryTrait, geom::AbstractGeometry) =
isEmpty(geom.ptr) ? 0 : getCoordinateDimension(geom.ptr)
Expand Down

0 comments on commit a0df6fc

Please sign in to comment.