Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ext/GMTDGTLidarExt/GMTDGTLidarExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,25 @@ module GMTDGTLidarExt
Float64(delay), collection, dry, mosaic, Float64(inc), method, latest, Int(verbose), 0, zoom, compress, proj)
end

# --------------------------------------------------------------------------------------------------------------------------
function _pt_overlaps(b::NTuple{4,Float64})
pt_bbox = (-9.6, -6.1, 36.9, 42.2) # Portugal bounding box: [min_lon, max_lon, min_lat, max_lat]
b[1] <= pt_bbox[2] && b[2] >= pt_bbox[1] && b[3] <= pt_bbox[4] && b[4] >= pt_bbox[3]
end

function _validate_pt_bbox(b::NTuple{4,Float64})::NTuple{4,Float64}
_pt_overlaps(b) && return b
bs = (b[3], b[4], b[1], b[2])
_pt_overlaps(bs) && @warn("Coordinates probably given as lat/lon INSTEAD of lon/lat.") && return bs
error("Coordinates $b do not intersect Portugal (-9.6, -6.1, 36.9, 42.2)")
end

# --------------------------------------------------------------------------------------------------------------------------
function _dgt_lidar(bbox, user::String, password::String, save::Bool, output_dir::String, delay::Float64, collection::String,
dry::Bool, mosaic::String, inc::Float64, method::String, latest::Bool, verbose::Int,
_neighbors, _zoom::Int, compress::String, proj::String)

bbox = _validate_pt_bbox(NTuple{4,Float64}(bbox))
_valid = ("LAZ", "MDT-50cm", "MDS-50cm", "MDT-2m", "MDS-2m")
_coll = uppercase(collection) # Because of Core.Boxes
_canonical = findfirst(c -> uppercase(c) == _coll, _valid)
Expand Down
3 changes: 1 addition & 2 deletions test/test_dgt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ const INTEGRATION_BBOX = [-9.11, -9.0877, 38.728, 38.735]

if isfile(joinpath(homedir(), ".dgt"))
@testset "DGT LIDAR Integration" begin
#mktempdir() do tmpdir
tmpdir = mktempdir()

# --- dgt_lidar: auth + search, no download (primary bbox form) ---
Expand Down Expand Up @@ -499,6 +498,6 @@ if isfile(joinpath(homedir(), ".dgt"))
GMT.dgt_lidar(INTEGRATION_BBOX; output_dir=tmpdir, verbose=3)
@test length(readdir(coll_dir)) == n_before
end
#end
end
@test_throws ErrorException("Coordinates (10.1, 10.1, 10.0, 10.1) do not intersect Portugal (-9.6, -6.1, 36.9, 42.2)") GMT.dgt_lidar([10.1,10.1],[10., 10.1])
end
4 changes: 2 additions & 2 deletions test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
image_alpha!(I, alpha_ind=5);
image_alpha!(I, alpha_vec=round.(UInt32,rand(6).*255));
@info "before 3"
image_alpha!(I, alpha_band=round.(UInt8,rand(27,27).*255))
@test_nowarn image_alpha!(I, alpha_band=round.(UInt8,rand(27,27).*255))
img = mat2img(rand(UInt8, 6, 6, 3));
mask = fill(UInt8(0), 6, 6);
mask[3:4,3:4] .= 255;
Expand All @@ -243,7 +243,7 @@

GMT.resetGMT()
try
upGMT()
@test_nowarn upGMT()
catch
end
image_cpt!(I, C)
Expand Down
Loading