Isis 3.0 Developer's Reference (API) |
Home |
00001 #ifndef Projection_h 00002 #define Projection_h 00003 00025 #include <string> 00026 #include "Pvl.h" 00027 #include "WorldMapper.h" 00028 00029 namespace Isis { 00030 class Displacement; 00031 00123 class Projection { 00124 public: 00125 // constructor 00126 Projection(Isis::Pvl &label); 00127 00129 virtual ~Projection() { 00130 if(p_mapper) delete p_mapper; 00131 }; 00132 00145 void SetWorldMapper(Isis::WorldMapper *mapper) { 00146 p_mapper = mapper; 00147 }; 00148 00149 // Set world position 00150 bool SetWorld(const double x, const double y); 00151 00152 // Set ground position 00153 virtual bool SetGround(const double lat, const double lon); 00154 00155 // Set x/y coordinate 00156 virtual bool SetCoordinate(const double x, const double y); 00157 00158 // set UpperLeftCornerX and UpperLeftCornerY in mapping group 00159 void SetUpperLeftCorner(const Displacement &x, const Displacement &y); 00160 00169 inline bool IsGood() const { 00170 return p_good; 00171 }; 00172 00173 // Return computed world X/Y after successful SetGround 00174 double WorldX() const; 00175 double WorldY() const; 00176 00185 inline double Longitude() const { 00186 return p_longitude; 00187 }; 00188 00197 inline double Latitude() const { 00198 return p_latitude; 00199 }; 00200 00209 inline double XCoord() const { 00210 return p_x; 00211 }; 00212 00213 00222 inline double YCoord() const { 00223 return p_y; 00224 }; 00225 00232 inline double EquatorialRadius() const { 00233 return p_equatorialRadius; 00234 }; 00235 00242 inline double PolarRadius() const { 00243 return p_polarRadius; 00244 }; 00245 00246 00252 inline double Eccentricity() const { 00253 return p_eccentricity; 00254 }; 00255 00256 // Obtain latitude type 00257 enum LatitudeType { Planetographic, Planetocentric }; 00258 00266 inline bool IsPlanetographic() const { 00267 return p_latitudeType == Planetographic; 00268 }; 00269 00270 00278 inline bool IsPlanetocentric() const { 00279 return p_latitudeType == Planetocentric; 00280 }; 00281 00282 // Obtain latitude type as a string 00283 std::string LatitudeTypeString() const; 00284 00285 // Obtain longitude directions as a string 00286 std::string LongitudeDirectionString() const; 00287 00288 // Obtain longitude domain as a string 00289 std::string LongitudeDomainString() const; 00290 00291 // Obtain longitude direction 00292 enum LongitudeDirection { PositiveEast, PositiveWest }; 00293 00301 inline bool IsPositiveWest() const { 00302 return p_longitudeDirection == PositiveWest; 00303 }; 00304 00312 inline bool IsPositiveEast() const { 00313 return p_longitudeDirection == PositiveEast; 00314 }; 00315 00323 inline bool Has360Domain() const { 00324 return p_longitudeDomain == 360; 00325 }; 00326 00327 00335 inline bool Has180Domain() const { 00336 return p_longitudeDomain == 180; 00337 }; 00338 00348 inline bool HasGroundRange() const { 00349 return p_groundRangeGood; 00350 }; 00351 00359 inline double MinimumLatitude() const { 00360 return p_minimumLatitude; 00361 }; 00362 00370 inline double MaximumLatitude() const { 00371 return p_maximumLatitude; 00372 }; 00373 00381 inline double MinimumLongitude() const { 00382 return p_minimumLongitude; 00383 }; 00384 00392 inline double MaximumLongitude() const { 00393 return p_maximumLongitude; 00394 }; 00395 00396 // Return the x/y range which covers the lat/lon range in the labels 00397 virtual bool XYRange(double &minX, double &maxX, double &minY, double &maxY); 00398 00399 00405 inline double Rotation() const { 00406 return p_rotation; 00407 }; 00408 00409 // Return the universal ground coordinate after successful SetCoordinate 00410 double UniversalLatitude(); 00411 double UniversalLongitude(); 00412 00413 // Set the universal ground coordinate 00414 bool SetUniversalGround(const double lat, const double lon); 00415 00416 // Convert latitude value from Planetographic to Planetocentric and vice versa 00417 double ToPlanetocentric(const double lat) const; 00418 double ToPlanetographic(const double lat) const; 00419 00420 // Convert longitude value from (0:360) to (-180:180) or vice versa 00421 static double To360Domain(const double lon); 00422 static double To180Domain(const double lon); 00423 00424 // Convert longitude value from positive east to positive west or vice verse 00425 static double ToPositiveEast(const double lon, const int domain); 00426 static double ToPositiveWest(const double lon, const int domain); 00427 00428 double ToWorldX(const double projectionX) const; 00429 double ToWorldY(const double projectionY) const; 00430 double ToProjectionX(const double worldX) const; 00431 double ToProjectionY(const double worldY) const; 00432 double Resolution() const; 00433 double Scale() const; 00434 virtual double TrueScaleLatitude() const; 00435 virtual PvlGroup Mapping(); 00436 virtual PvlGroup MappingLatitudes(); 00437 virtual PvlGroup MappingLongitudes(); 00438 00439 virtual bool operator== (const Projection &proj); 00440 bool operator!= (const Projection &proj); 00441 00450 virtual bool IsEquatorialCylindrical() { 00451 return false; 00452 } 00453 00459 virtual std::string Name() const = 0; 00460 virtual std::string Version() const = 0; 00461 00462 double LocalRadius() const; 00463 double LocalRadius(double lat) const; 00464 00466 bool IsSky() const { 00467 return p_sky; 00468 }; 00469 00470 // Static conversion methods 00471 static double ToHours(double angle); 00472 static std::string ToDMS(double angle); 00473 static std::string ToHMS(double angle); 00474 static double ToPlanetographic(double lat, 00475 double eRadius, double pRadius); 00476 static double ToPlanetocentric(double lat, 00477 double eRadius, double pRadius); 00478 static PvlGroup TargetRadii(std::string target); 00479 static PvlGroup TargetRadii(Pvl &cubeLab, PvlGroup &mapGroup); 00480 00481 protected: 00482 Isis::WorldMapper *p_mapper; 00491 double p_latitude; 00493 double p_longitude; 00495 bool p_good; 00498 LatitudeType p_latitudeType; 00503 LongitudeDirection p_longitudeDirection; 00510 int p_longitudeDomain; 00519 double p_equatorialRadius; 00523 double p_polarRadius; 00530 double p_eccentricity; 00531 bool p_sky; 00532 00533 bool p_groundRangeGood; 00535 double p_minimumLatitude; 00538 double p_maximumLatitude; 00541 double p_minimumLongitude; 00544 double p_maximumLongitude; 00548 // Convience data/methods for XYRange virtual function 00549 double p_minimumX; 00558 double p_maximumX; 00559 double p_minimumY; 00560 double p_maximumY; 00561 PvlGroup p_mappingGrp; 00562 void XYRangeCheck(const double latitude, const double longitude); 00563 00564 // Convience methods for typical projection computations 00565 double mCompute(const double sinphi, const double cosphi) const; 00566 double e4Compute() const; 00567 double tCompute(const double phi, const double sinphi) const; 00568 double phi2Compute(const double t) const; 00569 00570 void SetXY(double x, double y); 00571 void SetComputedXY(double x, double y); 00572 double GetX() const; 00573 double GetY() const; 00574 00575 private: 00576 double p_rotation; 00577 00578 double p_x; 00582 double p_y; 00586 }; 00587 }; 00588 00589 #endif 00590