00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef CONSTANTS_H
00050 #define CONSTANTS_H
00051
00052 using namespace std;
00053
00054 #include "bk_messages.hh"
00055 #include "refsystems.hh"
00056 #include "cstring"
00057
00058
00059
00060
00061
00062
00063 #include <cmath>
00064 #include <complex>
00065 #include <iostream>
00066 #include <strstream>
00067
00068
00069
00070
00071 extern bk_messages TRACE;
00072 extern bk_messages DEBUG;
00073 extern bk_messages INFO;
00074 extern bk_messages PROGRESS;
00075 extern bk_messages WARNING;
00076 extern bk_messages ERROR;
00077
00078
00079
00080
00081
00082
00083
00084 #define TRACE_FUNCTION(s) {TRACE.reset();\
00085 TRACE<<"["<<__FILE__<<"["<<__LINE__<<"]]: "<<s<<ends;\
00086 TRACE.print();}//
00087
00088
00089
00090 #define PRINT_ERROR(s) {ERROR.terminate(); char cp_s[256]; strcpy(cp_s,s); ERROR.reset();\
00091 ERROR<<"["<<__FILE__<<"["<<__LINE__<<"]]: "<<cp_s<<ends; ERROR.print();}//
00092
00093
00094
00095
00096
00097 #define SWNAME "Doris (Delft o-o Radar Interferometric Software)"
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 #define SWVERSION "Version 3.15 (07-MAR-2005)" // baseline class, exceptions
00122
00123
00124
00125 typedef short int int16;
00126 typedef int int32;
00127 typedef unsigned int uint;
00128 typedef float real4;
00129 typedef double real8;
00130 typedef complex<int16> compli16;
00131 typedef complex<int32> compli32;
00132 typedef complex<real4> complr4;
00133 typedef complex<real8> complr8;
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 #ifdef __GNUC__
00149 inline int16 sqr(int16 x) {return(x*x);}
00150 inline int32 sqr(int32 x) {return(x*x);}
00151 inline uint sqr(uint x) {return(x*x);}
00152 inline real4 sqr(real4 x) {return(x*x);}
00153 inline real8 sqr(real8 x) {return(x*x);}
00154 #endif
00155
00156
00157
00158
00159
00160 const real8 SOL = 299792458.0;
00161 const real8 EPS = 1e-13;
00162 const int32 NaN = -999;
00163 const int32 Inf = 99999;
00164 const real8 PI = real8(4)*atan(real8(1));
00165
00166 const int16 EIGHTY = 200;
00167 const int16 ONE27 = 127;
00168
00169
00170 const int16 LOGID = 1;
00171 const int16 MASTERID = 2;
00172 const int16 SLAVEID = 3;
00173 const int16 INTERFID = 4;
00174 const int16 FORMATCI2 = 11;
00175 const int16 FORMATCR4 = 12;
00176 const int16 FORMATR4 = 13;
00177 const int16 FORMATI2 = 14;
00178 const int16 FORMATI2_BIGENDIAN = 17;
00179 const int16 FORMATHGT = 15;
00180 const int16 FORMATR8 = 16;
00181
00182
00183 const int16 SLC_ERS = 1;
00184 const int16 SLC_ASAR = 2;
00185 const int16 SLC_RSAT = 3;
00186 const int16 SLC_JERS = 4;
00187
00188 const int16 SARPR_VMP = 11;
00189 const int16 SARPR_ATL = 12;
00190 const int16 SARPR_TUD = 13;
00191
00192
00193
00194 const int16 ORB_SPLINE = -11;
00195 const int16 ORB_DEFAULT = -12;
00196
00197
00198
00199
00200 class cn
00201 {
00202 public:
00203 real8 x,
00204 y,
00205 z;
00206
00207 cn()
00208 {x=0.0; y=0.0; z=0.0;};
00209 cn(real8 Px, real8 Py, real8 Pz)
00210 {x=Px; y=Py; z=Pz;};
00211
00212 cn(const cn& P)
00213 {x=P.x; y=P.y; z=P.z;};
00214
00215 ~cn()
00216 {;};
00217
00218 inline cn& operator = (const cn &P)
00219 {if (this != &P) {x=P.x; y=P.y; z=P.z;} return *this;};
00220 inline cn& operator += (const cn &P)
00221 {x+=P.x; y+=P.y; z+=P.z; return *this;}
00222 inline cn& operator -= (const cn &P)
00223 {x-=P.x; y-=P.y; z-=P.z; return *this;}
00224 inline cn& operator *= (const real8 s)
00225 {x*=s; y*=s; z*=s; return *this;}
00226 inline cn& operator *= (const cn &P)
00227 {x*=P.x; y*=P.y; z*=P.z; return *this;}
00228 inline cn& operator /= (const real8 s)
00229 {x/=s; y/=s; z/=s; return *this;}
00230 inline cn& operator /= (const cn &P)
00231 {x/=P.x; y/=P.y; z/=P.z; return *this;}
00232 inline cn operator + ()
00233 {return cn(x,y,z);};
00234 inline cn operator + (const cn &P)
00235 {return cn(x,y,z)+=P;};
00236 inline cn operator - ()
00237 {return cn(-x, -y, -z);};
00238 inline cn operator - (const cn &P)
00239 {return cn(x,y,z)-=P;};
00240 inline cn operator * (const real8 s)
00241 {return cn(x,y,z)*=s;};
00242 inline cn operator * (const cn &P)
00243 {return cn(x,y,z)*=P;};
00244 inline cn operator / (const real8 s)
00245 {return cn(x,y,z)/=s;};
00246 inline cn operator / (const cn &P)
00247 {return cn(x,y,z)/=P;};
00248 inline bool operator == (const cn &P) const
00249 {return (P.x==x && P.y==y && P.z==z) ? true : false;}
00250 inline bool operator != (const cn &P) const
00251 {return (P.x==x && P.y==y && P.z==z) ? false : true;}
00252
00253 inline real8 in(cn P) const
00254 {return x*P.x+y*P.y+z*P.z;}
00255 inline cn out(cn P) const
00256 {return cn(y*P.z-z*P.y, z*P.x-x*P.z, x*P.y-y*P.x);}
00257 inline real8 dist(cn P) const
00258 {return sqrt(sqr(x-P.x)+sqr(y-P.y)+sqr(z-P.z));}
00259 inline cn min(cn P) const
00260 {return cn(x-P.x, y-P.y, z-P.z);}
00261 inline real8 norm2() const
00262 {return sqr(x)+sqr(y)+sqr(z);}
00263 inline real8 norm() const
00264 {return sqrt(sqr(x)+sqr(y)+sqr(z));}
00265 inline cn normalize() const
00266 {return cn(x,y,z)/norm();}
00267
00268 inline real8 angle(cn A) const
00269 {return acos(in(A)/(norm()*A.norm()));}
00270 inline cn scale(real8 val) const
00271 {return cn(x*val, y*val, z*val);}
00272 inline void showdata() const
00273 {DEBUG << "cn.x=" << x << "; cn.y=" << y << "; cn.z=" << z; DEBUG.print();}
00274
00275
00276 inline void test()
00277 {
00278
00279 cn X(1,2,3);
00280 DEBUG << "cn X(1,2,3): "; X.showdata();
00281 cn Y;
00282 DEBUG << "cn Y: "; Y.showdata();
00283 Y.x=4; Y.y=5; Y.z=6;
00284 DEBUG << "Y.x=4;Y.y=5;Y.z=6: "; Y.showdata();
00285 cn Z=Y;
00286 DEBUG << "Z=Y: "; Z.showdata();
00287
00288 Z*=X;
00289 DEBUG << "Z*=X: "; Z.showdata();
00290 Z/=X;
00291 DEBUG << "Z/=X: "; Z.showdata();
00292 Z+=X;
00293 DEBUG << "Z+=X: "; Z.showdata();
00294 Z-=X;
00295 DEBUG << "Z-=X: "; Z.showdata();
00296
00297 DEBUG << "X+Y: "; (X+Y).showdata();
00298 DEBUG << "X-Y: "; (X-Y).showdata();
00299 DEBUG << "X/Y: "; (X/Y).showdata();
00300 DEBUG << "X*Y: "; (X*Y).showdata();
00301 DEBUG << "+X: "; (+X).showdata();
00302 DEBUG << "-X: "; (-X).showdata();
00303 DEBUG << "X==Y: " << (X==Y); DEBUG.print();
00304 DEBUG << "X!=Y: " << (X!=Y); DEBUG.print();
00305
00306 DEBUG << "X.min(Y): "; (X.min(Y)).showdata();
00307 DEBUG << "X.normalize(): "; (X.normalize()).showdata();
00308 DEBUG << "X.scale(5): "; (X.scale(5)).showdata();
00309 DEBUG << "X.out(Y): "; (X.out(Y)).showdata();
00310 DEBUG << "X.dist(Y): " << X.dist(Y); DEBUG.print();
00311 DEBUG << "X.norm(): " << X.norm(); DEBUG.print();
00312 DEBUG << "X.norm2(): " << X.norm2(); DEBUG.print();
00313 DEBUG << "X.angle(Y): " << X.angle(Y); DEBUG.print();
00314 DEBUG << "X.in(Y): " << X.in(Y); DEBUG.print();
00315 }
00316 };
00317
00318
00319
00320
00321 class input_ell
00322 {
00323 public:
00324 real8 a;
00325 real8 b;
00326 real8 e2;
00327 real8 e2b;
00328 char name[EIGHTY];
00329
00330 input_ell()
00331 {a = WGS84_A;
00332 b = WGS84_B;
00333 e2 = (sqr(a)-sqr(b))/sqr(a);
00334 e2b = (sqr(a)-sqr(b))/sqr(b);
00335 strcpy(name,"WGS84");
00336 }
00337
00338 input_ell(const input_ell& ell)
00339 {a=ell.a; b=ell.b; e2=ell.e2; e2b=ell.e2b; strcpy(name,ell.name);};
00340
00341 ~input_ell()
00342 {;};
00343
00344 inline input_ell& operator = (const input_ell &ell)
00345 {if (this != &ell)
00346 {a=ell.a; b=ell.b; e2=ell.e2; e2b=ell.e2b; strcpy(name,ell.name);}
00347 return *this;};
00348 inline void ecc1st_sqr()
00349 {e2=(sqr(a)-sqr(b))/sqr(a);}
00350 inline void ecc2nd_sqr()
00351 {e2b=(sqr(a)-sqr(b))/sqr(b);}
00352 inline void showdata() const
00353 {DEBUG << "ELLIPS: " << name
00354 << ": ell.a=" << a << "; ell.b=" << b
00355 << "; ell.e2=" << e2 << "; ell.e2b=" << e2b;
00356 DEBUG.print();
00357 }
00358
00359
00360 inline void test()
00361 {
00362
00363 input_ell X;
00364
00365 DEBUG << "ELLIPS: " << X.name
00366 << ": X.a=" << X.a << "; X.b=" << X.b
00367 << "; X.e2=" << X.e2 << "; X.e2b=" << X.e2b;
00368 DEBUG.print();
00369
00370
00371 }
00372 };
00373
00374
00375
00376
00377
00378 class window
00379 {
00380 public:
00381 uint linelo,
00382 linehi,
00383 pixlo,
00384 pixhi;
00385
00386 window()
00387 {linelo=0; linehi=0; pixlo=0; pixhi=0;};
00388 window(uint ll, uint lh, uint pl, uint ph)
00389 {linelo=ll; linehi=lh; pixlo=pl; pixhi=ph;};
00390
00391 window(const window& w)
00392 {linelo=w.linelo; linehi=w.linehi; pixlo=w.pixlo; pixhi=w.pixhi;};
00393
00394 ~window()
00395 {;};
00396
00397 inline void disp() const
00398 {DEBUG << "window l0, lN, p0, pN: "
00399 << linelo << ", " << linehi << ", "
00400 << pixlo << ", " << pixhi; DEBUG.print();};
00401 inline uint lines() const
00402 {return linehi-linelo+1;}
00403 inline uint pixels() const
00404 {return pixhi-pixlo+1;}
00405 inline window& operator = (const window &X)
00406 {if (this != &X)
00407 {linelo=X.linelo;linehi=X.linehi;pixlo=X.pixlo;pixhi=X.pixhi;}
00408 return *this;};
00409 inline bool operator == (const window &X) const
00410 {return (linelo==X.linelo&&linehi==X.linehi &&
00411 pixlo==X.pixlo && pixhi==X.pixhi) ? true : false;};
00412 inline bool operator != (const window &X) const
00413 {return (linelo==X.linelo&&linehi==X.linehi &&
00414 pixlo==X.pixlo && pixhi==X.pixhi) ? false : true;};
00415
00416
00417 inline void test()
00418 {
00419
00420 window X;
00421 DEBUG << "window X: "; X.disp();
00422 window Y(11,21,103,114);
00423 DEBUG << "window Y(11,21,103,114): "; Y.disp();
00424
00425 X=Y;
00426 DEBUG << "X=Y: "; X.disp();
00427 DEBUG << "X.lines(): " << X.lines(); DEBUG.print();
00428 DEBUG << "X.pixels(): " << X.pixels(); DEBUG.print();
00429 DEBUG << "X==Y: " << (X==Y); DEBUG.print();
00430 DEBUG << "X!=Y: " << (X!=Y); DEBUG.print();
00431 }
00432 };
00433
00434
00435 #endif // CONSTANTS_H
00436
00437