/// <summary> /// Initializes a new instance of the GeoPoint class. /// </summary> /// <param name="value">GeoPoint to copy data from.</param> public GeoPoint(GeoPoint value) { Latitude = value.Latitude; Longitude = value.Longitude; Altitude = value.Altitude; _Datum = (GeoDatum)value.Datum.Clone(); }
static char ZoneBand(Int32 northing, bool isNorthernHemisphere) { UtmPoint tempPoint = new UtmPoint(0, northing, 1, isNorthernHemisphere); GeoPoint geoPoint = new GeoPoint(tempPoint, GeoDatum.DatumWGS84()); char zoneChar = UtmLetterDesignator(geoPoint.Latitude); return(zoneChar); }
/// <summary> /// Initializes a new instance of the GeoPoint class. /// </summary> /// <param name="utmPoint">UTM coordinates.</param> /// <param name="datum">Geographical datum.</param> public GeoPoint(UtmPoint utmPoint, GeoDatum datum) { Double excentricitySquared = datum.Ellipsoid.ExcentricitySquared; Double equatorialRadius = datum.Ellipsoid.SemiMajorAxis; Boolean northernHemisphere = utmPoint.IsNorthernHemisphere; Int32 zoneNumber = utmPoint.ZoneNumber; Double x = utmPoint.Easting - 500000.0; //remove 500,000 meter offset for longitude Double y = utmPoint.Northing; if (!northernHemisphere) { // point is in southern hemisphere y = y - 10000000.0; // remove 10,000,000 meter offset used for southern hemisphere } Double longOrigin = (zoneNumber - 1) * 6 - 180 + 3; // +3 puts origin in middle of zone Double excentricityPrimeSquared = (excentricitySquared) / (1 - excentricitySquared); Double M = y / dScaleFactor; Double mu = M / (equatorialRadius * (1 - excentricitySquared / 4 - 3 * excentricitySquared * excentricitySquared / 64 - 5 * excentricitySquared * excentricitySquared * excentricitySquared / 256)); Double e1 = (1 - Math.Sqrt(1 - excentricitySquared)) / (1 + Math.Sqrt(1 - excentricitySquared)); // phi in radians Double phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.Sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.Sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * Math.Sin(6 * mu); // convert to degrees Double phi1 = phi1Rad * _convertRadianToDegree; Double N1 = equatorialRadius / Math.Sqrt(1 - excentricitySquared * Math.Sin(phi1Rad) * Math.Sin(phi1Rad)); Double T1 = Math.Tan(phi1Rad) * Math.Tan(phi1Rad); Double C1 = excentricityPrimeSquared * Math.Cos(phi1Rad) * Math.Cos(phi1Rad); Double R1 = equatorialRadius * (1 - excentricitySquared) / Math.Pow(1 - excentricitySquared * Math.Sin(phi1Rad) * Math.Sin(phi1Rad), 1.5); Double D = x / (N1 * dScaleFactor); // phi in radians Double latitude = phi1Rad - (N1 * Math.Tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * excentricityPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * excentricityPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720); // convert to degrees latitude = latitude * _convertRadianToDegree; // lon in radians Double longitude = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * excentricityPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.Cos(phi1Rad); // convert to degrees longitude = longOrigin + longitude * _convertRadianToDegree; Longitude = longitude; Latitude = latitude; _Datum = datum; }
private void SetMaidenhead(String value) { Double latitude = 0; Double longitude = 0; MaidenheadLocator.GeographicalCoordinatesByMaidenheadLocator(value, _DefaultPositionInRectangle, out latitude, out longitude); Datum = GeoDatum.DatumWGS84(); this.Latitude = latitude; this.Longitude = longitude; }
/// <summary> /// Initializes a new instance of the GeoPoint class. /// </summary> /// <exception cref="ArgumentOutOfRangeException">Thrown when latitude is larger than ±90° or longitude is larger than ±180°.</exception> /// <exception cref="ArgumentNullException">Thrown when datum is null.</exception> /// <param name="latitude">Latitude in degrees.</param> /// <param name="longitude">Longitude in degrees.</param> /// <param name="altitude">Altitude in meter.</param> /// <param name="datum">Geographical datum.</param> public GeoPoint(double latitude, double longitude, double altitude, GeoDatum datum) { if (Math.Abs(latitude) > 90) { throw new ArgumentOutOfRangeException("latitude"); } if (Math.Abs(longitude) > 180) { throw new ArgumentOutOfRangeException("longitude"); } if (datum == null) { throw new ArgumentNullException("datum"); } Latitude = latitude; Longitude = longitude; Altitude = altitude; _Datum = datum; }
private void SetDatum(GeoDatum newDatum) { // Source http://home.hiwaay.net/~taylorc/bookshelf/math-science/geodesy/datum/transform/molodensky/ double LatRad = Latitude / _convertRadianToDegree; double LongRad = Longitude / _convertRadianToDegree; double slat = Math.Sin(LatRad); double clat = Math.Cos(LatRad); double slon = Math.Sin(LongRad); double clon = Math.Cos(LongRad); double from_a = Datum.Ellipsoid.SemiMajorAxis; double from_f = Datum.Ellipsoid.Flattening; double from_esq = Datum.Ellipsoid.ExcentricitySquared; double ssqlat = slat * slat; double adb = 1.0 / (1.0 - from_f); // "a divided by b" double da = newDatum.Ellipsoid.SemiMajorAxis - Datum.Ellipsoid.SemiMajorAxis; double df = newDatum.Ellipsoid.Flattening - Datum.Ellipsoid.Flattening; double dx = -newDatum.DeltaX + Datum.DeltaX; double dy = -newDatum.DeltaY + Datum.DeltaY; double dz = -newDatum.DeltaZ + Datum.DeltaZ; double rn = from_a / Math.Sqrt(1.0 - from_esq * ssqlat); double rm = from_a * (1.0 - from_esq) / Math.Pow((1.0 - from_esq * ssqlat), 1.5); double dlat = (((((-dx * slat * clon - dy * slat * slon) + dz * clat) + (da * ((rn * from_esq * slat * clat) / from_a))) + (df * (rm * adb + rn / adb) * slat * clat))) / (rm + Altitude); double dlon = (-dx * slon + dy * clon) / ((rn + Altitude) * clat); double dh = (dx * clat * clon) + (dy * clat * slon) + (dz * slat) - (da * (from_a / rn)) + ((df * rn * ssqlat) / adb); Longitude = Longitude + dlon * _convertRadianToDegree; Latitude = Latitude + dlat * _convertRadianToDegree; Altitude = Altitude + dh; _Datum = newDatum; }
public MgrsGridElement(String mgrs) { Datum = GeoDatum.DatumWGS84(); SetMgrs(mgrs); }
public MgrsGridElement() { Datum = GeoDatum.DatumWGS84(); }