Skip to content

Commit

Permalink
Merge pull request #15 from IGNF/14-colorisation-des-nuages-de-point-…
Browse files Browse the repository at this point in the history
…étroits-largeur-ou-hauteur-02m

14 colorisation des nuages de point étroits largeur ou hauteur 02m
  • Loading branch information
leavauchier authored Aug 17, 2023
2 parents 07aec62 + 2dd8467 commit 998987d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pdaltools/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.2.0"
__version__ = "1.3.0"


if __name__ == "__main__":
Expand Down
12 changes: 11 additions & 1 deletion pdaltools/color.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from math import ceil
import subprocess as sp
import tempfile
import pdal
Expand Down Expand Up @@ -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
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 998987d

Please sign in to comment.