List of usage examples for android.location Location setAltitude
public void setAltitude(double altitude)
From source file:Main.java
public static Location readLocation(Parcel in) { Location loc = new Location(in.readString()); loc.setTime(in.readLong());//from w ww. ja v a 2s .c om loc.setLatitude(in.readDouble()); loc.setLongitude(in.readDouble()); loc.setAltitude(in.readDouble()); loc.setAccuracy(in.readFloat()); loc.setBearing(in.readFloat()); loc.setSpeed(in.readFloat()); return loc; }
From source file:Main.java
/** * Create a {@link Location} object from the speified latitude and longitude. * @param latitude the latitude for the location to create. * @param longitude the longitude for the location to create. * @return a {@link Location} object.//from w ww. j av a2 s .com */ public static Location createLocation(double latitude, double longitude) { Location location = new Location(LocationManager.NETWORK_PROVIDER); location.setLatitude(latitude); location.setLongitude(longitude); location.setAccuracy(10f); location.setTime(System.currentTimeMillis()); location.setAltitude(0d); location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); return location; }
From source file:uk.ac.horizon.ug.exploding.client.LocationUtils.java
public static Location getLocation(double lat, double lon) { Location l2 = new Location("gps"); l2.setLatitude(lat);// w w w . j a va 2 s. c o m l2.setLongitude(lon); l2.setAltitude(0); return l2; }
From source file:to.sven.androidrccar.common.communication.model.LocationMessage.java
/** * Converts the Location Message to {@link Location}. * @return An {@link Location} with the information of this Message. *///from w ww . j a va 2s . c o m public Location toAndroidLocation() { Location location = new Location((String) null); location.setLatitude(latitude); location.setLongitude(longitude); if (hasAltitude) { location.setAltitude(altitude); } if (hasAccuracy) { location.setAccuracy(accuracy); } if (hasBearing) { location.setBearing(bearing); } if (hasSpeed) { location.setSpeed(speed); } return location; }
From source file:de.tu_darmstadt.kom.freifunkfinder.common.converter.JSONAndDTOConverter.java
/** * Returns a Location object from a Location key. * * @param locationKey the Location key in Json response. * @return the Location object for WifiAccessPointDTO. * @throws JSONException if an error occurs due to type mismatch. *//*from w w w. jav a 2 s. co m*/ private Location getLocation(JSONObject locationKey) throws JSONException { Location location = new Location(GlobalParams.getBestLocationProvider()); location.setLatitude((double) locationKey.getDouble("latitude")); location.setLongitude((double) locationKey.getDouble("longitude")); if (locationKey.has("altitude")) { location.setAltitude(locationKey.getDouble("altitude")); } return location; }
From source file:com.kevinquan.android.location.SimpleRecordedLocation.java
public Location asLocation() { Location location = new Location(TAG); location.setLatitude(mLatitude);//ww w. j av a2 s . co m location.setLongitude(mLongitude); location.setAccuracy(mAccuracy); location.setAltitude(mAltitude); location.setBearing(mBearing); location.setSpeed(mSpeed); location.setTime(mRecordedAt); return location; }
From source file:com.luke.lukef.lukeapp.fragments.MapViewFragment.java
/** * Returns the previously known user location, either the last location or last known location * * @return Location object, either long press location, last known location or null if no location is available. */// w w w .j av a 2 s .c o m private Location getLastLoc() { Location location = new Location(""); if (this.lastLoc != null) { location.setAltitude(this.lastLoc.getAltitude()); location.setLatitude(this.lastLoc.getLatitude()); location.setLongitude(this.lastLoc.getLongitude()); return location; } else if (this.lastKnownLoc != null) { location.setAltitude(this.lastKnownLoc.getAltitude()); location.setLatitude(this.lastKnownLoc.getLatitude()); location.setLongitude(this.lastKnownLoc.getLongitude()); return location; } else { return null; } }
From source file:com.umaps.gpslogger.GpsLoggingService.java
private void AdjustAltitude(Location loc) { if (!loc.hasAltitude()) { return;/*from w w w. j a v a 2 s .co m*/ } if (AppSettings.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null) { String geoidheight = loc.getExtras().getString("GEOIDHEIGHT"); if (!Utilities.IsNullOrEmpty(geoidheight)) { loc.setAltitude((float) loc.getAltitude() - Float.valueOf(geoidheight)); } } loc.setAltitude(loc.getAltitude() - AppSettings.getSubtractAltitudeOffset()); }
From source file:org.cowboycoders.cyclisimo.turbo.TurboService.java
private synchronized void updateLocation(LatLongAlt pos) { LocationManager locationManager = (LocationManager) getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { try {// ww w. j ava2s . co m float locSpeed = (float) (lastRecordedSpeed / UnitConversions.MS_TO_KMH); final long timestamp = System.currentTimeMillis(); Log.v(TAG, "location timestamp: " + timestamp); Location loc = new Location(MOCK_LOCATION_PROVIDER); Log.d(TAG, "alt: " + pos.getAltitude()); Log.d(TAG, "lat: " + pos.getLatitude()); Log.d(TAG, "long: " + pos.getLongitude()); loc.setLatitude(pos.getLatitude()); loc.setLongitude(pos.getLongitude()); loc.setAltitude(pos.getAltitude()); loc.setTime(timestamp); loc.setSpeed(locSpeed); loc.setAccuracy(GPS_ACCURACY); locationManager.setTestProviderLocation(MOCK_LOCATION_PROVIDER, loc); Log.e(TAG, "updated location"); } catch (SecurityException e) { handleException(e, "Error updating location", true, NOTIFCATION_ID_STARTUP); } return; } Log.e(TAG, "no gps provider"); }
From source file:org.path.episample.android.fragments.NavigateFragment.java
private void itemSelected(int position) { mSelectedCensusRow = position;/*from w w w . j a v a 2s . c o m*/ CensusModel census = (((CensusListAdapter) getListAdapter()).getItem(position)); String instanceId = census.getInstanceId(); Location censusLocation = new Location(instanceId); censusLocation.setAccuracy((float) census.getAccuracy()); censusLocation.setAltitude(census.getAltitude()); censusLocation.setLatitude(census.getLatitude()); censusLocation.setLongitude(census.getLongitude()); mDirectionProvider.setDestinationLocation(censusLocation); ((CensusListAdapter) getListAdapter()).notifyDataSetChanged(); if (mDirectionProvider.getCurrentLocation() != null) { updateDistance(mDirectionProvider.getCurrentLocation()); } else { mDistanceTextView.setText(getActivity().getString(R.string.distance, "-")); } }