JuliaGeo / LibGEOS.jl

Julia package for manipulation and analysis of planar geometric objects
MIT License
72 stars 23 forks source link

remove evals #116

Closed visr closed 2 years ago

visr commented 2 years ago

Fixes #105

This replaces this pattern:

for geom in (
    :Point,
    :MultiPoint,
    :LineString,
    :MultiLineString,
    :LinearRing,
    :Polygon,
    :MultiPolygon,
    :GeometryCollection,
)
    @eval getXMin(obj::$geom, context::GEOSContext = _context) = getXMin(obj.ptr, context)
end

With this:

getXMin(obj::Geometry, context::GEOSContext = _context) = getXMin(obj.ptr, context)

Where Geometry was already defined as:

const Geometry = Union{
    Point,
    MultiPoint,
    LineString,
    MultiLineString,
    LinearRing,
    Polygon,
    MultiPolygon,
    GeometryCollection,
}

So instead of having one method per geometry type, there is just one for all of them. According to https://github.com/JuliaGeo/LibGEOS.jl/pull/95#issuecomment-1058868759 it specializes fine.

Everything except the last one is a simple replace that shouldn't change any behavior. The last one is separated in 3c9a7f7fe562d402f168c9a95da688afc063da53 and should allow some new functionality.