Simple overrides
This file contains simple overrides for GEOS, essentially only those functions which have direct counterparts in LibGEOS and only require conversion before calling.
They can all be invoked by calling GO.$fname(GO.GEOS(), geom1, ...).
Polygon set operations
Difference
julia
function GO.difference(::GEOS, geom_a, geom_b; target=nothing, calc_extent = false)
return _wrap(LG.difference(GI.convert(LG, geom_a), GI.convert(LG, geom_b)); crs = GI.crs(geom_a), calc_extent)
endUnion
julia
function GO.union(::GEOS, geom_a, geom_b; target=nothing, calc_extent = false)
return _wrap(LG.union(GI.convert(LG, geom_a), GI.convert(LG, geom_b)); crs = GI.crs(geom_a), calc_extent)
endIntersection
julia
function GO.intersection(::GEOS, geom_a, geom_b; target=nothing, calc_extent = false)
return _wrap(LG.intersection(GI.convert(LG, geom_a), GI.convert(LG, geom_b)); crs = GI.crs(geom_a), calc_extent)
endSymmetric difference
julia
function GO.symdifference(::GEOS, geom_a, geom_b; target=nothing, calc_extent = false)
return _wrap(LG.symmetric_difference(GI.convert(LG, geom_a), GI.convert(LG, geom_b)); crs = GI.crs(geom_a), calc_extent)
endDE-9IM boolean methods
These are all the same so we loop over all names and eval them in
julia
for fn in (:equals, :disjoint, :touches, :crosses, :within, :contains, :overlaps, :covers, :coveredby, :intersects)
@eval beginThe basic method for geometries
julia
function GO.$fn(::GEOS, geom_a, geom_b)
return LG.$fn(GI.convert(LG, geom_a), GI.convert(LG, geom_b))
endExtents and geometries
julia
function GO.$fn(alg::GEOS, geom_a::GO.Extents.Extent, geom_b)
return GO.$fn(alg, GO.extent_to_polygon(geom_a), geom_b)
end
function GO.$fn(alg::GEOS, geom_a, geom_b::GO.Extents.Extent)
return GO.$fn(alg, geom_a, GO.extent_to_polygon(geom_b))
endPure extents - this should probably be some GEOSRect or something, but for now this works
julia
function GO.$fn(alg::GEOS, geom_a::GO.Extents.Extent, geom_b::GO.Extents.Extent)
return GO.$fn(alg, GO.extent_to_polygon(geom_a), GO.extent_to_polygon(geom_b))
end
end
endConvex hull
julia
function GO.convex_hull(::GEOS, geoms)
chull = LG.convexhull(
LG.MultiPoint(
collect(
GO.flatten(
x -> GI.convert(LG.Point, x),
GI.PointTrait,
geoms
)
)
)
);
return _wrap(
chull;
crs = GI.crs(geoms),
calc_extent = false
)
endThis page was generated using Literate.jl.