Android GPS 定位的 getAltitude() 如何工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2791927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does getAltitude() of Android GPS Location Works
提问by RoflcoptrException
HI
你好
I tried to implement a simple GPS tracker. Therefore is used
我试图实现一个简单的 GPS 跟踪器。因此被使用
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
Then i used the
然后我用
public void onLocationChanged(Location location) {
method to read the altitude of my current location.
读取我当前位置高度的方法。
But i dont really know what Location.getAltitude() returns. The document says it returns the altitude. But is this in meters? or feets? if i put the phone on the desk next to me, this value changes between 500 and -500??
但我真的不知道 Location.getAltitude() 返回什么。该文件说它返回高度。但这是以米为单位吗?或脚?如果我把电话放在我旁边的桌子上,这个值会在 500 和 -500 之间变化??
How does this really work???
这到底是怎么工作的???
回答by Jonas
The altitude value you get is in meters from the gps (WGS84)reference ellipsoidand not from the geoid.
您获得的高度值是以米为单位的 gps (WGS84)参考椭球,而不是来自大地水准面。
From my own experience the GPS are really bad at altitude values.
根据我自己的经验,GPS 在高度值方面非常糟糕。
I read this on the GPS StatusFAQ:
我在GPS 状态常见问题解答中读到了这个:
GPS does not report the height above the mean sea level, rather the GPS system compares the height to the WGS84 reference ellipsoid which may be above or below the actual sea level. In different parts of the earth it can be off by more than 200 meters (depending on the mass distribution of Earth). For example the geoid's surface around Florida is above the mean sea level by a good 30-40 meters, which means that standing on the shore would show you -30m as altitude. This is normal, and not an error, and caused by the fact that the altitude is relative to an artificial reference surface and not to the sea level. If you are interested in this topic, I recommend to read Mean Sea Level, GPS, and the Geoid.
GPS 不报告平均海平面以上的高度,而是 GPS 系统将高度与 WGS84 参考椭球进行比较,后者可能高于或低于实际海平面。在地球的不同部分,它可能会偏离 200 多米(取决于地球的质量分布)。例如,佛罗里达州周围的大地水准面比平均海平面高 30-40 米,这意味着站在岸边会显示 -30m 的高度。这是正常现象,不是错误,是由于高度是相对于人工参考面而不是海平面这一事实造成的。如果您对此主题感兴趣,我建议您阅读平均海平面、GPS 和大地水准面。
回答by edestrero
old post, i rekon, but someone might still be interested. while listening to GPS, you can parse NMEA GPGGA sentence (http://aprs.gids.nl/nmea/#gga), in which there is the geoid height (Height of geoid above WGS84 ellipsoid). just subtract this heigh from the getAltitude returned value, one and you'll have a more accurate elevation value.
旧帖子,我认为,但有人可能仍然感兴趣。听GPS的时候,可以解析出NMEA GPGGA语句(http://aprs.gids.nl/nmea/#gga),其中有大地水准面高度(Height of geoid above WGS84 ellipsoid)。只需从 getAltitude 返回值中减去这个高度,您将获得更准确的高度值。
Edit after several months of usage and feedback received from users of my app
经过几个月的使用和从我的应用程序用户那里收到的反馈后进行编辑
A better solution is to get directly the elevation value in the GPGGA sentence:
更好的解决方案是直接获取GPGGA语句中的高程值:
double GGA_ALTITUDE = 0d;
private static final String NMEA_GGA = "$GPGGA";
private static final int altitude_element_id = 9;
@Override
public void onNmeaReceived(long timestamp, String nmea) {
foundSats = true;
// check that this is an RMC string
if (nmea.startsWith(NMEA_GGA)) {
String[] tokens = nmea.split(",");
try {
// get orthometric elevation
String elevation = tokens[altitude_element_id];
if (!elevation.equals("")) {
Log.d("NMEA", "ortho elev: " + ortho);
GGA_ALTITUDE = Double.parseDouble(elevation);
}
} catch (Exception ex) {
Log.e("NMEA", "onNmeaReceived: "
+ ex.getMessage());
onNmeaException(ex.getMessage());
ex.printStackTrace();
}
}
}
回答by user2304994
Gps simply measures the time a known signal is sent from several satellites. The more satellites in view of your Gps receiver the more accurate your position will be determined relative to those satellites. While the system is prone to some error- background noise (the satellite signal is relatively weak and space is relatively noisy), low precision time piece in your receiver, GDOP: geometric dillution of precision (all satellites grouped in one corner of sky), refraction of the signal due to the ionosphere changing heights,- overall it is very accurate in determining your distance from a satellite. Geometrically you need at least 3 satellites in view to get a position and a 4th to get altitude. More satellites contribute to greater accuracy and in some more complex receivers (not our phones but specifically aviation applications) RAIM: receiver autonomous integrity monitoring, is provided to forecast accuracy in an area and time ie before an aircraft lands...
Gps 只是测量从几颗卫星发送已知信号的时间。您的 Gps 接收器中的卫星越多,您相对于这些卫星的位置就越准确。虽然系统容易出现一些错误 - 背景噪声(卫星信号相对较弱,空间相对嘈杂),接收器中的低精度时钟,GDOP:几何精度稀释(所有卫星都聚集在天空的一个角落),由于电离层高度变化而导致的信号折射,总体而言,它在确定您与卫星的距离时非常准确。从几何上讲,您至少需要 3 颗卫星才能获得位置,并且需要 4 颗才能获得高度。更多的卫星有助于提高准确性和一些更复杂的接收器(不是我们的手机,而是特别是航空应用)RAIM:
Altitude is problematic for the gps system because the earth does not curve at mathematical constant. So while the system knows where you are relative to the satellite it must now overlay that on a mathematical model of the earth. In aviation the more accurate Gps receivers must have altitude supplemented with barometers and in some receivers enhanced position due to a known surveyed point comparison (WAAS and LAAS).
高度对于 gps 系统来说是有问题的,因为地球不会以数学常数弯曲。因此,当系统知道您相对于卫星的位置时,它现在必须将其覆盖在地球的数学模型上。在航空中,更准确的 Gps 接收器必须具有高度补充气压计,并且在某些接收器中,由于已知的测量点比较(WAAS 和 LAAS),位置增强。
回答by Volker Voecking
I assume that your desk is located inside a building. If you get a GPS fix in a building you shouldn't expect the accuracy to be very high. Have to tried getting the accuracy of the fix by calling getAccuracy()?
我假设您的办公桌位于建筑物内。如果您在建筑物中进行 GPS 定位,您不应该期望精度会非常高。必须尝试通过调用 getAccuracy() 来获得修复的准确性吗?
回答by zeusboy
This occur where you use the LocationManager.NETWORK_PROVIDER like location provider, ensure that you use LocationManager.GPS_PROVIDER like your favorite Gps Provider.
这种情况发生在您使用 LocationManager.NETWORK_PROVIDER 之类的位置提供程序时,请确保您使用 LocationManager.GPS_PROVIDER 就像您最喜欢的 Gps 提供程序一样。