本文整理汇总了Python中qgis.core.QgsPoint方法的典型用法代码示例。如果您正苦于以下问题:Python core.QgsPoint方法的具体用法?Python core.QgsPoint怎么用?Python core.QgsPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core
的用法示例。
在下文中一共展示了core.QgsPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: highlight
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [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: commitProject
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitProject(self):
projCRS = self.canvas.mapSettings().destinationCrs()
text = self.projLineEdit.text().strip()
try:
if projCRS == epsg4326:
lat, lon = parseDMSString(text, self.inputXYOrder)
else:
coords = re.split(r'[\s,;:]+', text, 1)
if len(coords) < 2:
self.showInvalid(1)
return
if self.inputXYOrder == 0: # Lat, Lon
lat = float(coords[0])
lon = float(coords[1])
else: # Lon, Lat
lon = float(coords[0])
lat = float(coords[1])
except Exception:
self.showInvalid(1)
return
pt = QgsPoint(lon, lat)
self.updateCoordinates(1, pt, projCRS)
示例3: commitCustom
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitCustom(self):
customCRS = self.customProjectionSelectionWidget.crs()
text = self.customLineEdit.text().strip()
try:
if customCRS == epsg4326:
lat, lon = parseDMSString(text, self.inputXYOrder)
else:
coords = re.split(r'[\s,;:]+', text, 1)
if len(coords) < 2:
self.showInvalid(2)
return
if self.inputXYOrder == 0: # Lat, Lon
lat = float(coords[0])
lon = float(coords[1])
else: # Lon, Lat
lon = float(coords[0])
lat = float(coords[1])
except Exception:
self.showInvalid(2)
return
pt = QgsPoint(lon, lat)
self.updateCoordinates(2, pt, customCRS)
示例4: set_feature_vertex_marker
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def set_feature_vertex_marker(map_canvas, lon, lat, color=VERTEX_COLOR):
"""
Sets single feature vertex
:param map_canvas: Map canvas object
:param lat: Vertex latitude value
:param lon: Vertex longitude value
:param color: Vertex color
:return marker: Vertex object
:rtype marker: Object
"""
marker = q_gui.QgsVertexMarker(map_canvas)
marker.setCenter(q_core.QgsPoint(lon, lat))
marker.setColor(qg.QColor(color))
marker.setIconType(q_gui.QgsVertexMarker.ICON_CIRCLE)
marker.setPenWidth(4)
return marker
示例5: project_point_on_line
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def project_point_on_line(pt, line):
""" Projects point onto line, needed for compatibility computation """
v0 = line.vertexAt(0)
v1 = line.vertexAt(1)
length = max(line.length(), 10**(-6))
r = ((v0.y() - pt.y()) * (v0.y() - v1.y()) -
(v0.x() - pt.x()) * (v1.x() - v0.x())) / (length**2)
return QgsPoint(v0.x() + r * (v1.x() - v0.x()), v0.y() + r * (v1.y() - v0.y()))
# ------------------------------------ EDGE-CLUSTER ------------------------------------ #
示例6: project_point_on_line
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def project_point_on_line(pt, line):
""" Projects point onto line, needed for compatibility computation """
v0 = line.vertexAt(0)
v1 = line.vertexAt(1)
length = max(line.length(), 10**(-6))
r = ((v0.y() - pt.y()) * (v0.y() - v1.y()) -
(v0.x() - pt.x()) * (v1.x() - v0.x())) / (length**2)
return QgsPoint(v0.x() + r * (v1.x() - v0.x()), v0.y() + r * (v1.y() - v0.y()))
# ------------------------------------ EDGE-CLUSTER ------------------------------------ #
示例7: commitWgs84
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitWgs84(self):
text = self.wgs84LineEdit.text().strip()
try:
lat, lon = parseDMSString(text, self.inputXYOrder)
pt = QgsPoint(lon, lat)
self.updateCoordinates(0, pt, epsg4326)
except Exception:
# traceback.print_exc()
self.showInvalid(0)
示例8: commitDms
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitDms(self):
text = self.dmsLineEdit.text().strip()
try:
lat, lon = parseDMSString(text, self.inputXYOrder)
pt = QgsPoint(lon, lat)
self.updateCoordinates(3, pt, epsg4326)
except Exception:
self.showInvalid(3)
示例9: commitDdmmss
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitDdmmss(self):
text = self.ddmmssLineEdit.text().strip()
try:
lat, lon = parseDMSString(text, self.inputXYOrder)
pt = QgsPoint(lon, lat)
self.updateCoordinates(5, pt, epsg4326)
except Exception:
self.showInvalid(5)
示例10: commitUtm
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitUtm(self):
text = self.utmLineEdit.text().strip()
if isUtm(text):
pt = utmString2Crs(text, epsg4326)
self.updateCoordinates(6, QgsPoint(pt), epsg4326)
else:
self.showInvalid(6)
示例11: commitMgrs
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitMgrs(self):
text = self.mgrsLineEdit.text().strip()
text = re.sub(r'\s+', '', text) # Remove all white space
try:
lat, lon = mgrs.toWgs(text)
pt = QgsPoint(lon, lat)
self.updateCoordinates(7, pt, epsg4326)
except Exception:
self.showInvalid(7)
示例12: commitPlus
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitPlus(self):
text = self.plusLineEdit.text().strip()
text = re.sub(r'\s+', '', text) # Remove all white space
try:
coord = olc.decode(text)
lat = coord.latitudeCenter
lon = coord.longitudeCenter
pt = QgsPoint(lon, lat)
self.updateCoordinates(8, pt, epsg4326)
except Exception:
self.showInvalid(8)
示例13: commitGeohash
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def commitGeohash(self):
text = self.geohashLineEdit.text().strip()
try:
(lat, lon) = geohash.decode(text)
pt = QgsPoint(float(lon), float(lat))
self.updateCoordinates(9, pt, epsg4326)
except Exception:
self.showInvalid(9)
示例14: _populate_data
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def _populate_data(self, feature_count, columns, headers):
"""
Populates table widget with data and creates temporary layer
:param feature_count: Number of features
:param columns: Number of table widget columns
:param headers: Table widget field names
:return: None
:rtype: None
"""
point_list = []
self.qgs_point_list = []
self.point_row_attr = []
self.data_changed = False
table_widget = self.table_widget
self.temp_layer_name = 'temp_layer'
self._set_table_structure(table_widget, feature_count, columns, headers)
for feature_attr, row in gpx_view.get_feature_attributes(self.gpx_layer):
point = q_core.QgsPoint(feature_attr[1], feature_attr[2])
point_list.append(point)
check_box = self._set_table_widget_item(feature_attr, table_widget, row)
checkbox_state = check_box.checkState()
marker = gpx_view.set_feature_vertex_marker(self.map_canvas, feature_attr[1], feature_attr[2])
self.point_row_attr.append({
'row': row, 'marker': marker, 'checkbox': check_box, 'check_state': checkbox_state, 'qgs_point': point
})
self._set_table_header_property(table_widget)
self._remove_prev_layer()
self.temp_mem_layer = gpx_view.create_feature(self.active_layer, self.geom_type, point_list, self.temp_layer_name)
gpx_view.add_map_layer(self.temp_mem_layer, )
gpx_view.set_layer_extent(self.map_canvas, self.gpx_layer)
self.qgs_point_list = list(point_list)
self.data_changed = True
示例15: __init__
# 需要导入模块: from qgis import core [as 别名]
# 或者: from qgis.core import QgsPoint [as 别名]
def __init__(self, parent=None, x=0, y=0):
QWidget.__init__(self,parent)
self.resize(270, 130)
self._gridLayout = QGridLayout(self)
self._sbYCoord = QDoubleSpinBox(self)
self._sbYCoord.setMinimumSize(QSize(0, 30))
self._sbYCoord.setDecimals(5)
self._sbYCoord.setMinimum(-180.0)
self._sbYCoord.setMaximum(180.0)
self._gridLayout.addWidget(self._sbYCoord, 2, 1, 1, 1)
self._label_2 = QLabel(self)
self._label_2.setText(QApplication.translate("CoordinatesWidget","Y-Coordinate"))
self._gridLayout.addWidget(self._label_2, 2, 0, 1, 1)
self._label = QLabel(self)
self._label.setMaximumSize(QSize(80, 16777215))
self._label.setText(QApplication.translate("CoordinatesWidget","X-Coordinate"))
self._gridLayout.addWidget(self._label, 1, 0, 1, 1)
self._sbXCoord = QDoubleSpinBox(self)
self._sbXCoord.setMinimumSize(QSize(0, 30))
self._sbXCoord.setDecimals(5)
self._sbXCoord.setMinimum(-180.0)
self._sbXCoord.setMaximum(180.0)
self._gridLayout.addWidget(self._sbXCoord, 1, 1, 1, 1)
self.vlNotification = QVBoxLayout()
self._gridLayout.addLayout(self.vlNotification, 0, 0, 1, 2)
#Set X and Y values
self._sbXCoord.setValue(float(x))
self._sbYCoord.setValue(float(y))
self._geomPoint = QgsPoint(x,y)
#Use default SRID
self._srid = 4326
#Connect signals
self._sbXCoord.valueChanged.connect(self.onXCoordValueChanged)
self._sbYCoord.valueChanged.connect(self.onYCoordValueChanged)