def getmap(self): if self.canvas: settings = self.canvas.mapSettings() layers = settings.layers() if GPS.isConnected: try: gpslayer = QgsMapLayerRegistry.instance().mapLayersByName( "__gps_layer")[0] except IndexError: gpslayer = QgsVectorLayer("Point", "__gps_layer", "memory") symbol = QgsMarkerSymbolV2.createSimple({ 'name': 'circle', 'color': 'blue', "size": '5' }) gpslayer.rendererV2().setSymbol(symbol) QgsMapLayerRegistry.instance().addMapLayer(gpslayer, False) layers.append(gpslayer.id()) settings.setLayers(layers) map_pos = QgsPoint(GPS.gpsinfo("longitude"), GPS.gpsinfo("latitude")) # map_pos = QgsPoint(115.72589,-32.29597) geom = QgsGeometry.fromPoint(map_pos) feature = QgsFeature() feature.setGeometry(geom) gpslayer.startEditing() gpslayer.addFeature(feature) # gpslayer.commitChanges() self.renderjob = QgsMapRendererParallelJob(settings) self.renderjob.finished.connect(self.rendermap) self.renderjob.start()
def getmap(self): if self.canvas: settings = self.canvas.mapSettings() layers = settings.layers() if GPS.isConnected: try: gpslayer = QgsMapLayerRegistry.instance().mapLayersByName("__gps_layer")[0] except IndexError: gpslayer = QgsVectorLayer("Point", "__gps_layer", "memory") symbol = QgsMarkerSymbolV2.createSimple({'name': 'circle', 'color': 'blue', "size": '5'}) gpslayer.rendererV2().setSymbol(symbol) QgsMapLayerRegistry.instance().addMapLayer(gpslayer, False) layers.append(gpslayer.id()) settings.setLayers(layers) map_pos = QgsPoint(GPS.gpsinfo("longitude"), GPS.gpsinfo("latitude")) # map_pos = QgsPoint(115.72589,-32.29597) geom = QgsGeometry.fromPoint(map_pos) feature = QgsFeature() feature.setGeometry(geom) gpslayer.startEditing() gpslayer.addFeature(feature) # gpslayer.commitChanges() self.renderjob = QgsMapRendererParallelJob(settings) self.renderjob.finished.connect(self.rendermap) self.renderjob.start()
def updateGPSPort(self): print GPS.isConnected print roam.config.settings['gpsport'] print GPS.currentport if GPS.isConnected and not roam.config.settings['gpsport'] == GPS.currentport: GPS.disconnectGPS() self.connectGPS()
def updateGPSPort(self): print GPS.isConnected print roam.config.settings['gpsport'] print GPS.currentport if GPS.isConnected and not roam.config.settings[ 'gpsport'] == GPS.currentport: GPS.disconnectGPS() self.connectGPS()
def connectGPS(self): if not GPS.isConnected: # Enable GPS self.setIcon(QIcon(":/icons/gps")) self.setIconText(self.tr("Connecting..")) self.setEnabled(False) portname = roam.config.settings.get('gpsport', '') GPS.connectGPS(portname) else: GPS.disconnectGPS()
def connectGPS(self): if not GPS.isConnected: # Enable GPS self.setIcon(QIcon(":/icons/gps")) self.setIconText(self.tr("Connecting..")) self.setEnabled(False) portname = roam.config.settings.get('gpsport', '') GPS.connectGPS(portname) else: GPS.disconnectGPS()
def add_point_avg(self): # if turned on if roam.config.settings.get('gps_averaging', True): # if currently happening if roam.config.settings.get('gps_averaging_in_action', True): # start -> stop # time to do some averaging average_point = GPS.average_func(GPS.gpspoints) point = QgsPoint(average_point[0], average_point[1], average_point[2]) self.geometryComplete.emit(QgsGeometry(point)) # default settings vertex_or_point = '' in_action = False start_time = '0:00:00' roam.config.settings['gps_averaging_measurements'] = 0 else: # stop -> start vertex_or_point = 'point' in_action = True start_time = datetime.now() roam.config.settings['gps_vertex_or_point'] = vertex_or_point roam.config.settings['gps_averaging_in_action'] = in_action roam.config.settings['gps_averaging_start_time'] = start_time roam.config.save() else: self.addatgps()
def add_vertex_avg(self): # if turned on if roam.config.settings.get('gps_averaging', True): # if currently happening if roam.config.settings.get('gps_averaging_in_action', True): # start -> stop # averaging average_point = GPS.average_func(GPS.gpspoints) point = QgsPoint(average_point[0], average_point[1], average_point[2]) self.add_point(point) self.band.addPoint(QgsPointXY(point)) # default settings vertex_or_point = '' in_action = False start_time = '0:00:00' roam.config.settings['gps_averaging_measurements'] = 0 self.set_buttons_avg(True) else: # stop -> start # avg settings vertex_or_point = 'vertex' in_action = True start_time = datetime.now() self.set_buttons_avg(False) roam.config.settings['gps_vertex_or_point'] = vertex_or_point roam.config.settings['gps_averaging_in_action'] = in_action roam.config.settings['gps_averaging_start_time'] = start_time roam.config.save() else: self.add_vertex()
def gps(values, *args): """ <h3>function gps</h3> <div class="description">Returns various attributes from the attached GPS.</div> <h4>Syntax</h4> <div class="syntax"> <code><span class="functionname">gps</span>(<span class="argument">string</span>)</code> <h4>Arguments</h4> <div class="arguments"> <table> <tr><td class="argument">string</td><td>A string representing an attribute passed by the gps.</td></tr> </table> </div> <h4>Examples</h4> <div class="examples"> <ul> <li><code>gps('x')</code> → <code>Current longitude coordinate</code></li> <li><code>gps('y')</code> → <code>Current latitude coordinate</code></li> <li><code>gps('z')</code> → <code>Current altitude</code></li> <li><code>gps('quality')</code> → <code>GPS fix quality<br />(0 = invalid, 1 = GPS fix, 2 = DGPS, 3 = PPS, 4 = RTK, 5 = Float RTK)</code></li> <li><code>gps('pdop')</code> → <code>PDOP (dilution of precision)</code></li> <li><code>gps('hdop')</code> → <code>Horizontal dilution of precision (HDOP)</code></li> <li><code>gps('vdop')</code> → <code>Vertical dilution of precision (VDOP)</code></li> <li><code>gps('fixType')</code> → <code>GPS fix type<br />(1 = no fix, 2 = 2D fix, 3 = 3D fix)</code></li> <li><code>gps('satellitesUsed')</code> → <code>Number of satellites being tracked</code></li> <li><code>gps('speed')</code> → <code>Speed over ground in kmph</code></li> <li><code>gps('direction')</code> → <code>Track angle in degrees True</code></li> </ul> </div> """ if GPS.isConnected: return GPS.gpsinfo(values[0]) else: return None
def gps(values, feature, parent): """ QGIS expression function to return information about the GPS postion. """ if GPS.isConnected: return GPS.gpsinfo(values[0]) else: return None
def gps_z(values, *args): """ <h3>function gps_z</h3> <div class="description">Returns the altitude reading from the GPS for the current point.</div> <h4>Syntax</h4> <div class="syntax"> <code><span class="functionname">$gps_z</span></code> <h4>Examples</h4> <div class="examples"> <ul> <li><code>$gps_z</code> → <code>Altitude of current point</code></li> </ul> </div> """ if GPS.isConnected: return GPS.gpsinfo('z') else: return None
def updateGPSPort(self): if GPS.isConnected and not roam.config.settings.get( 'gpsport', '') == GPS.currentport: GPS.disconnectGPS() self.connectGPS()
def updateGPSPort(self): if GPS.isConnected and not roam.config.settings.get('gpsport', '') == GPS.currentport: GPS.disconnectGPS() self.connectGPS()