From 61ecc77b8945b9ea092b7db07566dabf84f9304f Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 16 Sep 2024 15:02:52 -0400 Subject: [PATCH] Bump version, add dem_path --- cameralib/projector.py | 17 +++++++++++------ setup.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cameralib/projector.py b/cameralib/projector.py index 81392aa..2803339 100644 --- a/cameralib/projector.py +++ b/cameralib/projector.py @@ -22,8 +22,9 @@ class Projector: z_sample_target (str): Elevation raster to use for sampling elevation. One of: ['dsm', 'dtm'] z_fill_nodata: Whether to fill nodata cells with nearest neighbor cell values. This gives a wider coverage for queries, but increases the initialization time. raycast_resolution_multiplier (float): Value that affects the ray sampling resolution. Lower values can lead to slightly more precise results, but increase processing time. + dem_path (str): Manually set a path to a valid GeoTIFF DEM for sampling Z values instead of using the default. """ - def __init__(self, project_path, z_sample_window=1, z_sample_strategy='median', z_sample_target='dsm', z_fill_nodata=True, raycast_resolution_multiplier=0.7071): + def __init__(self, project_path, z_sample_window=1, z_sample_strategy='median', z_sample_target='dsm', z_fill_nodata=True, raycast_resolution_multiplier=0.7071, dem_path=None): if not os.path.isdir(project_path): raise IOError(f"{project_path} is not a valid path to an ODM project") @@ -38,12 +39,16 @@ def __init__(self, project_path, z_sample_window=1, z_sample_strategy='median', self.dsm_path = os.path.abspath(os.path.join(project_path, "odm_dem", "dsm.tif")) self.dtm_path = os.path.abspath(os.path.join(project_path, "odm_dem", "dtm.tif")) - if z_sample_target == 'dsm': - self.dem_path = self.dsm_path - elif z_sample_target == 'dtm': - self.dem_path = self.dtm_path + + if dem_path is not None: + self.dem_path = dem_path else: - raise InvalidArgError(f"Invalid z_sample_target {z_sample_target}") + if z_sample_target == 'dsm': + self.dem_path = self.dsm_path + elif z_sample_target == 'dtm': + self.dem_path = self.dtm_path + else: + raise InvalidArgError(f"Invalid z_sample_target {z_sample_target}") if not os.path.isfile(self.dem_path): raise InvalidArgError(f"{self.dem_path} does not exist. A surface model is required.") diff --git a/setup.py b/setup.py index 6bcb10f..90fe702 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setuptools.setup( name="cameralib", - version="1.0.0", + version="1.0.1", author="OpenDroneMap Contributors", author_email="pt@uav4geo.com", description="Camera library for ODM",