List of usage examples for android.location Location getAltitude
public double getAltitude()
From source file:Main.java
/** * Returns declination in degrees at given location * /*w ww .ja v a 2 s . c o m*/ * @param location * @return Declination in degrees */ public static float getDeclinationAt(Location location) { return getDeclinationAt((float) location.getLatitude(), (float) location.getLongitude(), (float) location.getAltitude()); }
From source file:Main.java
/***********************************/ public static void writeLocation(Parcel dest, Location loc) { dest.writeString(loc.getProvider()); dest.writeLong(loc.getTime());/*from w ww. j av a 2 s . com*/ dest.writeDouble(loc.getLatitude()); dest.writeDouble(loc.getLongitude()); dest.writeDouble(loc.getAltitude()); dest.writeFloat(loc.getAccuracy()); dest.writeFloat(loc.getBearing()); dest.writeFloat(loc.getSpeed()); }
From source file:com.googlecode.android_scripting.jsonrpc.JsonBuilder.java
private static JSONObject buildJsonLocation(Location location) throws JSONException { JSONObject result = new JSONObject(); result.put("altitude", location.getAltitude()); result.put("latitude", location.getLatitude()); result.put("longitude", location.getLongitude()); result.put("time", location.getTime()); result.put("accuracy", location.getAccuracy()); result.put("speed", location.getSpeed()); result.put("provider", location.getProvider()); result.put("bearing", location.getBearing()); return result; }
From source file:com.tenforwardconsulting.cordova.bgloc.LocationConverter.java
public static JSONObject toJSONObject(android.location.Location location) throws JSONException { JSONObject json = new JSONObject(); json.put("time", location.getTime()); json.put("latitude", location.getLatitude()); json.put("longitude", location.getLongitude()); json.put("accuracy", location.getAccuracy()); json.put("speed", location.getSpeed()); json.put("altitude", location.getAltitude()); json.put("bearing", location.getBearing()); return json;/* www .j a v a 2 s .c om*/ }
From source file:de.ncoder.sensorsystem.android.logging.JSONUtils.java
private static Object wrapLocation(Location loc) { try {/*ww w .j a v a 2 s . co m*/ JSONObject json = new JSONObject(); json.put("provider", loc.getProvider()); json.put("latitude", loc.getLatitude()); json.put("longitude", loc.getLongitude()); if (loc.hasAccuracy()) json.put("accuracy", loc.getAccuracy()); json.put("time", loc.getTime()); if (loc.hasAltitude()) json.put("alt", loc.getAltitude()); if (loc.hasSpeed()) json.put("vel", loc.getSpeed()); if (loc.hasBearing()) json.put("bear", loc.getBearing()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) if (loc.isFromMockProvider()) json.put("mock", true); if (loc.getExtras() != null) { json.put("extra", wrap(loc.getExtras())); } return json; } catch (JSONException e) { return loc.toString() + " threw " + e.toString(); } }
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
public static float getDeclination(Location location, long timestamp) { if (location == null) return 0; GeomagneticField field = new GeomagneticField((float) location.getLatitude(), (float) location.getLongitude(), (float) location.getAltitude(), timestamp); return field.getDeclination(); }
From source file:com.nextgis.mobile.forms.CompassFragment.java
public static float getDeclination(Location location, long timestamp) { if (location == null) { return 0; }/* w w w . ja v a 2 s . c o m*/ GeomagneticField field = new GeomagneticField((float) location.getLatitude(), (float) location.getLongitude(), (float) location.getAltitude(), timestamp); return field.getDeclination(); }
From source file:com.facebook.react.modules.location.LocationModule.java
private static WritableMap locationToMap(Location location) { WritableMap map = Arguments.createMap(); WritableMap coords = Arguments.createMap(); coords.putDouble("latitude", location.getLatitude()); coords.putDouble("longitude", location.getLongitude()); coords.putDouble("altitude", location.getAltitude()); coords.putDouble("accuracy", location.getAccuracy()); coords.putDouble("heading", location.getBearing()); coords.putDouble("speed", location.getSpeed()); map.putMap("coords", coords); map.putDouble("timestamp", location.getTime()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { map.putBoolean("mocked", location.isFromMockProvider()); }//from w w w . j a v a 2s.com return map; }
From source file:com.platform.GeoLocationManager.java
public static String getJsonLocation(Location location) { try {// w ww. j a v a 2 s . co m JSONObject responseJson = new JSONObject(); JSONObject coordObj = new JSONObject(); coordObj.put("latitude", location.getLatitude()); coordObj.put("longitude", location.getLongitude()); responseJson.put("timestamp", location.getTime()); responseJson.put("coordinate", coordObj); responseJson.put("altitude", location.getAltitude()); responseJson.put("horizontal_accuracy", location.getAccuracy()); responseJson.put("description", ""); return responseJson.toString(); } catch (JSONException e) { Log.e(TAG, "handleLocation: Failed to create json response"); e.printStackTrace(); } return null; }
From source file:org.odk.collect.android.map.GoogleMapFragment.java
protected static @Nullable MapPoint fromLocation(@Nullable Location location) { if (location == null) { return null; }/*from w w w . jav a 2 s .c o m*/ return new MapPoint(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); }