Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
 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()
Ejemplo n.º 9
0
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> &rarr; <code>Current longitude coordinate</code></li>
    <li><code>gps('y')</code> &rarr; <code>Current latitude coordinate</code></li>
    <li><code>gps('z')</code> &rarr; <code>Current altitude</code></li>
    <li><code>gps('quality')</code> &rarr; <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> &rarr; <code>PDOP (dilution of precision)</code></li>
    <li><code>gps('hdop')</code> &rarr; <code>Horizontal dilution of precision (HDOP)</code></li>
    <li><code>gps('vdop')</code> &rarr; <code>Vertical dilution of precision (VDOP)</code></li>
    <li><code>gps('fixType')</code> &rarr; <code>GPS fix type<br />(1 = no fix, 2 = 2D fix, 3 = 3D fix)</code></li>
    <li><code>gps('satellitesUsed')</code> &rarr; <code>Number of satellites being tracked</code></li>
    <li><code>gps('speed')</code> &rarr; <code>Speed over ground in kmph</code></li>
    <li><code>gps('direction')</code> &rarr; <code>Track angle in degrees True</code></li>
    </ul>
    </div>
    """
    if GPS.isConnected:
        return GPS.gpsinfo(values[0])
    else:
        return None
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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> &rarr; <code>Altitude of current point</code></li>
    </ul>
    </div>
    """
    if GPS.isConnected:
        return GPS.gpsinfo('z')
    else:
        return None
Ejemplo n.º 12
0
 def updateGPSPort(self):
     if GPS.isConnected and not roam.config.settings.get(
             'gpsport', '') == GPS.currentport:
         GPS.disconnectGPS()
         self.connectGPS()
Ejemplo n.º 13
0
 def updateGPSPort(self):
     if GPS.isConnected and not roam.config.settings.get('gpsport', '') == GPS.currentport:
         GPS.disconnectGPS()
         self.connectGPS()