Esempio 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) });
        }
Esempio n. 2
0
 /// <summary>
 /// Converts a longitude value in degrees to radians.
 /// </summary>
 /// <param name="x">The value in degrees to convert to radians.</param>
 /// <param name="edge">If true, -180 and +180 are valid, otherwise they are considered out of range.</param>
 /// <returns></returns>
 protected static double LongitudeToRadians(double x, bool edge)
 {
     if (!(edge ? ((x >= -180) && (x <= 180)) : ((x > -180) && (x < 180))))
     {
         throw new ArgumentOutOfRangeException("x", x, " not a valid longitude in degrees.");
     }
     return(MathTransform.Degrees2Radians(x));
 }
Esempio n. 3
0
 /// <summary>
 /// Converts a latitude value in degrees to radians.
 /// </summary>
 /// <param name="y">The value in degrees to to radians.</param>
 /// <param name="edge">If true, -90 and +90 are valid, otherwise they are considered out of range.</param>
 /// <returns></returns>
 protected static double LatitudeToRadians(double y, bool edge)
 {
     if (!(edge ? ((y >= -90) && (y <= 90)) : ((y > -90) && (y < 90))))
     {
         throw new ArgumentOutOfRangeException("x", y, " not a valid latitude in degrees.");
     }
     return(MathTransform.Degrees2Radians(y));
 }
Esempio n. 4
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);
        }
Esempio n. 5
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>Items</term><description>Descriptions</description></listheader>
        /// <item><term>latitude_of_center</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>longitude_of_center</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 AlbersProjection(List <ProjectionParameter> parameters, bool isInverse) : base(parameters, isInverse)
        {
            base.Name = "Albers_Conic_Equal_Area";
            ProjectionParameter parameter  = base.GetParameter("longitude_of_center");
            ProjectionParameter parameter2 = base.GetParameter("latitude_of_center");
            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 'longitude_of_center'");
            }
            if (parameter2 == null)
            {
                throw new ArgumentException("Missing projection parameter 'latitude_of_center'");
            }
            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'");
            }
            this.lon_center = MathTransform.Degrees2Radians(parameter.Value);
            double lat  = MathTransform.Degrees2Radians(parameter2.Value);
            double num2 = MathTransform.Degrees2Radians(parameter3.Value);
            double num3 = MathTransform.Degrees2Radians(parameter4.Value);

            this._falseEasting  = MathTransform.Degrees2Radians(parameter5.Value);
            this._falseNorthing = MathTransform.Degrees2Radians(parameter6.Value);
            if (Math.Abs((double)(num2 + num3)) < double.Epsilon)
            {
                throw new ApplicationException("Equal latitudes for standard parallels on opposite sides of Equator.");
            }
            this.e_sq = 1 - Math.Pow(base._semiMinor / base._semiMajor, 2);
            this.e    = Math.Sqrt(this.e_sq);
            double num4 = this.alpha(num2);
            double num5 = this.alpha(num3);
            double x    = Math.Cos(num2) / Math.Sqrt(1 - (this.e_sq * Math.Pow(Math.Sin(num2), 2)));
            double num7 = Math.Cos(num3) / Math.Sqrt(1 - (this.e_sq * Math.Pow(Math.Sin(num3), 2)));

            this.n   = (Math.Pow(x, 2) - Math.Pow(num7, 2)) / (num5 - num4);
            this.C   = Math.Pow(x, 2) + (this.n * num4);
            this.ro0 = this.Ro(this.alpha(lat));
        }
Esempio n. 6
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 num  = MathTransform.Degrees2Radians(lonlat[0]);
            double lat  = MathTransform.Degrees2Radians(lonlat[1]);
            double a    = this.alpha(lat);
            double num4 = this.Ro(a);
            double num5 = this.n * (num - this.lon_center);

            return(new double[] { (this._falseEasting + (num4 * Math.Sin(num5))), ((this._falseNorthing + this.ro0) - (num4 * Math.Cos(num5))) });
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes the MercatorProjection object with the specified parameters.
        /// </summary>
        /// <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>
        /// <remarks>
        /// <para>The parameters this projection expects are listed below.</para>
        /// <list type="table">
        /// <listheader><term>Items</term><description>Descriptions</description></listheader>
        /// <item><term>central_meridian</term><description>The longitude of the point from which the values of both the geographical coordinates on the ellipsoid and the grid coordinates on the projection are deemed to increment or decrement for computational purposes. Alternatively it may be considered as the longitude of the point which in the absence of application of false coordinates has grid coordinates of (0,0).</description></item>
        /// <item><term>latitude_of_origin</term><description>The latitude of the point from which the values of both the geographical coordinates on the ellipsoid and the grid coordinates on the projection are deemed to increment or decrement for computational purposes. Alternatively it may be considered as the latitude of the point which in the absence of application of false coordinates has grid coordinates of (0,0).</description></item>
        /// <item><term>scale_factor</term><description>The factor by which the map grid is reduced or enlarged during the projection process, defined by its value at the natural origin.</description></item>
        /// <item><term>false_easting</term><description>Since the natural origin may be at or near the centre of the projection and under normal coordinate circumstances would thus give rise to negative coordinates over parts of the mapped area, this origin is usually given false coordinates which are large enough to avoid this inconvenience. The False Easting, FE, is the easting value assigned to the abscissa (east).</description></item>
        /// <item><term>false_northing</term><description>Since the natural origin may be at or near the centre of the projection and under normal coordinate circumstances would thus give rise to negative coordinates over parts of the mapped area, this origin is usually given false coordinates which are large enough to avoid this inconvenience. The False Northing, FN, is the northing value assigned to the ordinate.</description></item>
        /// </list>
        /// </remarks>
        public Mercator(List <ProjectionParameter> parameters, bool isInverse) : base(parameters, isInverse)
        {
            base.Authority = "EPSG";
            ProjectionParameter parameter  = base.GetParameter("central_meridian");
            ProjectionParameter parameter2 = base.GetParameter("latitude_of_origin");
            ProjectionParameter parameter3 = base.GetParameter("scale_factor");
            ProjectionParameter parameter4 = base.GetParameter("false_easting");
            ProjectionParameter parameter5 = base.GetParameter("false_northing");

            if (parameter == null)
            {
                throw new ArgumentException("Missing projection parameter 'central_meridian'");
            }
            if (parameter2 == null)
            {
                throw new ArgumentException("Missing projection parameter 'latitude_of_origin'");
            }
            if (parameter4 == null)
            {
                throw new ArgumentException("Missing projection parameter 'false_easting'");
            }
            if (parameter5 == null)
            {
                throw new ArgumentException("Missing projection parameter 'false_northing'");
            }
            this.lon_center     = MathTransform.Degrees2Radians(parameter.Value);
            this.lat_origin     = MathTransform.Degrees2Radians(parameter2.Value);
            this._falseEasting  = parameter4.Value;
            this._falseNorthing = parameter5.Value;
            double num = base._semiMinor / base._semiMajor;

            this.e2 = 1 - (num * num);
            this.e  = Math.Sqrt(this.e2);
            if (parameter3 == null)
            {
                this.k0            = Math.Cos(this.lat_origin) / Math.Sqrt(1 - ((this.e2 * Math.Sin(this.lat_origin)) * Math.Sin(this.lat_origin)));
                base.AuthorityCode = 0x264dL;
                base.Name          = "Mercator_2SP";
            }
            else
            {
                this.k0   = parameter3.Value;
                base.Name = "Mercator_1SP";
            }
            base.Authority = "EPSG";
        }
Esempio n. 8
0
        /// <summary>
        /// Converts coordinates in decimal degrees to projected meters.
        /// </summary>
        /// <remarks>
        /// <para>The parameters this projection expects are listed below.</para>
        /// <list type="table">
        /// <listheader><term>Items</term><description>Descriptions</description></listheader>
        /// <item><term>longitude_of_natural_origin</term><description>The longitude of the point from which the values of both the geographical coordinates on the ellipsoid and the grid coordinates on the projection are deemed to increment or decrement for computational purposes. Alternatively it may be considered as the longitude of the point which in the absence of application of false coordinates has grid coordinates of (0,0).  Sometimes known as ""central meridian""."</description></item>
        /// <item><term>latitude_of_natural_origin</term><description>The latitude of the point from which the values of both the geographical coordinates on the ellipsoid and the grid coordinates on the projection are deemed to increment or decrement for computational purposes. Alternatively it may be considered as the latitude of the point which in the absence of application of false coordinates has grid coordinates of (0,0).</description></item>
        /// <item><term>scale_factor_at_natural_origin</term><description>The factor by which the map grid is reduced or enlarged during the projection process, defined by its value at the natural origin.</description></item>
        /// <item><term>false_easting</term><description>Since the natural origin may be at or near the centre of the projection and under normal coordinate circumstances would thus give rise to negative coordinates over parts of the mapped area, this origin is usually given false coordinates which are large enough to avoid this inconvenience. The False Easting, FE, is the easting value assigned to the abscissa (east).</description></item>
        /// <item><term>false_northing</term><description>Since the natural origin may be at or near the centre of the projection and under normal coordinate circumstances would thus give rise to negative coordinates over parts of the mapped area, this origin is usually given false coordinates which are large enough to avoid this inconvenience. The False Northing, FN, is the northing value assigned to the ordinate .</description></item>
        /// </list>
        /// </remarks>
        /// <param name="lonlat">The point in decimal degrees.</param>
        /// <returns>Point in projected meters</returns>
        public override double[] DegreesToMeters(double[] lonlat)
        {
            if (double.IsNaN(lonlat[0]) || double.IsNaN(lonlat[1]))
            {
                return(new double[] { double.NaN, double.NaN });
            }
            double num  = MathTransform.Degrees2Radians(lonlat[0]);
            double num2 = MathTransform.Degrees2Radians(lonlat[1]);

            if (Math.Abs((double)(Math.Abs(num2) - 1.5707963267948966)) <= 1E-10)
            {
                throw new ApplicationException("Transformation cannot be computed at the poles.");
            }
            double num3 = this.e * Math.Sin(num2);
            double num4 = this._falseEasting + ((base._semiMajor * this.k0) * (num - this.lon_center));
            double num5 = this._falseNorthing + ((base._semiMajor * this.k0) * Math.Log(Math.Tan(0.78539816339744828 + (num2 * 0.5)) * Math.Pow((1 - num3) / (1 + num3), this.e * 0.5)));

            return(new double[] { num4, num5 });
        }
Esempio n. 9
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) });
        }
Esempio n. 10
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);
        }