diff --git a/encoder.py b/encoder.py index b18c62440b50524b575c0c0b5f02936c6f9e312c..43f9a2e8ea4cefc49ef811d91b45f9b91b87fddc 100644 --- a/encoder.py +++ b/encoder.py @@ -558,7 +558,10 @@ class EncoderAlgorithm(QgsProcessingAlgorithm): if not all_encoding_done : dst_path = Path(os.path.join(self.output_subdir,'merged_tmp.tif')) else: - dst_path = Path(os.path.join(self.output_subdir,'merged.tif')) + # dst_path = Path(os.path.join(self.output_subdir,'merged.tif')) + ## update filename if a merged.tif file allready exists + dst_path, layer_name = get_unique_filename(self.output_subdir, 'merged.tif') + dst_path = Path(dst_path) merge_tiles( tiles = all_tiles, @@ -593,7 +596,7 @@ class EncoderAlgorithm(QgsProcessingAlgorithm): parameters['OUTPUT_RASTER']=dst_path - return {"Output feature path": self.output_subdir, 'Patch samples saved': self.iPatch, 'OUTPUT_RASTER':dst_path} + return {"Output feature path": self.output_subdir, 'Patch samples saved': self.iPatch, 'OUTPUT_RASTER':dst_path, 'OUTPUT_LAYER_NAME':layer_name} def get_last_batch_done(self): diff --git a/iamap.py b/iamap.py index a0a36a04b2e46e524943d893f9e614773bdd63b4..f66f95b781000424ce68d2c784759b730b7e534b 100644 --- a/iamap.py +++ b/iamap.py @@ -111,9 +111,10 @@ class IAMap(QObject): # Retrieve output parameters from the result dictionary if 'OUTPUT_RASTER' in result: output_raster_path = result['OUTPUT_RASTER'] + output_layer_name = result['OUTPUT_LAYER_NAME'] # Add the output raster layer to the map canvas - self.iface.addRasterLayer(str(output_raster_path), 'merged features') + self.iface.addRasterLayer(str(output_raster_path),output_layer_name) else: # Handle missing or unexpected output print('Output raster not found in algorithm result.')