Beispiel #1
0
 /// <summary>
 ///     Instantiate a new point from a coordinate array
 /// </summary>
 /// <param name="projection">The projection owning these coordinates</param>
 /// <param name="xy">List of xy coordinates</param>
 /// <exception cref="IndexOutOfRangeException">Raised if the array is not two-dimensional</exception>
 public EuclidianCoordinate(MercatorProjection projection, IReadOnlyList <double> xy)
 {
     if (xy.Count != 2)
     {
         throw new IndexOutOfRangeException(Resources.COORD_ARRAY_MUST_BE_2DIM);
     }
     Projection = projection;
     X          = xy[0];
     Y          = xy[1];
 }
Beispiel #2
0
        /// <summary>
        ///     The UTM Grid for a given latitude/longitude
        /// </summary>
        /// <param name="projection">The projection to use</param>
        /// <param name="coord">Latitude/Longitude of the location</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if the latitude is out of the limits for the UTM projection</exception>
        public UtmGrid(UtmProjection projection, GlobalCoordinates coord) : this(projection)
        {
            if (coord.Latitude < projection.MinLatitude || coord.Latitude > projection.MaxLatitude)
            {
                throw new ArgumentOutOfRangeException(Resources.INVALID_LATITUDE);
            }

            var longitude = MercatorProjection.NormalizeLongitude(coord.Longitude).Degrees + 180.0;
            var latitude  = projection.NormalizeLatitude(coord.Latitude);
            var band      = (int)((latitude - projection.MinLatitude).Degrees / Ystep.Degrees);
            if (band == NumberOfBands)
            {
                var northernLimit = projection.MinLatitude + NumberOfBands * Ystep;
                if (latitude >= northernLimit && latitude <= projection.MaxLatitude)
                {
                    band--;
                }
            }
            var zone = (int)(longitude / Xstep.Degrees) + 1;
            SetZoneAndBandInConstructor(zone, band, true);

            if (_zone == 31 && Band == 'V')
            {
                var delta = coord.Longitude.Degrees - _llCoordinates.Longitude.Degrees - Width.Degrees;
                if (Math.Sign(delta) != -1)
                {
                    Zone = _zone + 1;
                }
            }
            else if (Band == 'X')
            {
                if (_zone == 32 || _zone == 34 || _zone == 36)
                {
                    var delta = coord.Longitude.Degrees - CenterMeridian.Degrees;
                    if (Math.Sign(delta) == -1)
                    {
                        Zone = _zone - 1;
                    }
                    else
                    {
                        Zone = _zone + 1;
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 ///     The default coordinates (X and Y are zero)
 /// </summary>
 /// <param name="projection">The projection owning these coordinates</param>
 public EuclidianCoordinate(MercatorProjection projection) : this(projection, 0.0, 0.0)
 {
 }
Beispiel #4
0
 /// <summary>
 ///     Instantiate a new point
 /// </summary>
 /// <param name="projection">The projection owning these coordinates</param>
 /// <param name="x">The X coordinate</param>
 /// <param name="y">The Y coordinate</param>
 public EuclidianCoordinate(MercatorProjection projection, double x, double y)
 {
     Projection = projection;
     X          = x;
     Y          = y;
 }