示例#1
0
 def accept(self):
     input_path = str(self.leInputPath.text())
     output_path = str(self.leOutputPath.text())
     if not output_path.endswith('.tif'):
         QMessageBox.warning(
             self.parent, self.tr('InaSAFE'),
             (self.tr('Output file name must be tif file')))
     if not os.path.exists(input_path):
         QMessageBox.warning(
             self.parent, self.tr('InaSAFE'),
             (self.tr('Input file is not exist')))
         return
     my_algorithm = str(self.cboAlgorithm.currentText()).lower()
     fileName = convert_mmi_data(input_path, output_path,
                                 the_algorithm=my_algorithm,
                                 algorithm_name=False)
     if self.cBLoadLayer.isChecked():
         fileInfo = QFileInfo(fileName)
         baseName = fileInfo.baseName()
         my_raster_layer = QgsRasterLayer(fileName, baseName)
         if not my_raster_layer.isValid():
             LOGGER.debug("Failed to load")
         else:
             QgsMapLayerRegistry.instance().addMapLayer(my_raster_layer)
     self.done(self.Accepted)
     if not self.test_mode:
         QMessageBox.warning(
             self.parent, self.tr('InaSAFE'),
             (self.tr('Success to convert %1 to %2').
              arg(input_path).arg(output_path)))
示例#2
0
 def accept(self):
     input_path = str(self.leInputPath.text())
     output_path = str(self.leOutputPath.text())
     if not output_path.endswith('.tif'):
         QMessageBox.warning(self.parent, self.tr('InaSAFE'),
                             (self.tr('Output file name must be tif file')))
     if not os.path.exists(input_path):
         QMessageBox.warning(self.parent, self.tr('InaSAFE'),
                             (self.tr('Input file is not exist')))
         return
     my_algorithm = str(self.cboAlgorithm.currentText()).lower()
     fileName = convert_mmi_data(input_path,
                                 output_path,
                                 the_algorithm=my_algorithm,
                                 algorithm_name=False)
     if self.cBLoadLayer.isChecked():
         fileInfo = QFileInfo(fileName)
         baseName = fileInfo.baseName()
         my_raster_layer = QgsRasterLayer(fileName, baseName)
         if not my_raster_layer.isValid():
             LOGGER.debug("Failed to load")
         else:
             QgsMapLayerRegistry.instance().addMapLayer(my_raster_layer)
     self.done(self.Accepted)
     if not self.test_mode:
         QMessageBox.warning(self.parent, self.tr('InaSAFE'),
                             (self.tr('Success to convert %1 to %2').arg(
                                 input_path).arg(output_path)))
示例#3
0
    def accept(self):
        """Handler for when OK is clicked.
        """
        input_path = str(self.input_path.text())
        input_title = str(self.line_edit_title.text())
        input_source = str(self.line_edit_source.text())
        output_path = str(self.output_path.text())
        if not output_path.endswith('.tif'):
            # noinspection PyArgumentList,PyCallByClass,PyTypeChecker
            QMessageBox.warning(
                self,
                self.tr('InaSAFE'),
                (self.tr('Output file name must be tif file')))
        if not os.path.exists(input_path):
            # noinspection PyArgumentList,PyCallByClass,PyTypeChecker
            QMessageBox.warning(
                self,
                self.tr('InaSAFE'),
                (self.tr('Input file is not exist')))
            return

        if self.nearest_mode.isChecked():
            algorithm = 'nearest'
        else:
            algorithm = 'invdist'

        QtGui.qApp.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))

        file_name = convert_mmi_data(
            input_path,
            input_title,
            input_source,
            output_path,
            algorithm=algorithm,
            algorithm_filename_flag=False)

        QtGui.qApp.restoreOverrideCursor()

        if self.load_result.isChecked():
            file_info = QFileInfo(file_name)
            base_name = file_info.baseName()
            layer = QgsRasterLayer(file_name, base_name)
            mmi_ramp(layer)
            layer.saveDefaultStyle()
            if not layer.isValid():
                LOGGER.debug("Failed to load")
            else:
                # noinspection PyArgumentList
                QgsMapLayerRegistry.instance().addMapLayer(layer)
        self.done(self.Accepted)
示例#4
0
    def accept(self):
        """Handler for when OK is clicked.
        """
        input_path = str(self.leInputPath.text())
        output_path = str(self.leOutputPath.text())
        if not output_path.endswith('.tif'):
            # noinspection PyArgumentList
            QMessageBox.warning(
                self.parent, self.tr('InaSAFE'),
                (self.tr('Output file name must be tif file')))
        if not os.path.exists(input_path):
            # noinspection PyArgumentList
            QMessageBox.warning(
                self.parent, self.tr('InaSAFE'),
                (self.tr('Input file is not exist')))
            return
        if self.radNearest.isChecked():
            my_algorithm = 'nearest'
        else:
            my_algorithm = 'invdist'

        QtGui.qApp.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))

        fileName = convert_mmi_data(
            input_path, output_path,
            algorithm=my_algorithm,
            algorithm_filename_flag=False)

        QtGui.qApp.restoreOverrideCursor()

        if self.cBLoadLayer.isChecked():
            fileInfo = QFileInfo(fileName)
            baseName = fileInfo.baseName()
            layer = QgsRasterLayer(fileName, baseName)
            layer.setGrayBandName(layer.bandName(1))
            layer.setDrawingStyle(QgsRasterLayer.SingleBandPseudoColor)
            layer.setColorShadingAlgorithm(QgsRasterLayer.PseudoColorShader)
            layer.saveDefaultStyle()
            if not layer.isValid():
                LOGGER.debug("Failed to load")
            else:
                # noinspection PyArgumentList
                QgsMapLayerRegistry.instance().addMapLayer(layer)
        self.done(self.Accepted)
示例#5
0
    def accept(self):
        """Handler for when OK is clicked.
        """
        input_path = str(self.input_path.text())
        output_path = str(self.output_path.text())
        if not output_path.endswith('.tif'):
            # noinspection PyArgumentList
            QMessageBox.warning(
                self.parent, self.tr('InaSAFE'),
                (self.tr('Output file name must be tif file')))
        if not os.path.exists(input_path):
            # noinspection PyArgumentList
            QMessageBox.warning(
                self.parent, self.tr('InaSAFE'),
                (self.tr('Input file is not exist')))
            return
        if self.nearest_mode.isChecked():
            my_algorithm = 'nearest'
        else:
            my_algorithm = 'invdist'

        QtGui.qApp.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))

        file_name = convert_mmi_data(
            input_path, output_path,
            algorithm=my_algorithm,
            algorithm_filename_flag=False)

        QtGui.qApp.restoreOverrideCursor()

        if self.load_result.isChecked():
            file_info = QFileInfo(file_name)
            base_name = file_info.baseName()
            layer = QgsRasterLayer(file_name, base_name)
            mmi_ramp(layer)
            layer.saveDefaultStyle()
            if not layer.isValid():
                LOGGER.debug("Failed to load")
            else:
                # noinspection PyArgumentList
                QgsMapLayerRegistry.instance().addMapLayer(layer)
        self.done(self.Accepted)
示例#6
0
    def accept(self):
        """Handler for when OK is clicked.
        """
        input_path = str(self.leInputPath.text())
        output_path = str(self.leOutputPath.text())
        if not output_path.endswith('.tif'):
            # noinspection PyArgumentList
            QMessageBox.warning(self.parent, self.tr('InaSAFE'),
                                (self.tr('Output file name must be tif file')))
        if not os.path.exists(input_path):
            # noinspection PyArgumentList
            QMessageBox.warning(self.parent, self.tr('InaSAFE'),
                                (self.tr('Input file is not exist')))
            return
        if self.radNearest.isChecked():
            my_algorithm = 'nearest'
        else:
            my_algorithm = 'invdist'

        fileName = convert_mmi_data(input_path,
                                    output_path,
                                    the_algorithm=my_algorithm,
                                    algorithm_name=False)
        if self.cBLoadLayer.isChecked():
            fileInfo = QFileInfo(fileName)
            baseName = fileInfo.baseName()
            layer = QgsRasterLayer(fileName, baseName)
            layer.setGrayBandName(layer.bandName(1))
            layer.setDrawingStyle(QgsRasterLayer.SingleBandPseudoColor)
            layer.setColorShadingAlgorithm(QgsRasterLayer.PseudoColorShader)
            layer.saveDefaultStyle()
            if not layer.isValid():
                LOGGER.debug("Failed to load")
            else:
                # noinspection PyArgumentList
                QgsMapLayerRegistry.instance().addMapLayer(layer)
        self.done(self.Accepted)