Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch always remove tmp orthoimages #23

Merged
merged 2 commits into from
Sep 12, 2023
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# dev

# 1.3.1
- fix color: ensure that tmp orthoimages are deleted after use by using the namedTemporaryFile properly.

# 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
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.3.0"
__version__ = "1.3.1"


if __name__ == "__main__":
Expand Down
14 changes: 8 additions & 6 deletions pdaltools/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,17 @@ def color(

tmp_ortho = None
if color_rvb_enabled:
tmp_ortho = tempfile.NamedTemporaryFile().name
tmp_ortho = tempfile.NamedTemporaryFile()
download_image_from_geoportail_retrying(
proj, "ORTHOIMAGERY.ORTHOPHOTOS", minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho, timeout_second
proj, "ORTHOIMAGERY.ORTHOPHOTOS", minx, miny, maxx, maxy, pixel_per_meter, tmp_ortho.name, timeout_second
)
pipeline |= pdal.Filter.colorization(
raster=tmp_ortho.name, dimensions="Red:1:256.0, Green:2:256.0, Blue:3:256.0"
)
pipeline |= pdal.Filter.colorization(raster=tmp_ortho, dimensions="Red:1:256.0, Green:2:256.0, Blue:3:256.0")

tmp_ortho_irc = None
if color_ir_enabled:
tmp_ortho_irc = tempfile.NamedTemporaryFile().name
tmp_ortho_irc = tempfile.NamedTemporaryFile()
download_image_from_geoportail_retrying(
proj,
"ORTHOIMAGERY.ORTHOPHOTOS.IRC",
Expand All @@ -168,10 +170,10 @@ def color(
maxx,
maxy,
pixel_per_meter,
tmp_ortho_irc,
tmp_ortho_irc.name,
timeout_second,
)
pipeline |= pdal.Filter.colorization(raster=tmp_ortho_irc, dimensions="Infrared:1:256.0")
pipeline |= pdal.Filter.colorization(raster=tmp_ortho_irc.name, dimensions="Infrared:1:256.0")

pipeline |= pdal.Writer.las(
filename=output_file, extra_dims=writer_extra_dims, minor_version="4", dataformat_id="8"
Expand Down
4 changes: 2 additions & 2 deletions test/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def test_epsg_fail():

def test_color_and_keeping_orthoimages():
tmp_ortho, tmp_ortho_irc = color.color(INPUT_PATH, OUTPUT_FILE, epsg)
assert Path(tmp_ortho).exists()
assert Path(tmp_ortho_irc).exists()
assert Path(tmp_ortho.name).exists()
assert Path(tmp_ortho_irc.name).exists()


def test_color_narrow_cloud():
Expand Down