/// <summary> /// Instantiate a grid by its ordinal number. /// </summary> /// <param name="projection">The UTM projection this Grid belongs to</param> /// <param name="ordinal">The unique ordinal number of the grid</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if the ordinal number is invalid</exception> public UtmGrid(UtmProjection projection, int ordinal) : this(projection) { if (ordinal < 0 || ordinal >= NumberOfGrids) { throw new ArgumentOutOfRangeException(Resources.INVALID_ORDINAL); } SetZoneAndBandInConstructor(1 + ordinal / NumberOfBands, ordinal % NumberOfBands); }
private UtmGrid(UtmProjection projection) { // Assign default values Projection = projection ?? throw new ArgumentNullException(Properties.Resource.PROJECTION_NULL); _origin = null; _mapHeight = 0.0; _mapWidth = 0.0; Width = Xstep; Height = Ystep; _zone = 0; _band = 0; _llCoordinates = new GlobalCoordinates(); }
/// <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; } } } }
private UtmGrid(UtmProjection projection) { if (null == projection) { throw new ArgumentNullException(Resources.PROJECTION_NULL); } // Assign default values _utm = projection; _origin = null; _mapHeight = 0.0; _mapWidth = 0.0; Width = Xstep; Height = Ystep; _zone = 0; _band = 0; _llCoordinates = new GlobalCoordinates(); }
/// <summary> /// Instantiate a new UTM Grid object /// </summary> /// <param name="projection">The UTM projection this grid belongs to</param> /// <param name="zone">The zone of the grid</param> /// <param name="band">The band of the grid</param> /// <exception cref="ArgumentOutOfRangeException">Throw if zone or band are invalid</exception> /// <exception cref="ArgumentNullException">Thrown if the projection is null</exception> public UtmGrid(UtmProjection projection, int zone, int band) : this(projection) { SetZoneAndBandInConstructor(zone, band); }
/// <summary> /// Instantiate a new UTM Grid object /// </summary> /// <param name="projection">The UTM projection this grid belongs to</param> /// <param name="zone">The zone of the grid</param> /// <param name="band">The band of the grid</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if zone or band are requested</exception> /// <exception cref="ArgumentNullException">Thrown if the projection is null</exception> public UtmGrid(UtmProjection projection, int zone, char band) : this(projection, zone, BandChars.IndexOf(band)) { }