【问题标题】:how to change a particular index of gps latitude and longitude如何更改gps纬度和经度的特定索引
【发布时间】:2017-11-03 07:58:49
【问题描述】:
我想添加实时更新 GPS 纬度和经度的索引,例如如果我有 lat,lng (18.6032,73.7910) 那么我想添加 8th 和 9th 索引,其值从 00 到 99
【问题讨论】:
标签:
java
android
indexing
latitude-longitude
【解决方案1】:
这里有一个解决方案。这是mts
原帖: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);
}