月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-09-16 8300bfcfd58e84d27163ba94b8e026cfcf4f90a6
src/main/java/com/moon/server/helper/GeoHelper.java
@@ -17,6 +17,10 @@
 * @date 2023-09-14
 */
public class GeoHelper {
    public static SpatialReference sr4326;
    public static SpatialReference sr4490;
    public static SpatialReference sr104903;
    public final static double MOON_RADIUS = 1738000;
@@ -30,6 +34,12 @@
     */
    public static void initSr() {
        try {
            sr4326 = new SpatialReference();
            sr4326.ImportFromEPSG(StaticData.I4326);
            sr4490 = new SpatialReference();
            sr4490.ImportFromEPSG(StaticData.I4490);
            sr104903 = new SpatialReference(StaticData.MOON_2000_WKT);
            crs104903 = CRS.parseWKT(StaticData.MOON_2000_WKT);
@@ -39,9 +49,20 @@
    }
    /**
     * 获取距离1
     * 获取距离
     */
    public static double getDistance1(double lon1, double lat1, double lon2, double lat2) {
    public static double getDistance(double x1, double y1, double x2, double y2) {
        GeodeticCalculator geodeticCalculator = new GeodeticCalculator(crs104903);
        geodeticCalculator.setStartingGeographicPoint(x1, y1);
        geodeticCalculator.setDestinationGeographicPoint(x2, y2);
        return geodeticCalculator.getOrthodromicDistance();
    }
    /**
     * 获取距离2
     */
    public static double getDistance2(double lon1, double lat1, double lon2, double lat2) {
        double radLat1 = Math.toRadians(lat1);
        double radLat2 = Math.toRadians(lat2);
        double a = radLat1 - radLat2;
@@ -52,17 +73,6 @@
    }
    /**
     * 获取距离2
     */
    public static double getDistance2(double x1, double y1, double x2, double y2) {
        GeodeticCalculator geodeticCalculator = new GeodeticCalculator(crs104903);
        geodeticCalculator.setStartingGeographicPoint(x1, y1);
        geodeticCalculator.setDestinationGeographicPoint(x2, y2);
        return geodeticCalculator.getOrthodromicDistance();
    }
    /**
     * 获取方向角
     */
    public static double getBearing(double x1, double y1, double x2, double y2) {
@@ -70,9 +80,9 @@
    }
    /**
     * 获取角度1
     * 获取角度
     */
    public static double getAngle1(double x1, double y1, double x2, double y2) {
    public static double getAngle(double x1, double y1, double x2, double y2) {
        DirectPosition2D p1 = new DirectPosition2D(crs104903, x1, y1);
        DirectPosition2D p2 = new DirectPosition2D(crs104903, x2, y2);
@@ -100,7 +110,7 @@
    /**
     * 根据距离和角度获取目标点
     */
    private static Point2D getPointByDistanceAndAngle(double x, double y, double angle, double distance) {
    public static Point2D getPointByDistanceAndAngle(double x, double y, double angle, double distance) {
        DirectPosition2D p1 = new DirectPosition2D(x, y);
        GeodeticCalculator gc = new GeodeticCalculator();