diff --git a/felt/core/fsl_converter.py b/felt/core/fsl_converter.py index fb1c4fa..6b9c4fd 100644 --- a/felt/core/fsl_converter.py +++ b/felt/core/fsl_converter.py @@ -2,6 +2,7 @@ QGIS to FSL conversion """ +import math from enum import ( Enum, auto @@ -11,13 +12,11 @@ List, Optional ) -import math from qgis.PyQt.QtCore import ( Qt, ) from qgis.PyQt.QtGui import QColor - from qgis.core import ( NULL, QgsVectorLayer, @@ -60,7 +59,9 @@ QgsRasterRenderer, QgsSingleBandPseudoColorRenderer, QgsPalettedRasterRenderer, - QgsSingleBandGrayRenderer + QgsSingleBandGrayRenderer, + QgsRasterPipe, + QgsRasterDataProvider ) from .map_utils import MapUtils @@ -1531,6 +1532,15 @@ def raster_layer_to_fsl( if not fsl: return None + if (layer.resamplingStage() == QgsRasterPipe.ResamplingStage.Provider + and (layer.dataProvider().zoomedInResamplingMethod() != + QgsRasterDataProvider.ResamplingMethod.Nearest + or layer.dataProvider().zoomedOutResamplingMethod() != + QgsRasterDataProvider.ResamplingMethod.Nearest)): + fsl['config']['rasterResampling'] = "linear" + else: + fsl['config']['rasterResampling'] = "nearest" + if layer.hasScaleBasedVisibility(): if layer.minimumScale(): fsl['style']['minZoom'] = ( diff --git a/felt/core/map_uploader.py b/felt/core/map_uploader.py index 1db7087..38ac09f 100644 --- a/felt/core/map_uploader.py +++ b/felt/core/map_uploader.py @@ -33,7 +33,8 @@ QgsTask, QgsFeedback, QgsBlockingNetworkRequest, - QgsReferencedRectangle + QgsReferencedRectangle, + QgsRasterLayer ) from qgis.utils import iface @@ -75,7 +76,7 @@ def __init__(self, project.transformContext() ) self.layers = [ - layer.clone() for layer in layers + MapUploaderTask.clone_layer(layer) for layer in layers ] self.unsupported_layer_details = {} else: @@ -95,7 +96,8 @@ def __init__(self, ] self.layers = [ - layer.clone() for layer in visible_layers if + MapUploaderTask.clone_layer(layer) for layer in visible_layers + if LayerExporter.can_export_layer(layer)[ 0] == LayerSupport.Supported ] @@ -137,6 +139,23 @@ def __init__(self, self.feedback: Optional[QgsFeedback] = None self.was_canceled = False + @staticmethod + def clone_layer(layer: QgsMapLayer) -> QgsMapLayer: + """ + Clones a layer + """ + res = layer.clone() + if isinstance(layer, QgsRasterLayer): + res.setResamplingStage(layer.resamplingStage()) + res.dataProvider().setZoomedInResamplingMethod( + layer.dataProvider().zoomedInResamplingMethod() + ) + res.dataProvider().setZoomedOutResamplingMethod( + layer.dataProvider().zoomedOutResamplingMethod() + ) + + return res + def set_workspace_id(self, workspace_id: Optional[str]): """ Sets the target workspace ID