示例#1
0
    def exportTxt(self):
        delimiter = self.__getDelimiter()
        decimalDelimiter = self.__getDecimalDelimiter()
        if delimiter == decimalDelimiter:
            msg = QApplication.translate(
                'code', 'Gleiches Dezimal- und Spaltentrennzeichen gewählt!',
                None, QApplication.UnicodeUTF8)
            QMessageBox.warning(self.iface.mainWindow(), 'VoGIS-Profiltool',
                                msg)
            return

        u = Util(self.iface)
        caption = QApplication.translate('code', 'Textdatei exportieren', None,
                                         QApplication.UnicodeUTF8)
        fileName, file_ext = u.getFileName(caption, [["txt", "txt"]],
                                           self.filePath)
        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        hekto = (self.ui.IDC_chkHekto.checkState() == Qt.Checked)
        attribs = (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked)
        txt = open(fileName, 'w')

        txt.write(self.profiles[0].writeHeader(
            self.settings.mapData.rasters.selectedRasters(), hekto, attribs,
            delimiter))
        for p in self.profiles:
            #txt.write('=====Profil {0}======{1}'.format(p.id, os.linesep))
            #txt.write('Segments:{0}{1}'.format(len(p.segments), os.linesep))
            #for s in p.segments:
            #    txt.write('Vertices:{0}{1}'.format(len(s.vertices), os.linesep))
            txt.write(p.toString(hekto, attribs, delimiter, decimalDelimiter))
        txt.close()
示例#2
0
    def __exportShp(self, asPnt):

        u = Util(self.iface)
        if asPnt is True:
            caption = QApplication.translate('code',
                                             'Punkt Shapefile exportieren',
                                             None, QApplication.UnicodeUTF8)
        else:
            caption = QApplication.translate('code',
                                             'Linien Shapefile exportieren',
                                             None, QApplication.UnicodeUTF8)
        fileName, file_ext = u.getFileName(caption, [["shp", "shp"]],
                                           self.filePath)
        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        expShp = ExportShape(
            self.iface, (self.ui.IDC_chkHekto.checkState() == Qt.Checked),
            (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked),
            self.__getDelimiter(), self.__getDecimalDelimiter(), fileName,
            self.settings, self.profiles)
        if asPnt is False:
            expShp.exportLine()
        else:
            expShp.exportPoint()
示例#3
0
    def exportTxt(self):
        delimiter = self.__getDelimiter()
        decimalDelimiter = self.__getDecimalDelimiter()
        if delimiter == decimalDelimiter:
            msg = QApplication.translate('code', 'Gleiches Dezimal- und Spaltentrennzeichen gewählt!', None, QApplication.UnicodeUTF8)
            QMessageBox.warning(self.iface.mainWindow(), 'VoGIS-Profiltool', msg)
            return

        u = Util(self.iface)
        caption = QApplication.translate('code', 'Textdatei exportieren', None, QApplication.UnicodeUTF8)
        fileName = u.getFileName(caption, [["txt", "txt"]], self.filePath)
        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        hekto = (self.ui.IDC_chkHekto.checkState() == Qt.Checked)
        attribs = (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked)
        txt = open(fileName, 'w')

        txt.write(self.profiles[0].writeHeader(self.settings.mapData.rasters.selectedRasters(), hekto, attribs, delimiter))
        for p in self.profiles:
            #txt.write('=====Profil {0}======{1}'.format(p.id, os.linesep))
            #txt.write('Segments:{0}{1}'.format(len(p.segments), os.linesep))
            #for s in p.segments:
            #    txt.write('Vertices:{0}{1}'.format(len(s.vertices), os.linesep))
            txt.write(p.toString(hekto,
                                 attribs,
                                 delimiter,
                                 decimalDelimiter
                                 ))

        txt.close()
示例#4
0
    def __exportShp(self, asPnt):

        u = Util(self.iface)
        if asPnt is True:
            caption = QApplication.translate('code', 'Punkt Shapefile exportieren', None, QApplication.UnicodeUTF8)
        else:
            caption = QApplication.translate('code', 'Linien Shapefile exportieren', None, QApplication.UnicodeUTF8)
        fileName = u.getFileName(caption, [["shp", "shp"]], self.filePath)
        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        expShp = ExportShape(self.iface,
                             (self.ui.IDC_chkHekto.checkState() == Qt.Checked),
                             (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked),
                             self.__getDelimiter(),
                             self.__getDecimalDelimiter(),
                             fileName,
                             self.settings,
                             self.profiles
                             )
        if asPnt is False:
            expShp.exportLine()
        else:
            expShp.exportPoint()
示例#5
0
    def exportCsvXls(self):
        u = Util(self.iface)
        caption = QApplication.translate('code', 'CSV-datei exportieren', None, QApplication.UnicodeUTF8)
        fileName = u.getFileName(caption, [["csv", "csv"]], self.filePath)
        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        hekto = (self.ui.IDC_chkHekto.checkState() == Qt.Checked)
        attribs = (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked)
        delimiter = ';'
        decimalDelimiter = self.__getDecimalDelimiter()

        txt = open(fileName, 'w')

        txt.write(self.profiles[0].writeHeader(self.settings.mapData.rasters.selectedRasters(), hekto, attribs, delimiter))
        for p in self.profiles:
            #txt.write('=====Profil {0}======{1}'.format(p.id, os.linesep))
            #txt.write('Segments:{0}{1}'.format(len(p.segments), os.linesep))
            #for s in p.segments:
            #    txt.write('Vertices:{0}{1}'.format(len(s.vertices), os.linesep))
            txt.write(p.toString(hekto,
                                 attribs,
                                 delimiter,
                                 decimalDelimiter
                                 ))
示例#6
0
    def exportCsvXls(self):
        u = Util(self.iface)
        caption = QApplication.translate('code', 'CSV-datei exportieren', None,
                                         QApplication.UnicodeUTF8)
        fileName = u.getFileName(caption, [["csv", "csv"]], self.filePath)
        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        hekto = (self.ui.IDC_chkHekto.checkState() == Qt.Checked)
        attribs = (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked)
        delimiter = ';'
        decimalDelimiter = self.__getDecimalDelimiter()

        txt = open(fileName, 'w')

        txt.write(self.profiles[0].writeHeader(
            self.settings.mapData.rasters.selectedRasters(), hekto, attribs,
            delimiter))
        for p in self.profiles:
            #txt.write('=====Profil {0}======{1}'.format(p.id, os.linesep))
            #txt.write('Segments:{0}{1}'.format(len(p.segments), os.linesep))
            #for s in p.segments:
            #    txt.write('Vertices:{0}{1}'.format(len(s.vertices), os.linesep))
            txt.write(p.toString(hekto, attribs, delimiter, decimalDelimiter))
    def exportCsvXls(self):
        u = Util(self.iface)
        caption = QApplication.translate("code", "Excel- oder CSV-Datei exportieren", None, QApplication.UnicodeUTF8)
        file_format = []
        file_format.append(["Microsoft Excel 2007/2010 XML", "xlsx"])
        file_format.append(["Comma-Separated Values CSV", "csv"])

        fileName, fileExt = u.getFileName(caption, file_format, self.filePath)
        QgsMessageLog.logMessage(u"fileName: {0} fileExt:{1}".format(fileName, fileExt), "VoGis")

        if fileName == "":
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        hekto = self.ui.IDC_chkHekto.checkState() == Qt.Checked
        attribs = self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked
        delimiter = ";"
        decimalDelimiter = self.__getDecimalDelimiter()

        if fileExt == "csv":
            txt = open(fileName, "w")
            txt.write(
                self.profiles[0].writeHeader(self.settings.mapData.rasters.selectedRasters(), hekto, attribs, delimiter)
            )
            for p in self.profiles:
                # txt.write('=====Profil {0}======{1}'.format(p.id, os.linesep))
                # txt.write('Segments:{0}{1}'.format(len(p.segments), os.linesep))
                # for s in p.segments:
                #    txt.write('Vertices:{0}{1}'.format(len(s.vertices), os.linesep))
                txt.write(p.toString(hekto, attribs, delimiter, decimalDelimiter))
        else:
            # BEGIN XLSX-Export
            exXls = ExportXls(self.iface, fileName, self.settings, self.profiles, hekto, attribs, decimalDelimiter)
            exXls.create()
示例#8
0
 def exportAutoCadTxt(self):
     u = Util(self.iface)
     caption = QApplication.translate('code', 'AutoCad Textdatei exportieren', None, QApplication.UnicodeUTF8)
     fileName = u.getFileName(caption, [["txt", "txt"]], self.filePath)
     if fileName == '':
         return
     fInfo = QFileInfo(fileName)
     self.filePath = fInfo.path()
     QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
     txt = open(fileName, 'w')
     for p in self.profiles:
         txt.write(p.toACadTxt(' ', '.'))
     txt.close()
示例#9
0
 def __exportDxf(self, asPnt):
     u = Util(self.iface)
     caption = QApplication.translate('code', 'DXF exportieren', None, QApplication.UnicodeUTF8)
     fileName = u.getFileName(caption, [["dxf", "dxf"]], self.filePath)
     if fileName == '':
         return
     fInfo = QFileInfo(fileName)
     self.filePath = fInfo.path()
     QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
     exDxf = ExportDxf(self.iface, fileName, self.settings, self.profiles)
     if asPnt is True:
         exDxf.exportPoint()
     else:
         exDxf.exportLine()
示例#10
0
 def __exaggerationEdited(self, *args):
     if self.debug: QgsMessageLog.logMessage('__exaggerationEdited, exaggerationEdited:{0} drawEventFired: {1}'.format(self.exaggerationEdited, self.drawEventFired), 'VoGis')
     #this event handler seems to get called twice????
     if self.drawEventFired == True: return
     if self.exaggerationEdited == True: return
     self.exaggerationEdited = True
     #QgsMessageLog.logMessage('__exaggerationEdited: {0}'.format(self.exaggerationEdited), 'VoGis')
     ut = Util(self.iface)
     txtExa = QApplication.translate('code', 'Überhöhung', None, QApplication.UnicodeUTF8)
     if ut.isFloat(self.editExaggeration.text(), txtExa) is False:
         return False
     #clear focus of lineedit, otherwise it gets called even when the user wants to close the dialog
     self.editExaggeration.clearFocus()
     exa = float(self.editExaggeration.text().replace(',', '.'))
     self.__adjustAxes(exa)
示例#11
0
 def __exportDxf(self, asPnt):
     u = Util(self.iface)
     caption = QApplication.translate('code', 'DXF exportieren', None,
                                      QApplication.UnicodeUTF8)
     fileName = u.getFileName(caption, [["dxf", "dxf"]], self.filePath)
     if fileName == '':
         return
     fInfo = QFileInfo(fileName)
     self.filePath = fInfo.path()
     QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
     exDxf = ExportDxf(self.iface, fileName, self.settings, self.profiles)
     if asPnt is True:
         exDxf.exportPoint()
     else:
         exDxf.exportLine()
示例#12
0
 def exportAutoCadTxt(self):
     u = Util(self.iface)
     caption = QApplication.translate('code',
                                      'AutoCad Textdatei exportieren', None,
                                      QApplication.UnicodeUTF8)
     fileName = u.getFileName(caption, [["txt", "txt"]], self.filePath)
     if fileName == '':
         return
     fInfo = QFileInfo(fileName)
     self.filePath = fInfo.path()
     QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
     txt = open(fileName, 'w')
     for p in self.profiles:
         txt.write(p.toACadTxt(' ', '.'))
     txt.close()
示例#13
0
    def __getSettingsFromGui(self):
        self.settings.linesExplode = (self.ui.IDC_chkLinesExplode.checkState() == Qt.Checked)
        self.settings.linesMerge = (self.ui.IDC_chkLinesMerge.checkState() == Qt.Checked)
        self.settings.onlySelectedFeatures = (self.ui.IDC_chkOnlySelectedFeatures.checkState() == Qt.Checked)
        self.settings.equiDistance = self.ui.IDC_dblspinDistance.value()
        self.settings.vertexCnt = self.ui.IDC_dblspinVertexCnt.value()
        #self.settings.createHekto = (self.ui.IDC_chkCreateHekto.checkState() == Qt.Checked)
        self.settings.nodesAndVertices = (self.ui.IDC_chkNodesAndVertices.checkState() == Qt.Checked)

        if QGis.QGIS_VERSION_INT < 10900:
            self.settings.mapData.selectedLineLyr = (self.ui.IDC_cbLineLayers.itemData(
                                                     self.ui.IDC_cbLineLayers.currentIndex()
                                                     ).toPyObject()
                                                     )
        else:
            self.settings.mapData.selectedLineLyr = (self.ui.IDC_cbLineLayers.itemData(self.ui.IDC_cbLineLayers.currentIndex()))

        if self.settings.onlySelectedFeatures is True and self.settings.mapData.selectedLineLyr.line.selectedFeatureCount() < 1:
            QMessageBox.warning(self.iface.mainWindow(), "VoGIS-Profiltool", QApplication.translate('code', u'Der gewählte Layer hat keine selektierten Elemente.', None, QApplication.UnicodeUTF8))
            return False

        if self.ui.IDC_rbDigi.isChecked():
            self.settings.modeLine = enumModeLine.customLine
        elif self.ui.IDC_rbShapeLine.isChecked():
            self.settings.modeLine = enumModeLine.line
        else:
            #self.ui.IDC_rbStraigthLine
            self.settings.modeLine = enumModeLine.straightLine

        if self.ui.IDC_rbEquiDistance.isChecked():
            self.settings.modeVertices = enumModeVertices.equiDistant
        else:
            self.settings.modeVertices = enumModeVertices.vertexCnt

        if self.ui.IDC_rbStraigthLine.isChecked():
            ut = Util(self.iface)
            if ut.isFloat(self.ui.IDC_tbFromX.text(), QApplication.translate('code', 'Rechtswert von', None, QApplication.UnicodeUTF8)) is False:
                return False
            else:
                fromX = float(self.ui.IDC_tbFromX.text())
            if ut.isFloat(self.ui.IDC_tbFromY.text(), QApplication.translate('code', 'Hochwert von', None, QApplication.UnicodeUTF8)) is False:
                return False
            else:
                fromY = float(self.ui.IDC_tbFromY.text())
            if ut.isFloat(self.ui.IDC_tbToX.text(), QApplication.translate('code', 'Rechtswert nach', None, QApplication.UnicodeUTF8)) is False:
                return False
            else:
                toX = float(self.ui.IDC_tbToX.text())
            if ut.isFloat(self.ui.IDC_tbToY.text(), QApplication.translate('code', 'Hochwert nach', None, QApplication.UnicodeUTF8)) is False:
                return False
            else:
                toY = float(self.ui.IDC_tbToY.text())

            fromPnt = QgsPoint(fromX, fromY)
            toPnt = QgsPoint(toX, toY)

            self.settings.mapData.customLine = ut.createQgLineFeature([fromPnt, toPnt])

        return True
示例#14
0
 def __exaggerationEdited(self, *args):
     if self.debug:
         QgsMessageLog.logMessage(
             '__exaggerationEdited, exaggerationEdited:{0} drawEventFired: {1}'
             .format(self.exaggerationEdited, self.drawEventFired), 'VoGis')
     #this event handler seems to get called twice????
     if self.drawEventFired == True: return
     if self.exaggerationEdited == True: return
     self.exaggerationEdited = True
     #QgsMessageLog.logMessage('__exaggerationEdited: {0}'.format(self.exaggerationEdited), 'VoGis')
     ut = Util(self.iface)
     txtExa = QApplication.translate('code', 'Überhöhung', None,
                                     QApplication.UnicodeUTF8)
     if ut.isFloat(self.editExaggeration.text(), txtExa) is False:
         return False
     #clear focus of lineedit, otherwise it gets called even when the user wants to close the dialog
     self.editExaggeration.clearFocus()
     exa = float(self.editExaggeration.text().replace(',', '.'))
     self.__adjustAxes(exa)
示例#15
0
    def exportCsvXls(self):
        u = Util(self.iface)
        caption = QApplication.translate('code',
                                         'Excel- oder CSV-Datei exportieren',
                                         None, QApplication.UnicodeUTF8)
        file_format = []
        file_format.append(["Microsoft Excel 2007/2010 XML", "xlsx"])
        file_format.append(["Comma-Separated Values CSV", "csv"])

        fileName, fileExt = u.getFileName(caption, file_format, self.filePath)
        QgsMessageLog.logMessage(
            u'fileName: {0} fileExt:{1}'.format(fileName, fileExt), 'VoGis')

        if fileName == '':
            return
        fInfo = QFileInfo(fileName)
        self.filePath = fInfo.path()
        QSettings().setValue("vogisprofiltoolmain/savepath", self.filePath)
        hekto = (self.ui.IDC_chkHekto.checkState() == Qt.Checked)
        attribs = (self.ui.IDC_chkLineAttributes.checkState() == Qt.Checked)
        delimiter = ';'
        decimalDelimiter = self.__getDecimalDelimiter()

        if fileExt == 'csv':
            txt = open(fileName, 'w')
            txt.write(self.profiles[0].writeHeader(
                self.settings.mapData.rasters.selectedRasters(), hekto,
                attribs, delimiter))
            for p in self.profiles:
                #txt.write('=====Profil {0}======{1}'.format(p.id, os.linesep))
                #txt.write('Segments:{0}{1}'.format(len(p.segments), os.linesep))
                #for s in p.segments:
                #    txt.write('Vertices:{0}{1}'.format(len(s.vertices), os.linesep))
                txt.write(
                    p.toString(hekto, attribs, delimiter, decimalDelimiter))
        else:
            # BEGIN XLSX-Export
            exXls = ExportXls(self.iface, fileName, self.settings,
                              self.profiles, hekto, attribs, decimalDelimiter)
            exXls.create()
示例#16
0
 def __createDigiFeature(self, pnts):
     u = Util(self.iface)
     f = u.createQgLineFeature(pnts)
     self.settings.mapData.customLine = f