示例#1
0
 def __init__(self):
     QtGui.QDialog.__init__(self)
     # Set up the user interface from Designer.
     self.ui = Ui_PointsToPaths()
     self.ui.setupUi(self)
     QtCore.QObject.connect(self.ui.btnBrowse, QtCore.SIGNAL("clicked()"),
                            self.outFile)
     QtCore.QObject.connect(self.ui.inShape,
                            QtCore.SIGNAL("currentIndexChanged(QString)"),
                            self.checkLayer)
     QtCore.QObject.connect(self.ui.inShape,
                            QtCore.SIGNAL("currentIndexChanged(QString)"),
                            self.update)
     self.manageGui()
     self.show()
示例#2
0
 def __init__(self):
     QtGui.QDialog.__init__(self)
     # Set up the user interface from Designer.
     self.ui = Ui_PointsToPaths()
     self.ui.setupUi(self)
     QtCore.QObject.connect( self.ui.btnBrowse, QtCore.SIGNAL( "clicked()" ), self.outFile )
     QtCore.QObject.connect( self.ui.inShape, QtCore.SIGNAL( "currentIndexChanged(QString)" ), self.checkLayer )
     QtCore.QObject.connect( self.ui.inShape, QtCore.SIGNAL( "currentIndexChanged(QString)" ), self.update )
     self.manageGui()
     self.show()
示例#3
0
class PointsToPathsDialog(QtGui.QDialog, Ui_PointsToPaths):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        # Set up the user interface from Designer.
        self.ui = Ui_PointsToPaths()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.btnBrowse, QtCore.SIGNAL("clicked()"),
                               self.outFile)
        QtCore.QObject.connect(self.ui.inShape,
                               QtCore.SIGNAL("currentIndexChanged(QString)"),
                               self.checkLayer)
        QtCore.QObject.connect(self.ui.inShape,
                               QtCore.SIGNAL("currentIndexChanged(QString)"),
                               self.update)
        self.manageGui()
        self.show()

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def checkLayer(self):
        inputLayer = unicode(self.ui.inShape.currentText())
        if inputLayer != "":
            changedLayer = getVectorLayerByName(inputLayer)

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def update(self):
        self.ui.orderField.clear()
        self.ui.attrField.clear()
        inputLayer = unicode(self.ui.inShape.currentText())
        if inputLayer != "":
            changedLayer = getVectorLayerByName(inputLayer)
            changedField = changedLayer.dataProvider().fields()
            for field in changedField:
                name = field.name()
                self.ui.orderField.addItem(name)
                self.ui.attrField.addItem(name)

    # Return list point layer names in QgsMapLayerRegistry
    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def manageGui(self):
        myList = []
        self.ui.inShape.clear()
        myList = getLayerNames([QGis.Point])
        self.ui.inShape.addItems(myList)
        return

    # portions adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def accept(self):
        QtGui
        if self.ui.inShape.currentText() == "":
            QtGui.QMessageBox.warning(self, "PointsToPaths",
                                      self.tr("Please specify an input layer"))
            return
        elif self.ui.attrField.currentText() == "":
            QtGui.QMessageBox.warning(
                self, "PointsToPaths",
                self.tr("Please define specific input field"))
        elif self.ui.orderField.currentText() == "":
            QtGui.QMessageBox.warning(
                self, "PointsToPaths",
                self.tr("Please define specific input field"))
        elif self.getOutFilePath() == "":
            QtGui.QMessageBox.warning(
                self, "PointsToPaths",
                self.tr("Please specify output shapefile"))
        else:
            inputLayer = unicode(self.ui.inShape.currentText())
            layer = getVectorLayerByName(inputLayer)
            provider = layer.dataProvider()
            processor = ProcessFeatures(layer, self.getOutFilePath(),
                                        self.ui.orderField.currentText(),
                                        self.getTimeFormat(),
                                        self.ui.attrField.currentText())
            points = processor.generatePointDict()
            processor.writeShapefile(points, layer.crs(), self.getGapPeriod(),
                                     self.getLinesPerVertex())
            message = unicode(self.tr('Created output shapefile:'))
            message = '\n'.join([message, unicode(self.getOutFilePath())])
            message = '\n'.join([
                message,
                unicode(
                    self.tr('Would you like to add the new layer to the TOC?'))
            ])
            addToTOC = QtGui.QMessageBox.question(self, "PointsToPaths",
                                                  message,
                                                  QtGui.QMessageBox.Yes,
                                                  QtGui.QMessageBox.No,
                                                  QtGui.QMessageBox.NoButton)
            if addToTOC == QtGui.QMessageBox.Yes:
                addShapeToCanvas(unicode(self.getOutFilePath()))

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def outFile(self):
        outFilePath = saveDialog(self)
        if not outFilePath:
            return
        self.setOutFilePath(outFilePath)

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def getOutFilePath(self):
        return self.ui.outShape.text()

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def setOutFilePath(self, outFilePath):
        self.ui.outShape.setText(outFilePath)

    def getTimeFormat(self):
        return self.ui.dateFormat.text()

    def getGapPeriod(self):
        gap_string = self.ui.gapPeriod.text()
        if gap_string != '':
            try:
                gap = float(gap_string)
            except:
                raise ValueError, 'Gap period not a numeric value'
        else:
            gap = None
        return gap

    def getLinesPerVertex(self):
        is_checked = self.ui.linePerVertex.isChecked()
        return is_checked
示例#4
0
class PointsToPathsDialog(QtGui.QDialog,Ui_PointsToPaths):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        # Set up the user interface from Designer.
        self.ui = Ui_PointsToPaths()
        self.ui.setupUi(self)
        QtCore.QObject.connect( self.ui.btnBrowse, QtCore.SIGNAL( "clicked()" ), self.outFile )
        QtCore.QObject.connect( self.ui.inShape, QtCore.SIGNAL( "currentIndexChanged(QString)" ), self.checkLayer )
        QtCore.QObject.connect( self.ui.inShape, QtCore.SIGNAL( "currentIndexChanged(QString)" ), self.update )
        self.manageGui()
        self.show()

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def checkLayer(self):
        inputLayer = unicode( self.ui.inShape.currentText() )
        if inputLayer != "":
            changedLayer = getVectorLayerByName( inputLayer )

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def update(self):
        self.ui.orderField.clear()
        self.ui.attrField.clear()
        inputLayer = unicode( self.ui.inShape.currentText() )
        if inputLayer != "":
            changedLayer = getVectorLayerByName( inputLayer )
            changedField = changedLayer.dataProvider().fields()
            for field in changedField:
                name = field.name()
                self.ui.orderField.addItem(name)
                self.ui.attrField.addItem(name)

    # Return list point layer names in QgsMapLayerRegistry
    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def manageGui(self):
        myList = []
        self.ui.inShape.clear()
        myList = getLayerNames( [ QGis.Point ] )
        self.ui.inShape.addItems( myList )
        return

    # portions adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def accept(self):
        QtGui
        if self.ui.inShape.currentText() == "":
            QtGui.QMessageBox.warning( self, "PointsToPaths", self.tr( "Please specify an input layer" ) )
            return
        elif self.ui.attrField.currentText() == "":
            QtGui.QMessageBox.warning( self, "PointsToPaths", self.tr( "Please define specific input field" ) )
        elif self.ui.orderField.currentText() == "":
            QtGui.QMessageBox.warning( self, "PointsToPaths", self.tr( "Please define specific input field" ) )
        elif self.getOutFilePath() == "":
            QtGui.QMessageBox.warning( self, "PointsToPaths", self.tr( "Please specify output shapefile" ) )
        else:
            inputLayer = unicode( self.ui.inShape.currentText() )
            layer = getVectorLayerByName( inputLayer )
            provider = layer.dataProvider()
            processor = ProcessFeatures(layer, self.getOutFilePath(), self.ui.orderField.currentText(), self.getTimeFormat(), self.ui.attrField.currentText())
            points = processor.generatePointDict()
            processor.writeShapefile(points, layer.crs(), self.getGapPeriod())
            message = unicode(self.tr('Created output shapefile:'))
            message = '\n'.join([message, unicode(self.getOutFilePath())])
            message = '\n'.join([message,unicode(self.tr('Would you like to add the new layer to the TOC?'))])
            addToTOC = QtGui.QMessageBox.question(self, "PointsToPaths", message,
                QtGui.QMessageBox.Yes, QtGui.QMessageBox.No, QtGui.QMessageBox.NoButton)
            if addToTOC == QtGui.QMessageBox.Yes:
                addShapeToCanvas(unicode(self.getOutFilePath()))


    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def outFile(self):
        outFilePath = saveDialog(self)
        if not outFilePath:
            return
        self.setOutFilePath(outFilePath)

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def getOutFilePath(self):
        return self.ui.outShape.text()

    # adopted from 'points2one', Copyright (C) 2010 Pavol Kapusta & Goyo Diaz
    def setOutFilePath(self, outFilePath):
        self.ui.outShape.setText(outFilePath)

    def getTimeFormat(self):
        return self.ui.dateFormat.text()

    def getGapPeriod(self):
        gap_string = self.ui.gapPeriod.text()
        if gap_string != '':
            try:
                gap = float(gap_string)
            except:
                raise ValueError, 'Gap period not a numeric value'
        else:
            gap = None
        return gap