Python qgis.core.QgsWkbTypes.PointGeometry() Examples
The following are 14
code examples of qgis.core.QgsWkbTypes.PointGeometry().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qgis.core.QgsWkbTypes
, or try the search function
.
Example #1
Source File: shapeTools.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 6 votes |
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)
Example #2
Source File: inspectFeatures.py From DsgTools with GNU General Public License v2.0 | 6 votes |
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()
Example #3
Source File: inspectFeatures.py From DsgTools with GNU General Public License v2.0 | 6 votes |
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))
Example #4
Source File: contour_tool.py From DsgTools with GNU General Public License v2.0 | 6 votes |
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
Example #5
Source File: circle.py From DsgTools with GNU General Public License v2.0 | 6 votes |
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)
Example #6
Source File: polygon.py From DsgTools with GNU General Public License v2.0 | 6 votes |
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()
Example #7
Source File: latLonTools.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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()
Example #8
Source File: QgsVideo.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
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)
Example #9
Source File: QgsVideo.py From QGISFMV with GNU General Public License v3.0 | 5 votes |
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)
Example #10
Source File: inspectFeatures.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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)
Example #11
Source File: dsgRasterInfoTool.py From DsgTools with GNU General Public License v2.0 | 5 votes |
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)
Example #12
Source File: QgsVideo.py From QGISFMV with GNU General Public License v3.0 | 4 votes |
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)
Example #13
Source File: inspectFeatures.py From DsgTools with GNU General Public License v2.0 | 4 votes |
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()
Example #14
Source File: acquisition.py From DsgTools with GNU General Public License v2.0 | 4 votes |
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