Open
Description
This can actually cause some conversions to fail because the create$(geom)
function may not have a dispatch for what GI.coordinates outputs, if it's e.g. a StaticArray.
It seems entirely doable to do this manually or in a loop for each type of geometry.
Here's an example for PolygonTrait:
function GeoInterface.convert(
::Type{T},
type::GeoInterface.PolygonTrait,
geom,
) where {T<:IGeometry}
f = get(lookup_method, typeof(type), nothing)
isnothing(f) && error(
"Cannot convert an object of $(typeof(geom)) with the $(typeof(type)) trait (yet). Please report an issue.",
)
poly = createpolygon()
foreach(GeoInterface.getring(geom)) do ring
xs = GeoInterface.x.(GeoInterface.getpoint(ring))
ys = GeoInterface.y.(GeoInterface.getpoint(ring))
subgeom = unsafe_createlinearring(xs, ys)
result = GDAL.ogr_g_addgeometrydirectly(poly, subgeom)
@ogrerr result "Failed to add linearring."
end
return poly
end
Metadata
Metadata
Assignees
Labels
No labels