當前位置: 首頁>>代碼示例>>Python>>正文


Python QgsWkbTypes.PointGeometry方法代碼示例

本文整理匯總了Python中qgis.core.QgsWkbTypes.PointGeometry方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsWkbTypes.PointGeometry方法的具體用法?Python QgsWkbTypes.PointGeometry怎麽用?Python QgsWkbTypes.PointGeometry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qgis.core.QgsWkbTypes的用法示例。


在下文中一共展示了QgsWkbTypes.PointGeometry方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: enableTools

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def enableTools(self):
        self.digitizeAction.setEnabled(False)
        self.lineDigitizeAction.setEnabled(False)
        self.flipHorizontalAction.setEnabled(False)
        self.flipVerticalAction.setEnabled(False)
        self.rotate180Action.setEnabled(False)
        self.rotate90CWAction.setEnabled(False)
        self.rotate90CCWAction.setEnabled(False)
        layer = self.iface.activeLayer()

        if not layer or not layer.isValid() or (layer.type() != QgsMapLayer.VectorLayer) or not layer.isEditable():
            return
        wkbtype = layer.wkbType()
        geomtype = QgsWkbTypes.geometryType(wkbtype)
        self.lineDigitizeAction.setEnabled(True)
        if geomtype == QgsWkbTypes.PointGeometry or geomtype == QgsWkbTypes.LineGeometry:
            self.digitizeAction.setEnabled(True)
        if geomtype == QgsWkbTypes.LineGeometry or geomtype == QgsWkbTypes.PolygonGeometry:
            self.flipHorizontalAction.setEnabled(True)
            self.flipVerticalAction.setEnabled(True)
            self.rotate180Action.setEnabled(True)
            self.rotate90CWAction.setEnabled(True)
            self.rotate90CCWAction.setEnabled(True) 
開發者ID:NationalSecurityAgency,項目名稱:qgis-shapetools-plugin,代碼行數:25,代碼來源:shapeTools.py

示例2: enableScale

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def enableScale(self):
        """
        The scale combo should only be enabled for point layers
        """
        currentLayer = self.getIterateLayer()
        if QgsMapLayer is not None and currentLayer:
                if currentLayer.type() == QgsMapLayer.VectorLayer:
                    if currentLayer.geometryType() == QgsWkbTypes.PointGeometry:
                        self.mScaleWidget.setEnabled(True)
                        self.mScaleWidget.show()
                        self.zoomPercentageSpinBox.setEnabled(False)
                        self.zoomPercentageSpinBox.hide()
                    else:
                        self.mScaleWidget.setEnabled(False)
                        self.mScaleWidget.hide()
                        self.zoomPercentageSpinBox.setEnabled(True)
                        self.zoomPercentageSpinBox.show() 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:19,代碼來源:inspectFeatures.py

示例3: zoomFeature

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def zoomFeature(self, zoom, idDict = None):
        """
        Zooms to current layer selected features according to a specific zoom
        zoom: zoom to be applied
        """
        idDict = dict() if idDict is None else idDict
        currentLayer = self.getIterateLayer()
        if idDict == {}:
            self.zoomToLayer(currentLayer, zoom=float(zoom))
        else:
            id = idDict['id']
            lyr = idDict['lyr']
            selectIdList = lyr.selectedFeatureIds()
            lyr.removeSelection()
            lyr.selectByIds([id])
            self.zoomToLayer(layer = lyr, zoom=float(zoom))
            lyr.selectByIds(selectIdList)

        if self.getIterateLayer().geometryType() == QgsWkbTypes.PointGeometry:
            self.iface.mapCanvas().zoomScale(float(zoom)) 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:22,代碼來源:inspectFeatures.py

示例4: resetEditingSignals

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def resetEditingSignals(self, currentLayer):
        """
        Disconnects editing signal from previously selected layer and connects it to newly selected layer.
        Method is called whenever currentlLayerChanged signal is emitted.
        """
        # get previous selected layer
        prevLayer = self.currentLayer
        # update current selected layer
        if not currentLayer:
            self.currentLayer = currentLayer
        self.activateAlias = partial(self.activateValueSetter, True)
        self.deactivateAlias = partial(self.activateValueSetter, False)
        if prevLayer:
            try:
                # if there was a previous selection, signals must be disconnected from it before connecting to the new layer
                prevLayer.editingStarted.disconnect(self.activateAlias)
                prevLayer.editingStopped.disconnect(self.deactivateAlias)
            except:
                # in case signal is not yet connected, somehow
                pass
        # connecting signals to new layer
        if isinstance(self.currentLayer, QgsVectorLayer):
            if self.currentLayer.geometryType() == QgsWkbTypes.PointGeometry:
                self.currentLayer.editingStarted.connect(self.activateAlias)
                self.currentLayer.editingStopped.connect(self.deactivateAlias) 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:27,代碼來源:dsgRasterInfoTool.py

示例5: sortFeatures

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def sortFeatures(self, geom, features):
        """
        Sorts features according to the distance
        """
        #sorting by distance
        distances = []
        
        firstPoint = geom.asPolyline()[0]
        pointGeom = QgsGeometry.fromPointXY(firstPoint)

        for intersected in features:
            intersection = geom.intersection(intersected.geometry())
            if intersection.type() == QgsWkbTypes.PointGeometry:
                distance = intersection.distance(pointGeom)
                distances.append((distance, intersected))
        
        ordered = sorted(distances, key=self.getKey)
        #returning a list of tuples (distance, feature)
        return ordered 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:21,代碼來源:contour_tool.py

示例6: enableDigitizeTool

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def enableDigitizeTool(self):
        self.digitizeAction.setEnabled(False)
        layer = self.iface.activeLayer()

        if layer is not None and isinstance(layer, QgsVectorLayer) and (layer.geometryType() == QgsWkbTypes.PointGeometry) and layer.isEditable():
            self.digitizeAction.setEnabled(True)
        else:
            if self.digitizerDialog is not None:
                self.digitizerDialog.close() 
開發者ID:NationalSecurityAgency,項目名稱:qgis-latlontools-plugin,代碼行數:11,代碼來源:latLonTools.py

示例7: RemoveCanvasRubberbands

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def RemoveCanvasRubberbands(self):
        ''' Remove Canvas Rubberbands '''
        self.poly_Canvas_RubberBand.reset()
        self.Track_Canvas_RubberBand.reset(QgsWkbTypes.LineGeometry)
        self.Cursor_Canvas_RubberBand.reset(QgsWkbTypes.PointGeometry) 
開發者ID:All4Gis,項目名稱:QGISFMV,代碼行數:7,代碼來源:QgsVideo.py

示例8: leaveEvent

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def leaveEvent(self, _):
        """
        @type _: QEvent
        @param _:
        @return:
        """
        # Remove coordinates label value
        self.parent.lb_cursor_coord.setText("")
        # Change cursor
        self.setCursor(QCursor(Qt.ArrowCursor))
        # Reset mouse rubberband
        self.Cursor_Canvas_RubberBand.reset(QgsWkbTypes.PointGeometry) 
開發者ID:All4Gis,項目名稱:QGISFMV,代碼行數:14,代碼來源:QgsVideo.py

示例9: setNewId

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def setNewId(self, newId):
        if not isinstance(self.sender(), QSpinBox):
            self.idSpinBox.setValue(newId)
        else:
            currentLayer = self.getIterateLayer()
            lyrName = currentLayer.name()
            if lyrName not in list(self.allLayers.keys()):
                self.allLayers[lyrName] = 0
                return
            oldIndex = self.allLayers[lyrName]
            if oldIndex == 0:
                return
            featIdList = self.getFeatIdList(currentLayer)
            if oldIndex not in featIdList:
                oldIndex = 0
            zoom = self.mScaleWidget.scale() if currentLayer.geometryType() == QgsWkbTypes.PointGeometry else self.zoomPercentageSpinBox.value()
            if oldIndex == newId:
                # self.iface.messageBar().pushMessage(self.tr('Warning!'), self.tr('Selected id does not exist in layer {0}. Returned to previous id.').format(lyrName), level=Qgis.Warning, duration=2)
                return
            try:
                index = featIdList.index(newId)
                self.allLayers[lyrName] = index
                self.makeZoom(zoom, currentLayer, newId)
                self.idSpinBox.setSuffix(' ({0}/{1})'.format(index+1,len(featIdList)))
            except:
                # self.iface.messageBar().pushMessage(self.tr('Warning!'), self.tr('Selected id does not exist in layer {0}. Returned to previous id.').format(lyrName), level=Qgis.Warning, duration=2)
                self.idSpinBox.setValue(oldIndex)
                self.makeZoom(zoom, currentLayer, oldIndex) 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:30,代碼來源:inspectFeatures.py

示例10: canvasMoveEvent

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def canvasMoveEvent(self, event):
        if self.snapCursorRubberBand:
            self.snapCursorRubberBand.hide()
            self.snapCursorRubberBand.reset(geometryType=QgsWkbTypes.PointGeometry)
            self.snapCursorRubberBand = None
        oldPoint = QgsPointXY(event.mapPoint())
        event.snapPoint()
        point = QgsPointXY(event.mapPoint())
        if oldPoint != point:
            self.createSnapCursor(point)
        if self.startPoint:
            self.endPoint = QgsPointXY(event.mapPoint())
            self.showCircle(self.startPoint, self.endPoint) 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:15,代碼來源:circle.py

示例11: canvasMoveEvent

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def canvasMoveEvent(self, event):
        if self.snapCursorRubberBand:
            self.snapCursorRubberBand.hide()
            self.snapCursorRubberBand.reset(geometryType=QgsWkbTypes.PointGeometry)
            self.snapCursorRubberBand = None
        oldPoint = QgsPointXY(event.mapPoint())
        event.snapPoint()
        point = QgsPointXY(event.mapPoint())
        if oldPoint != point:
            self.createSnapCursor(point)
        if self.rubberBand:
            if self.qntPoint == 1:
                self.distanceToolTip.canvasMoveEvent(self.geometry[0], point)
                geom = QgsGeometry.fromPolylineXY([self.geometry[0], point])
                self.rubberBand.setToGeometry(geom, None)
            elif self.qntPoint >= 2:                
                if self.free:
                    self.distanceToolTip.canvasMoveEvent(self.geometry[-1], point)
                    geom = QgsGeometry.fromPolygonXY([self.geometry+[QgsPointXY(point.x(), point.y())]])
                    self.rubberBand.setToGeometry(geom, None)
                else:   
                    if (self.qntPoint % 2 == 1): 
                        self.setAvoidStyleSnapRubberBand()
                    else:
                        self.setAllowedStyleSnapRubberBand()     
                    projectedMousePoint = self.projectPoint(self.geometry[-2], self.geometry[-1], point)
                    self.distanceToolTip.canvasMoveEvent(self.geometry[-1], projectedMousePoint)
                    if projectedMousePoint:
                        geom, pf = self.completePolygon(self.geometry, projectedMousePoint)
                        self.rubberBand.setToGeometry(geom, None)
        else:
            self.initVariable() 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:34,代碼來源:polygon.py

示例12: setToolEnabled

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def setToolEnabled(self):
        layer = self.iface.activeLayer()  
        if not isinstance(layer, QgsVectorLayer) or layer.geometryType() == QgsWkbTypes.PointGeometry or not layer.isEditable():
            enabled = False
        else:
            enabled = True
        if not enabled and self.tool:
            self.tool.deactivate()
        if self.polygonAction:
            self.polygonAction.setEnabled(enabled)
        if self.circleAction:
            self.circleAction.setEnabled(enabled)
        return enabled 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:15,代碼來源:acquisition.py

示例13: __init__

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def __init__(self, parent=None):
        ''' Constructor '''
        super().__init__(parent)
        self.surface = VideoWidgetSurface(self)
        self.setAttribute(Qt.WA_OpaquePaintEvent)

        self.Tracking_Video_RubberBand = QRubberBand(QRubberBand.Rectangle, self)
        self.Censure_RubberBand = QRubberBand(QRubberBand.Rectangle, self)

        color_blue = QColor(Qt.blue)
        color_black = QColor(Qt.black)
        color_amber = QColor(252, 215, 108)

        pal_blue = QPalette()
        pal_blue.setBrush(QPalette.Highlight, QBrush(color_blue))
        self.Tracking_Video_RubberBand.setPalette(pal_blue)

        pal_black = QPalette()
        pal_black.setBrush(QPalette.Highlight, QBrush(color_black))
        self.Censure_RubberBand.setPalette(pal_black)

        self._interaction = InteractionState()
        self._filterSatate = FilterState()

        self._isinit = False
        self._MGRS = False
        self.gt = None

        self.drawCesure = []
        self.poly_coordinates, self.drawPtPos, self.drawLines, self.drawMeasureDistance, self.drawMeasureArea, self.drawPolygon = [], [], [], [], [], []
        # Draw Polygon Canvas Rubberband
        self.poly_Canvas_RubberBand = QgsRubberBand(
            iface.mapCanvas(), True)  # Polygon type
        # set rubber band style
        self.poly_Canvas_RubberBand.setColor(color_amber)
        self.poly_Canvas_RubberBand.setWidth(3)

        # Tracking Canvas Rubberband
        self.Track_Canvas_RubberBand = QgsRubberBand(
            iface.mapCanvas(), QgsWkbTypes.LineGeometry)
        # set rubber band style
        self.Track_Canvas_RubberBand.setColor(color_blue)
        self.Track_Canvas_RubberBand.setWidth(5)

        # Cursor Canvas Rubberband
        self.Cursor_Canvas_RubberBand = QgsRubberBand(
            iface.mapCanvas(), QgsWkbTypes.PointGeometry)
        self.Cursor_Canvas_RubberBand.setWidth(4)
        self.Cursor_Canvas_RubberBand.setColor(QColor(255, 100, 100, 250))
        self.Cursor_Canvas_RubberBand.setIcon(QgsRubberBand.ICON_FULL_DIAMOND)

        self.parent = parent.parent()

        palette = self.palette()
        palette.setColor(QPalette.Background, Qt.transparent)
        self.setPalette(palette)

        self.origin, self.dragPos = QPoint(), QPoint()
        self.tapTimer = QBasicTimer()
        self.brush = QBrush(color_black)
        self.blue_Pen = QPen(color_blue, 3) 
開發者ID:All4Gis,項目名稱:QGISFMV,代碼行數:63,代碼來源:QgsVideo.py

示例14: iterateFeature

# 需要導入模塊: from qgis.core import QgsWkbTypes [as 別名]
# 或者: from qgis.core.QgsWkbTypes import PointGeometry [as 別名]
def iterateFeature(self, method):
        """
        Iterates over the features selecting and zooming to the desired one
        method: method used to determine the desired feature index
        """
        currentLayer = self.getIterateLayer()
        lyrName = currentLayer.name()
        
        zoom = self.mScaleWidget.scale() if currentLayer.geometryType() == QgsWkbTypes.PointGeometry else self.zoomPercentageSpinBox.value()
        
        featIdList = self.getFeatIdList(currentLayer)
        
        if currentLayer and len(featIdList) > 0:
            #checking if this is the first time for this layer (currentLayer)
            first = False
            if lyrName not in list(self.allLayers.keys()):
                self.allLayers[lyrName] = 0
                first = True

            #getting the current index
            index = self.allLayers[lyrName]

            #getting max and min ids
            #this was made because the list is already sorted, there's no need to calculate max and min
            maxIndex = len(featIdList) - 1
            minIndex = 0
            
            self.idSpinBox.setMaximum(featIdList[maxIndex])
            self.idSpinBox.setMinimum(featIdList[minIndex])

            #getting the new index
            if not first:
                index = method(index, maxIndex, minIndex)
            self.idSpinBox.setSuffix(' ({0}/{1})'.format(index+1,len(featIdList)))
            self.allLayers[lyrName] = index

            #getting the new feature id
            id = featIdList[index]

            #adjustin the spin box value
            self.idxChanged.emit(id)

            self.makeZoom(zoom, currentLayer, id)
            self.selectLayer(id, currentLayer)
        else:
            self.errorMessage() 
開發者ID:dsgoficial,項目名稱:DsgTools,代碼行數:48,代碼來源:inspectFeatures.py


注:本文中的qgis.core.QgsWkbTypes.PointGeometry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。