开发者

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

How do I g开发者_StackOverflowet the HDOP or VDOP values from the GPS LocationManager?


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);


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


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)


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜