本文整理汇总了Java中com.mapbox.mapboxsdk.geometry.LatLng.getLongitude方法的典型用法代码示例。如果您正苦于以下问题:Java LatLng.getLongitude方法的具体用法?Java LatLng.getLongitude怎么用?Java LatLng.getLongitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mapbox.mapboxsdk.geometry.LatLng
的用法示例。
在下文中一共展示了LatLng.getLongitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLocationInside
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public static boolean isLocationInside(LatLng point, ArrayList<? extends LatLng> positions) {
boolean result = false;
LatLng p1 = positions.get(0);
for (int i = 1; i < positions.size(); i++) {
LatLng p2 = positions.get(i);
if (((p2.getLatitude() <= point.getLatitude()
&& point.getLatitude() < p1.getLatitude())
|| (p1.getLatitude() <= point.getLatitude()
&& point.getLatitude() < p2.getLatitude()))
&& (point.getLongitude() < (p1.getLongitude() - p2.getLongitude())
* (point.getLatitude() - p2.getLatitude())
/ (p1.getLatitude() - p2.getLatitude()) + p2.getLongitude())) {
result = !result;
}
p1 = p2;
}
return result;
}
示例2: findInteriorAngle
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public double findInteriorAngle(LatLng a, LatLng b) {
//System.out.println(180/Math.PI*Math.acos(dot(a,b)/(calculateLength(a)*calculateLength(b))));
// System.out.println("a " + calculateLength(a));
// System.out.println("b " + calculateLength(b));
// System.out.println("a.b: " + dot(a,b));
// System.out.println("dot(a,b)/lengtha*lengthb : " + Math.acos(dot(a,b)/(calculateLength(a)*calculateLength(b
// ))));
double dot = dot(a, b);
double cross = a.getLatitude() * b.getLongitude() - a.getLongitude() * b.getLatitude();
double output = Math.atan2(dot, cross);
if (output < 0) {
output += Math.PI;
}
if (output == 0) {
output = Math.PI / 2;
}
// if (output > Math.PI/2)
// {
// output = Math.PI - output;
// }
//return output;
return Math.acos(dot(a, b) / (calculateLength(a) * calculateLength(b)));
}
示例3: toPoint
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public Point toPoint(final LatLng latLng) {
final double x = latLng.getLongitude() / 360 + .5;
final double siny = Math.sin(Math.toRadians(latLng.getLatitude()));
final double y = 0.5 * Math.log((1 + siny) / (1 - siny)) / -(2 * Math.PI) + .5;
return new Point(x * mWorldWidth, y * mWorldWidth);
}
示例4: OsmAnimatorUpdateListener
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public OsmAnimatorUpdateListener(LatLng originPos, LatLng destinationPos, MapboxMap mapboxMap) {
this.originPos = originPos;
this.destinationPos = destinationPos;
this.mapboxMap = mapboxMap;
latStep = (destinationPos.getLatitude() - originPos.getLatitude()) / STEPS_CENTER_ANIMATION;
lngStep = (destinationPos.getLongitude() - originPos.getLongitude()) / STEPS_CENTER_ANIMATION;
}
示例5: distance
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public double distance(LatLng A, LatLng B, LatLng C) {
double ABx = B.getLongitude() - A.getLongitude();
double ABy = B.getLatitude() - A.getLatitude();
double num = ABx * (A.getLatitude() - C.getLatitude()) - ABy * (A.getLongitude() - C.getLongitude());
if (num < 0)
num = -num;
return num;
}
示例6: pointLocation
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public double pointLocation(LatLng A, LatLng B, LatLng P) {
double cp1 = (B.getLongitude() - A.getLongitude()) * (P.getLatitude() - A.getLatitude()) - (B.getLatitude() - A.getLatitude()) * (P.getLongitude() - A.getLongitude());
if (cp1 > 0)
return 1;
else if (cp1 == 0)
return 0;
else
return -1;
}
示例7: computeCentroid
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public LatLng computeCentroid(ArrayList<LatLng> vertices) {
double tempLat = 0;
double tempLon = 0;
for (LatLng i : vertices) {
tempLat += i.getLatitude();
tempLon += i.getLongitude();
}
return new LatLng(tempLat / vertices.size(), tempLon / vertices.size());
}
示例8: distance
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public double distance(LatLng A, LatLng B, LatLng C) {
double ABx = B.getLongitude() - A.getLongitude();
double ABy = B.getLatitude() - A.getLatitude();
double num = ABx * (A.getLatitude() - C.getLatitude()) - ABy * (A.getLongitude() - C.getLongitude());
if (num < 0)
num = -num;
return num;
}
示例9: computeCentroid
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public LatLng computeCentroid(ArrayList<LatLng> vertices) {
double tempLat = 0;
double tempLon = 0;
for (LatLng i : vertices) {
tempLat += i.getLatitude();
tempLon += i.getLongitude();
}
return new LatLng(tempLat / vertices.size(), tempLon / vertices.size());
}
示例10: findBoundingBoxForGivenLocations
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public BoundingBox findBoundingBoxForGivenLocations(ArrayList<LatLng> coordinates)
{
double west = 0.0;
double east = 0.0;
double north = 0.0;
double south = 0.0;
for (int lc = 0; lc < coordinates.size(); lc++)
{
LatLng loc = coordinates.get(lc);
if (lc == 0)
{
north = loc.getLatitude();
south = loc.getLatitude();
west = loc.getLongitude();
east = loc.getLongitude();
}
else
{
if (loc.getLatitude() > north)
{
north = loc.getLatitude();
}
else if (loc.getLatitude() < south)
{
south = loc.getLatitude();
}
if (loc.getLongitude() < west)
{
west = loc.getLongitude();
}
else if (loc.getLongitude() > east)
{
east = loc.getLongitude();
}
}
}
// OPTIONAL - Add some extra "padding" for better map display
double padding = 0.005;
north = north + padding;
south = south - padding;
west = west - padding;
east = east + padding;
return new BoundingBox(north, east, south, west);
}
示例11: getLawnmowerPath
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public static Object[] getLawnmowerPath(ArrayList<LatLng> area, double stepSize) {
// Compute the bounding box
area.add(area.get(0)); //adds first point to end so the final vector can be computed...
double minLat = 360;
double maxLat = -360;
double minLon = 360;
double maxLon = -360;
Double curLat = null;
System.out.println(area);
for (LatLng latLon : area) { //get list of points
if (latLon.getLatitude() > maxLat) { //if latlong.getLatitude()...
maxLat = latLon.getLatitude();
} else if (latLon.getLatitude() < minLat) {
minLat = latLon.getLatitude();
}
if (latLon.getLongitude() > maxLon) {
maxLon = latLon.getLongitude();
} else if (latLon.getLongitude() < minLon) {
minLon = latLon.getLongitude();
}
}
curLat = minLat;
System.out.println(curLat);
double totalLength = 0.0;
Double leftLon = null, rightLon = null; //locations
ArrayList<LatLng> path = new ArrayList<LatLng>(); //can just
//be latlng
while (curLat <= maxLat) {
// Left to right
leftLon = getMinLonAt(area, minLon, maxLon, curLat);
rightLon = getMaxLonAt(area, minLon, maxLon, curLat);
if (leftLon != null && rightLon != null) {
path.add(new LatLng(curLat, leftLon));
path.add(new LatLng(curLat, rightLon));
totalLength += Math.abs((rightLon - leftLon) * LON_D_PER_M);
} else {
System.out.println("null");
}
// Right to left
curLat = curLat+stepSize;
if (curLat <= maxLat) {
totalLength += stepSize;
rightLon = getMaxLonAt(area, minLon, maxLon, curLat);
leftLon = getMinLonAt(area, minLon, maxLon, curLat);
if (leftLon != null && rightLon != null) {
path.add(new LatLng(curLat, rightLon));
path.add(new LatLng(curLat, leftLon));
totalLength += Math.abs((rightLon - leftLon) * LON_D_PER_M);
} else {
System.out.println("null");
}
}
curLat = curLat + stepSize;
if (curLat <= maxLat) {
totalLength += stepSize;
}
}
return new Object[]{path, totalLength};
}
示例12: orderCCWUpRight
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public static ArrayList<LatLng> orderCCWUpRight(ArrayList<LatLng> list)
{
if (list.size() < 3)
{
return list;
}
//look for most left up point
double minLat = 360;
double maxLat = -360;
double minLon = 360;
double maxLon = -360;
Double curLat = null;
for (LatLng latLon : list) { //get list of points
if (latLon.getLatitude() > maxLat) { //if latlong.getLatitude()...
maxLat = latLon.getLatitude();
} else if (latLon.getLatitude() < minLat) {
minLat = latLon.getLatitude();
}
if (latLon.getLongitude() > maxLon) {
maxLon = latLon.getLongitude();
} else if (latLon.getLongitude() < minLon) {
minLon = latLon.getLongitude();
}
}
curLat = minLat;
// System.out.print(maxLat);
// System.out.print(",");
// System.out.print(maxLon);
// System.out.println("");
ArrayList<LatLng> reordered = new ArrayList<LatLng>();
int start = -1;
for (int i = 0; i < list.size(); i++)
{
if (list.get(i).equals(new LatLng(maxLat,maxLon)))
{
start = i;
// System.out.println(i);
break;
}
}
for (int i = start; i < list.size(); i++)
{
reordered.add(list.get(i));
}
for (int i = 0; i < start; i++)
{
reordered.add(list.get(i));
}
// System.out.println(reordered);
return reordered;
}
示例13: dot
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public double dot(LatLng a, LatLng b) {
return a.getLatitude() * b.getLatitude() + a.getLongitude() * b.getLongitude();
}
示例14: add
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public LatLng add(LatLng a, LatLng b) {
return new LatLng(a.getLatitude() + b.getLatitude(), a.getLongitude() + b.getLongitude());
}
示例15: subtract
import com.mapbox.mapboxsdk.geometry.LatLng; //导入方法依赖的package包/类
public LatLng subtract(LatLng a, LatLng b) {
return new LatLng(a.getLatitude() - b.getLatitude(), a.getLongitude() - b.getLongitude());
//return new LatLng(b.getLatitude() - a.getLatitude(),b.getLongitude() - a.getLongitude());
}