本文整理汇总了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();
}
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}