本文整理汇总了Python中qgis.core.QgsWkbTypes.LineGeometry方法的典型用法代码示例。如果您正苦于以下问题:Python QgsWkbTypes.LineGeometry方法的具体用法?Python QgsWkbTypes.LineGeometry怎么用?Python QgsWkbTypes.LineGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsWkbTypes
的用法示例。
在下文中一共展示了QgsWkbTypes.LineGeometry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: highlight
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def highlight(self, point):
currExt = self.canvas.extent()
leftPt = QgsPoint(currExt.xMinimum(), point.y())
rightPt = QgsPoint(currExt.xMaximum(), point.y())
topPt = QgsPoint(point.x(), currExt.yMaximum())
bottomPt = QgsPoint(point.x(), currExt.yMinimum())
horizLine = QgsGeometry.fromPolyline([leftPt, rightPt])
vertLine = QgsGeometry.fromPolyline([topPt, bottomPt])
self.crossRb.reset(QgsWkbTypes.LineGeometry)
self.crossRb.addGeometry(horizLine, None)
self.crossRb.addGeometry(vertLine, None)
QTimer.singleShot(700, self.resetRubberbands)
示例2: enableTools
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [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)
示例3: canvasPressEvent
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def canvasPressEvent(self, event):
'''Capture the coordinate when the mouse button has been released.'''
pt = self.snappoint(event.originalPixelPoint())
self.removeVertexMarker()
layer = self.iface.activeLayer()
if layer is None:
return
if self.lineDigitizerDialog is None:
from .lineDigitizer import LineDigitizerWidget
self.lineDigitizerDialog = LineDigitizerWidget(self.iface, self.iface.mainWindow())
if layer.geometryType() == QgsWkbTypes.LineGeometry:
self.lineDigitizerDialog.closeLineCheckBox.setEnabled(True)
else:
self.lineDigitizerDialog.closeLineCheckBox.setEnabled(False)
try:
canvasCRS = self.canvas.mapSettings().destinationCrs()
transform = QgsCoordinateTransform(canvasCRS, epsg4326, QgsProject.instance())
pt4326 = transform.transform(pt.x(), pt.y())
self.lineDigitizerDialog.setPoint(pt4326)
self.lineDigitizerDialog.valuesTextEdit.clear()
self.lineDigitizerDialog.show()
except Exception:
self.iface.messageBar().pushMessage("", tr("Clicked location is invalid"), level=Qgis.Warning, duration=4)
示例4: __init__
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def __init__(self, iface):
self.iface = iface
self.canvas = iface.mapCanvas()
self.crossRb = QgsRubberBand(self.canvas, QgsWkbTypes.LineGeometry)
self.crossRb.setColor(Qt.red)
self.provider = LatLonToolsProvider()
self.toolbar = self.iface.addToolBar('Lat Lon Tools Toolbar')
self.toolbar.setObjectName('LatLonToolsToolbar')
示例5: RemoveCanvasRubberbands
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [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)
示例6: populateLayers
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def populateLayers(self):
"""
Populates the layer combo box
"""
self.layerCombo.clear()
self.layerCombo.addItem(self.tr('Select a Layer'))
layers = self.iface.mapCanvas().layers()
for layer in layers:
if isinstance(layer, QgsVectorLayer) and layer.geometryType() == QgsWkbTypes.LineGeometry:
self.layerCombo.addItem(layer.name())
示例7: reset
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def reset(self):
"""
Resets the tool
"""
if self.rubberBand:
self.rubberBand.reset(QgsWkbTypes.LineGeometry)
self.isEmittingPoint = False
self.defineRubberBand()
示例8: setToolEnabled
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def setToolEnabled(self, layer=None):
"""
Checks if it is possible to use tool given layer editting conditions and type.
:param layer: (QgsVectorLayer) layer that may have its lines flipped.
:return: (bool) whether tool may be used.
"""
if not isinstance(layer, QgsVectorLayer):
layer = self.iface.mapCanvas().currentLayer()
if not layer or not isinstance(layer, QgsVectorLayer) or layer.geometryType() != QgsWkbTypes.LineGeometry or not layer.isEditable():
enabled = False
else:
enabled = True
self.toolAction.setEnabled(enabled) if self.toolAction else None
return enabled
示例9: endGeometry
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def endGeometry(self):
if len(self.geometry) > 2:
if self.iface.activeLayer().geometryType() == QgsWkbTypes.PolygonGeometry:
geom = QgsGeometry.fromPolygonXY([self.geometry])
elif self.iface.activeLayer().geometryType() == QgsWkbTypes.LineGeometry:
geom = QgsGeometry.fromPolylineXY(self.geometry)
self.rubberBand.setToGeometry(geom, self.iface.activeLayer())
self.createGeometry(geom)
示例10: endGeometryFree
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [as 别名]
def endGeometryFree(self):
if len(self.geometry) > 2:
if self.iface.activeLayer().geometryType() == QgsWkbTypes.PolygonGeometry:
geom = QgsGeometry.fromPolygonXY([self.geometry])
elif self.iface.activeLayer().geometryType() == QgsWkbTypes.LineGeometry:
geom = QgsGeometry.fromPolylineXY(self.geometry + [self.geometry[0]])
self.rubberBand.setToGeometry(geom, self.iface.activeLayer())
self.createGeometry(geom)
示例11: __init__
# 需要导入模块: from qgis.core import QgsWkbTypes [as 别名]
# 或者: from qgis.core.QgsWkbTypes import LineGeometry [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)