本文整理汇总了Java中android.location.Location.setLatitude方法的典型用法代码示例。如果您正苦于以下问题:Java Location.setLatitude方法的具体用法?Java Location.setLatitude怎么用?Java Location.setLatitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.Location
的用法示例。
在下文中一共展示了Location.setLatitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restoreHabitEvent
import android.location.Location; //导入方法依赖的package包/类
/**
* Displays the habitEvent's details onto the edit page
* @param habitEvent the habit event to be edited
*/
public void restoreHabitEvent(HabitEvent habitEvent) {
editingHabitEventKey = habitEvent.getKey();
habitKey = habitEvent.getHabitKey();
if(habitEvent.getLatitude() !=0 && habitEvent.getLongitude() !=0) {
location = new Location("");
location.setLatitude(habitEvent.getLatitude());
location.setLongitude(habitEvent.getLongitude());
//map updated in onMapReady()
}
if(habitEvent.getPhotoUrl() != null) {
byte[] decodedByteArray = Base64.decode(habitEvent.getPhotoUrl(), Base64.NO_WRAP);
imageBitmap = BitmapFactory.decodeByteArray(decodedByteArray, 0, decodedByteArray.length);
image.setImageBitmap(imageBitmap);
}
if(habitEvent.getComment() != null && !Objects.equals(habitEvent.getComment(), "")) {
comment.setText(habitEvent.getComment());
}
creationDate.setText("Created: "+ habitEvent.getEventDate().toString("EEEE MMMM d, YYYY"));
}
示例2: isClosestGate
import android.location.Location; //导入方法依赖的package包/类
public boolean isClosestGate(LatLng point){
int gate=Integer.MAX_VALUE;
float minDistance=Float.MAX_VALUE;
Location loca1 = new Location("");
loca1.setLatitude(point.latitude);
loca1.setLongitude(point.longitude);
int count=0;
for(String iterator:delegate.gateNameArray()){
Location loca2 = new Location("");
loca2.setLatitude(Double.parseDouble(delegate.gateLatArray()[count]));
loca2.setLongitude(Double.parseDouble(delegate.gateLongArray()[count]));
float distance = loca1.distanceTo(loca2);
if(distance <= minDistance){
gate = count;
minDistance = distance;
}
count++;
}
if(gate == this.gatePosition) return true;
else return false;
}
示例3: 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);
}
示例4: setLocation
import android.location.Location; //导入方法依赖的package包/类
public static void setLocation(float f, float f2) {
if (VERSION.SDK_INT < 10) {
ib.b(a, "Device SDK Version older than 10");
return;
}
Location location = new Location("Explicit");
location.setLatitude((double) f);
location.setLongitude((double) f2);
je.a().a("ExplicitLocation", (Object) location);
}
示例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;
}
示例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: setLimit
import android.location.Location; //导入方法依赖的package包/类
public void setLimit(Double limit, Double lat, Double lon) {
prevLimitTime = System.nanoTime();
if (limit != null) {
this.limit = limit;
if (firstLimitTime == 0 && limit != 0) firstLimitTime = prevLimitTime;
}
prevLimitLocation = new Location("fused");
prevLimitLocation.setLatitude(lat);
prevLimitLocation.setLongitude(lon);
networkDown = false;
callback.handleNetworkUpdate();
}
示例8: 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;
}
}
示例9: snapLocationLatLng
import android.location.Location; //导入方法依赖的package包/类
/**
* Logic used to snap the users location coordinates to the closest position along the current
* step.
*
* @param location the raw location
* @param coords the list of step geometry coordinates
* @return the altered user location
* @since 0.4.0
*/
private static Location snapLocationLatLng(Location location, List<Point> coords) {
Location snappedLocation = new Location(location);
Point locationToPoint = Point.fromLngLat(location.getLongitude(), location.getLatitude());
// Uses Turf's pointOnLine, which takes a Point and a LineString to calculate the closest
// Point on the LineString.
if (coords.size() > 1) {
Feature feature = TurfMisc.pointOnLine(locationToPoint, coords);
Point point = ((Point) feature.geometry());
snappedLocation.setLongitude(point.longitude());
snappedLocation.setLatitude(point.latitude());
}
return snappedLocation;
}
示例10: autoCenterMap
import android.location.Location; //导入方法依赖的package包/类
void autoCenterMap() {
/*
autocentre the map if:
the setting is on,
and we moved more than 10 meters
or we have not centreed the map at our location
*/
if (mMap == null) {
//prevent null pointer exceptions
return;
}
SharedPreferences myPrefs = getSharedPreferences(SettingConstants.PREFERENCES, MODE_PRIVATE);
if (myPrefs.getBoolean(SettingConstants.AUTO_CENTER, SettingConstants.AUTO_CENTER_DEFAULT)) {
Location mapCentreLocation = new Location("");
mapCentreLocation.setLatitude(mMap.getCameraPosition().target.latitude);
mapCentreLocation.setLongitude(mMap.getCameraPosition().target.longitude);
MyApplication mApplication = (MyApplication) getApplicationContext();
if (mApplication.getLatestLon() != 0 && mApplication.getLatestLat() != 0) {
Location currentLocation = new Location("");
currentLocation.setLatitude(mApplication.getLatestLat());
currentLocation.setLongitude(mApplication.getLatestLon());
if (currentLocation.distanceTo(mapCentreLocation) > 10) {
mMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(mApplication.getLatestLat(), mApplication.getLatestLon())));
}
}
}
if (myPrefs.getBoolean(SettingConstants.AUTO_ZOOM, SettingConstants.AUTO_CENTER_DEFAULT)) {
autoZoomMap();
}
}
示例11: 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;
}
示例12: getLocation
import android.location.Location; //导入方法依赖的package包/类
public Location getLocation() {
Location location = new Location(LocationManager.NETWORK_PROVIDER);
location.setLatitude(getLatitude());
location.setLongitude(getLongitude());
return location;
}
示例13: set
import android.location.Location; //导入方法依赖的package包/类
@Override
public void set(Cursor c, String fieldName) {
double lat = c.getDouble(c.getColumnIndexOrThrow(latName(fieldName)));
double lng = c.getDouble(c.getColumnIndexOrThrow(lngName(fieldName)));
Location l = new Location(LocationManager.GPS_PROVIDER);
l.setLatitude(lat);
l.setLongitude(lng);
mValue = l;
}
示例14: 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);
}
示例15: onCreate
import android.location.Location; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initUI();
//only measure when the user is in the app for longer than 60 seconds
getMeasurer().addThreshold(new SessionLengthThreshold(true, 60));
try {
//only measure between the specified dates and/or times
Date startDate = SimpleDateFormat.getDateInstance().parse("4/20/2017");
Date endDate = SimpleDateFormat.getDateInstance().parse("4/21/2017");
//measure when between these dates, but DON'T require if another threshold matches
getMeasurer().addThreshold(new DateThreshold(false, startDate, endDate));
}
catch (ParseException pe){}
//use a simple geodistance filter to limit measurement only within a specific location
double latitude = 40.758896; //Times Square, NYC!
double longitude = -73.985130;
Location locationNear = new Location("dummyprovider");
locationNear.setLatitude(latitude);
locationNear.setLongitude(longitude);
float distanceLimit = 1000; //meters
getMeasurer().addThreshold(new GeoFenceThreshold(false, this, locationNear, distanceLimit));
//implement custom threshold that only allows when random number is greater than 0.5
getMeasurer().addThreshold(new BaseThreshold(true) {
@Override
public boolean allowMeasurement() {
return Math.random()>0.5f;
}
});
}