Python qgis.core.QgsPoint() Examples
The following are 18
code examples of qgis.core.QgsPoint().
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
, or try the search function
.
Example #1
Source File: latLonTools.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 6 votes |
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)
Example #2
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 6 votes |
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)
Example #3
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 6 votes |
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)
Example #4
Source File: gps_tool_data_view_utils.py From stdm with GNU General Public License v2.0 | 6 votes |
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
Example #5
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #6
Source File: qgis-sample-QgsMapTip.py From pyqgis-samples with GNU General Public License v2.0 | 5 votes |
def mapTipXYChanged(self, p): """ SLOT. Initialize the Timer to show MapTips on the map """ if self.canvas.underMouse(): # Only if mouse is over the map # Here you could check if your custom MapTips button is active self.lastMapPosition = QgsPoint(p.x(), p.y()) self.map_tip.clear(self.canvas) self.timer_map_tips.start(750) # time in milliseconds
Example #7
Source File: coordinates_editor.py From stdm with GNU General Public License v2.0 | 5 votes |
def geomPoint(self): """ Returns the coordinate representation as a QgsPoint. """ return self._geomPoint
Example #8
Source File: coordinates_editor.py From stdm with GNU General Public License v2.0 | 5 votes |
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)
Example #9
Source File: gps_tool.py From stdm with GNU General Public License v2.0 | 5 votes |
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
Example #10
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #11
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #12
Source File: bundle_edges.py From qgis-edge-bundling with GNU General Public License v2.0 | 5 votes |
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 ------------------------------------ #
Example #13
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #14
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #15
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #16
Source File: coordinateConverter.py From qgis-latlontools-plugin with GNU General Public License v2.0 | 5 votes |
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)
Example #17
Source File: edgebundlingUtils.py From qgis-edge-bundling with GNU General Public License v2.0 | 5 votes |
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 ------------------------------------ #
Example #18
Source File: gps_tool_data_view_utils.py From stdm with GNU General Public License v2.0 | 4 votes |
def get_qgs_points(qt_widget, checkbox_col='', lon_col='Longitude', lat_col='Latitude', ): """ Gets new coordinates on drag and drop event or on text edit :param qt_widget: QT widget - table widget :param checkbox_col: Checkbox column name :param lon_col: Longitude column name :param lat_col: Latitude column name :return point_list: List of coordinates :rtype point_list: List object :return new_point_row_attr: List of dictionary with points and table row :rtype new_point_row_attr: List object with dictionary object """ point_list = [] new_point_row_attr = [] checkbox_state = lon_value = lat_value= None row_count = qt_widget.rowCount() column_count = qt_widget.columnCount() row = 0 for row_index in xrange(row_count): for column_index in xrange(column_count): column_name = qt_widget.horizontalHeaderItem(column_index).text() cell_item = qt_widget.item(row_index, column_index) if cell_item: if unicode(column_name) == checkbox_col: checkbox_state = cell_item.checkState() elif unicode(column_name) == lon_col: lon_value = cell_item.text().strip() elif unicode(column_name) == lat_col: lat_value = cell_item.text().strip() lon_value = _valid_number(lon_value) lat_value = _valid_number(lat_value) if lon_value and lat_value: point = q_core.QgsPoint(lon_value, lat_value) new_point_row_attr.append({'row': row, 'qgs_point': point, 'check_state': checkbox_state}) if checkbox_state == 2: point_list.append(point) else: if checkbox_state is not None: new_point_row_attr.append({'row': row, 'qgs_point': None, 'check_state': checkbox_state}) if checkbox_state is not None: row += 1 checkbox_state = lon_value = lat_value= None return point_list, new_point_row_attr