コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ellip">椭圆体</param>
        /// <param name="isSouth_hemisphere">是否南半球 UTM的“false easting”值为500km,而南半球UTM带的“false northing”为10000km</param>
        /// <param name="_xyc">投影经纬度</param>
        /// <param name="_log0">起始经度</param>
        /// <param name="_lat0">起始维度</param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static LBCoord reverseUTM(ellipsoid ellip, bool isSouth_hemisphere, XYCoord _xyc, double _log0, double _lat0)
        {
            Ellipsoid _ellip = new Ellipsoid(ellip);
            double    e1     = _ellip.e1;
            double    e2     = _ellip.e2;
            double    k0     = 0.9996;
            double    FE     = 500000;
            double    FN     = 0;

            if (isSouth_hemisphere)
            {
                FN = 10000000;
            }

            double a = _ellip.a;

            double log0 = _log0 * Math.PI / 180.0;
            double lat0 = _lat0 * Math.PI / 180.0;

            double E = _xyc.X;
            double N = _xyc.Y;

            double M0 = a * ((1 - Math.Pow(e1, 2) / 4 - 3 * Math.Pow(e1, 4) / 64 - 5 * Math.Pow(e1, 6) / 256) * log0 -
                             (3 * Math.Pow(e1, 2) / 8 + 3 * Math.Pow(e1, 4) / 32 + 45 * Math.Pow(e1, 6) / 1024) * Math.Sin(2 * log0) +
                             (15 * Math.Pow(e1, 4) / 256 + 45 * Math.Pow(e1, 6) / 1024) * Math.Sin(4 * log0) -
                             (35 * Math.Pow(e1, 6) / 3027) * Math.Sin(6 * log0));
            double M1   = M0 + (N - FN) / k0;
            double miu1 = M1 / (a * (1 - e1 * e1 / 4 - 3 * Math.Pow(e1, 4) / 64 - 5 * Math.Pow(e1, 6) / 256));
            double _e1  = (1 - Math.Sqrt(1 - e1 * e1)) / (1 + Math.Sqrt(1 - e1 * e1));
            double log1 = miu1 +
                          ((3 * _e1 / 2 - 27 * _e1 * _e1 * _e1 / 32) * Math.Sin(2 * miu1) +
                           (21 * _e1 * _e1 / 16 - 55 * Math.Pow(_e1, 4) / 32) * Math.Sin(4 * miu1)
                           + (151 * Math.Pow(_e1, 3) / 96) * Math.Sin(6 * miu1) + (1097 * Math.Pow(_e1, 4)) * Math.Sin(8 * miu1));

            double T1 = Math.Pow(Math.Tan(log1), 2);
            double C1 = Math.Pow(e2 * Math.Cos(log1), 2);

            double v1 = a / Math.Sqrt(1 - Math.Pow(e1 * Math.Sin(log1), 2));
            double D  = (E - FE) / (v1 * k0);

            double rol1 = a * (1 - e1 * e1) / Math.Pow(1 - Math.Pow(e1 * Math.Sin(log1), 2), 1.5);


            double log = log1 -
                         (v1 * Math.Tan(log1) / rol1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * e2 * e2) * Math.Pow(D, 4) / 24
                                                         +
                                                         (61 + 90 * T1 + 298 * C1 + 45 * T1 - 252 * e2 * e2 - 3 * C1 * C1) * Math.Pow(D, 6) /
                                                         720);

            double lat = lat0 +
                         (D - (1 + 2 * T1 + C1) * Math.Pow(D, 3) / 6 +
                          (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * Math.Pow(e2, 2) + 24 * T1 * T1) * Math.Pow(D, 5) / 120) /
                         Math.Cos(log1);

            return(new LBCoord(tools.toDegree(lat), tools.toDegree(log)));
        }
コード例 #2
0
        public static LBCoord reverseMercator(ellipsoid ellip, XYCoord _xyc, double _log1, double _log0, double _lat0)
        {
            Ellipsoid _ellip = new Ellipsoid(ellip);
            double    e1     = _ellip.e1;
            double    e2     = _ellip.e2;

            double FE = 0;
            double FN = 0;

            //result+="ellipsoid.Clarke1866\n";
            double a = _ellip.a;

            //a=6377563.396;
            //e1=Math.Sqrt(0.00667054);
            //e2=Math.Sqrt(0.00671534);

            double lat0 = _lat0 * Math.PI / 180.0;

            double E = _xyc.X;
            double N = _xyc.Y;

            double log1 = tools.toRad(_log1);
            double k0   = Math.Cos(log1) / Math.Sqrt(1 - Math.Pow(e1 * Math.Sin(log1), 2));

            double t   = Math.Pow(Math.E, (FN - N) / (a * k0));
            double x   = Math.PI / 2 - 2 * Math.Atan(t);
            double log = x +
                         (e1 * e1 / 2 + 5 * Math.Pow(e1, 4) / 24 + Math.Pow(e1, 6) / 12 + 13 * Math.Pow(e1, 8) / 360) * Math.Sin(2 * x) +
                         (7 * Math.Pow(e1, 4) / 48 + 29 * Math.Pow(e1, 6) / 240 + 811 * Math.Pow(e1, 8) / 11520) * Math.Sin(4 * x)
                         + (7 * Math.Pow(e1, 6) / 120 + 81 * Math.Pow(e1, 8) / 1120) * Math.Sin(6 * x) +
                         (4279 * Math.Pow(e1, 8) / 161280) * Math.Sin(8 * x);
            //double log=log1;
            //double templog=log+1;
            //while(log!=templog)
            //{
            //	templog=log;
            //	log=Math.PI/2-2*Math.Atan(Math.Pow(Math.E,-N/k0)*Math.Pow(Math.E,e1/2*Math.Log((1-e1*Math.Sin(log))/(1+e1*Math.Sin(log)),Math.E)));
            //}
            double lat = (E - FE) / (a * k0) + lat0;

            return(new LBCoord(tools.toDegree(lat), tools.toDegree(log)));
        }
コード例 #3
0
        public static LBCoord reversLambert(ellipsoid ellip, XYCoord _xyc, double _log1, double _log2, double _log0,
                                            double _lat0, ref string result)
        {
            Ellipsoid _ellip = new Ellipsoid(ellip);

            double e = _ellip.e1;

            result += "e:" + e.ToString() + " a:" + _ellip.a.ToString() + "\n";
            result += "-------------------------------------\n";

            double log1 = _log1 * Math.PI / 180.0;
            double log2 = _log2 * Math.PI / 180.0;

            double log0 = _log0 * Math.PI / 180.0;
            double lat0 = _lat0 * Math.PI / 180.0;

            double E = _xyc.X;
            double N = _xyc.Y;


            result += "l1:" + log1.ToString() + "\n";

            result += "l2:" + log2.ToString() + "\n";
            result += "log0:" + log0.ToString() + "\n";
            result += "lat0:" + lat0.ToString() + "\n";
            result += "E:" + E.ToString() + "\n";
            result += "N:" + N.ToString() + "\n";
            result += "-----------------------\n";

            double m1 = Math.Cos(log1) / Math.Sqrt(1 - e * e * Math.Sin(log1) * Math.Sin(log1));
            double m2 = Math.Cos(log2) / Math.Sqrt(1 - e * e * Math.Sin(log2) * Math.Sin(log2));

            result += "m1:" + m1.ToString() + "\n";
            result += "m1:" + m2.ToString() + "\n";

            double t1 = Lam_gett(log1, e);
            double t2 = Lam_gett(log2, e);
            double tF = Lam_gett(log0, e);


            result += "t1:" + t1.ToString() + "\n";
            result += "t2:" + t2.ToString() + "\n";
            result += "tF:" + tF.ToString() + "\n";


            double n  = Math.Log(m1 / m2, Math.E) / Math.Log(t1 / t2, Math.E);
            double F  = m1 / (n * Math.Pow(t1, n));
            double rF = _ellip.a * (F * Math.Pow(tF, n));


            result += "n:" + n.ToString() + "\n";
            result += "F:" + F.ToString() + "\n";
            result += "rF:" + rF.ToString() + "\n";


            double EF  = 0;
            double NF  = 0.0;
            double tht = Math.Atan((E - EF) / (rF - (N - NF)));
            double r   = Math.Sqrt((E - EF) * (E - EF) + (rF - (N - NF)) * (rF - (N - NF)));

            if (n < 0)
            {
                r = -r;
            }
            double t = Math.Pow(r / (_ellip.a * F), 1 / n);

            result += "tht:" + tht.ToString() + "\n";
            result += "r:" + r.ToString() + "\n";
            result += "t:" + t.ToString() + "\n";

            double log    = Math.PI / 2 - 2 * Math.Atan(t);
            double prelog = log + 1;

            while (log != prelog)
            {
                prelog = log;
                log    = Math.PI / 2 - 2 * Math.Atan(t * Math.Pow((1 - e * Math.Sin(log)) / (1 + e * Math.Sin(log)), e / 2));
            }
            double lat = tht / n + lat0;

            return(new LBCoord(lat / Math.PI * 180, log / Math.PI * 180));
        }
コード例 #4
0
        public static LBCoord reVersAlbers(ellipsoid ellip, XYCoord _xyc, double _log1, double _log2, double _log0,
                                           double _lat0, ref string result)
        {
            Ellipsoid _ellip = new Ellipsoid(ellip);

            double e = _ellip.e1;

            result += "e:" + e.ToString() + " a:" + _ellip.a.ToString() + "\n";
            result += "-------------------------------------\n";

            double l1 = _log1 * Math.PI / 180.0;
            double l2 = _log2 * Math.PI / 180.0;

            double l0   = _log0 * Math.PI / 180.0;
            double lmt0 = _lat0 * Math.PI / 180.0;

            double E = _xyc.X;
            double N = _xyc.Y;


            result += "l1:" + l1.ToString() + "\n";

            result += "l2:" + l2.ToString() + "\n";
            result += "l0:" + l0.ToString() + "\n";
            result += "lmt0:" + lmt0.ToString() + "\n";
            result += "E:" + E.ToString() + "\n";
            result += "N:" + N.ToString() + "\n";
            result += "-----------------------\n";


            double alpha1 = getalpha(_ellip, l1);
            double alpha2 = getalpha(_ellip, l2);
            double alpha0 = getalpha(_ellip, l0);


            double m1 = Math.Cos(l1) / Math.Sqrt(1 - e * e * Math.Sin(l1) * Math.Sin(l1));
            double m2 = Math.Cos(l2) / Math.Sqrt(1 - e * e * Math.Sin(l2) * Math.Sin(l2));


            result += "m1:" + m1.ToString() + "\nm2:" + m2.ToString() + "\n";
            double n = (m1 * m1 - m2 * m2) / (alpha2 - alpha1);
            double c = (m1 * m1 * alpha2 - m2 * m2 * alpha1) / (alpha2 - alpha1);

            result += "n:" + n.ToString() + "\nc:" + c.ToString() + "\n";

            double rol0  = (_ellip.a * Math.Sqrt(c - n * alpha0)) / n;
            double tht   = Math.Atan(E / (rol0 - N));
            double rol   = Math.Sqrt(E * E + (rol0 - N) * (rol0 - N));
            double alpha = (c - rol * rol * n * n / (_ellip.a * _ellip.a)) / n;

            //λO + (θ / n) ?' + (e2/3 + 31e4/180 + 517e6/5040) . sin 2?'] + [(23e4/360 + 251e6/3780) . sin 4?']
            //+ [(761e6/45360) . sin 6?']
            result += "rol0:" + rol0.ToString() + "\nrol:" + rol.ToString() + "\n";
            double beta = Math.Asin(alpha / (1 - (1 - e * e) / (2 * e) * Math.Log((1 - e) / (1 + e), Math.E)));

            double lmt = (lmt0 + (tht / n)) / Math.PI * 180.0;

            double l = beta + (e * e / 3 + 31 * Math.Pow(e, 4) / 180 + 517 * Math.Pow(e, 6) / 5040) * Math.Sin(2 * beta) +
                       (23 * Math.Pow(e, 4) / 360
                        + 251 * Math.Pow(e, 6) / 3780) * Math.Sin(4 * beta) + 761 * Math.Pow(e, 6) / 45360 * Math.Sin(6 * beta);

            return(new LBCoord(lmt, (l / Math.PI * 180.0)));
        }