Skip to content

Commit

Permalink
handle FeatureTrait and GeometryCollectionTrait in `_get_geometri…
Browse files Browse the repository at this point in the history
…es` (#853)

* _get_geometries tries to return `GI.geometry`

* handle geometrycollection and featuretrait

* better error message for traits that aren't handled
  • Loading branch information
tiemvanderdeure authored Jan 15, 2025
1 parent 28a21cf commit a2e2d46
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,19 @@ function _get_geometries(data, ::Nothing)
data
else
trait = GI.trait(data)
if trait isa GI.FeatureCollectionTrait
if trait isa GI.AbstractFeatureCollectionTrait
[GI.geometry(f) for f in GI.getfeature(data)]
elseif trait isa GI.AbstractGeometryCollectionTrait
GI.getgeom(data)
elseif trait isa GI.AbstractFeatureTrait
GI.geometry(data)
elseif isnothing(trait)
collect(data)
else
elseif trait isa GI.AbstractGeometryTrait
# data is already a geometry, so return as-is
data
else
ArgumentError("data has $trait, which is not handled")
end
end
# check if data iterates valid geometries before returning
Expand Down

0 comments on commit a2e2d46

Please sign in to comment.