@@ -9,8 +9,8 @@ const DEFAULT_TABLE_DIM_KEYS = (:X, :Y, :Z)
99function _fill_geometry! (B:: AbstractRaster , geom; kw... )
1010 _fill_geometry! (B, GI. trait (geom), geom; kw... )
1111end
12- function _fill_geometry! (B:: AbstractRaster , :: GI.AbstractFeatureTrait , geom ; kw... )
13- return _fill_geometry! (B, GI. geometry (geom), geom ; kw... )
12+ function _fill_geometry! (B:: AbstractRaster , :: GI.AbstractFeatureTrait , feature ; kw... )
13+ return _fill_geometry! (B, GI. geometry (feature) ; kw... )
1414end
1515function _fill_geometry! (B:: AbstractRaster , :: GI.AbstractFeatureCollectionTrait , fc; kw... )
1616 for feature in GI. getfeature (fc)
@@ -25,7 +25,7 @@ function _fill_geometry!(B::AbstractRaster, ::GI.AbstractGeometryTrait, geom; sh
2525 _fill_linestring! (B, geom; shape, kw... )
2626 elseif shape === :polygon
2727 geomextent = _extent (geom)
28- arrayextent = Extents. extent (B, DEFAULT_POINT_ORDER)
28+ arrayextent = Extents. extent (B, DEFAULT_POINT_ORDER)
2929 # Only fill if the gemoetry bounding box overlaps the array bounding box
3030 Extents. intersects (geomextent, arrayextent) || return B
3131 _fill_polygon! (B, geom; shape, geomextent, kw... )
@@ -125,14 +125,15 @@ function _iyperm(dims::Tuple{<:Dimension,<:Dimension})
125125 return iyperm
126126end
127127function _iyperm (dims:: Tuple{<:Dimension,<:Dimension,<:Dimension} )
128+ # TODO : test this 3d case
128129 a1, a2, a3 = map (dims) do d
129130 l = parent (d)
130131 LA. ordered_firstindex (l): _order_step (l): LA. ordered_lastindex (l)
131132 end
132133 iyperm = Array {Int} (undef, length (a1) * length (a2) * length (a3))
133134 lis = (LinearIndices (size (dims))[i, j, k] for k in a3 for j in a2 for i in a1)
134135 for (i, li) in enumerate (lis)
135- Iyperm [i] = li
136+ iyperm [i] = li
136137 end
137138 return iyperm
138139end
@@ -263,7 +264,7 @@ function _fill_line!(A::AbstractRaster, line, fill)
263264 # delta: How far to move along the ray to move 1 grid cell.
264265 cs = cos (angle)
265266 si = sin (angle)
266- max_x, delta_x = if isapprox (cs, zero (cs); atol= 1e-10 )
267+ max_x, delta_x = if isapprox (cs, zero (cs); atol= 1e-10 )
267268 - Inf , Inf
268269 else
269270 1.0 / cs, xoffset / cs
@@ -280,7 +281,7 @@ function _fill_line!(A::AbstractRaster, line, fill)
280281 for t in 0 : manhattan_distance
281282 D = map ((d, o) -> d (o), dimconstructors, (x, y))
282283 if checkbounds (Bool, A, D... )
283- if fill isa Function
284+ if fill isa Function
284285 @inbounds A[D... ] = fill (A[D... ])
285286 else
286287 @inbounds A[D... ] = fill
@@ -333,7 +334,7 @@ function to_edges_and_nodes!(edges, nodes, lastnode, geom)
333334 for (n, point) in enumerate (GI. getpoint (geom))
334335 i = lastnode + n
335336 if n == npoints
336- # The closing edge of a sub-polygon
337+ # The closing edge of a sub-polygon
337338 edges[i, 1 ] = i
338339 edges[i, 2 ] = lastnode + 1
339340 else
@@ -367,10 +368,11 @@ function _extent(::Nothing, data)
367368 Extents. union (ext, _extent (geom))
368369 end
369370 else
371+ # TODO : test this branch
370372 # Table of points with dimension columns
371373 reduce (DEFAULT_TABLE_DIM_KEYS; init= (;)) do acc, key
372- if key in Tables. columnnames (cols)
373- merge (acc, (; key= extrema (columns )))
374+ if key in Tables. columnnames (cols)
375+ merge (acc, (; key= extrema (cols[key] )))
374376 else
375377 acc
376378 end
@@ -393,7 +395,7 @@ function _extent(::GI.AbstractTrait, geom)
393395 end
394396end
395397_extent (:: GI.AbstractFeatureTrait , feature) = _extent (GI. geometry (feature))
396- function _extent (:: GI.AbstractFeatureCollectionTrait , features)
398+ function _extent (:: GI.AbstractFeatureCollectionTrait , features)
397399 features = GI. getfeature (features)
398400 reduce (features; init= _extent (first (features))) do acc, f
399401 Extents. union (acc, _extent (f))
@@ -403,12 +405,13 @@ end
403405# extent_may_intersect
404406# Check if there is an extent for the geometry
405407function extent_may_intersect (x, geom)
408+ # TODO : this is not actually used.
406409 rasterextent = Extents. extent (x, DEFAULT_POINT_ORDER)
407410 geomextent = GI. extent (geom)
408- if ext isa Nothing
411+ if isnothing (rasterextent) || isnothing (geomextent)
409412 return true
410413 else
411- return Extents. intersects (geomextent, rasterext )
414+ return Extents. intersects (geomextent, rasterextent )
412415 end
413416end
414417
@@ -422,7 +425,7 @@ _dimcoord(::ZDim, point) = GI.z(point)
422425# Get the shape category for a geometry
423426@inline _geom_shape (geom) = _geom_shape (GI. geomtrait (geom))
424427@inline _geom_shape (geom:: Union{<:GI.PointTrait,<:GI.MultiPointTrait} ) = :point
425- @inline _geom_shape (geom:: Union{<:GI.LineStringTrait,<:GI.MultiLineStringTrait} ) = :line
428+ @inline _geom_shape (geom:: Union{<:GI.LineStringTrait,<:GI.MultiLineStringTrait} ) = :line
426429@inline _geom_shape (geom:: Union{<:GI.LinearRingTrait,<:GI.PolygonTrait,<:GI.MultiPolygonTrait} ) = :polygon
427430# _geom_shape(trait, geom) = throw(ArgumentError("Geometry trait $trait not handled by Rasters.jl"))
428431
0 commit comments