0
私はリアルタイム更新のGPS緯度と経度のインデックスを追加したいと思います。私は緯度持っていた場合、LNG (18.6032,73.7910)
は、私はここに解決策がある00
から99
どのようにGPSの緯度と経度の特定のインデックスを変更する
私はリアルタイム更新のGPS緯度と経度のインデックスを追加したいと思います。私は緯度持っていた場合、LNG (18.6032,73.7910)
は、私はここに解決策がある00
から99
どのようにGPSの緯度と経度の特定のインデックスを変更する
に値を8th
と9th
インデックスを追加します。これは
オリジナルポストメートルです:https://dzone.com/articles/distance-calculation-using-3
private void distance(double lat1, double lon1,double lat2, double lon2) {
double theta = lon1 - lon2;
double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2)) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.cos(deg2rad(theta));
dist = Math.acos(dist);
dist = rad2deg(dist);
this.distancia = dist * 60 * 1.1515 * 1609.344;
}
/**
* This function converts decimal degrees to radians
* @param deg
* @return
*/
private static double deg2rad(double deg) {
return (deg * Math.PI/180.0);
}
/**
* This function converts radians to decimal degrees
* @param rad
* @return
*/
private static double rad2deg(double rad) {
return (rad * 180.0/Math.PI);
}
はStackOverflowのへようこそ。 [ツアー](http://stackoverflow.com/tour)を見て、[ヘルプセンター](http://stackoverflow.com/help)を読んで[質問する方法]を読んでください。 (http://stackoverflow.com/help/how-to-ask)、[どのような質問を避けるべきですか?](http://stackoverflow.com/help/dont-ask)、[MCVE:最小、完全、および検証可能な例](http://stackoverflow.com/help/mcve)周囲の人々があなたが何を意味するのか、問題が何であるかを簡単に読んで理解することができれば、彼らはもっと助けてくれるでしょう:) – Dwhitz