Beispiel #1
0
def getGpsConnection():
    gpsConnectionList = QgsApplication.gpsConnectionRegistry().connectionList()
    LOG.debug("gpsConnectionList = {}".format(gpsConnectionList))
    if len(gpsConnectionList) > 0:
        return gpsConnectionList[0]
    else:
        return None
Beispiel #2
0
 def getCurrentPosition(self):
     # Get GNSS info to tag position on the picture
     connectionRegistry = QgsApplication.gpsConnectionRegistry()
     connectionList = connectionRegistry.connectionList()
     if len(connectionList) > 0:
         self.GPSInfo = connectionList[0].currentGPSInformation()
         self.currentPosition = [
             self.GPSInfo.longitude, self.GPSInfo.latitude
         ]
     else:
         QtWidgets.QMessageBox.warning(self, "GPS information",
                                       "Can\'t load GPS information")
Beispiel #3
0
 def testMembers(self):
     self.assertTrue(QgsApplication.actionScopeRegistry())
     # self.assertTrue(QgsApplication.annotationRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.colorSchemeRegistry())
     self.assertTrue(QgsApplication.fieldFormatterRegistry())
     self.assertTrue(QgsApplication.gpsConnectionRegistry())
     self.assertTrue(QgsApplication.messageLog())
     self.assertTrue(QgsApplication.paintEffectRegistry())
     self.assertTrue(QgsApplication.pluginLayerRegistry())
     self.assertTrue(QgsApplication.processingRegistry())
     self.assertTrue(QgsApplication.profiler())
     # self.assertTrue(QgsApplication.rasterRendererRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.rendererRegistry())
     self.assertTrue(QgsApplication.svgCache())
     self.assertTrue(QgsApplication.symbolLayerRegistry())
     self.assertTrue(QgsApplication.taskManager())
 def testMembers(self):
     self.assertTrue(QgsApplication.actionScopeRegistry())
     # self.assertTrue(QgsApplication.annotationRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.colorSchemeRegistry())
     self.assertTrue(QgsApplication.fieldFormatterRegistry())
     self.assertTrue(QgsApplication.gpsConnectionRegistry())
     self.assertTrue(QgsApplication.messageLog())
     self.assertTrue(QgsApplication.paintEffectRegistry())
     self.assertTrue(QgsApplication.pluginLayerRegistry())
     self.assertTrue(QgsApplication.processingRegistry())
     self.assertTrue(QgsApplication.profiler())
     # self.assertTrue(QgsApplication.rasterRendererRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.rendererRegistry())
     self.assertTrue(QgsApplication.svgCache())
     self.assertTrue(QgsApplication.symbolLayerRegistry())
     self.assertTrue(QgsApplication.taskManager())
Beispiel #5
0
 def coordgps (self):
     connectionRegistry = QgsApplication.gpsConnectionRegistry()
     connectionList = connectionRegistry.connectionList()
     coordenadas = []
     gps = QgsCoordinateReferenceSystem(4326)
     crsAuthId = QgsProject.instance().crs().authid()
     crs= QgsCoordinateReferenceSystem()
     crs.createFromUserInput(crsAuthId)
     tform = QgsCoordinateTransform(gps, crs, QgsProject.instance())
     #Advertencia si no hay GPS conectado
     if connectionList == []:
         QtWidgets.QMessageBox.information(None, "GPS no conectado",
                                           "Conecta un GPS para obtener las coordenadas.\nMientras tanto, puede introducirlas manualmente.")
     #Transformación de coordenadas al sistema actual
     else:
         GPSInfo = connectionList[0].currentGPSInformation()
         x,y = tform.transform(GPSInfo.longitude, GPSInfo.latitude)
         coordenadas.append(x)
         coordenadas.append(y)
     return coordenadas
Beispiel #6
0
    def __init__(self, dest_crs, gpsPort):
        self.prj = QgsProject().instance()
        self.connectionRegistry = QgsApplication.gpsConnectionRegistry()
        super(GPS_Thread, self).__init__()
        try:
            self.gps_active = False
            # set up transformation
            self.dest_crs = self.prj.crs()
            self.transformation = QgsCoordinateTransform(
                QgsCoordinateReferenceSystem("EPSG:4326"), self.dest_crs,
                QgsProject.instance())
            self.gpsCon = None
            TOMsMessageLog.logMessage(
                "In GPS_Thread.__init__ - initialised ... ", level=Qgis.Info)
            self.retry_attempts = 0
        except Exception as e:
            TOMsMessageLog.logMessage(
                ("In GPS_Thread.__init__ - exception: " + str(e)),
                level=Qgis.Warning)
            self.gpsError.emit(e)

        self.gpsPort = gpsPort