Skip to content

Commit

Permalink
✨ 完善 GeoUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
li-xunhuan committed Dec 15, 2023
1 parent b8d7eac commit 577754a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mica-core/src/main/java/net/dreamlu/mica/core/geo/GeoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ public static double getDistance(double lng1, double lat1, double lng2, double l
* EARTH_RADIUS;
}

/**
* 将整数形式的经纬度转换为十进制度格式
*
* @param coordinate 整数形式的经度或纬度
* @return 十进制度格式的经纬度
*/
public static double getGpsValue(int coordinate) {
int degrees = coordinate / (3600 * 100);
int remainder = coordinate % (3600 * 100);
int minutes = remainder / (60 * 100);
remainder = remainder % (60 * 100);
double seconds = remainder / 100.0;
// 将分和秒转换为度的小数部分
return degrees + (minutes / 60.0) + (seconds / 3600.0);
}

private static double radian(double d) {
return d * Math.PI / 180.0;
}
Expand Down

0 comments on commit 577754a

Please sign in to comment.