Exemplo n.º 1
0
    def processAlgorithm(self, parameters, context, feedback):
        input_layer = self.parameterAsVectorLayer(parameters, self.INPUT,
                                                  context)
        reach_name = (self.parameterAsString(parameters, self.REACH_NAME,
                                             context) or input_layer.name())
        output_path = self.parameterAsString(parameters, self.OUTPUT, context)

        precourlis_file = PreCourlisFileLine(input_layer)
        reach = precourlis_file.get_reach(reach_name)

        output_file = MascaretGeoFile(output_path, mode="write")
        output_file.has_ref = "ref" in os.path.splitext(output_path)[1][1:]
        output_file.add_reach(reach)
        output_file.save(output_path)

        return {self.OUTPUT: output_path}
    def processAlgorithm(self, parameters, context, feedback):
        input_layer = self.parameterAsVectorLayer(parameters, self.INPUT,
                                                  context)
        reach_name = (self.parameterAsString(parameters, self.REACH_NAME,
                                             context) or input_layer.name())
        output_path = self.parameterAsString(parameters, self.OUTPUT, context)

        # Processing GUI does not correctly handle uppercase characters in file extensions before
        # QGIS 3.14
        if Qgis.QGIS_VERSION_INT < 31400:
            output_path = output_path.replace(".georefc", ".georefC")
            output_path = output_path.replace(".geoc", ".geoC")

        precourlis_file = PreCourlisFileLine(input_layer)
        reach = precourlis_file.get_reach(reach_name)

        output_file = MascaretGeoFile(output_path, mode="write")
        output_file.has_ref = "ref" in os.path.splitext(output_path)[1][1:]
        output_file.add_reach(reach)
        output_file.nlayers = len(precourlis_file.layers())
        output_file.save(output_path)

        return {self.OUTPUT: output_path}