2 つの緯度と経度の間の距離を計算しています。いくつかの距離で結果が得られますが、NAN として結果が得られることもあります。
これは、私が取得した 2 つの場所の緯度と経度です。
例: 38.655553,-121.091611
38.654875、-121.091324
以下のコードを使用して、以下のリンクを参照して距離を計算しています
public static double distanceBetween (double currentLat2, double currentLong2, double mallLat2, double mallLong2)
{
float pk = (float) (180/3.14169);
double a1 = currentLat2 / pk;
double a2 = currentLong2 / pk;
double b1 = mallLat2 / pk;
double b2 = mallLong2 / pk;
double t1 = FloatMath.cos((float) a1)*FloatMath.cos((float) a2)*FloatMath.cos((float) b1)*FloatMath.cos((float) b2);
double t2 = FloatMath.cos((float) a1)*FloatMath.sin((float) a2)*FloatMath.cos((float) b1)*FloatMath.sin((float) b2);
double t3 = FloatMath.sin((float) a1)*FloatMath.sin((float) b1);
double tt = Math.acos(t1 + t2 + t3);
return 6366000*tt;
}
ヘルプはありますか?
ありがとう。