USGS

Isis 3.0 Developer's Reference (API)

Home

Projection.h

Go to the documentation of this file.
00001 #ifndef Projection_h
00002 #define Projection_h
00003 
00025 #include <string>
00026 #include <vector>
00027 
00028 #include "PvlGroup.h" // protected data member object (m_mappingGrp)
00029 
00030 namespace Isis {
00031   class Displacement;
00032   class Pvl;
00033   class WorldMapper;
00166   class Projection {
00167     public:
00168       // constructor
00169       Projection(Pvl &label);
00170       virtual ~Projection();
00171       virtual bool operator== (const Projection &proj);
00172       bool operator!= (const Projection &proj);
00173 
00174       // These return properties of the target
00175       bool IsSky() const;
00176       double EquatorialRadius() const;
00177       double PolarRadius() const;
00178       double Eccentricity() const;
00179       double LocalRadius(double lat) const;
00180       double LocalRadius() const; // requires SetGround or SetCoordinate
00181 
00182       // These return or change properties of the projection, independent of calculations
00189       virtual QString Name() const = 0;
00196       virtual QString Version() const = 0;
00197       virtual double TrueScaleLatitude() const;
00198       virtual bool IsEquatorialCylindrical();
00202       enum LatitudeType { Planetocentric, 
00208                           Planetographic  
00213                         };
00214       // Check latitude type or get latitude type as a string
00215       bool IsPlanetocentric() const;
00216       bool IsPlanetographic() const;
00217       QString LatitudeTypeString() const;
00218       // change latitude type
00219       double ToPlanetocentric(const double lat) const;
00220       double ToPlanetographic(const double lat) const;
00225       enum LongitudeDirection { PositiveEast, 
00227                                 PositiveWest  
00229                               };
00230       // Check longitude direction or get longitude direction as a string
00231       bool IsPositiveEast() const;
00232       bool IsPositiveWest() const;
00233       QString LongitudeDirectionString() const;
00234       // Check longitude domain or get longitude domain as a string
00235       bool Has180Domain() const;
00236       bool Has360Domain() const;
00237       QString LongitudeDomainString() const;
00238       // Check if labels contain min/max lat/lon
00239       bool HasGroundRange() const;
00240       // Get min/max lat/lon
00241       double MinimumLatitude() const;
00242       double MaximumLatitude() const;
00243       double MinimumLongitude() const;
00244       double MaximumLongitude() const;
00245       // get rotation
00246       double Rotation() const;
00247       // Set world mapper
00248       void SetWorldMapper(WorldMapper *mapper);
00249 
00250       //  Calculations
00251       // Set ground position or x/y coordinate
00252       virtual bool SetGround(const double lat, const double lon);
00253       virtual bool SetCoordinate(const double x, const double y);
00254       bool IsGood() const;
00255 
00256       // Methods that depend on successful completion
00257       // of SetGround/SetCoordinate Get lat,lon, x,y
00258       double Latitude() const;
00259       double Longitude() const;
00260       double XCoord() const;
00261       double YCoord() const;
00262       // Set the universal ground coordinate (calls SetGround)
00263       bool SetUniversalGround(const double lat, const double lon);
00264       // Return the universal ground coordinate after successful SetCoordinate
00265       double UniversalLatitude();
00266       double UniversalLongitude();
00267       // Set world position (calls SetCoordinate on projected x/y)
00268       bool SetWorld(const double x, const double y);
00269       // Get computed world X/Y after successful SetGround
00270       double WorldX() const;
00271       double WorldY() const;
00272       // convert from projected coordinate to world coordinate
00273       double ToWorldX(const double projectionX) const;
00274       double ToWorldY(const double projectionY) const;
00275       // convert from world coordinate to projected coordinate
00276       double ToProjectionX(const double worldX) const;
00277       double ToProjectionY(const double worldY) const;
00278       // get resolution and scale for mapping world coordinates
00279       double Resolution() const;
00280       double Scale() const;
00281 
00282       // Return the x/y range which covers the lat/lon range in the labels
00283       virtual bool XYRange(double &minX, double &maxX,
00284                            double &minY, double &maxY);
00285 
00286       // set UpperLeftCornerX and UpperLeftCornerY in mapping group
00287       void SetUpperLeftCorner(const Displacement &x, const Displacement &y);
00288 
00289       // get mapping information
00290       virtual PvlGroup Mapping();
00291       virtual PvlGroup MappingLatitudes();
00292       virtual PvlGroup MappingLongitudes();
00293 
00294       // Static conversion methods
00295       static PvlGroup TargetRadii(QString target);
00296       static PvlGroup TargetRadii(Pvl &cubeLab, PvlGroup &mapGroup);
00297       static double ToHours(double angle);
00298       static QString ToDMS(double angle);
00299       static QString ToHMS(double angle);
00300       // change latitude type
00301       static double ToPlanetocentric(double lat,
00302                                      double eRadius, double pRadius);
00303       static double ToPlanetographic(double lat,
00304                                      double eRadius, double pRadius);
00305       // change longitude direction
00306       static double ToPositiveEast(const double lon, const int domain);
00307       static double ToPositiveWest(const double lon, const int domain);
00308       // change longitude domain
00309       static double To180Domain(const double lon);
00310       static double To360Domain(const double lon);
00311 
00312     protected:
00313       void XYRangeCheck(const double latitude, const double longitude);
00314       bool xyRangeOblique(double &minX, double &maxX,
00315                           double &minY, double &maxY);
00316       void SetXY(double x, double y);
00317       void SetComputedXY(double x, double y);
00318       double GetX() const;
00319       double GetY() const;
00320 
00321       // Convience methods for typical projection computations from Snyder
00322       double qCompute(const double sinPhi) const; // page 16
00323       double phi2Compute(const double t) const; // page 44
00324       double mCompute(const double sinphi, const double cosphi) const; // page 101
00325       double tCompute(const double phi, const double sinphi) const; //page 108
00326       double e4Compute() const; // page 161
00327 
00328     private:
00329       void doSearch(double minBorder, double maxBorder,
00330                     double &extremeVal, const double constBorder,
00331                     bool searchX, bool searchLongitude, bool findMin);
00332       void findExtreme(double &minBorder,  double &maxBorder,
00333                        double &minBorderX, double &minBorderY,
00334                        double &maxBorderX, double &maxBorderY,
00335                        const double constBorder, bool searchX,
00336                        bool searchLongitude, bool findMin);
00337       void setSearchGround(const double variableBorder,
00338                            const double constBorder, bool variableIsLat);
00339 
00340     protected:
00341       WorldMapper *m_mapper;  
00349       double m_latitude;   
00351       double m_longitude;  
00353       bool m_good;         
00356       LatitudeType m_latitudeType; 
00361       LongitudeDirection m_longitudeDirection; 
00368       int m_longitudeDomain; 
00374       double m_equatorialRadius;  
00379       double m_polarRadius;       
00386       double m_eccentricity;      
00387       bool m_sky;                 
00390       bool m_groundRangeGood;     
00392       double m_minimumLatitude;   
00395       double m_maximumLatitude;   
00398       double m_minimumLongitude;  
00401       double m_maximumLongitude;  
00405       // Convience data for XYRange virtual function
00406       double m_minimumX;  
00415       double m_maximumX;  
00416       double m_minimumY;  
00417       double m_maximumY;  
00418       PvlGroup m_mappingGrp; 
00419 
00420     private:
00421       double m_rotation;   
00422 
00423       double m_x;          
00427       double m_y;          
00431       // These are necessary for calculating oblique X/Y range with
00432       // discontinuity
00433       std::vector<double> m_specialLatCases; 
00435       std::vector<double> m_specialLonCases; 
00438       double m_pixelResolution; 
00440   };
00441 };
00442 #endif
00443