1 #ifndef SZA_UTIL_GEOID_H
2 #define SZA_UTIL_GEOID_H
11 #include "carma/szautil/Constants.h"
14 #include "carma/szautil/HourAngle.h"
15 #include "carma/szautil/Vector.h"
179 enum SphericalCoordSystem {
190 class PolarLengthVector {
214 SphericalCoordSystem coordSystem_;
216 void setCoordSystem(SphericalCoordSystem coordSystem) {
217 coordSystem_ = coordSystem;
220 PolarLengthVector() {
223 PolarLengthVector(
const PolarLengthVector& sap) {
227 PolarLengthVector(PolarLengthVector& sap) {
231 void operator=(
const PolarLengthVector& cs) {
232 *
this = (PolarLengthVector&)cs;
235 void operator=(PolarLengthVector& cs) {
237 longitude_ = cs.longitude_;
238 latitude_ = cs.latitude_;
244 length_ = cs.length_;
246 coordSystem_ = cs.coordSystem_;
249 friend std::ostream& operator<<(std::ostream& os,
const PolarLengthVector& angles);
250 friend std::ostream& operator<<(std::ostream& os, PolarLengthVector& angles);
254 std::ostream& operator<<(std::ostream& os,
const PolarLengthVector& angles);
255 std::ostream& operator<<(std::ostream& os, PolarLengthVector& angles);
262 class LengthTriplet {
265 Vector<Length> coords_;
294 Hemisphere hemisphere_;
305 GeoCoordSystem coordSystem_;
306 Length sphericalRadius_;
308 void setCoordSystem(GeoCoordSystem coordSystem) {
309 coordSystem_ = coordSystem;
312 void setDatum(GeoDatum datum, Length sphericalRadius=Constants::defaultEarthRadius_) {
314 sphericalRadius_ = sphericalRadius;
320 hemisphere_ = HEMI_NONE;
322 coordSystem_ = COORD_UNKNOWN;
323 sphericalRadius_ = Constants::defaultEarthRadius_;
327 coords_[0].setMeters(0.0);
328 coords_[1].setMeters(0.0);
329 coords_[2].setMeters(0.0);
332 LengthTriplet() : coords_(3),
333 x_(coords_[0]), y_(coords_[1]), z_(coords_[2]),
334 X_(coords_[0]), Y_(coords_[1]), Z_(coords_[2]),
335 u_(coords_[0]), v_(coords_[1]), w_(coords_[2]),
336 east_(coords_[0]), north_(coords_[1]), up_(coords_[2]),
337 easting_(coords_[0]), northing_(coords_[1]), height_(coords_[2])
342 LengthTriplet(
const LengthTriplet& triplet) : coords_(3),
343 x_(coords_[0]), y_(coords_[1]), z_(coords_[2]),
344 X_(coords_[0]), Y_(coords_[1]), Z_(coords_[2]),
345 u_(coords_[0]), v_(coords_[1]), w_(coords_[2]),
346 east_(coords_[0]), north_(coords_[1]), up_(coords_[2]),
347 easting_(coords_[0]), northing_(coords_[1]), height_(coords_[2])
352 LengthTriplet(LengthTriplet& triplet) : coords_(3),
353 x_(coords_[0]), y_(coords_[1]), z_(coords_[2]),
354 X_(coords_[0]), Y_(coords_[1]), Z_(coords_[2]),
355 u_(coords_[0]), v_(coords_[1]), w_(coords_[2]),
356 east_(coords_[0]), north_(coords_[1]), up_(coords_[2]),
357 easting_(coords_[0]), northing_(coords_[1]), height_(coords_[2])
362 LengthTriplet(
const Vector<Length>& vec) : coords_(3),
363 x_(coords_[0]), y_(coords_[1]), z_(coords_[2]),
364 X_(coords_[0]), Y_(coords_[1]), Z_(coords_[2]),
365 u_(coords_[0]), v_(coords_[1]), w_(coords_[2]),
366 east_(coords_[0]), north_(coords_[1]), up_(coords_[2]),
367 easting_(coords_[0]), northing_(coords_[1]), height_(coords_[2])
372 LengthTriplet(Vector<Length>& vec) : coords_(3),
373 x_(coords_[0]), y_(coords_[1]), z_(coords_[2]),
374 X_(coords_[0]), Y_(coords_[1]), Z_(coords_[2]),
375 u_(coords_[0]), v_(coords_[1]), w_(coords_[2]),
376 east_(coords_[0]), north_(coords_[1]), up_(coords_[2]),
377 easting_(coords_[0]), northing_(coords_[1]), height_(coords_[2])
382 virtual ~LengthTriplet() {};
385 Vector<double> dVec(3);
386 dVec[0] = coords_[0].meters();
387 dVec[1] = coords_[1].meters();
388 dVec[2] = coords_[2].meters();
391 mag.setMeters(dVec.magnitude());
396 void operator=(
const LengthTriplet& triplet) {
397 *
this = (LengthTriplet&)triplet;
400 void operator=(LengthTriplet& triplet) {
402 coords_[0] = triplet.coords_[0];
403 coords_[1] = triplet.coords_[1];
404 coords_[2] = triplet.coords_[2];
406 zone_ = triplet.zone_;
407 coordSystem_ = triplet.coordSystem_;
408 hemisphere_ = triplet.hemisphere_;
409 datum_ = triplet.datum_;
410 sphericalRadius_ = triplet.sphericalRadius_;
413 void operator=(
const Vector<Length>& vec) {
414 *
this = ((Vector<Length>&) vec);
417 void operator=(Vector<Length>& vec) {
419 if(vec.size() != 3) {
420 ThrowError(
"Cannot assign a length " << vec.size()
421 <<
" vector to a LengthTriplet (obviously, \"Triplet\" implies 3)");
428 LengthTriplet operator*(
double fac) {
435 LengthTriplet operator/(
double fac) {
442 Vector<double> operator/(
const Length& length) {
443 return operator/((Length&) length);
446 Vector<double> operator/(Length& length) {
447 return coords_ / length;
450 LengthTriplet operator-(
const LengthTriplet& triplet) {
451 return operator-((LengthTriplet&) triplet);
454 LengthTriplet operator-(LengthTriplet& triplet) {
455 LengthTriplet ret = *
this;
456 ret.coords_ = coords_ - triplet.coords_;
460 friend std::ostream& operator<<(std::ostream& os,
const LengthTriplet& triplet);
461 friend std::ostream& operator<<(std::ostream& os, LengthTriplet& triplet);
465 std::ostream& operator<<(std::ostream& os,
const LengthTriplet& triplet);
466 std::ostream& operator<<(std::ostream& os, LengthTriplet& triplet);
481 GeoCoordSystem coordSystem_;
482 Length sphericalRadius_;
486 coordSystem_ = COORD_UNKNOWN;
487 sphericalRadius_ = Constants::defaultEarthRadius_;
490 Lla(
const Lla& lla) {
498 void operator=(
const Lla& lla) {
502 void operator=(Lla& lla) {
503 longitude_ = lla.longitude_;
504 latitude_ = lla.latitude_;
505 altitude_ = lla.altitude_;
507 coordSystem_ = lla.coordSystem_;
508 sphericalRadius_ = lla.sphericalRadius_;
511 void setCoordSystem(GeoCoordSystem coordSystem) {
512 coordSystem_ = coordSystem;
515 void setDatum(GeoDatum datum, Length sphericalRadius=Constants::defaultEarthRadius_) {
517 sphericalRadius_ = sphericalRadius;
520 friend std::ostream& operator<<(std::ostream& os,
const Lla& lla);
521 friend std::ostream& operator<<(std::ostream& os, Lla& lla);
524 std::ostream& operator<<(std::ostream& os,
const Lla& lla);
525 std::ostream& operator<<(std::ostream& os, Lla& lla);
531 class Geoid :
public Ellipsoid {
537 Geoid(GeoDatum referenceSystem);
548 void changeDatum(GeoDatum datum, Length sphericalRadius = Constants::defaultEarthRadius_);
550 void setDatum(GeoDatum datum, Length sphericalRadius = Constants::defaultEarthRadius_);
551 void setDefaultDatum(GeoDatum datum, Length sphericalRadius = Constants::defaultEarthRadius_);
553 void restoreDefaultDatum();
559 Length earthEquatorialRadius();
560 Length earthPolarRadius();
568 Length geocentricRadius(Angle geocentricLatitude);
575 Length geodeticRadius(Angle geodeticLatitude);
583 Angle geocentricLatitude(Angle geodeticLatitude);
591 Angle geodeticLatitude(Angle geocentricLatitude);
598 Lla geocentricLlaAndEnhToGeodeticLla(Lla& geocentricLla, LengthTriplet enh=LengthTriplet());
605 Lla geocentricLlaAndEnhToGeocentricLla(Lla& geocentricLla, LengthTriplet enh=LengthTriplet());
612 Lla geodeticLlaAndEnuToGeocentricLla(Lla& geodeticLla, LengthTriplet enu=LengthTriplet());
619 Lla geodeticLlaAndEnuToGeodeticLla(Lla& geodeticLla, LengthTriplet enu=LengthTriplet());
626 LengthTriplet geodeticLlaAndEnuToUtm(Lla& geodeticLla, LengthTriplet enu=LengthTriplet());
633 Lla utmToGeodeticLla(LengthTriplet& utm);
640 LengthTriplet utmToUtm(LengthTriplet& utm);
647 LengthTriplet geodeticLlaAndEnuToUps(Lla& geodeticLla, LengthTriplet enu=LengthTriplet());
654 Lla upsToGeodeticLla(LengthTriplet& ups);
662 Lla geodeticLlaAndDeltaUtmToGeodeticLla(Lla& geodeticLla, LengthTriplet& deltaUtm);
673 PolarLengthVector geodeticLlaAndHaDecToAzEl(Lla& geodeticLla,
674 HourAngle ha, Declination declination,
675 SrcDist type=DIST_INF, Length distance=Length(Length::Meters(), 0.0));
681 LengthTriplet geodeticLlaAndHaDecToUvw(Lla& geodeticLla,
683 Declination declination);
692 GeoDatum defaultDatum_;
693 Length defaultSphericalRadius_;
699 LengthTriplet geodeticLlaAndEnuToEcf(Lla& geodeticLla, LengthTriplet enu=LengthTriplet());
705 LengthTriplet geocentricLlaAndEnhToEcf(Lla& geocentricLla, LengthTriplet enh=LengthTriplet());
711 LengthTriplet geodeticLlaAndEnuToXyz(Lla& geodeticLla, LengthTriplet enu=LengthTriplet());
712 LengthTriplet geodeticLlaAndXyzToEnu(Lla& geodeticLla, LengthTriplet xyz=LengthTriplet());
718 LengthTriplet geocentricLlaAndEnhToXyz(Lla& geocentricLla, LengthTriplet enh=LengthTriplet());
726 LengthTriplet geodeticLlaAndGeodeticLlaToEnu(Lla& geodeticLlaRef, Lla& geodeticLlaObs);
732 Lla ecfToGeocentricLla(LengthTriplet& ecf);
738 Lla ecfToGeodeticLla(LengthTriplet& ecf);
748 LengthTriplet transverseSecantProjection(Lla& geodeticLla, Lla& referenceLla,
double k0);
754 Lla inverseTransverseSecantProjection(LengthTriplet& xyk, Lla& referenceLla,
double k0);
761 LengthTriplet polarStereographicProjection(Lla& geodeticLla, Lla& referenceLla,
double k0);
768 Lla inversePolarStereographicProjection(LengthTriplet& xyk,
double k0);
774 double utmSeriesExpansionForM(Angle& lat);
780 unsigned longitudeToUtmZone(Angle longitude);
786 Angle utmZoneToLongitude(
unsigned zone);
793 Angle getUtmReferenceLongitude(Angle longitude);
799 LengthTriplet haDecDistToXyz(HourAngle ha, Declination dec, Length distance);
800 LengthTriplet haDecDistToXyz2(HourAngle ha, Declination dec, Length distance);
801 Vector<double> haDecToXyzDir(HourAngle ha, Declination dec);
805 PolarLengthVector xyzToHaDec(LengthTriplet& xyz);
809 PolarLengthVector enuToAzEl(LengthTriplet& enu);
813 LengthTriplet azElToEnu(Angle az, Angle el, Length distance);
822 sza::util::Matrix<double> getEnuToEnhRot(Angle latDiff);
824 sza::util::Matrix<double> getEnhToXyzLatRot(Angle geocentricLatitude);
825 sza::util::Matrix<double> getXyzToEcfLngRot(Angle longitude);
827 sza::util::Matrix<double> getXyzToUvwHaRot(HourAngle ha);
828 sza::util::Matrix<double> getXyzToUvwDecRot(Declination dec);
832 std::ostream& operator<<(std::ostream& os, GeoDatum datum);
833 std::ostream& operator<<(std::ostream& os, GeoCoordSystem coordSystem);
834 GeoDatum stringToDatum(std::string);
836 Vector<Length> operator*(Matrix<double>& mat, LengthTriplet& triplet);
843 #endif // End #ifndef SZA_UTIL_GEOID_H
Tagged: Fri Jun 15 16:44:12 PDT 2007.
Tagged: Wed Aug 25 02:50:06 PDT 2004.