Location: add HDOP; change speed to km/h; change altitude from geoid to sea level
The speed is now close to the value obtained on original hardware but the altitude on original hardawre is too imprecise to tell if we're good
This commit is contained in:
parent
8203c79e43
commit
83277680da
6 changed files with 48 additions and 15 deletions
|
@ -952,8 +952,8 @@ extern "C" jint Java_org_ppsspp_ppsspp_NativeApp_getSelectedCamera(JNIEnv *, jcl
|
|||
}
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setGpsDataAndroid(JNIEnv *, jclass,
|
||||
jfloat latitude, jfloat longitude, jfloat altitude, jfloat speed, jfloat bearing, jlong time) {
|
||||
GPS::setGpsData(latitude, longitude, altitude, speed, bearing, time);
|
||||
jlong time, jfloat hdop, jfloat latitude, jfloat longitude, jfloat altitude, jfloat speed, jfloat bearing) {
|
||||
GPS::setGpsData(time, hdop, latitude, longitude, altitude, speed, bearing);
|
||||
}
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setSatInfoAndroid(JNIEnv *, jclass,
|
||||
|
|
|
@ -12,10 +12,12 @@ import android.util.Log;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
class LocationHelper implements LocationListener, GpsStatus.Listener {
|
||||
class LocationHelper implements LocationListener, GpsStatus.Listener, GpsStatus.NmeaListener {
|
||||
private static final String TAG = LocationHelper.class.getSimpleName();
|
||||
private LocationManager mLocationManager;
|
||||
private boolean mLocationEnable;
|
||||
private float mAltitudeAboveSeaLevel = 0f;
|
||||
private float mHdop = 0f;
|
||||
|
||||
LocationHelper(Context context) {
|
||||
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
@ -33,6 +35,7 @@ class LocationHelper implements LocationListener, GpsStatus.Listener {
|
|||
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
|
||||
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, this);
|
||||
mLocationManager.addGpsStatusListener(this);
|
||||
mLocationManager.addNmeaListener(this);
|
||||
mLocationEnable = true;
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "Cannot start location updates: " + e.toString());
|
||||
|
@ -52,17 +55,20 @@ class LocationHelper implements LocationListener, GpsStatus.Listener {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* LocationListener
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
long time = location.getTime() / 1000; // ms to s !!
|
||||
float latitude = (float) location.getLatitude();
|
||||
float longitude = (float) location.getLongitude();
|
||||
// Android altitude is in meters above the WGS 84 reference ellipsoid
|
||||
float altitude = (float) location.getAltitude();
|
||||
float speed = location.getSpeed();
|
||||
float speed = location.getSpeed() * 3.6f; // m/s to km/h !!
|
||||
float bearing = location.getBearing();
|
||||
long time = location.getTime() / 1000; // ms to s !!
|
||||
|
||||
NativeApp.setGpsDataAndroid(latitude, longitude, altitude, speed, bearing, time);
|
||||
NativeApp.setGpsDataAndroid(time, mHdop, latitude, longitude, mAltitudeAboveSeaLevel, speed, bearing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,6 +84,10 @@ class LocationHelper implements LocationListener, GpsStatus.Listener {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* GpsStatus.Listener
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onGpsStatusChanged(int i) {
|
||||
switch (i) {
|
||||
|
@ -110,4 +120,24 @@ class LocationHelper implements LocationListener, GpsStatus.Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GpsStatus.Listener
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onNmeaReceived(long timestamp, String nmea) {
|
||||
String[] tokens = nmea.split(",");
|
||||
Log.e(TAG, nmea);
|
||||
if (tokens.length < 10 || !tokens[0].equals("$GPGGA")) {
|
||||
return;
|
||||
}
|
||||
if (!tokens[8].isEmpty()) {
|
||||
mHdop = Float.valueOf(tokens[8]);
|
||||
}
|
||||
if (!tokens[9].isEmpty()) {
|
||||
mAltitudeAboveSeaLevel = Float.valueOf(tokens[9]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class NativeApp {
|
|||
public static native String queryConfig(String queryName);
|
||||
|
||||
public static native int getSelectedCamera();
|
||||
public static native void setGpsDataAndroid(float latitude, float longitude, float altitude, float speed, float bearing, long time);
|
||||
public static native void setGpsDataAndroid(long time, float hdop, float latitude, float longitude, float altitude, float speed, float bearing);
|
||||
public static native void setSatInfoAndroid(short index, short id, short elevation, short azimuth, short snr, short good);
|
||||
public static native void pushCameraImageAndroid(byte[] image);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue