本文整理汇总了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)
示例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()
示例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))
示例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)
示例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
示例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()
示例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)
示例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)
示例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)
示例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)
示例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()
示例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
示例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)
示例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()