Beispiel #1
0
        /// <summary>
        /// Retrieves a world zone.
        /// </summary>
        /// <param name="longitude">The longitude.</param>
        /// <param name="hemisphere">The ellipsoid hemisphere.</param>
        /// <returns>The world zone for the specified number and hemisphere</returns>
        /// <exception cref="System.ArgumentException">
        /// The longitude is not valid.;longitude
        /// or
        /// The hemisphere is not south or north.hemisphere
        /// </exception>
        public static AreaOfUse WorldZone(Angle longitude, EllipsoidHemisphere hemisphere)
        {
            if (longitude.BaseValue < -Constants.PI || longitude.BaseValue > Constants.PI)
            {
                throw new ArgumentException("The longitude is not valid.", "longitude");
            }
            if (hemisphere == EllipsoidHemisphere.Equador)
            {
                throw new ArgumentException("The hemisphere must be north or south.", "hemisphere");
            }

            Double zoneWidth = Constants.PI / 30;

            Double zoneCenter = Math.Floor(Math.Round(longitude.BaseValue / zoneWidth, 4)) * zoneWidth + zoneWidth / 2;
            Int32  zoneNumber = Convert.ToInt32(Math.Floor(Math.Round((longitude.BaseValue + Constants.PI) / zoneWidth, 4))) + 1;

            Double zoneWest  = Math.Round(zoneCenter * Constants.RadianToDegree) - 3;
            Double zoneEast  = Math.Round(zoneCenter * Constants.RadianToDegree) + 3;
            Double zoneNorth = (hemisphere == EllipsoidHemisphere.North ? 84 : 0);
            Double zoneSouth = (hemisphere == EllipsoidHemisphere.North ? 0 : -80);

            String identifier = "EPSG::" + (1872 + (hemisphere == EllipsoidHemisphere.North ? zoneNumber * 2 - 1 : zoneNumber * 2));
            String name       = "World - " + (hemisphere == EllipsoidHemisphere.North ? "N" : "S") +
                                " hemisphere - " + Math.Abs(zoneWest) +
                                "°" + (zoneWest < 0 ? "W" : "E") + " to " +
                                Math.Abs(zoneEast) +
                                "°" + (zoneEast < 0 ? "W" : "E");

            return(new AreaOfUse(identifier, name, Angle.FromDegree(zoneWest), Angle.FromDegree(zoneEast), Angle.FromDegree(zoneNorth), Angle.FromDegree(zoneSouth)));
        }
Beispiel #2
0
        /// <summary>
        /// Retrieves a world zone.
        /// </summary>
        /// <param name="zoneNumber">The zone number.</param>
        /// <param name="hemisphere">The ellipsoid hemisphere.</param>
        /// <returns>The world zone for the specified number and hemisphere</returns>
        /// <exception cref="System.ArgumentException">
        /// The zone number is not valid.;zoneNumber
        /// or
        /// The hemisphere is not south or north.hemisphere
        /// </exception>
        public static AreaOfUse WorldZone(Int32 zoneNumber, EllipsoidHemisphere hemisphere)
        {
            if (zoneNumber < 1 || zoneNumber > 60)
            {
                throw new ArgumentException("The zone number is not valid.", "zoneNumber");
            }
            if (hemisphere == EllipsoidHemisphere.Equador)
            {
                throw new ArgumentException("The hemisphere is not south or north.", "hemisphere");
            }

            Double zoneWidth  = Constants.PI / 30;
            Double zoneCenter = (zoneNumber - 1) * zoneWidth + zoneWidth / 2;

            Double zoneWest  = Math.Round(zoneCenter * Constants.RadianToDegree) - 3;
            Double zoneEast  = Math.Round(zoneCenter * Constants.RadianToDegree) + 3;
            Double zoneNorth = (hemisphere == EllipsoidHemisphere.North ? 84 : 0);
            Double zoneSouth = (hemisphere == EllipsoidHemisphere.North ? 0 : -80);

            String identifier = "EPSG::" + (1872 + (hemisphere == EllipsoidHemisphere.North ? zoneNumber * 2 - 1 : zoneNumber * 2));
            String name       = "World - " + (hemisphere == EllipsoidHemisphere.North ? "N" : "S") +
                                " hemisphere - " + Math.Abs(zoneWest) +
                                "°" + (zoneWest < 0 ? "W" : "E") + " to " +
                                Math.Abs(zoneEast) +
                                "°" + (zoneEast < 0 ? "W" : "E");

            return(new AreaOfUse(identifier, name, Angle.FromDegree(zoneWest), Angle.FromDegree(zoneEast), Angle.FromDegree(zoneNorth), Angle.FromDegree(zoneSouth)));
        }
        /// <summary>
        /// UTM zone.
        /// </summary>
        /// <param name="ellipsoid">The ellipsoid.</param>
        /// <param name="longitude">The longitude.</param>
        /// <param name="hemisphere">The hemisphere.</param>
        /// <returns>The coordinate projection produced by the method.</returns>
        /// <exception cref="System.ArgumentException">
        /// The longitude is invalid.;longitude
        /// or
        /// The hemisphere must be north or south.;hemisphere
        /// </exception>
        public static CoordinateProjection UniversalTransverseMercatorZone(Ellipsoid ellipsoid, Angle longitude, EllipsoidHemisphere hemisphere)
        {
            if (longitude.BaseValue < -Constants.PI || longitude.BaseValue > Constants.PI)
            {
                throw new ArgumentException("The longitude is invalid.", "longitude");
            }
            if (hemisphere == EllipsoidHemisphere.Equador)
            {
                throw new ArgumentException("The hemisphere must be north or south.", "hemisphere");
            }

            Double zoneWidth = Constants.PI / 30;

            Double zoneCenter = Math.Floor(Math.Round(longitude.BaseValue / zoneWidth, 4)) * zoneWidth + zoneWidth / 2;
            Int32  zoneNumber = Convert.ToInt32(Math.Floor(Math.Round((longitude.BaseValue + Constants.PI) / zoneWidth, 4))) + 1;

            String name       = "UTM zone " + zoneNumber + (hemisphere == EllipsoidHemisphere.North ? "N" : "S");
            String identifier = "EPSG::" + (16000 + zoneNumber + (hemisphere == EllipsoidHemisphere.South ? 100 : 0));

            Dictionary <CoordinateOperationParameter, Object> parameters = new Dictionary <CoordinateOperationParameter, Object>();

            parameters.Add(CoordinateOperationParameters.LatitudeOfNaturalOrigin, Angle.FromRadian(0));
            parameters.Add(CoordinateOperationParameters.LongitudeOfNaturalOrigin, Angle.FromRadian(zoneCenter));
            parameters.Add(CoordinateOperationParameters.ScaleFactorAtNaturalOrigin, 0.9996);
            parameters.Add(CoordinateOperationParameters.FalseEasting, Length.FromMetre(500000));
            parameters.Add(CoordinateOperationParameters.FalseNorthing, Length.FromMetre(10000000));

            return(new TransverseMercatorProjection(identifier, name, parameters, ellipsoid, AreasOfUse.WorldZone(longitude, hemisphere)));
        }