60

GPS のみを使用して高度を正確に測定する必要があります。

試してみLocation.getAltitude()ましたが、それはひどく不正確です。何かアドバイス?

4

8 に答える 8

62

There are two issues with using altitude of a smartphone / tablet GPS:

  1. The altitude is the altitude above the WGS84 reference ellipsoid. It is not the altitude above ground level or sea level. Here is more detail on that: http://www.gpspassion.com/forumsen/topic.asp?TOPIC_ID=10915. This error can be corrected; here is a description how to do that by hand: http://www.unavco.org/edu_outreach/tutorial/geoidcorr.html. The web article links to a calculator to get the Geoid height for correction; I do not know if there is also a web service available for this computation.
  2. The GPS altitude is terribly inaccurate for relatively cheap GPS receivers. Here is an article on that: http://gpsinformation.net/main/altitude.htm. One method to cope with this kind of inaccuracy is to filter the altitude data. I used a circular array data structure to remember the last few (I used 4) altitude readings and compute the average. This sufficed to get a relatively accurate reading of vertical speed for my application.
于 2012-02-24T14:29:54.107 に答える
8

別の方法は、NMEA 文字列を解析することです。$GPGGA 文には、修正された海抜高度データが既に含まれています。

したがって、LocationManager の NMEA 文字列へのリスナーを作成し、メッセージを解析するだけです。

private GpsStatus.NmeaListener mNmeaListener = new GpsStatus.NmeaListener() {
    @Override
    public void onNmeaReceived(long timestamp, String nmea) {
        parseNmeaString(nmea);
    }
};

public void registerLocationManager(Context context) {
        mLocationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);
        mLocationManager.addNmeaListener(mNmeaListener);
}

private void parseNmeaString(String line) {
        if (line.startsWith("$")) {
            String[] tokens = line.split(",");
            String type = tokens[0];

            // Parse altitude above sea level, Detailed description of NMEA string here http://aprs.gids.nl/nmea/#gga
            if (type.startsWith("$GPGGA")) {
                if (!tokens[9].isEmpty()) {
                    mLastMslAltitude = Double.parseDouble(tokens[9]);
                }
            }
        }
    }

位置リスナーを介して受信した最後の Location オブジェクトの高度を置き換えるか、NMEA を介して新しい位置全体を解析できます。

于 2017-06-13T10:05:28.893 に答える
1

GPS 以外にも高度を取得する方法はあります。気圧計を使用できますが、気圧センサーを備えたデバイスはまだそれほど多くないため (新しいもののみ)。必要なデータを取得するには、Web サービスを使用することをお勧めします。

Androidで経度と緯度で高度を取得するのに役立つ質問があります

于 2013-01-25T20:39:44.597 に答える
-1

sladstaetter が回答で提案したように、 NmeaListener使用することをお勧めします。ただし、NMEA のドキュメントによると、取得できる文は「$GPGGA」だけではありません。「GGA」文 ($--GGA) を探す必要があります。

正規表現はそのために最適です。たとえば、次のようになります。

@Override
public void onNmeaReceived(final long timestamp, final String nmea) {
    final Pattern pattern = Pattern.compile("\\$..GGA,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,([+-]?\\d+(.\\d+)?),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$");
    final Matcher matcher = pattern.matcher(nmea);
    if (matcher.find()) {
        final float altitude = Float.parseFloat(matcher.group(1));
        // ...enjoy the altitude!
    }
}
于 2019-07-01T11:51:40.210 に答える