def getSafeExportedLayers(self): '''Returns not the value entered by the user, but a string with semicolon-separated filenames which contains the data of the selected layers, but saved in a standard format (currently shapefiles for vector layers and GeoTiff for raster) so that they can be opened by most external applications. If there is a selection and QGIS is configured to use just the selection, if exports the layer even if it is already in a suitable format. Works only if the layer represented by the parameter value is currently loaded in QGIS. Otherwise, it will not perform any export and return the current value string. If the current value represents a layer in a suitable format, it does no export at all and returns that value. Currently, it works just for vector layer. In the case of raster layers, it returns the parameter value. The layers are exported just the first time the method is called. The method can be called several times and it will always return the same string, performing the export only the first time.''' if self.exported: return self.exported self.exported = self.value layers = self.value.split(";") if layers == None or len(layers) == 0: return self.value if self.datatype == ParameterMultipleInput.TYPE_RASTER: for layerfile in layers: layer = QGisLayers.getObjectFromUri(layerfile, False) if layer: filename = LayerExporter.exportRasterLayer(layer) self.exported = self.exported.replace(layerfile, filename) return self.exported else: for layerfile in layers: layer = QGisLayers.getObjectFromUri(layerfile, False) if layer: filename = LayerExporter.exportVectorLayer(layer) self.exported = self.exported.replace(layerfile, filename) return self.exported
def getSafeExportedLayer(self): '''Returns not the value entered by the user, but a string with a filename which contains the data of this layer, but saved in a standard format (currently always a geotiff file) so that it can be opened by most external applications. Works only if the layer represented by the parameter value is currently loaded in QGIS. Otherwise, it will not perform any export and return the current value string. If the current value represents a layer in a suitable format, it does not export at all and returns that value. The layer is exported just the first time the method is called. The method can be called several times and it will always return the same file, performing the export only the first time.''' if self.exported: return self.exported layer = QGisLayers.getObjectFromUri(self.value, False) if layer: self.exported = LayerExporter.exportRasterLayer(layer) else: self.exported = self.value return self.exported