diff --git a/ext/GMTDGTLidarExt/GMTDGTLidarExt.jl b/ext/GMTDGTLidarExt/GMTDGTLidarExt.jl index d1b091519..bfd54b871 100644 --- a/ext/GMTDGTLidarExt/GMTDGTLidarExt.jl +++ b/ext/GMTDGTLidarExt/GMTDGTLidarExt.jl @@ -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) diff --git a/test/test_dgt.jl b/test/test_dgt.jl index 0be716d36..3114ad224 100644 --- a/test/test_dgt.jl +++ b/test/test_dgt.jl @@ -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) --- @@ -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 diff --git a/test/test_misc.jl b/test/test_misc.jl index 0712b21d7..3c99ddb40 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -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; @@ -243,7 +243,7 @@ GMT.resetGMT() try - upGMT() + @test_nowarn upGMT() catch end image_cpt!(I, C)