Skip to content

Commit

Permalink
edit test and log values to reproject
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Feb 8, 2024
1 parent 74c47ad commit b1a5899
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions geovita_processing_plugin/test/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def setUp(self):
self.building_layer_path = self.data_dir / 'bygninger.shp'
self.excavation_layer_path = self.data_dir / 'byggegrop.shp'
self.raster_rock_surface_path = self.data_dir / 'DTB-dummy-25833-clip.tif'
self.assertTrue(self.building_layer_path.is_file(), "Building shape source file does not exist.")
self.assertTrue(self.excavation_layer_path.is_file(), "Excavation shape surface source file does not exist.")
self.assertTrue(self.raster_rock_surface_path.is_file(), "Raster rock surface source file does not exist.")

# Assuming these layers exist for testing purposes
self.building_layer = QgsVectorLayer(str(self.building_layer_path), 'test_building', 'ogr')
Expand Down
7 changes: 6 additions & 1 deletion geovita_processing_plugin/utilities/methodslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,18 @@ def reproject_layers(keep_interm_layer: bool,
if raster_layer is not None:
feedback.pushInfo(f"Raster layer to reproject: Valid: {raster_layer.isValid()}, Name: {raster_layer.name()}.tif, Source: {raster_layer.source()}")
reprojected_raster_path = temp_folder / f"reprojected_{raster_layer.name()}.tif"
if logger:
logger.info(f"@reproject_layers@ - Raster to reproject 'INPUT': {raster_layer.source()}")
logger.info(f"@reproject_layers@ - Raster to reproject 'SOURCE_CRS': {raster_layer.crs().authid()}")
logger.info(f"@reproject_layers@ - Raster to reproject 'TARGET_CRS': {output_crs.authid()}")
processing.run("gdal:warpreproject", {
'INPUT': raster_layer.source(),
'SOURCE_CRS': raster_layer.crs().authid(),
'TARGET_CRS': output_crs.authid(),
'OUTPUT': str(reprojected_raster_path)
}, context=context, feedback=feedback)

if logger:
logger.info(f"@reproject_layers@ - Raster to reproject 'OUTPUT': {str(reprojected_raster_path)}")
# Save the reprojected raster layer to the output folder, else return the temporary interm. layer
final_raster_path = output_folder / f"reprojected_{raster_layer.name()}.tif" if keep_interm_layer else reprojected_raster_path
if keep_interm_layer:
Expand Down

0 comments on commit b1a5899

Please sign in to comment.