Skip to content

Commit

Permalink
Merge branch 'main' into breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Dec 26, 2024
2 parents e846044 + b89b0b6 commit 1e8ea6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Adapt = "2, 3.0, 4"
Aqua = "0.8"
ArchGDAL = "0.9, 0.10"
CFTime = "0.1"
ColorTypes = "0.10, 0.11"
ColorTypes = "0.10, 0.11, 0.12"
CommonDataModel = "0.2.3, 0.3"
ConstructionBase = "1"
CoordinateTransformations = "0.6.2"
Expand Down Expand Up @@ -106,6 +106,7 @@ RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand Down
10 changes: 4 additions & 6 deletions src/methods/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ function _extract(A::RasterStackOrArray, e::Extractor, id::Int, geom; kw...)
_extract(A, e, id, GI.geomtrait(geom), geom; kw...)
end
function _extract(A::RasterStackOrArray, e::Extractor{T}, id::Int, ::Nothing, geoms::AbstractArray;
threaded=false, progress=true, kw...
threaded=false, progress=true, skipmissing, kw...
) where T
# Handle emptycases
isempty(geoms) && return T[]

geom1 = all(ismissing, geoms) ? missing : first(skipmissing(geoms))
trait1 = GI.trait(geom1)
# Handle empty / all missing cases
isempty(geoms) || all(ismissing, geoms) && return T[]
trait1 = GI.trait(first(Base.skipmissing(geoms)))
# We split out points from other geoms for performance
if trait1 isa GI.PointTrait
allpoints = true
Expand Down
11 changes: 7 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,12 @@ function _get_geometries(data, ::Nothing)
data
else
trait = GI.trait(data)
if GI.trait(data) isa GI.FeatureCollectionTrait
if trait isa GI.FeatureCollectionTrait
[GI.geometry(f) for f in GI.getfeature(data)]
else
elseif isnothing(trait)
collect(data)
else
data
end
end
# check if data iterates valid geometries before returning
Expand All @@ -240,9 +242,10 @@ function _get_geometries(data, geometrycolumn::NTuple{<:Any, <:Symbol})
return points
end
function _check_geometries(geoms)
!isnothing(GI.trait(geoms)) && return
for g in geoms
ismissing(g) || GI.geomtrait(g) !== nothing ||
throw(ArgumentError("$g is not a valid GeoInterface.jl geometry"))
ismissing(g) || !isnothing(GI.geomtrait(g)) ||
throw(ArgumentError("$g is not a valid GeoInterface.jl geometry"))
end
return
end
Expand Down

0 comments on commit 1e8ea6d

Please sign in to comment.