// ----------- Part 8: member functions: set ----------------------------- // Set the Position given geodetic coordinates, system is set to Geodetic. // @param lat geodetic latitude in degrees North // @param lon geodetic longitude in degrees East // @param ht height above the ellipsoid in meters // @return a reference to this object. // @throw GeometryException on invalid input public void SetGeodetic(double lat, double lon, double ht, EllipsoidModel ell) { if (lat > 90 || lat < -90) { throw new Exception("Invalid latitude in setGeodetic "); } this[0] = lat; this[1] = lon; if (this[1] < 0) { this[1] += 360 * (1 - Math.Ceiling(this[1] / 360)); } else if (this[1] >= 360) { this[1] -= 360 * Math.Floor(this[1] / 360); } this[2] = ht; if (ell != null) { Ellipsoid = ell; } System = CoordinateSystem.Geodetic; }
public Position(Triple ABC, CoordinateSystem s, EllipsoidModel ell) { double a = ABC[0]; double b = ABC[1]; double c = ABC[2]; Initialize(a, b, c, s, ell); }
// ----------- Part 12: private functions and member data ----------------- // // Initialization function, used by the constructors. // @param a coordinate [ X(m), or latitude (degrees N) ] // @param b coordinate [ Y(m), or longitude (degrees E) ] // @param c coordinate [ Z, height above ellipsoid or radius, in m ] // @param s CoordinateSystem, defaults to Cartesian // @param geiod pointer to a GeoidModel, default NULL (WGS84) // @throw GeometryException on invalid input. private void Initialize(double a, double b, double c, CoordinateSystem s, EllipsoidModel ell) { double bb = b; if (s == CoordinateSystem.Geodetic || s == CoordinateSystem.Geocentric) { if (a > 90 || a < -90) { throw new Exception("Invalid latitude in constructor: " + a.ToString()); } if (bb < 0) { bb += 360 * (1 - Math.Ceiling(bb / 360)); } else if (bb >= 360) { bb -= 360 * Math.Floor(bb / 360); } } if (s == CoordinateSystem.Geocentric || s == CoordinateSystem.Spherical) { if (c < 0) { throw new Exception("Invalid radius in constructor: " + c); } } if (s == CoordinateSystem.Spherical) { if (a < 0 || a > 180) { throw new Exception("Invalid theta in constructor: " + a); } if (bb < 0) { bb += 360 * (1 - Math.Ceiling(bb / 360)); } else if (bb >= 360) { bb -= 360 * Math.Floor(bb / 360); } } this[0] = a; this[1] = bb; this[2] = c; System = s; Ellipsoid = ell; Tolerance = POSITION_TOLERANCE; }
public Position(double a, double b, double c, CoordinateSystem s, EllipsoidModel ell) { Initialize(a, b, c, s, ell); }