如何从 GPS LocationManager 获取 HDOP 或 VDOP 值?

发布于 2024-11-28 12:04:58 字数 138 浏览 1 评论 0原文

如何从 GPS LocationManager 获取HDOP 或 VDOP 值

How do I get the HDOP or VDOP values from the GPS LocationManager?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

幸福还没到 2024-12-05 12:04:59

GPS_Location:

double lo=gps_loc.getLongitude();
double la=gps_loc.getLatitude();

Horizo​​ntal_Accuracy:

int horiAcc=(int)(gps_loc.getAccuracy());

HDOP:

int hd= (int) (horiAcc/5);

The GPS_Location:

double lo=gps_loc.getLongitude();
double la=gps_loc.getLatitude();

The Horizontal_Accuracy:

int horiAcc=(int)(gps_loc.getAccuracy());

The HDOP:

int hd= (int) (horiAcc/5);
柒夜笙歌凉 2024-12-05 12:04:59

要获取 HDOP、VDOP、PDOP、DGPSID 和 GEOFDGPSDATA,请使用 GpsStatus.NmeaListener 并实现 onNmeaReceived()

protected String latestHdop;
protected String latestPdop;
protected String latestVdop;
protected String geoIdHeight;
protected String ageOfDgpsData;
protected String dgpsId;


@Override
public void onNmeaReceived(long timestamp, String nmeaSentence) {
    loggingService.OnNmeaSentence(timestamp, nmeaSentence);

    if(Utilities.IsNullOrEmpty(nmeaSentence)){
        return;
    }

    String[] nmeaParts = nmeaSentence.split(",");

    if (nmeaParts[0].equalsIgnoreCase("$GPGSA")) {

        if (nmeaParts.length > 15 && !Utilities.IsNullOrEmpty(nmeaParts[15])) {
            this.latestPdop = nmeaParts[15];
        }

        if (nmeaParts.length > 16 &&!Utilities.IsNullOrEmpty(nmeaParts[16])) {
            this.latestHdop = nmeaParts[16];
        }

        if (nmeaParts.length > 17 &&!Utilities.IsNullOrEmpty(nmeaParts[17]) && !nmeaParts[17].startsWith("*")) {

            this.latestVdop = nmeaParts[17].split("\\*")[0];
        }
    }


    if (nmeaParts[0].equalsIgnoreCase("$GPGGA")) {
        if (nmeaParts.length > 8 &&!Utilities.IsNullOrEmpty(nmeaParts[8])) {
            this.latestHdop = nmeaParts[8];
        }

        if (nmeaParts.length > 11 &&!Utilities.IsNullOrEmpty(nmeaParts[11])) {
            this.geoIdHeight = nmeaParts[11];
        }

        if (nmeaParts.length > 13 &&!Utilities.IsNullOrEmpty(nmeaParts[13])) {
            this.ageOfDgpsData = nmeaParts[13];
        }

        if (nmeaParts.length > 14 &&!Utilities.IsNullOrEmpty(nmeaParts[14]) && !nmeaParts[14].startsWith("*")) {
            this.dgpsId = nmeaParts[14].split("\\*")[0];
        }
    }
}

适用于 Android 的轻量级 GPS 记录应用程序

To get HDOP, VDOP, PDOP, DGPSID and AGEOFDGPSDATA Use GpsStatus.NmeaListener and implement onNmeaReceived()

protected String latestHdop;
protected String latestPdop;
protected String latestVdop;
protected String geoIdHeight;
protected String ageOfDgpsData;
protected String dgpsId;


@Override
public void onNmeaReceived(long timestamp, String nmeaSentence) {
    loggingService.OnNmeaSentence(timestamp, nmeaSentence);

    if(Utilities.IsNullOrEmpty(nmeaSentence)){
        return;
    }

    String[] nmeaParts = nmeaSentence.split(",");

    if (nmeaParts[0].equalsIgnoreCase("$GPGSA")) {

        if (nmeaParts.length > 15 && !Utilities.IsNullOrEmpty(nmeaParts[15])) {
            this.latestPdop = nmeaParts[15];
        }

        if (nmeaParts.length > 16 &&!Utilities.IsNullOrEmpty(nmeaParts[16])) {
            this.latestHdop = nmeaParts[16];
        }

        if (nmeaParts.length > 17 &&!Utilities.IsNullOrEmpty(nmeaParts[17]) && !nmeaParts[17].startsWith("*")) {

            this.latestVdop = nmeaParts[17].split("\\*")[0];
        }
    }


    if (nmeaParts[0].equalsIgnoreCase("$GPGGA")) {
        if (nmeaParts.length > 8 &&!Utilities.IsNullOrEmpty(nmeaParts[8])) {
            this.latestHdop = nmeaParts[8];
        }

        if (nmeaParts.length > 11 &&!Utilities.IsNullOrEmpty(nmeaParts[11])) {
            this.geoIdHeight = nmeaParts[11];
        }

        if (nmeaParts.length > 13 &&!Utilities.IsNullOrEmpty(nmeaParts[13])) {
            this.ageOfDgpsData = nmeaParts[13];
        }

        if (nmeaParts.length > 14 &&!Utilities.IsNullOrEmpty(nmeaParts[14]) && !nmeaParts[14].startsWith("*")) {
            this.dgpsId = nmeaParts[14].split("\\*")[0];
        }
    }
}

find the implementation from Lightweight GPS Logging Application For Android

杀お生予夺 2024-12-05 12:04:59

您可以从 GpsStatus 对象中的 GpsSatellite 对象获得 DOP 值的粗略估计(从技术上讲,它是原始值)。这使得您不需要解析 NMEA 字符串,您不仅可以获得 H(水平)、V(垂直)和 P(位置)DOP;您还可以获得 N(orth)、E(ast)、T(ime) 和 G(eometric) DOP。

对于每个 GpsSatellite 对象,您需要获取仰角、方位角、usedInFix 和 snr。
首先过滤掉所有卫星,仅保留 snr>0 且usedInFix==true 的卫星。

为每个卫星创建一个矩阵,其中每个卫星代表矩阵中的一行(表示为双精度数组)来创建我们称为 A 的矩阵:

注意:要使其正常工作,您需要至少 4 颗卫星

el=以弧度为单位的仰角

az=以弧度为单位的方位角

Sv=GpsSatellites 的集合

A[n]={sin(Sv[n].az)*cos(Sv[n].el), cos(Sv[n].az)*cos(Sv[n].el), sin(Sv[ n].el), 1d}

有趣的部分来了

DOP 矩阵方程如下

At = 转置矩阵 A

(At*A)^-1 = inverse(transpose(A).times(A)) =

EDOP^2    x      x      x
  x     NDOP^2   x      x
  x       x    VDOP^2   x
  x       x      x    TDOP^2

显而易见DOP:

EDOP = sqrt(EDOP^2)

NDOP = sqrt(NDOP^2)

VDOP = sqrt(VDOP^2)

TDOP = sqrt(TDOP^2)

导出的 DOP:

GDOP = sqrt(EDOP^2+NDOP^2+VDOP) ^2+TDOP^2)

HDOP = sqrt(EDOP^2+NDOP^2)

PDOP = sqrt(EDOP^2+NDOP^2+VDOP^2)

You can get a rough estimate (technically it's the raw value) of the DOP values from GpsSatellite objects in the the GpsStatus object. This makes it so you do not need to parse the NMEA strings and you can not only get the H(orizontal),V(ertical), and P(ositional) DOPs; you can also get the N(orth),E(ast),T(ime),and G(eometric) DOPs.

For each of the GpsSatellite objects you'll want to get the elevation,azimuth,usedInFix,and snr.
First filter out all of the satellites only keeping the satellite the where the snr>0 and usedInFix==true.

For each satellite create a matrix where each satellite represents a row in the matrix (represented as an array of doubles) to create the Matrix we'll call A:

Note: for this to work properly you need at least 4 satellites

el=elevation in radians

az=azimuth in radians

Sv=the collection of GpsSatellites

A[n]={sin(Sv[n].az)*cos(Sv[n].el), cos(Sv[n].az)*cos(Sv[n].el), sin(Sv[n].el), 1d}

here comes the fun part

The DOP matrix equation is as follows

At = the trasnposed Matrix A

(At*A)^-1 = inverse(transpose(A).times(A)) =

EDOP^2    x      x      x
  x     NDOP^2   x      x
  x       x    VDOP^2   x
  x       x      x    TDOP^2

obvious DOPs:

EDOP = sqrt(EDOP^2)

NDOP = sqrt(NDOP^2)

VDOP = sqrt(VDOP^2)

TDOP = sqrt(TDOP^2)

derived DOPs:

GDOP = sqrt(EDOP^2+NDOP^2+VDOP^2+TDOP^2)

HDOP = sqrt(EDOP^2+NDOP^2)

PDOP = sqrt(EDOP^2+NDOP^2+VDOP^2)

小猫一只 2024-12-05 12:04:59

准确度通常是指 GPS 定位的 HDOP班级。但是,如果您想要两者,您可以尝试 NmeaListener 来获取原始 NMEA 字符串并解析它以获得 HDOP 和 VDOP。

Accuracy usually refers to HDOP for GPS in location class. However in case you want both you can try NmeaListener to get the raw NMEA string and parse it to get HDOP and VDOP.

玉环 2024-12-05 12:04:59

您需要注册一个NMEAListener并尝试解析GSA句子(包含HDOP、VDOP和PDOP)或GGA句子(包含HDOP)进行修复)。

请参阅 NMEA 0183 标准了解更多信息。

You need to register an NMEAListener and try to parse the GSA sentence (contains HDOP, VDOP and PDOP) or the GGA sentence (which contains HDOP for a fix).

Refer to NMEA 0183 standard for more info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文