|
@@ -21,9 +21,9 @@ public class LocationDistanceUtils {
|
|
|
*/
|
|
*/
|
|
|
public static float getDistance(LatLng a, LatLng b) {
|
|
public static float getDistance(LatLng a, LatLng b) {
|
|
|
try {
|
|
try {
|
|
|
- return Float.valueOf(getDistanceStr(a,b));
|
|
|
|
|
|
|
+ return Float.valueOf(getDistanceStr(a, b));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return -1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -60,20 +60,22 @@ public class LocationDistanceUtils {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取距离,将第一个参数的经纬度反过来
|
|
* 获取距离,将第一个参数的经纬度反过来
|
|
|
|
|
+ *
|
|
|
* @param a
|
|
* @param a
|
|
|
* @param b
|
|
* @param b
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public static float getDistanceBackFrist(LatLng a, LatLng b) {
|
|
public static float getDistanceBackFrist(LatLng a, LatLng b) {
|
|
|
try {
|
|
try {
|
|
|
- return Float.valueOf(getDistanceStr(new LatLng(a.longitude,a.latitude),b));
|
|
|
|
|
|
|
+ return Float.valueOf(getDistanceStr(new LatLng(a.longitude, a.latitude), b));
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return -1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public static float distanceMeBack(LatLng a) {
|
|
public static float distanceMeBack(LatLng a) {
|
|
|
- if (a==null)return -1;
|
|
|
|
|
- String distance = distanceMeStr(new LatLng(a.longitude,a.latitude));
|
|
|
|
|
|
|
+ if (a == null) return -1;
|
|
|
|
|
+ String distance = distanceMeStr(new LatLng(a.longitude, a.latitude));
|
|
|
try {
|
|
try {
|
|
|
return Float.valueOf(distance);
|
|
return Float.valueOf(distance);
|
|
|
} catch (ClassCastException e) {
|
|
} catch (ClassCastException e) {
|
|
@@ -82,6 +84,7 @@ public class LocationDistanceUtils {
|
|
|
return -1f;
|
|
return -1f;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public static String distanceMeStr(LatLng a) {
|
|
public static String distanceMeStr(LatLng a) {
|
|
|
if (a == null) return "";
|
|
if (a == null) return "";
|
|
|
UASLocation mUASLocation = UasLocationHelper.getInstance().getUASLocation();
|
|
UASLocation mUASLocation = UasLocationHelper.getInstance().getUASLocation();
|