diff --git a/CHANGELOG.md b/CHANGELOG.md index b1c5f14..a50402a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ # dev + +# 1.3.0 +- color: support colorization for <0.2m clouds (including height=0/width=0) +- color: ceil width/height to have a bbox that contains all points + +# 1.2.1 - fix cicd_full github action: deployment was triggered on pushing to dev instead of master only # 1.2.0 -color: keep downloaded orthoimages by returning them to make them stay in executionn scope +- color: keep downloaded orthoimages by returning them to make them stay in execution scope # 1.1.1 - unlock: fix main @@ -12,7 +18,7 @@ color: keep downloaded orthoimages by returning them to make them stay in execut # 1.1.0 - standardization: handle malformed laz input ("Global encoding WKT flag not set for point format 6 - 10") -color: extract unlock module from colorization and rename colorization function +- color: extract unlock module from colorization and rename colorization function # 1.0.0 - first public version diff --git a/pdaltools/_version.py b/pdaltools/_version.py index 986d109..692e5cc 100644 --- a/pdaltools/_version.py +++ b/pdaltools/_version.py @@ -1,4 +1,4 @@ -__version__ = "1.2.0" +__version__ = "1.3.0" if __name__ == "__main__": diff --git a/pdaltools/color.py b/pdaltools/color.py index d1e840b..2f33516 100644 --- a/pdaltools/color.py +++ b/pdaltools/color.py @@ -1,4 +1,5 @@ import json +from math import ceil import subprocess as sp import tempfile import pdal @@ -59,13 +60,22 @@ def newfn(*args, **kwargs): def download_image_from_geoportail(proj, layer, minx, miny, maxx, maxy, pixel_per_meter, outfile, timeout): + # Give single-point clouds a width/height of at least one pixel to have valid BBOX and SIZE + if minx == maxx: + maxx = minx + 1 / pixel_per_meter + if miny == maxy: + maxy = miny + 1 / pixel_per_meter + # for layer in layers: URL_GPP = "https://wxs.ign.fr/ortho/geoportail/r/wms?" URL_FORMAT = "&EXCEPTIONS=text/xml&FORMAT=image/geotiff&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&STYLES=" URL_EPSG = "&CRS=EPSG:" + str(proj) URL_BBOX = "&BBOX=" + str(minx) + "," + str(miny) + "," + str(maxx) + "," + str(maxy) URL_SIZE = ( - "&WIDTH=" + str(int((maxx - minx) * pixel_per_meter)) + "&HEIGHT=" + str(int((maxy - miny) * pixel_per_meter)) + "&WIDTH=" + + str(ceil((maxx - minx) * pixel_per_meter)) + + "&HEIGHT=" + + str(ceil((maxy - miny) * pixel_per_meter)) ) URL = URL_GPP + "LAYERS=" + layer + URL_FORMAT + URL_EPSG + URL_BBOX + URL_SIZE diff --git a/test/data/test_data_0436_6384_LA93_IGN69_single_point.laz b/test/data/test_data_0436_6384_LA93_IGN69_single_point.laz new file mode 100644 index 0000000..069d123 Binary files /dev/null and b/test/data/test_data_0436_6384_LA93_IGN69_single_point.laz differ diff --git a/test/test_color.py b/test/test_color.py index a123f04..fa02db8 100644 --- a/test/test_color.py +++ b/test/test_color.py @@ -23,8 +23,10 @@ def setup_module(module): TEST_PATH = os.path.dirname(os.path.abspath(__file__)) INPUT_PATH = os.path.join(TEST_PATH, "data/test_noepsg_043500_629205_IGN69.laz") +INPUT_PATH_SINGLE_POINT_CLOUD = os.path.join(TEST_PATH, "data/test_data_0436_6384_LA93_IGN69_single_point.laz") OUTPUT_FILE = TMPDIR + "Semis_2021_0435_6292_LA93_IGN69.las" +OUTPUT_FILE_SINGLE_POINT_CLOUD = TMPDIR + "test_data_0436_6384_LA93_IGN69_single_point.colorized.laz" @pytest.mark.geoportail @@ -48,6 +50,11 @@ def test_color_and_keeping_orthoimages(): assert Path(tmp_ortho_irc).exists() +def test_color_narrow_cloud(): + # Test that clouds that are smaller in width or height to 20cm are still clorized without an error. + color.color(INPUT_PATH_SINGLE_POINT_CLOUD, OUTPUT_FILE_SINGLE_POINT_CLOUD, epsg) + + @pytest.mark.geoportail def test_download_image_ok(): color.download_image_from_geoportail(epsg, layer, minx, miny, maxx, maxy, pixel_per_meter, OUTPUT_FILE, 15)