Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Dec 10, 2023
1 parent 45f34d1 commit 0ab3ded
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/rasterize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ st = RasterStack((A1, copy(A1)))
geom = pointvec
geom = line_collection
geom = poly_collection
threaded = true

for A in (A1, A2),
geom in (pointvec, pointfc, multi_point, linestring, multi_linestring, linearring, polygon, multi_polygon, table, line_collection, poly_collection),
Expand All @@ -57,6 +58,8 @@ st = RasterStack((A1, copy(A1)))
rasterize!(sum, A, geom; shape=:point, fill=1, threaded);
@test sum(A) == 5.0
@test sum(rasterize(sum, geom; to=A, shape=:point, fill=1, missingval=0, threaded)) == 5.0
@test sum(rasterize(xs -> sum(xs), geom; to=A, shape=:point, fill=1, missingval=0, threaded)) == 5.0
@test sum(rasterize(xs -> sum(xs), geom; to=A, shape=:point, fill=1, missingval=0, threaded, threadsafe=true)) == 5.0
rasterize!(last, A, geom; shape=:point, fill=1, threaded);
@test sum(A) == 4.0
@test sum(rasterize(last, geom; to=A, shape=:point, fill=1, missingval=0, threaded)) == 4.0
Expand Down Expand Up @@ -124,6 +127,8 @@ end
rasterize!(sum, A, geom; shape=:line, fill=1, threaded)
@test sum(A) == 20 + 20 + 20 + 20
@test sum(rasterize(sum, geom; to=A, shape=:line, fill=1, missingval=0, threaded)) == 80
@test sum(rasterize(xs -> sum(xs), geom; to=A, shape=:line, fill=1, missingval=0, threaded, threadsafe=true)) == 80
@test sum(rasterize(xs -> sum(xs), geom; to=A, shape=:line, fill=1, missingval=0, threaded, threadsafe=false)) == 80
end
@testset ":line is detected for line geometries" begin
for A in (A1, A2), geom in (linestring, multi_linestring), threaded in (true, false)
Expand All @@ -139,6 +144,7 @@ end
A = A1
poly = polygon
poly = poly_collection
threaded = false
for A in (A1, A2), poly in (polygon, multi_polygon, poly_collection), threaded in (true, false)
A .= 0
ra = rasterize(last, poly; to=A, missingval=0, shape=:polygon, fill=1, boundary=:center, threaded)
Expand Down Expand Up @@ -195,6 +201,7 @@ end
end
@testset "Single value fill makes an array (ignoring table vals)" begin
ra = rasterize(sum, data; to=A, fill=0x03, missingval=0x00)
@test ra isa Raster
@test eltype(ra) == UInt64
@test sum(ra) === 0x000000000000000f
end
Expand Down

0 comments on commit 0ab3ded

Please sign in to comment.