本文整理汇总了Java中android.location.Location.getAltitude方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getAltitude方法的具体用法?Java Location.getAltitude怎么用?Java Location.getAltitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.Location
的用法示例。
在下文中一共展示了Location.getAltitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LocationInfo
import android.location.Location; //导入方法依赖的package包/类
LocationInfo(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();
horizontalAccuracy = location.getAccuracy();
timeStampSecs = TimeUnit.MILLISECONDS.toSeconds(location.getTime());
speed = location.getSpeed();
course = location.getBearing();
altitude = location.getAltitude();
}
示例2: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
// Don't update position with gps position if pre-existing entry or location has already been set.
if (getView() != null && mEvent.mLocalId <= 0
&& (mEvent.mLocationSource == null || mEvent.mLocationSource.equals(GameHarvest.LOCATION_SOURCE_GPS))) {
mEvent.mLocation = location;
mEvent.mAccuracy = location.getAccuracy();
mEvent.mHasAltitude = location.hasAltitude();
mEvent.mAltitude = location.getAltitude();
mEvent.mCoordinates = MapUtils.WGS84toETRSTM35FIN(location.getLatitude(), location.getLongitude());
mEvent.mLocationSource = GameHarvest.LOCATION_SOURCE_GPS;
updateLocationOnMap();
updateSubmitButton();
}
}
示例3: updateLocInfo
import android.location.Location; //导入方法依赖的package包/类
void updateLocInfo (Location location) {
if (location != null) {
float latitude = (float) location.getLatitude();
float longitude = (float) location.getLongitude();
float altitude = (float) location.getAltitude();
float altitude_feet = altitude * 3.28f;
float speed = (float) location.getSpeed();
float speed_knots = speed*1.94f;
String latitude_str = String.format("%.1f", Math.abs(latitude)) + '°' + (latitude >= 0 ? 'N' : 'S');
String longitude_str = String.format("%.1f", Math.abs(longitude)) + '°' + (longitude >= 0 ? 'E' : 'W');
String altitude_str, altitude_feet_str;
if (altitude > 1000) altitude_str = String.format("%.1f",(altitude/1000f)) + " km";
else altitude_str = String.format("%.1f",altitude) + " m";
if (altitude_feet > 1000) altitude_feet_str = String.format("%.1f",(altitude_feet/1000f)) + "k feet";
else altitude_feet_str = String.format("%.1f",altitude_feet) + " feet";
String speed_str = (int)speed + " m/s";
String speed_knots_str = (int)speed_knots + " knots";
loc_out.setText(latitude_str + " " + longitude_str + "\n\n"+
altitude_str + " " + altitude_feet_str + "\n\n"+
speed_str + " " + speed_knots_str);
if (loc_log) {
loc_pw.println(df.format(new Date())+" "+latitude_str+" "+longitude_str+" "+altitude_str+" "+speed_str);
}
}
}
示例4: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
public void onLocationChanged(Location location) {
mGeomagneticField = new GeomagneticField((float) location.getLatitude(),
(float) location.getLongitude(), (float) location.getAltitude(),
location.getTime());
currentLocation = mProj.LL2TM2(location.getLongitude(), location.getLatitude());
mTvGps.setText(String.format(Locale.CHINESE, "== GPS資訊 ==\n經度=%s\n緯度=%s\n橢球高=%.2f公尺\n速度=%.2f公尺/秒\n航向:%s\nTM2 E %.2f公尺, N %.2f公尺",
Tools.Deg2DmsStr2(location.getLongitude()),
Tools.Deg2DmsStr2(location.getLatitude()),
location.getAltitude(),
location.getSpeed(),
Tools.ang2Str(location.getBearing()),
currentLocation[0], currentLocation[1]));
double dx = currentLocation[0] - lastX;
double dy = currentLocation[1] - lastY;
if (Math.sqrt(dx*dx + dy*dy) > 1) {
lastX = currentLocation[0]/10; lastX *= 10;
lastY = currentLocation[1]/10; lastY *= 10;
List<CPDB.CP> cps = cpdb.getCp(lastX, lastY, 0);
if (cps.size() > 0) {
String cpMsg = "鄰近控制點:\n";
int i=0;
for (CPDB.CP cp : cps) {
double dx1 = cp.x - currentLocation[0], dy1 = cp.y-currentLocation[1];
double[] resCP = Tools.POLd(dy1, dx1);
cpMsg += String.format(Locale.CHINESE, "%s %[email protected]%d%s\n距離=%.0f公尺\n方位=%s\n",
cp.number, (++i), cp.t, (cp.name.length()>0?"("+cp.name+")":""),
resCP[0], Tools.Deg2DmsStr2(resCP[1])
);
}
mTvControllPoint.setText(cpMsg);
}
}
}
示例5: Kalman
import android.location.Location; //导入方法依赖的package包/类
/**
*
* @param location
*/
public Kalman(Location location, double coordinateNoise) {
final double accuracy = location.getAccuracy();
final double coordinateNoiseDegrees = coordinateNoise * BackendService.METER_TO_DEG;
double position, noise;
long timeMs = location.getTime();
// Latitude
position = location.getLatitude();
noise = accuracy * BackendService.METER_TO_DEG;
mLatTracker = new Kalman1Dim(coordinateNoiseDegrees, timeMs);
mLatTracker.setState(position, 0.0, noise);
// Longitude
position = location.getLongitude();
noise = accuracy * Math.cos(Math.toRadians(location.getLatitude())) * BackendService.METER_TO_DEG;
mLonTracker = new Kalman1Dim(coordinateNoiseDegrees, timeMs);
mLonTracker.setState(position, 0.0, noise);
// Altitude
position = 0.0;
if (location.hasAltitude()) {
position = location.getAltitude();
noise = accuracy;
mAltTracker = new Kalman1Dim(ALTITUDE_NOISE, timeMs);
mAltTracker.setState(position, 0.0, noise);
}
mTimeOfUpdate = timeMs;
samples = 1;
}
示例6: update
import android.location.Location; //导入方法依赖的package包/类
public synchronized void update(Location location) {
if (location == null)
return;
// Reusable
final double accuracy = location.getAccuracy();
double position, noise;
long timeMs = location.getTime();
predict(timeMs);
mTimeOfUpdate = timeMs;
samples++;
// Latitude
position = location.getLatitude();
noise = accuracy * BackendService.METER_TO_DEG;
mLatTracker.update(position, noise);
// Longitude
position = location.getLongitude();
noise = accuracy * Math.cos(Math.toRadians(location.getLatitude())) * BackendService.METER_TO_DEG ;
mLonTracker.update(position, noise);
// Altitude
if (location.hasAltitude()) {
position = location.getAltitude();
noise = accuracy;
if (mAltTracker == null) {
mAltTracker = new Kalman1Dim(ALTITUDE_NOISE, timeMs);
mAltTracker.setState(position, 0.0, noise);
} else {
mAltTracker.update(position, noise);
}
}
}
示例7: updateLatLongAlt
import android.location.Location; //导入方法依赖的package包/类
/**
* Update the lat/long/alt with the new location data.
*
* @param location new location
*/
synchronized private void updateLatLongAlt(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();
if (location.hasAltitude()) {
hasAltitude = true;
altitude = location.getAltitude();
}
}
示例8: LocSample
import android.location.Location; //导入方法依赖的package包/类
LocSample(Location l) {
super();
Latitude = l.getLatitude();
Longitude = l.getLongitude();
Alt = (int) (l.getAltitude() * MFBConstants.METERS_TO_FEET);
Speed = l.getSpeed() * MFBConstants.MPS_TO_KNOTS;
HError = l.getAccuracy();
TimeStamp.setTime(l.getTime());
TZOffset = 0;
}
示例9: fromLocation
import android.location.Location; //导入方法依赖的package包/类
public static GeoLocation fromLocation(Location location) {
Pair<Long, Long> coords = MapUtils.WGS84toETRSTM35FIN(location.getLatitude(), location.getLongitude());
GeoLocation geoLocation = new GeoLocation();
geoLocation.latitude = coords.first.intValue();
geoLocation.longitude = coords.second.intValue();
if (location.hasAccuracy()) {
geoLocation.accuracy = (double) location.getAccuracy();
}
if (location.hasAltitude()) {
geoLocation.altitude = location.getAltitude();
}
return geoLocation;
}
示例10: LocationRecord
import android.location.Location; //导入方法依赖的package包/类
public LocationRecord(Location location) {
super(new RecordInfo(location.getAccuracy(), location.getTime()));
this.latitude = location.getLatitude();
this.longitude = location.getLongitude();
this.altitude = location.getAltitude();
this.speed = location.getSpeed();
this.bearing = location.getBearing();
}
示例11: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
// This sets fields longitude, latitude, altitude, hasLocationData, and
// hasAltitude, then calls LocationSensor.LocationChanged(), all in the
// enclosing class LocationSensor.
public void onLocationChanged(Location location) {
lastLocation = location;
longitude = location.getLongitude();
latitude = location.getLatitude();
speed = location.getSpeed();
// If the current location doesn't have altitude information, the prior
// altitude reading is retained.
if (location.hasAltitude()) {
hasAltitude = true;
altitude = location.getAltitude();
}
// By default Location.latitude == Location.longitude == 0.
// So we want to ignore that case rather than generating a changed event.
if (longitude != UNKNOWN_VALUE || latitude != UNKNOWN_VALUE) {
hasLocationData = true;
final double argLatitude = latitude;
final double argLongitude = longitude;
final double argAltitude = altitude;
final float argSpeed = speed;
androidUIHandler.post(new Runnable() {
@Override
public void run() {
LocationChanged(argLatitude, argLongitude, argAltitude, argSpeed);
}
});
}
}
示例12: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
float latitude = (float) location.getLatitude();
float longitude = (float) location.getLongitude();
float altitude = (float) location.getAltitude();
for (SensorInfo sensorInfo : sensorInfos) {
if (sensorInfo.getType() == SensorType.GPS) {
sensorInfo.setValues(new float[]{latitude, longitude, altitude});
break;
}
}
}
示例13: setGpsLocation
import android.location.Location; //导入方法依赖的package包/类
public void setGpsLocation(final Location loc, final boolean manual) {
Log.i(TAG, "setGpsLocation: loc: " + (loc != null ? loc.toString() : "loc == null"));
if (loc != null) {
curAltitude = loc.getAltitude();
if (isAdded() && (manual || !locationHasSet)) {
setGpsText(loc.getLatitude(), loc.getLongitude());
}
if (!manual) {
locationHasSet = true;
}
RAApplication.getInstance().getGpsDetector().removeGpsMapListener(this);
} else {
RAApplication.getInstance().getGpsDetector().setGpsMapListener(this);
}
}
示例14: checkInterval
import android.location.Location; //导入方法依赖的package包/类
private void checkInterval(Location location) {
if (location == null) {
return;
}
if (!isValidState()) {
distanceInterval = 0;
recentSpeed = 0;
return;
}
recentSpeed = location.getSpeed();
if (!isValidSpeed()) {
return;
}
double distance = 0;
if (prevLatitude != location.getLatitude()
|| prevLongitude != location.getLongitude()) {
distance = calcDistance(location);
}
// enable fake speed for tests:
if (BuildConfig.FAKE) {
distance += 20;
}
prevLatitude = location.getLatitude();
prevLongitude = location.getLongitude();
prevAltitude = location.getAltitude();
if (distance < intervalLength) {
distanceInterval += distance;
} else {
sendOnIntervalChanged(distanceInterval, false);
distanceInterval = 0;
return;
}
if (distanceInterval >= intervalLength) {
boolean correctData = distanceInterval < MAX_DISTANCE;
sendOnIntervalChanged(distanceInterval, correctData);
distanceInterval = 0;
}
}
示例15: checkIsDataAvailableForRecord
import android.location.Location; //导入方法依赖的package包/类
private boolean checkIsDataAvailableForRecord() {
GPSDetector gpsDetector = getGPSDetector();
if (gpsDetector == null ||
!gpsDetector.isValidSpeed() || !gpsDetector.isValidState()) {
return false;
}
Location loc = gpsDetector.getLocation();
if (loc == null) {
return false;
}
double latitude = loc.getLatitude();
double longitude = loc.getLongitude();
double altitude = loc.getAltitude();
curSpeed = loc.getSpeed();
double distance = 0;
if (latitude >= 0 && longitude >= 0) {
distance = calcDistance(latitude, longitude);
if (curLatitude != latitude && curLongitude != longitude) {
curLatitude = latitude;
curLongitude = longitude;
curAltitude = altitude;
//Log.d(TAG, "curLatitude= " + curLatitude + ", curLongitude= "
//+ curLongitude + ", distance= " + distance);
}
}
if (distance >= MIN_DISTANCE) {
curDistance = distance;
Log.d(TAG, "data available for record, distance= " + distance);
return true;
}
return false;
}