Ejemplo n.º 1
0
        /// <summary>
        /// Converts coordinates in decimal degrees to projected meters.
        /// </summary>
        /// <param name="lonlat">The point in decimal degrees.</param>
        /// <returns>Point in projected meters</returns>
        public override double[] DegreesToMeters(double[] lonlat)
        {
            double num4;
            double num  = MathTransform.Degrees2Radians(lonlat[0]);
            double num2 = MathTransform.Degrees2Radians(lonlat[1]);

            if (Math.Abs((double)(Math.Abs(num2) - 1.5707963267948966)) > 1E-10)
            {
                double sinphi = Math.Sin(num2);
                double x      = MapProjection.tsfnz(this.e, num2, sinphi);
                num4 = (base._semiMajor * this.f0) * Math.Pow(x, this.ns);
            }
            else
            {
                double num3 = num2 * this.ns;
                if (num3 <= 0)
                {
                    throw new ApplicationException();
                }
                num4 = 0;
            }
            double a = this.ns * MapProjection.adjust_lon(num - this.center_lon);

            return(new double[] { ((num4 * Math.Sin(a)) + this._falseEasting), ((this.rh - (num4 * Math.Cos(a))) + this._falseNorthing) });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an instance of an TransverseMercatorProjection projection object.
        /// </summary>
        /// <param name="parameters">List of parameters to initialize the projection.</param>
        /// <param name="inverse">Flag indicating wether is a forward/projection (false) or an inverse projection (true).</param>
        /// <remarks>
        /// <list type="bullet">
        /// <listheader><term>Items</term><description>Descriptions</description></listheader>
        /// <item><term>semi_major</term><description>Semi major radius</description></item>
        /// <item><term>semi_minor</term><description>Semi minor radius</description></item>
        /// <item><term>scale_factor</term><description></description></item>
        /// <item><term>central meridian</term><description></description></item>
        /// <item><term>latitude_origin</term><description></description></item>
        /// <item><term>false_easting</term><description></description></item>
        /// <item><term>false_northing</term><description></description></item>
        /// </list>
        /// </remarks>
        public TransverseMercator(List <ProjectionParameter> parameters, bool inverse) : base(parameters, inverse)
        {
            base.Name          = "Transverse_Mercator";
            base.Authority     = "EPSG";
            base.AuthorityCode = 0x264fL;
            ProjectionParameter parameter  = base.GetParameter("semi_major");
            ProjectionParameter parameter2 = base.GetParameter("semi_minor");
            ProjectionParameter parameter3 = base.GetParameter("scale_factor");
            ProjectionParameter parameter4 = base.GetParameter("central_meridian");
            ProjectionParameter parameter5 = base.GetParameter("latitude_of_origin");
            ProjectionParameter parameter6 = base.GetParameter("false_easting");
            ProjectionParameter parameter7 = base.GetParameter("false_northing");

            if (parameter == null)
            {
                throw new ArgumentException("Missing projection parameter 'semi_major'");
            }
            if (parameter2 == null)
            {
                throw new ArgumentException("Missing projection parameter 'semi_minor'");
            }
            if (parameter3 == null)
            {
                throw new ArgumentException("Missing projection parameter 'scale_factor'");
            }
            if (parameter4 == null)
            {
                throw new ArgumentException("Missing projection parameter 'central_meridian'");
            }
            if (parameter5 == null)
            {
                throw new ArgumentException("Missing projection parameter 'latitude_of_origin'");
            }
            if (parameter6 == null)
            {
                throw new ArgumentException("Missing projection parameter 'false_easting'");
            }
            if (parameter7 == null)
            {
                throw new ArgumentException("Missing projection parameter 'false_northing'");
            }
            this.r_major          = parameter.Value;
            this.r_minor          = parameter2.Value;
            this.scale_factor     = parameter3.Value;
            this.central_meridian = MathTransform.Degrees2Radians(parameter4.Value);
            this.lat_origin       = MathTransform.Degrees2Radians(parameter5.Value);
            this.false_easting    = parameter6.Value;
            this.false_northing   = parameter7.Value;
            this.es  = 1 - Math.Pow(this.r_minor / this.r_major, 2);
            this.e   = Math.Sqrt(this.es);
            this.e0  = MapProjection.e0fn(this.es);
            this.e1  = MapProjection.e1fn(this.es);
            this.e2  = MapProjection.e2fn(this.es);
            this.e3  = MapProjection.e3fn(this.es);
            this.ml0 = this.r_major * MapProjection.mlfn(this.e0, this.e1, this.e2, this.e3, this.lat_origin);
            this.esp = this.es / (1 - this.es);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts coordinates in projected meters to decimal degrees.
        /// </summary>
        /// <param name="p">Point in meters</param>
        /// <returns>Transformed point in decimal degrees</returns>
        public override double[] MetersToDegrees(double[] p)
        {
            long   num16 = 6L;
            double num17 = p[0] - this.false_easting;
            double x     = p[1] - this.false_northing;
            double d     = (this.ml0 + (x / this.scale_factor)) / this.r_major;
            double num2  = d;
            long   num4  = 0L;

            while (true)
            {
                double num3 = ((((d + (this.e1 * Math.Sin(2 * num2))) - (this.e2 * Math.Sin(4 * num2))) + (this.e3 * Math.Sin(6 * num2))) / this.e0) - num2;
                num2 += num3;
                if (Math.Abs(num3) <= 1E-10)
                {
                    break;
                }
                if (num4 >= num16)
                {
                    throw new ApplicationException("Latitude failed to converge");
                }
                num4 += 1L;
            }
            if (Math.Abs(num2) < 1.5707963267948966)
            {
                double num5;
                double num6;
                MapProjection.sincos(num2, out num5, out num6);
                double num7  = Math.Tan(num2);
                double num8  = this.esp * Math.Pow(num6, 2);
                double num9  = Math.Pow(num8, 2);
                double num10 = Math.Pow(num7, 2);
                double num11 = Math.Pow(num10, 2);
                d = 1 - (this.es * Math.Pow(num5, 2));
                double num12 = this.r_major / Math.Sqrt(d);
                double num13 = (num12 * (1 - this.es)) / d;
                double num14 = num17 / (num12 * this.scale_factor);
                double num15 = Math.Pow(num14, 2);
                double rad   = num2 - ((((num12 * num7) * num15) / num13) * (0.5 - ((num15 / 24) * (((((5 + (3 * num10)) + (10 * num8)) - (4 * num9)) - (9 * this.esp)) - ((num15 / 30) * (((((61 + (90 * num10)) + (298 * num8)) + (45 * num11)) - (252 * this.esp)) - (3 * num9)))))));
                double num20 = MapProjection.adjust_lon(this.central_meridian + ((num14 * (1 - ((num15 / 6) * (((1 + (2 * num10)) + num8) - ((num15 / 20) * (((((5 - (2 * num8)) + (28 * num10)) - (3 * num9)) + (8 * this.esp)) + (24 * num11))))))) / num6));
                return(new double[] { MathTransform.Radians2Degrees(num20), MathTransform.Radians2Degrees(rad) });
            }
            return(new double[] { MathTransform.Radians2Degrees(1.5707963267948966 * MapProjection.sign(x)), MathTransform.Radians2Degrees(this.central_meridian) });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts coordinates in projected meters to decimal degrees.
        /// </summary>
        /// <param name="p">Point in meters</param>
        /// <returns>Transformed point in decimal degrees</returns>
        public override double[] MetersToDegrees(double[] p)
        {
            double num3;
            double num4;
            double naN  = double.NaN;
            double rad  = double.NaN;
            long   flag = 0L;
            double num8 = p[0] - this._falseEasting;
            double num9 = (this.rh - p[1]) + this._falseNorthing;

            if (this.ns > 0)
            {
                num3 = Math.Sqrt((num8 * num8) + (num9 * num9));
                num4 = 1;
            }
            else
            {
                num3 = -Math.Sqrt((num8 * num8) + (num9 * num9));
                num4 = -1;
            }
            double num6 = 0;

            if (num3 != 0)
            {
                num6 = Math.Atan2(num4 * num8, num4 * num9);
            }
            if ((num3 != 0) || (this.ns > 0))
            {
                num4 = 1 / this.ns;
                double ts = Math.Pow(num3 / (base._semiMajor * this.f0), num4);
                rad = MapProjection.phi2z(this.e, ts, out flag);
                if (flag != 0L)
                {
                    throw new ApplicationException();
                }
            }
            else
            {
                rad = -1.5707963267948966;
            }
            naN = MapProjection.adjust_lon((num6 / this.ns) + this.center_lon);
            return(new double[] { MathTransform.Radians2Degrees(naN), MathTransform.Radians2Degrees(rad) });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Converts coordinates in decimal degrees to projected meters.
        /// </summary>
        /// <param name="lonlat">The point in decimal degrees.</param>
        /// <returns>Point in projected meters</returns>
        public override double[] DegreesToMeters(double[] lonlat)
        {
            double num4;
            double num5;
            double num  = MathTransform.Degrees2Radians(lonlat[0]);
            double val  = MathTransform.Degrees2Radians(lonlat[1]);
            double num3 = 0;

            num3 = MapProjection.adjust_lon(num - this.central_meridian);
            MapProjection.sincos(val, out num4, out num5);
            double x     = num5 * num3;
            double num7  = Math.Pow(x, 2);
            double num8  = this.esp * Math.Pow(num5, 2);
            double num10 = Math.Tan(val);
            double num9  = Math.Pow(num10, 2);
            double d     = 1 - (this.es * Math.Pow(num4, 2));
            double num12 = this.r_major / Math.Sqrt(d);
            double num13 = this.r_major * MapProjection.mlfn(this.e0, this.e1, this.e2, this.e3, val);

            return(new double[] { ((((this.scale_factor * num12) * x) * (1 + ((num7 / 6) * (((1 - num9) + num8) + ((num7 / 20) * ((((5 - (18 * num9)) + Math.Pow(num9, 2)) + (72 * num8)) - (58 * this.esp))))))) + this.false_easting), ((this.scale_factor * ((num13 - this.ml0) + ((num12 * num10) * (num7 * (0.5 + ((num7 / 24) * ((((5 - num9) + (9 * num8)) + (4 * Math.Pow(num8, 2))) + ((num7 / 30) * ((((61 - (58 * num9)) + Math.Pow(num9, 2)) + (600 * num8)) - (330 * this.esp)))))))))) + this.false_northing) });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Checks whether the values of this instance is equal to the values of another instance.
        /// Only parameters used for coordinate system are used for comparison.
        /// Name, abbreviation, authority, alias and remarks are ignored in the comparison.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>True if equal</returns>
        public bool EqualParams(object obj)
        {
            if (!(obj is MapProjection))
            {
                return(false);
            }
            MapProjection proj = obj as MapProjection;

            if (proj.NumParameters != this.NumParameters)
            {
                return(false);
            }
            Predicate <ProjectionParameter> match = null;

            for (int i = 0; i < this._Parameters.Count; i++)
            {
                if (match == null)
                {
                    match = delegate(ProjectionParameter par) {
                        return(par.Name.Equals(proj.GetParameter(i).Name, StringComparison.OrdinalIgnoreCase));
                    };
                }
                ProjectionParameter parameter = this._Parameters.Find(match);
                if (parameter == null)
                {
                    return(false);
                }
                if (parameter.Value != proj.GetParameter(i).Value)
                {
                    return(false);
                }
            }
            if (this.IsInverse != proj.IsInverse)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates an instance of an Albers projection object.
        /// </summary>
        /// <remarks>
        /// <para>The parameters this projection expects are listed below.</para>
        /// <list type="table">
        /// <listheader><term>Parameter</term><description>Description</description></listheader>
        /// <item><term>latitude_of_origin</term><description>The latitude of the point which is not the natural origin and at which grid coordinate values false easting and false northing are defined.</description></item>
        /// <item><term>central_meridian</term><description>The longitude of the point which is not the natural origin and at which grid coordinate values false easting and false northing are defined.</description></item>
        /// <item><term>standard_parallel_1</term><description>For a conic projection with two standard parallels, this is the latitude of intersection of the cone with the ellipsoid that is nearest the pole.  Scale is true along this parallel.</description></item>
        /// <item><term>standard_parallel_2</term><description>For a conic projection with two standard parallels, this is the latitude of intersection of the cone with the ellipsoid that is furthest from the pole.  Scale is true along this parallel.</description></item>
        /// <item><term>false_easting</term><description>The easting value assigned to the false origin.</description></item>
        /// <item><term>false_northing</term><description>The northing value assigned to the false origin.</description></item>
        /// </list>
        /// </remarks>
        /// <param name="parameters">List of parameters to initialize the projection.</param>
        /// <param name="isInverse">Indicates whether the projection forward (meters to degrees or degrees to meters).</param>
        public LambertConformalConic2SP(List <ProjectionParameter> parameters, bool isInverse) : base(parameters, isInverse)
        {
            double num5;
            double num6;

            base.Name          = "Lambert_Conformal_Conic_2SP";
            base.Authority     = "EPSG";
            base.AuthorityCode = 0x264aL;
            ProjectionParameter parameter  = base.GetParameter("latitude_of_origin");
            ProjectionParameter parameter2 = base.GetParameter("central_meridian");
            ProjectionParameter parameter3 = base.GetParameter("standard_parallel_1");
            ProjectionParameter parameter4 = base.GetParameter("standard_parallel_2");
            ProjectionParameter parameter5 = base.GetParameter("false_easting");
            ProjectionParameter parameter6 = base.GetParameter("false_northing");

            if (parameter == null)
            {
                throw new ArgumentException("Missing projection parameter 'latitude_of_origin'");
            }
            if (parameter2 == null)
            {
                throw new ArgumentException("Missing projection parameter 'central_meridian'");
            }
            if (parameter3 == null)
            {
                throw new ArgumentException("Missing projection parameter 'standard_parallel_1'");
            }
            if (parameter4 == null)
            {
                throw new ArgumentException("Missing projection parameter 'standard_parallel_2'");
            }
            if (parameter5 == null)
            {
                throw new ArgumentException("Missing projection parameter 'false_easting'");
            }
            if (parameter6 == null)
            {
                throw new ArgumentException("Missing projection parameter 'false_northing'");
            }
            double num  = MathTransform.Degrees2Radians(parameter.Value);
            double num2 = MathTransform.Degrees2Radians(parameter2.Value);
            double val  = MathTransform.Degrees2Radians(parameter3.Value);
            double num4 = MathTransform.Degrees2Radians(parameter4.Value);

            this._falseEasting  = parameter5.Value;
            this._falseNorthing = parameter6.Value;
            if (Math.Abs((double)(val + num4)) < 1E-10)
            {
                throw new ArgumentException("Equal latitudes for St. Parallels on opposite sides of equator.");
            }
            this.es         = 1 - Math.Pow(base._semiMinor / base._semiMajor, 2);
            this.e          = Math.Sqrt(this.es);
            this.center_lon = num2;
            this.center_lat = num;
            MapProjection.sincos(val, out num5, out num6);
            double num7 = num5;
            double num8 = MapProjection.msfnz(this.e, num5, num6);
            double x    = MapProjection.tsfnz(this.e, val, num5);

            MapProjection.sincos(num4, out num5, out num6);
            double num9  = MapProjection.msfnz(this.e, num5, num6);
            double num12 = MapProjection.tsfnz(this.e, num4, num5);

            num5 = Math.Sin(this.center_lat);
            double num10 = MapProjection.tsfnz(this.e, this.center_lat, num5);

            if (Math.Abs((double)(val - num4)) > 1E-10)
            {
                this.ns = Math.Log(num8 / num9) / Math.Log(x / num12);
            }
            else
            {
                this.ns = num7;
            }
            this.f0 = num8 / (this.ns * Math.Pow(x, this.ns));
            this.rh = (base._semiMajor * this.f0) * Math.Pow(num10, this.ns);
        }