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 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.º 4
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.º 5
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