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


Java Location.setAltitude方法代码示例

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


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

示例1: setLocation

import android.location.Location; //导入方法依赖的package包/类
/**
 * GPS定位需要不停的刷新经纬度值
 */
private static void setLocation(double latitude, double longitude) throws Exception{
    try {
        String providerStr = LocationManager.GPS_PROVIDER;
        Location mockLocation = new Location(providerStr);
        mockLocation.setLatitude(latitude);
        mockLocation.setLongitude(longitude);
        mockLocation.setAltitude(0);    // 高程(米)
        mockLocation.setBearing(0);   // 方向(度)
        mockLocation.setSpeed(0);    //速度(米/秒)
        mockLocation.setAccuracy(2);   // 精度(米)
        mockLocation.setTime(System.currentTimeMillis());   // 本地时间
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            //api 16以上的需要加上这一句才能模拟定位 , 也就是targetSdkVersion > 16
            mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
        }
        locationManager.setTestProviderLocation(providerStr, mockLocation);
    } catch (Exception e) {
        // 防止用户在软件运行过程中关闭模拟位置或选择其他应用
        stopMockLocation();
        throw e;
    }
}
 
开发者ID:littleRich,项目名称:VirtualLocation,代码行数:26,代码来源:LocationUtil.java

示例2: getLocation

import android.location.Location; //导入方法依赖的package包/类
public synchronized Location getLocation() {
    Long timeMs = System.currentTimeMillis();
    final Location location = new Location(BackendService.LOCATION_PROVIDER);

    predict(timeMs);
    location.setTime(timeMs);
    if (Build.VERSION.SDK_INT >= 17)
        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
    location.setLatitude(mLatTracker.getPosition());
    location.setLongitude(mLonTracker.getPosition());
    if (mAltTracker != null)
        location.setAltitude(mAltTracker.getPosition());

    float accuracy = (float) (mLatTracker.getAccuracy() * BackendService.DEG_TO_METER);
    if (accuracy < MIN_ACCURACY)
        accuracy = MIN_ACCURACY;
    location.setAccuracy(accuracy);

    // Derive speed from degrees/ms in lat and lon
    double latVeolocity = mLatTracker.getVelocity() * BackendService.DEG_TO_METER;
    double lonVeolocity = mLonTracker.getVelocity() * BackendService.DEG_TO_METER *
            Math.cos(Math.toRadians(location.getLatitude()));
    float speed = (float) Math.sqrt((latVeolocity*latVeolocity)+(lonVeolocity*lonVeolocity));
    location.setSpeed(speed);

    // Compute bearing only if we are moving. Report old bearing
    // if we are below our threshold for moving.
    if (speed > MOVING_THRESHOLD) {
        mBearing = (float) Math.toDegrees(Math.atan2(latVeolocity, lonVeolocity));
    }
    location.setBearing(mBearing);

    Bundle extras = new Bundle();
    extras.putLong("AVERAGED_OF", samples);
    location.setExtras(extras);

    return location;
}
 
开发者ID:n76,项目名称:DejaVu,代码行数:39,代码来源:Kalman.java

示例3: scheduleMockGps

import android.location.Location; //导入方法依赖的package包/类
private void scheduleMockGps(final Context context) {
    Gps gps;
    synchronized (mMockGps) {
        gps = mMockGps[0];
    }
    if (null == gps) {
        return;
    }
    if (!Macro.RealGps) {
        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        Location location = new Location(LocationManager.GPS_PROVIDER);
        location.setLatitude(gps.mLatitude);
        location.setLongitude(gps.mLongitude);
        location.setAltitude(0);
        location.setBearing(0);
        location.setSpeed(0);
        location.setAccuracy(2);
        location.setTime(System.currentTimeMillis());
        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
        locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, location);
    }
    new Handler(context.getMainLooper()).postDelayed(new Runnable() {
        @Override
        public void run() {
            scheduleMockGps(context);
        }
    }, 1000);
}
 
开发者ID:littleRich,项目名称:AutoInteraction-Library,代码行数:29,代码来源:GpsMocker.java

示例4: doInBackground

import android.location.Location; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(Integer... params) {
    LocSample l = m_rgSamples[params[0]];
    m_Loc = new Location("MFB");
    m_Loc.setAccuracy((float) l.HError);
    m_Loc.setAltitude(l.Alt);
    m_Loc.setLatitude(l.Latitude);
    m_Loc.setLongitude(l.Longitude);
    m_Loc.setSpeed((float) (l.Speed / MFBConstants.MPS_TO_KNOTS)); // locsample is in Knots, need to go back to MPS
    m_Loc.setTime(l.TimeStamp.getTime());
    return params[0];
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:13,代码来源:GPSSim.java

示例5: getLocation

import android.location.Location; //导入方法依赖的package包/类
public Location getLocation() {
    Location l = new Location("MFB");
    l.setLatitude(Latitude);
    l.setLongitude(Longitude);
    l.setSpeed((float) (Speed / MFBConstants.MPS_TO_KNOTS));  // convert back to Meters per Second
    l.setAltitude(Alt / MFBConstants.METERS_TO_FEET);         // Convert back to meters
    l.setTime(TimeStamp.getTime());
    l.setAccuracy((float)HError);
    return l;
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:11,代码来源:LocSample.java

示例6: 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

示例7: toLocation

import android.location.Location; //导入方法依赖的package包/类
public Location toLocation() {
    Pair<Double, Double> coords = MapUtils.ETRMStoWGS84(latitude, longitude);

    Location location = new Location("");
    location.setLatitude(coords.first);
    location.setLongitude(coords.second);
    if (accuracy != null) {
        location.setAccuracy(accuracy.floatValue());
    }
    if (altitude != null) {
        location.setAltitude(altitude.floatValue());
    }
    return location;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:15,代码来源:GeoLocation.java

示例8: readObject

import android.location.Location; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();

    Long first = in.readLong();
    Long second = in.readLong();
    if (first >= 0 || second >= 0) {
        mCoordinates = new Pair<>(first >= 0 ? first : null, second >= 0 ? second : null);
    }

    mLocation = new Location(in.readUTF());
    mLocation.setLatitude(in.readDouble());
    mLocation.setLongitude(in.readDouble());
    mLocation.setAccuracy(in.readFloat());
    mLocation.setAltitude(in.readDouble());
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:16,代码来源:GameHarvest.java

示例9: newLocation

import android.location.Location; //导入方法依赖的package包/类
private Location newLocation(double lat, double lon, double alt) {
    Location l = new Location("MOCK");
    l.setLatitude(lat);
    l.setLongitude(lon);
    l.setAltitude(alt);
    l.setAccuracy(0.5f);

    return l;
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:10,代码来源:MockWalk.java

示例10: correctLocationEncapsulation

import android.location.Location; //导入方法依赖的package包/类
@Test
public void correctLocationEncapsulation() {
    Location location = new Location("test");
    location.setLatitude(50);
    location.setLongitude(40);
    location.setAltitude(30);

    CheckPoint toTest = new CheckPoint(location);

    location.setLatitude(10);
    location.setLongitude(20);

    Assert.assertEquals(50, toTest.getLatitude(), 0);
    Assert.assertEquals(40, toTest.getLongitude(), 0);
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:16,代码来源:CheckPointTest.java

示例11: createEvent

import android.location.Location; //导入方法依赖的package包/类
/**
 * Create event from sqlite cursor
 *
 * @param cursor Sqlite cursor
 * @param images Images to be added to event
 * @return GameHarvest object
 */
private static GameHarvest createEvent(Cursor cursor, List<LogImage> images) {
    Location location = new Location("");
    Pair<Double, Double> loc = MapUtils.ETRMStoWGS84(cursor.getLong(cursor.getColumnIndex(DiaryHelper.COLUMN_LATITUDE)),
            cursor.getLong(cursor.getColumnIndex(DiaryHelper.COLUMN_LONGITUDE)));
    location.setLatitude(loc.first);
    location.setLongitude(loc.second);
    location.setAccuracy(cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_ACCURACY)));
    location.setAltitude(cursor.getFloat(cursor.getColumnIndex(DiaryHelper.COLUMN_ALTITUDE)));
    Calendar calendar = Calendar.getInstance();
    Date date = Utils.parseDate(cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_POINTOFTIME)));
    calendar.setTime(date);
    GameHarvest event = new GameHarvest(cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_GAMESPECIESID)),
            cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_AMOUNT)),
            cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_DESCRIPTION)),
            calendar,
            cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_TYPE)),
            location, images);
    int latitudeIndex = cursor.getColumnIndex(DiaryHelper.COLUMN_LATITUDE);
    int longitudeIndex = cursor.getColumnIndex(DiaryHelper.COLUMN_LONGITUDE);
    if (latitudeIndex != -1 && longitudeIndex != -1) {
        event.mCoordinates = new Pair<Long, Long>(cursor.getLong(latitudeIndex), cursor.getLong(longitudeIndex));
    }
    event.mAccuracy = cursor.getFloat(cursor.getColumnIndex(DiaryHelper.COLUMN_ACCURACY));
    event.mHasAltitude = (cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_HASALTITUDE)) == 1);
    event.mAltitude = cursor.getFloat(cursor.getColumnIndex(DiaryHelper.COLUMN_ALTITUDE));
    event.mAltitudeAccuracy = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_ALTITUDEACCURACY));
    event.mLocationSource = cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_LOCATION_SOURCE));

    event.mId = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_ID));
    event.mApiDataFormat = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_API_DATA_FORMAT));
    event.mClientDataFormat = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_CLIENT_DATA_FORMAT));
    event.mLocalId = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_LOCALID));
    event.mRev = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_REV));
    event.mSent = (cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_SENT)) == 1);
    event.mRemote = (cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_REMOTE)) == 1);
    event.mHarvestReportDone = (cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_HARVESTREPORTDONE)) == 1);
    event.mHarvestReportRequired = (cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_HARVESTREPORTREQUIRED)) == 1);
    event.mHarvestReportState = cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_HARVESTREPORTSTATE));
    event.mPermitNumber = cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_PERMITNUMBER));
    event.mPermitType = cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_PERMITTYPE));
    event.mStateAcceptedToHarvestPermit = cursor.getString(cursor.getColumnIndex(DiaryHelper.COLUMN_HARVESTPERMITSTATE));
    event.mCanEdit = (cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_CANEDIT)) == 1);
    event.mMobileClientRefId = cursor.getLong(cursor.getColumnIndex(DiaryHelper.COLUMN_MOBILEREFID));
    event.mPendingOperation = DiaryHelper.UpdateType.valueOf(cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_PENDINGOPERATION)));
    int specimenDataIndex = cursor.getColumnIndex(DiaryHelper.COLUMN_SPECIMENDATA);
    if (specimenDataIndex != -1) {
        try {
            // Column value may be null when migrating from old db version resulting in exception.
            String data = new String(cursor.getBlob(specimenDataIndex));

            event.mSpecimen = JsonUtils.jsonToList(data, Specimen.class);
        } catch (Exception e) {
            Log.d(DiaryDataSource.class.getSimpleName(), "Failed to deserialize specimen data: " + e.getMessage());
        }
    }
    return event;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:65,代码来源:DiaryDataSource.java


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