简体   繁体   English

如何从 GPSD 检索数据并在 Android 客户端中使用它们

[英]How to retrieve data from GPSD and use them in Android Client


I have to make Android client who will be showing car position in Google maps.我必须制作将在 Google 地图中显示汽车位置的 Android 客户端。 the vehicle has a Raspberry installed on board.车辆上安装了 Raspberry。 I have seen some applications to show GPSD data as NMEA form, but it's not enough for me.我见过一些将 GPSD 数据显示为 NMEA 形式的应用程序,但这对我来说还不够。

I make some review about buffering data from GPSD daemon.我做了一些关于缓冲来自 GPSD 守护进程的数据的评论。 Oracle supports java ME to share data into client, but does anyone know if exists any alternative? Oracle 支持 java ME 将数据共享到客户端,但有没有人知道是否存在任何替代方案?

Could You tell me what is the best way to retrieve this data and use them in google Maps Api (or the best protocol to get data from Android Daemon)?您能告诉我检索这些数据并在 google Maps Api 中使用它们的最佳方法是什么(或从 Android Daemon 获取数据的最佳协议)? Thanks for any help :)谢谢你的帮助 :)

One solution is to implement a GPSD client in your Android App.一种解决方案是在您的 Android 应用程序中实现 GPSD 客户端。 For that you can use for example this JAVA lib.为此,您可以使用例如这个 JAVA 库。 https://github.com/ivkos/gpsd4j https://github.com/ivkos/gpsd4j

Then you just need to know the IP address of the GPSD server installed on the Raspberry Pi and configure your client.然后你只需要知道安装在树莓派上的 GPSD 服务器的 IP 地址并配置你的客户端。

Below an example, showing how to instanciate the GPSD client and retrieve Gps data下面是一个示例,展示了如何实例化 GPSD 客户端并检索 Gps 数据

    GpsdClientOptions options = new GpsdClientOptions()
        .setReconnectOnDisconnect(true)
        .setConnectTimeout(3000) // ms
        .setIdleTimeout(30) // seconds
        .setReconnectAttempts(5)
        .setReconnectInterval(3000); // ms
    GpsdClient client = new GpsdClient("192.168.43.213", 2947, options);
    // Adds a message handler that handles incoming TPV messages
    client.addHandler(TPVReport.class, tpv -> {
        Double lat = tpv.getLatitude();
        Double lon = tpv.getLongitude();
        Double altitude = tpv.getAltitude();
        Double speed =tpv.getSpeed();

        logger.info("Latitude= "+lat+" Longitude="+lon+" Altitude="+altitude+" Speed="+speed);
    });

    client.start();
    client.watch();

Hope it will help.希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM