00001 #ifndef _WINC_DOMAIN
00002 #define _WINC_DOMAIN
00003
00004 #include <WXP/Const.h>
00005 #include <WXP/DomainVal.h>
00006 #include <WXP/EarthPoint.h>
00007 #include <WXP/GridPoint.h>
00008 #include <WXP/Point.h>
00009 #include <WXP/Points.h>
00010 #include <WXP/Rect.h>
00011 #include <WXP/String.h>
00012
00013 namespace WXP {
00014
00015
00016
00017 class Domain : private DomainVal {
00018 Rect limits;
00019 Rect view;
00020
00021 float sat_rad;
00022 float sat_rad2;
00023 float sat_rad4;
00024 float sat2_earth2;
00025 float earth_sat_ratio;
00026 float earth_ratio;
00027 float earth_ratio2;
00028 float tlat1;
00029 float tlat2;
00030 float xfactor;
00031 float mult;
00032 float yfactor;
00033 float scale;
00034
00035 public:
00036 static const float earth_rad;
00037 static const float earth_maj;
00038 static const float earth_min;
00039
00040 Domain();
00041 int init();
00042 int set( DomainVal &val );
00043 int set( const char *str );
00044 int set( EarthPoint &ul, EarthPoint &lr, int rnx, int rny );
00045 int set( int rnx, int rny );
00046 DomainVal get();
00048 inline bool isSet(){ return proj != Const::MISS? true: false; };
00049 int setParam();
00050 int setLimits();
00051 int getLimits( Rect &rect );
00052 Rect getLimits();
00053 int setView( Rect &rect );
00055 inline int getProj(){ return proj; };
00057 inline float getPLat(){ return plat; };
00059 inline float getPLon(){ return plon; };
00061 inline float getCLat(){ return clat; };
00063 inline float getCLon(){ return clon; };
00065 inline int getNx(){ return nx; };
00067 inline int getNy(){ return ny; };
00069 inline float getDx(){ return dx; };
00071 inline float getDy(){ return dy; };
00073 inline float getParam( int i ){ return i >= 0 && i < 5 ? param[i]: Const::MISS; };
00074 int tranCenter( Point &pt );
00075 float getAspect();
00076 int tran( EarthPoint &ept, Point &pt );
00077 int tran( Point &pt, EarthPoint &ept );
00078 int tran( GridPoint &gpt, Point &pt );
00079 int tran( Point &pt, GridPoint &gpt );
00080 int tran( EarthPoint &ept, GridPoint &gpt );
00081 int tran( GridPoint &gpt, EarthPoint &ept );
00082
00083 enum { UL,
00084 UR,
00085 LL,
00086 LR,
00087 CENTER
00088 };
00089 int tran( int w, EarthPoint &ept );
00090 int tran( int w, GridPoint &gpt );
00091 int tran( int w, Point &pt );
00092
00093 bool within( Point &pt );
00094 bool within( EarthPoint &ept );
00095 bool withinExt( Point &pt, int ext );
00096 bool withinExt( EarthPoint &ept, int ext );
00097 int where( Point &pt );
00098 int where( EarthPoint &ept );
00099 int scaleSize( int width, int height );
00100 int scaleGrid( float scale );
00101 int zoom( Point &pt, float zfac );
00102 int pan( Point &pt );
00103 int adjust( Point &pt );
00104 int adjust( Points &pts );
00105 float adjustDir( float dir, Point &pt );
00106 float adjustDir( float dir, EarthPoint &pt );
00107 float unadjustDir( float dir, Point &pt );
00108 int offset( Point &pt, float dir, float rad, Point &opt );
00109 float direct( Point &pt1, Point &pt2 );
00110 float getVert();
00111 float getMapFactor( EarthPoint &ept );
00112 int wrapLine( Point &pt1, Point &pt2 );
00113 int wrapLine( Points &pts );
00114 int offsetLine( Point &pt1, Point &pt2, int flag );
00115 int offsetLine( Points &pts, int flag );
00116 int toString( String &string );
00117 int print();
00118 int printLimits();
00119
00121 inline int isProj( int p ){ return p == proj; };
00123 inline int isMap(){ return isMap( proj ); };
00125 inline int isTherm(){ return isTherm( proj ); };
00127 inline int isCoord(){ return isCoord( proj ); };
00129 inline int isPolar(){ return isPolar( proj ); };
00130
00131 static int getProj( const char *proj );
00132 static bool compare( Domain &dom1, Domain &dom2 );
00133 static bool compareProj( Domain &dom1, Domain &dom2 );
00134 static int translate( Domain &dom1, Domain &dom2, Point &pt1, Point &pt2 );
00135 static float calcEarthDist( EarthPoint &ept1, EarthPoint &ept2 );
00136 static int offsetLatLon( EarthPoint &ept, float dir, float rad, EarthPoint &opt );
00137
00138 static const int PSTEREO = DomainVal::PSTEREO;
00139 static const int LATLON = DomainVal::LATLON;
00140 static const int MERC = DomainVal::MERC;
00141 static const int LAMB = DomainVal::LAMB;
00142 static const int ORTHO = DomainVal::ORTHO;
00143 static const int GNOM = DomainVal::GNOM;
00144 static const int MOLL = DomainVal::MOLL;
00145 static const int LAMBAZ = DomainVal::LAMBAZ;
00146 static const int SAT = DomainVal::SAT;
00147 static const int PIXEL = DomainVal::PIXEL;
00148 static const int XY = DomainVal::XY;
00149 static const int XZ = DomainVal::XZ;
00150 static const int XP = DomainVal::XP;
00151 static const int XLOGP = DomainVal::XLOGP;
00152 static const int POLAR = DomainVal::POLAR;
00153 static const int CAT = DomainVal::CAT;
00154 static const int SKEWT = DomainVal::SKEWT;
00155 static const int STUVE = DomainVal::STUVE;
00156 static const int EMA = DomainVal::EMA;
00157 static const int TEPH = DomainVal::TEPH;
00158 static const int RTEPH = DomainVal::RTEPH;
00159 static const int ZOOM = DomainVal::ZOOM;
00160 static const int SIZE = DomainVal::SIZE;
00163 static inline bool isMap( int a ){ return (a >= PSTEREO && a <= SAT);}
00165 static inline bool isTherm( int a ){ return (a >= SKEWT && a <= RTEPH);}
00167 static inline bool isCoord( int a ){ return (a >= PIXEL && a <= CAT);}
00169 static inline bool isPolar( int a ){ return (a == POLAR);}
00170
00171 static const float OFFSET_LL;
00172 static const float OFFSET_MERC;
00173 };
00174 }
00175 #endif