Esempio n. 1
0
        private static void ConvertToProjected(ProjectionInfo dest, double[][] points, int startIndex, int numPoints)
        {
            double frmMeter = 1 / dest.Unit.Meters;
            bool   geoc     = dest.Geoc;
            double lam0     = dest.GetLam0();
            double roneEs   = 1 / (1 - dest.GeographicInfo.Datum.Spheroid.EccentricitySquared());
            bool   over     = dest.Over;
            double x0       = 0;
            double y0       = 0;

            if (dest.FalseEasting != null)
            {
                x0 = dest.FalseEasting.Value;
            }
            if (dest.FalseNorthing != null)
            {
                y0 = dest.FalseNorthing.Value;
            }
            double a = dest.GeographicInfo.Datum.Spheroid.EquatorialRadius;

            for (int i = startIndex; i < numPoints; i++)
            {
                double[] lp = points[i];
                double   t  = Math.Abs(lp[1] - Math.PI / 2);
                if (t < Eps || Math.Abs(lp[0]) > 10)
                {
                    lp[X] = double.PositiveInfinity;
                    lp[Y] = double.PositiveInfinity;
                    continue;
                }
                if (Math.Abs(t) <= Eps)
                {
                    lp[Phi] = lp[Phi] < 0 ? -Math.PI / 2 : Math.PI / 2;
                }
                else if (geoc)
                {
                    lp[Phi] = Math.Atan(roneEs * Math.Tan(lp[Phi]));
                }
                lp[Lam] -= lam0;
                if (!over)
                {
                    lp[Lam] = Adjlon(lp[Lam]);
                }
            }

            // break this out because we don't want a chatty call to extension transforms
            dest.Transform.Forward(points, startIndex, numPoints);

            for (int i = startIndex; i < numPoints; i++)
            {
                points[i][X] = frmMeter * (a * points[i][X] + x0);
                points[i][Y] = frmMeter * (a * points[i][Y] + y0);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the transform using the parameters from the specified coordinate system information
        /// </summary>
        /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param>
        protected override void OnInit(ProjectionInfo projInfo)
        {
            /* read some Parameters,
             * here Latitude Truescale */
            double ts = 0;

            if (projInfo.StandardParallel1 != null)
            {
                ts = projInfo.StandardParallel1.Value * Math.PI / 180;
            }
            _C_x = ts;

            /* we want Bessel as fixed ellipsoid */
            A = 6377397.155;
            E = Math.Sqrt(Es = 0.006674372230614);

            /* if latitude of projection center is not set, use 49d30'N */
            Phi0 = projInfo.LatitudeOfOrigin != null?projInfo.GetPhi0() : 0.863937979737193;


            /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
            /* that will correspond to using longitudes relative to greenwich    */
            /* as input and output, instead of lat/long relative to Ferro */
            Lam0 = projInfo.CentralMeridian != null?projInfo.GetLam0() : 0.7417649320975901 - 0.308341501185665;

            /* if scale not set default to 0.9999 */
            K0 = projInfo.CentralMeridian != null?projInfo.GetLam0() : 0.9999;

            if (!projInfo.Parameters.ContainsKey("czech"))
            {
                return;
            }
            int temp = projInfo.ParamI("czech");

            if (temp != 0)
            {
                _czech = true;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the parameters from the projection info
        /// </summary>
        /// <param name="proj">The projection information used to control this transform</param>
        public void Init(ProjectionInfo proj)
        {
            // Setup protected values common to all the projections that inherit from this projection
            Es = proj.GeographicInfo.Datum.Spheroid.EccentricitySquared();
            if (proj.LatitudeOfOrigin != null)
            {
                Phi0 = proj.GetPhi0();
            }
            if (proj.CentralMeridian != null)
            {
                Lam0 = proj.GetLam0();
            }
            if (proj.FalseEasting != null)
            {
                X0 = proj.FalseEasting.Value;
            }
            if (proj.FalseNorthing != null)
            {
                Y0 = proj.FalseNorthing.Value;
            }
            K0        = proj.ScaleFactor;
            A         = proj.GeographicInfo.Datum.Spheroid.EquatorialRadius;
            E         = proj.GeographicInfo.Datum.Spheroid.Eccentricity();
            Ra        = 1 / A;
            OneEs     = 1 - Es;
            ROneEs    = 1 / OneEs;
            ToMeter   = 1;
            FromMeter = 1;
            //_datumParams = proj.GeographicInfo.Datum.ToWGS84;
            if (proj.Unit != null)
            {
                ToMeter   = proj.Unit.Meters;
                FromMeter = 1 / proj.Unit.Meters;
            }


            if (Es != 0)
            {
                IsElliptical = true;
            }
            OnInit(proj);
        }