当前位置: 首页>>代码示例>>Java>>正文


Java Location.hasAltitude方法代码示例

本文整理汇总了Java中android.location.Location.hasAltitude方法的典型用法代码示例。如果您正苦于以下问题:Java Location.hasAltitude方法的具体用法?Java Location.hasAltitude怎么用?Java Location.hasAltitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.Location的用法示例。


在下文中一共展示了Location.hasAltitude方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrent

import android.location.Location; //导入方法依赖的package包/类
@Override
public String getCurrent() {
    if (infoCollector != null) {
        String locationAltitudeString = "";
        final Location loc = infoCollector.getLocationInfo();
        if (loc != null && loc.hasAltitude()) {
            locationAltitudeString =  String.format("%.0f %s",loc.getAltitude(),"m");
        }
        else {
            locationAltitudeString = context.getString(R.string.not_available);
        }

        return locationAltitudeString;
    }

    return null;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:18,代码来源:LocationAltitudeItem.java

示例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();
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:17,代码来源:HarvestFragment.java

示例3: convertNmeaGGA

import android.location.Location; //导入方法依赖的package包/类
public static String convertNmeaGGA(Location paramLocation, int paramInt) {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("$GPGGA,");
    localStringBuilder.append(FormatUTCDate("HHmmss.SSS", new Date(paramLocation.getTime())));
    localStringBuilder.append(",");
    localStringBuilder.append(FormatLatLon("%02d%08.5f,%c,", 'S', 'N', paramLocation.getLatitude()));
    localStringBuilder.append(FormatLatLon("%03d%08.5f,%c,", 'W', 'E', paramLocation.getLongitude()));

    localStringBuilder.append(String.format(Locale.getDefault(), "1,%02d,,", paramInt));
    if (paramLocation.hasAltitude()) {
        localStringBuilder.append(String.format(Locale.getDefault(), "%.1f", paramLocation.getAltitude()));
    }
    localStringBuilder.append(",M,,M,,");
    localStringBuilder.append(calcNmeaCrc(localStringBuilder));
    return localStringBuilder.toString();
}
 
开发者ID:MaoJianwei,项目名称:Android_GPS_NMEA_Server_Reader_Sender,代码行数:17,代码来源:MaoNmeaTools.java

示例4: writeLocation

import android.location.Location; //导入方法依赖的package包/类
/**
 * Write location to database.
 *
 * @param loc Location
 */
void writeLocation(Location loc) {
    if (Logger.DEBUG) { Log.d(TAG, "[writeLocation]"); }
    ContentValues values = new ContentValues();
    values.put(DbContract.Positions.COLUMN_TIME, loc.getTime() / 1000);
    values.put(DbContract.Positions.COLUMN_LATITUDE, loc.getLatitude());
    values.put(DbContract.Positions.COLUMN_LONGITUDE, loc.getLongitude());
    if (loc.hasBearing()) {
        values.put(DbContract.Positions.COLUMN_BEARING, loc.getBearing());
    }
    if (loc.hasAltitude()) {
        values.put(DbContract.Positions.COLUMN_ALTITUDE, loc.getAltitude());
    }
    if (loc.hasSpeed()) {
        values.put(DbContract.Positions.COLUMN_SPEED, loc.getSpeed());
    }
    if (loc.hasAccuracy()) {
        values.put(DbContract.Positions.COLUMN_ACCURACY, loc.getAccuracy());
    }
    values.put(DbContract.Positions.COLUMN_PROVIDER, loc.getProvider());

    db.insert(DbContract.Positions.TABLE_NAME, null, values);
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:28,代码来源:DbAccess.java

示例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;
}
 
开发者ID:n76,项目名称:DejaVu,代码行数:35,代码来源:Kalman.java

示例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);
        }
    }
}
 
开发者ID:n76,项目名称:DejaVu,代码行数:36,代码来源:Kalman.java

示例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();
    }
}
 
开发者ID:w86763777,项目名称:BikeLine,代码行数:15,代码来源:GPSService.java

示例8: updateLocation

import android.location.Location; //导入方法依赖的package包/类
private void updateLocation(Location location, boolean isSetManually) {
    // Accuracy and altitude data is invalid when setting manual location.
    if (isSetManually) {
        location.setAccuracy(0);

        if (location.hasAltitude()) {
            location.setAltitude(0);
        }
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:11,代码来源:MapViewer.java

示例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;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:15,代码来源:GeoLocation.java

示例10: 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);
        }
      });
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:33,代码来源:LocationSensor.java

示例11: addAltitudeIfPresent

import android.location.Location; //导入方法依赖的package包/类
private void addAltitudeIfPresent(Location location, LocationEvent locationEvent) {
  if (location.hasAltitude()) {
    double altitudeRounded = Math.round(location.getAltitude());
    locationEvent.setAltitude(altitudeRounded);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:7,代码来源:LocationMapper.java

示例12: onActivityResult

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == MapViewerActivity.LOCATION_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            Location location = data.getParcelableExtra(MapViewerActivity.RESULT_LOCATION);

            if (mEvent != null) {
                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 = data.getStringExtra(MapViewerActivity.RESULT_LOCATION_SOURCE);
            }
        }
    } else if (requestCode == ChooseSpeciesActivity.SPECIES_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            mSelectedSpecies = (Species) data.getSerializableExtra(ChooseSpeciesActivity.RESULT_SPECIES);
            mEvent.mSpeciesID = mSelectedSpecies.mId;
        }
    } else if (requestCode == SPECIMENS_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            List<Specimen> specimens = (List<Specimen>) data.getSerializableExtra(HarvestSpecimensActivity.RESULT_SPECIMENS);

            for (Iterator<Specimen> iter = specimens.listIterator(); iter.hasNext(); ) {
                Specimen specimen = iter.next();
                if (specimen.isEmpty()) {
                    iter.remove();
                }
            }

            mEvent.mSpecimen.clear();
            mEvent.mSpecimen.addAll(specimens);
        }
    } else if (requestCode == HarvestPermitActivity.PERMIT_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            String permitNumber = data.getStringExtra(HarvestPermitActivity.RESULT_PERMIT_NUMBER);
            String permitType = data.getStringExtra(HarvestPermitActivity.RESULT_PERMIT_TYPE);
            int species = data.getIntExtra(HarvestPermitActivity.RESULT_PERMIT_SPECIES, -1);

            mEvent.mPermitNumber = permitNumber;
            mEvent.mPermitType = permitType;
            mEvent.mSpeciesID = species;

            mSelectedSpecies = SpeciesInformation.getSpecies(species);
            mPermitNumber.setText(permitNumber);
        }
    } else {
        mDiaryImageManager.handleImageResult(requestCode, resultCode, data);
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:52,代码来源:HarvestFragment.java

示例13: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(final Location location) {
    LogHelper.debugLog(TAG,
            "File name: \"" +
                    Thread.currentThread().getStackTrace()[2].getFileName() +
                    "\", Line number: " +
                    Thread.currentThread().getStackTrace()[2].getLineNumber() +
                    ", Class name: \"" +
                    Thread.currentThread().getStackTrace()[2].getClassName() +
                    "\", Method name: \"" +
                    Thread.currentThread().getStackTrace()[2].getMethodName() +
                    "\"");

    LogHelper.infoLog(TAG, "Location changed: " + location);

    LogHelper.infoLog(TAG, "Changed location provider: " + location.getProvider());

    LogHelper.infoLog(TAG, "Changed location latitude: " + location.getLatitude());

    LogHelper.infoLog(TAG, "Changed location longitude: " + location.getLongitude());

    LogHelper.infoLog(TAG, "Changed location time: " + location.getTime());

    LogHelper.infoLog(TAG, "Changed location elapsed realtime nanos: " + location.getElapsedRealtimeNanos());

    LogHelper.infoLog(TAG, "Changed location extras: " + location.getExtras());

    if (location.hasAccuracy()) {
        LogHelper.infoLog(TAG, "Changed location has accuracy: " + location.getAccuracy() + " m");
    }

    if (location.hasAltitude()) {
        LogHelper.infoLog(TAG, "Changed location has altitude: " + location.getAltitude() + " m");
    }

    if (location.hasBearing()) {
        LogHelper.infoLog(TAG, "Changed location has bearing: " + location.getBearing() + " °");
    }

    if (location.hasSpeed()) {
        LogHelper.infoLog(TAG, "Changed location has speed: " + location.getSpeed() + " m/s");
    }

    Intent intent = new Intent(ACTION_LOCATION_BROADCAST);
    intent.putExtra(EXTRA_PROVIDER, location.getProvider());
    intent.putExtra(EXTRA_LATITUDE, location.getLatitude());
    intent.putExtra(EXTRA_LONGITUDE, location.getLongitude());
    intent.putExtra(EXTRA_TIME, location.getTime());
    intent.putExtra(EXTRA_ELAPSED_REALTIME_NANOS, location.getElapsedRealtimeNanos());
    intent.putExtra(EXTRA_EXTRAS, location.getExtras());
    intent.putExtra(EXTRA_ACCURACY, location.getAccuracy());
    intent.putExtra(EXTRA_ALTITUDE, location.getAltitude());
    intent.putExtra(EXTRA_BEARING, location.getBearing());
    intent.putExtra(EXTRA_SPEED, location.getSpeed());

    LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

    try {
        mRealm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                LocationRealmObject locationRealmObject = realm.createObject(LocationRealmObject.class);
                locationRealmObject.setProvider(location.getProvider());
                locationRealmObject.setLatitude(location.getLatitude());
                locationRealmObject.setLongitude(location.getLongitude());
                locationRealmObject.setTime(location.getTime());
                locationRealmObject.setElapsedRealtimeNanos(location.getElapsedRealtimeNanos());
                locationRealmObject.setAccuracy(location.getAccuracy());
                locationRealmObject.setAltitude(location.getAltitude());
                locationRealmObject.setBearing(location.getBearing());
                locationRealmObject.setSpeed(location.getSpeed());
            }
        });
    } catch (Exception e) {
        LogHelper.errorLog(TAG, e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:n37bl4d3,项目名称:Android-Location-Tracker,代码行数:79,代码来源:LocationService.java


注:本文中的android.location.Location.hasAltitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。