當前位置: 首頁>>代碼示例>>Java>>正文


Java Location.setLongitude方法代碼示例

本文整理匯總了Java中android.location.Location.setLongitude方法的典型用法代碼示例。如果您正苦於以下問題:Java Location.setLongitude方法的具體用法?Java Location.setLongitude怎麽用?Java Location.setLongitude使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.location.Location的用法示例。


在下文中一共展示了Location.setLongitude方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMockLocation

import android.location.Location; //導入方法依賴的package包/類
private Location createMockLocation() {
    String longitudeString = longitudeInput.getText().toString();
    String latitudeString = latitudeInput.getText().toString();

    if (!longitudeString.isEmpty() && !latitudeString.isEmpty()) {
        double longitude = Location.convert(longitudeString);
        double latitude = Location.convert(latitudeString);

        Location mockLocation = new Location("flp");
        mockLocation.setLatitude(latitude);
        mockLocation.setLongitude(longitude);
        mockLocation.setAccuracy(1.0f);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
        }
        mockLocation.setTime(new Date().getTime());
        return mockLocation;
    } else {
        throw new IllegalArgumentException();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:MockLocationsActivity.java

示例2: testSave

import android.location.Location; //導入方法依賴的package包/類
public void testSave() {
	Location l = new Location(LocationManager.GPS_PROVIDER);
	l.setLatitude(1.0);
	l.setLongitude(2.0);

	BlankModel b = new BlankModel();
	b.setLocation(l);

	b.save(getContext());

	BlankModel b2 = Model.objects(getContext(), BlankModel.class).get(b.getId());
	Location l2 = b2.getLocation();

	assertEquals(1.0, l2.getLatitude());
	assertEquals(2.0, l2.getLongitude());
}
 
開發者ID:Linguaculturalists,項目名稱:Phoenicia,代碼行數:17,代碼來源:LocationFieldTest.java

示例3: setUp

import android.location.Location; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  Gson gson = new GsonBuilder()
    .registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
  String body = loadJsonFixture(MULTI_LEG_ROUTE);
  DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
  route = response.routes().get(0);

  Location location = new Location("test");
  List<Point> coords = PolylineUtils.decode(route.legs().get(0).steps().get(1).geometry(),
    Constants.PRECISION_6);
  location.setLatitude(coords.get(0).latitude());
  location.setLongitude(coords.get(0).longitude());

  routeProgressBuilder = RouteProgress.builder()
    .directionsRoute(route)
    .distanceRemaining(1000)
    .stepDistanceRemaining(1000)
    .legDistanceRemaining(1000)
    .stepIndex(0)
    .legIndex(0);
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:23,代碼來源:NavigationHelperTest.java

示例4: CheckPoint

import android.location.Location; //導入方法依賴的package包/類
/**
 * Constructor that takes values for latitude and longitude in degrees and constructs an encapsulated
 * Location object to store them. Latitude and longitude must belong to the intervals [-90°, 90°] and
 * [-180°, 180°] respectively.
 *
 * @param latitude      Latitude in degrees.
 * @param longitude     Longitude in degrees.
 */
public CheckPoint(double latitude, double longitude) {

    if (latitude < -90.0 || latitude > 90.0) {
        throw new IllegalArgumentException("Latitude must belong to interval [-90°, 90°]");
    } else if (longitude < -180 || longitude > 180) {
        throw new IllegalArgumentException("Longitude must belong to interval [-180°, 180°]");
    }

    location = new Location("AppRunnest");
    location.setLatitude(latitude);
    location.setLongitude(longitude);
}
 
開發者ID:IrrilevantHappyLlamas,項目名稱:Runnest,代碼行數:21,代碼來源:CheckPoint.java

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

示例6: calcDistance

import android.location.Location; //導入方法依賴的package包/類
/**
 * Receives as input the coordinates of a station and returns it's distance to the user
 */
private float calcDistance(float latitude, float longitude) {
    Location cli_loc = new Location("Client");
    Location station_loc = new Location("Station");

    cli_loc.setLongitude(userLong);
    cli_loc.setLatitude(userLat);

    station_loc.setLatitude(latitude);
    station_loc.setLongitude(longitude);

    return cli_loc.distanceTo(station_loc);
}
 
開發者ID:carlosfaria94,項目名稱:UbiBike-client,代碼行數:16,代碼來源:NetworkDetector.java

示例7: computeDistance

import android.location.Location; //導入方法依賴的package包/類
@Test
public void computeDistance() {
    Location location1 = new Location("test");
    location1.setLatitude(50);
    location1.setLongitude(40);

    Location location2 = new Location("test");
    location2.setLatitude(60);
    location2.setLongitude(50);

    CheckPoint toTest1 = new CheckPoint(location1);
    CheckPoint toTest2 = new CheckPoint(location2);

    Assert.assertEquals(location1.distanceTo(location2), toTest1.distanceTo(toTest2), 0.0f);
}
 
開發者ID:IrrilevantHappyLlamas,項目名稱:Runnest,代碼行數:16,代碼來源:CheckPointTest.java

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

示例9: getLocation

import android.location.Location; //導入方法依賴的package包/類
public Location getLocation() {
  if (location != null) {
    return location;
  }

  Location metricLocation = new Location("MetricsLocation");
  metricLocation.setLatitude(0.0);
  metricLocation.setLongitude(0.0);

  return metricLocation;
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:12,代碼來源:MetricsLocation.java

示例10: deserialize

import android.location.Location; //導入方法依賴的package包/類
public Location deserialize(JsonElement je, Type type,
                            JsonDeserializationContext jdc) {
    JsonObject jsonObject = je.getAsJsonObject();
    Location location = new Location(jsonObject.getAsJsonPrimitive("mProvider").getAsString());
    location.setAccuracy(jsonObject.getAsJsonPrimitive("mAccuracy").getAsFloat());
    location.setLatitude(jsonObject.getAsJsonPrimitive("mLatitude").getAsDouble());
    location.setLongitude(jsonObject.getAsJsonPrimitive("mLongitude").getAsDouble());
    location.setTime(jsonObject.getAsJsonPrimitive("mTime").getAsLong());
    location.setSpeed(jsonObject.getAsJsonPrimitive("mSpeed").getAsFloat());
    location.setBearing(jsonObject.getAsJsonPrimitive("mBearing").getAsFloat());
    return location;
}
 
開發者ID:hypertrack,項目名稱:hypertrack-live-android,代碼行數:13,代碼來源:LocationDeserializer.java

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

示例12: getLocation

import android.location.Location; //導入方法依賴的package包/類
@NonNull
public static Location getLocation(@NonNull LatLng latitudeLongitude) {
    Location location = new Location(LocationManager.GPS_PROVIDER);
    location.setLatitude(latitudeLongitude.latitude);
    location.setLongitude(latitudeLongitude.longitude);
    return location;
}
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:8,代碼來源:LocationAdapter.java

示例13: trackLocation

import android.location.Location; //導入方法依賴的package包/類
@ReactMethod
public void trackLocation(ReadableMap position) {
    final Location location = new Location("RNBatch");
    location.setLongitude(position.getDouble("longitude"));
    location.setLatitude(position.getDouble("latitude"));
    location.setAccuracy((float) position.getDouble("accuracy"));

    Batch.User.trackLocation(location);
}
 
開發者ID:dangerfarms,項目名稱:react-native-batch,代碼行數:10,代碼來源:RNBatchModule.java

示例14: getLocation

import android.location.Location; //導入方法依賴的package包/類
public Location getLocation() {

        Location location = new Location(LocationManager.NETWORK_PROVIDER);
        location.setLatitude(getLatitude());
        location.setLongitude(getLongitude());
        return location;
    }
 
開發者ID:tjjh89017,項目名稱:DoorAccess,代碼行數:8,代碼來源:ReaderLocation.java

示例15: getLocation

import android.location.Location; //導入方法依賴的package包/類
/**
 * Returns a new Location object based on the event's latitude and longitude
 * @return Event Location
 */
public Location getLocation() {
    if (this.Lat == null || this.Long == null){
        return null;
    }else{
        Location loc = new Location("");
        loc.setLatitude(this.Lat);
        loc.setLongitude(this.Long);
        return loc;
    }
}
 
開發者ID:CMPUT301F17T09,項目名稱:GoalsAndHabits,代碼行數:15,代碼來源:HabitEvent.java


注:本文中的android.location.Location.setLongitude方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。