Exemplo n.º 1
0
    def convertXMLToSH(self):
        xml_path = self.xmlsh_xml_path.text()
        sh_dir = self.xmlsh_sh_path.text()
        if xml_path == "" or sh_dir == "":
            self.xmlsh_status.setVisible(True)
            self.xmlsh_status.setText("<font color='red'>Please select XML file and destination directory!<font>")
            return

        formula_x = self.xmlsh_formula_x.text()
        formula_y = self.xmlsh_formula_y.text()
        if formula_x == "" or formula_y == "":
            self.xmlsh_status.setVisible(True)
            self.xmlsh_status.setText("<font color='red'>Please enter the coordinate conversion formular!<font>")
            return

        self.xmlsh_status.setVisible(False)
        self.xmlsh_progress.setVisible(True)
        self.xmlsh_converter_but.setEnabled(False)
        try:
            xmlToShapefile = XmlToShapefile(xml_path, sh_dir, [formula_x, formula_y])
            xmlToShapefile.prog_sig.connect(self.xmlshUpdateProgress)
            xmlToShapefile.run()
        except IOError as e:
            self.xmlsh_status.setVisible(True)
            self.xmlsh_progress.setVisible(False)
            self.xmlsh_converter_but.setEnabled(True)
            self.xmlsh_status.setText("<font color='red'>Error: %s<font>" % e.strerror)

        self.open_sig.emit(sh_dir)
        self.accept()
Exemplo n.º 2
0
    def new(self):
        sh_dir = QFileDialog.getExistingDirectory(None, 'Create new iSim Shapefile Directory', getenv('HOME'))
        if sh_dir == "":
            return
        prefix = path.basename(sh_dir)

        # find the template
        current_full_path = path.realpath(__file__)
        current_dir, current_file = path.split(current_full_path)
        template_dir = path.join(current_dir, "template")

        xml_path = path.join(template_dir, "template.xml")
        xmlToShapefile = XmlToShapefile(xml_path, sh_dir, ["x", "y"])
        xmlToShapefile.run()

        # open layer
        self.open(sh_dir)