2024-02-21 14:32:13.0
无极低码 :https://wheart.cn

标称上行列号和经纬度的互相转换

FY-4 卫星采用 CGMS LRIT/HRIT 全球规范定义的静止轨

道标称投影,地理坐标基于 WGS84 参考椭球计算得到。

import java.util.Scanner;
import java.math.*;

public class LatLon2Nominal {

    // 地球参数
    static final double EA = 6378.137; // 地球半长轴
    static final double EB = 6356.7523; // 地球半短轴
    static final double H = 42164; // 地心到卫星质心的距离
    static final double DLO = 104.7; // 卫星星下点所在经度
    static final double PI = Math.PI; // 圆周率

    // 比例因子和偏移量
    static final int COFF_500 = 10991;
    static final int CFAC_500 = 81865099;
    static final int LOFF_500 = 10991;
    static final int LFAC_500 = 81865099;

    // 将经纬度转标称上行列号
    public static int[] latLon2Nominal(double lon, double lat, int resolution) {
        int COFF = COFF_500;
        int CFAC = CFAC_500;
        int LOFF = LOFF_500;
        int LFAC = LFAC_500;

        if (resolution == 1000) {
            COFF /= 2;
            CFAC /= 2;
            LOFF /= 2;
            LFAC /= 2;
        } else if (resolution == 2000) {
            COFF /= 4;
            CFAC /= 4;
            LOFF /= 4;
            LFAC /= 4;
        } else if (resolution == 4000) {
            COFF /= 8;
            CFAC /= 8;
            LOFF /= 8;
            LFAC /= 8;
        }

        double e = lat * PI / 180;
        double r = EA * (1 - Math.pow(EB, 2) / Math.pow(EA, 2)) / Math.sqrt(1 - Math.pow(Math.sin(e), 2));
        double x = r * Math.cos(e) * Math.cos(lon * PI / 180);
        double y = r * Math.cos(e) * Math.sin(lon * PI / 180);
        double z = r * Math.sin(e);

        int c = (int) ((x / (resolution / 1000)) * CFAC) + COFF;
        int l = (int) ((y / (resolution / 1000)) * LFAC) + LOFF;

        return new int[]{l, c};
    }

    // 将标称上行列号转经纬度
    public static double[] nominal2LatLon(int l, int c, int resolution) {
        int COFF = COFF_500;
        int CFAC = CFAC_500;
        int LOFF = LOFF_500;
        int LFAC = LFAC_500;

        if (resolution == 1000) {
            COFF /= 2;
            CFAC /= 2;
            LOFF /= 2;
            LFAC /= 2;
        } else if (resolution == 2000) {
            COFF /= 4;
            CFAC /= 4;
            LOFF /= 4;
            LFAC /= 4;
        } else if (resolution == 4000) {
            COFF /= 8;
            CFAC /= 8;
            LOFF /= 8;
            LFAC /= 8;
        }

        double x = ((c - COFF) / CFAC) * (resolution / 1000);
        double y = ((l - LOFF) / LFAC) * (resolution / 1000);

        double sxy = Math.sqrt(x * x + y * y);
        double s = Math.sqrt(sxy * sxy + z * z);
        double lat = Math.asin(z / s) * 180 / PI;
        double lon = Math.atan2(y, x) * 180 / PI;

        return new double[]{lon, lat};
    }

    public static void main(String[] args) {
     
        double  lon=139.2234;
        double  lat=37.1232;
        int  resolution=500;//(500/1000/2000/4000)
        int[] nominal = latLon2Nominal(lon, lat, resolution);
        System.out.println("标称上行列号:" + nominal[0] + " " + nominal[1]);

        double[] latLon = nominal2LatLon(nominal[0],  nominal[1], resolution);
        System.out.println("地理经纬度:" + latLon[0] + " " + latLon[1]);
    }
}



无极低码 :https://wheart.cn
最新文章