Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

constants.hh

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999-2003 Bert Kampes
00003  * Copyright (c) 1999-2003 Delft University of Technology, The Netherlands
00004  *
00005  * This file is part of Doris, the Delft o-o radar interferometric software.
00006  *
00007  * Doris program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * Doris is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * Publications that contain results produced by the Doris software should
00022  * contain an acknowledgment. (For example: The interferometric processing
00023  * was performed using the freely available Doris software package developed
00024  * by the Delft Institute for Earth-Oriented Space Research (DEOS), Delft
00025  * University of Technology, or include a reference to: Bert Kampes and
00026  * Stefania Usai. \"Doris: The Delft Object-oriented Radar Interferometric
00027  * software.\" In: proceedings 2nd ITC ORS symposium, August 1999. (cdrom)).
00028  *
00029  */
00030 /****************************************************************
00031  * $Source: /users/kampes/DEVELOP/DORIS/doris/src/RCS/constants.hh,v $  *
00032  * $Revision: 3.25 $                                            *
00033  * $Date: 2005/04/13 11:12:23 $                                 *
00034  * $Author: kampes $                                            *
00035  *                                                              *
00036  * Definitions of some global (external) structs +functions,    *
00037  * constants                                                    *
00038  * define: SWNAME SWVERSION                                     *
00039  * __GplusplusCOMPILER__ then implement T sqr(T), cause no ansi c++ *
00040  * pragma: aCC things (removed since v3.8)                      * 
00041  *                                                              *
00042  * CLASSES IN THIS FILE:                                        *
00043  *   - ellips:  struct + functions                              *
00044  *   - cn:      3D coordinates + functions                      *
00045  *   - window:  in matrices/files + functions                   *
00046  ****************************************************************/
00047 
00048 
00049 #ifndef CONSTANTS_H
00050 #define CONSTANTS_H
00051 
00052 using namespace std;                    // BK 29-Mar-2003, new compiler?
00053 
00054 #include "bk_messages.hh"
00055 #include "refsystems.hh"        // ellips class
00056 #include "cstring"              // strcpy for exceptions
00057 
00058 //#if defined __GNUC__ && __GNUC__ >= 2
00059 //#else
00060 //#endif
00061 // g++ -v -c processor.cc gives (ao):
00062 // -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95
00063 #include <cmath>                        // for pi (atan)
00064 #include <complex>                      // default known complex type
00065 #include <iostream>                     // cout etc.
00066 #include <strstream>                  // for memory stream
00067 
00068 
00069 
00070 // ====== Globals for messages to stdout ======
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 // _____ Macros for abbreviation ______
00078 // ___ Note that useage could be like PRINT_ERROR(WARNING.get_str()) ___
00079 // ___ (normally WARNING.rewind() required after this, but exited) ___
00080 // ___                                PRINT_ERROR(".") ___
00081 // ___ w/o the ";"  (since in an if/else construction without {}{}
00082 // ___ it will otherwise crash ___
00083 // ___ use TRACE_FUNCTION ONLY SIMPLE WITH CHAR ARRAY "dadsa" ___
00084 #define TRACE_FUNCTION(s) {TRACE.reset();\
00085   TRACE<<"["<<__FILE__<<"["<<__LINE__<<"]]: "<<s<<ends;\
00086   TRACE.print();}//
00087 //#define PRINT_ERROR(s) {printcpu(); WARNING.summary();\
00088 //  ERROR.terminate(); char cp_s[256]; strcpy(cp_s,s); ERROR.reset();\
00089 //  ERROR<<"["<<__FILE__<<"["<<__LINE__<<"]]: "<<cp_s<<ends; ERROR.print();}//
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 // ====== Define name/version ======
00097 #define SWNAME    "Doris (Delft o-o Radar Interferometric Software)"
00098 //#define SWVERSION "Version 2.0"       // 4-Nov-99
00099 //#define SWVERSION "Version 2.2"       // 23-Feb-00 DEM subtraction
00100 //#define SWVERSION "Version 2.3"       // 05-Apr-00 rangefilter
00101 //#define SWVERSION "Version 2.4"       // 22-Jun-00 makefile for g++ all versions
00102 //#define SWVERSION "Version 2.5"       // 07-Jul-00 linux x86 byteorder
00103 //#define SWVERSION "Version 2.5.1"     // 19-Jul-00 orbit class
00104 //#define SWVERSION "Version 2.6"       // 26-Oct-00 dinsar
00105 //#define SWVERSION "Version 3.0"       // ??-???-00 filtphase, filtazi, filtrange2
00106 //#define SWVERSION "Version 3.1"       // 04-May-01 DEM radarcode formats, general impr.
00107 //#define SWVERSION "Version 3.3"       // 06-FEb-02 BEEP, PREVIEW,
00108                                         // Cygwin, COMPREFDEM (april).
00109 //#define SWVERSION "Version 3.4 (01-NOV-2002)" // azishift resample change
00110                                                 // ...snaphu unwrap
00111 //#define SWVERSION "Version 3.5 (03-APR-2003)" // compatible with g++ v3.2 c++ standard
00112 //#define SWVERSION "Version 3.6 (15-JUN-2003)" // envisat interface.
00113 //#define SWVERSION "Version 3.7 (02-SEP-2003)" // auto coregpm. example scripts geocoding
00114 //#define SWVERSION "Version 3.8 (22-SEP-2003)" // added fftw lib, quicklook option of runscript
00115 //#define SWVERSION "Version 3.9 (16-OKT-2003)" // mainly release under GPL
00116 //#define SWVERSION "Version 3.10 (16-JAN-2004)"        // ovs, resample, ...
00117 //#define SWVERSION "Version 3.11 (13-MAY-2004)"        // envisat bugfix, height card
00118 //#define SWVERSION "Version 3.12 (13-AUG-2004)"        // mainly radarsat added
00119 //#define SWVERSION "Version 3.13 (01-OCT-2004)"        // fleafixes
00120 //#define SWVERSION "Version 3.14 (07-MAR-2005)"        // fixes fdc computation; .h -> .hh
00121 #define SWVERSION "Version 3.15 (07-MAR-2005)"  // baseline class, exceptions
00122 
00123 
00124 // ====== Typedefs for portability ======
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 // ====== Pragma/Include ======
00137 //#ifndef __GplusplusCOMPILER__ // assume aCC (hp)
00138 //  #pragma COPYRIGHT "Bert Kampes, DEOS, Delft University of Technology"
00139 //  #pragma COPYRIGHT_DATE "1998-2003"
00140 //  #pragma VERSIONID SWVERSION
00141 //#endif
00142 
00143 
00144 // ====== function: Type sqr(Type) not in stdlib math.h! ======
00145 // ====== Possibly also for other compilers that have errors this define will fix it ===
00146 // note though that this is not save casted
00147 //#ifdef __GplusplusCOMPILER__
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 // ====== Global constants ======
00159 // ______ General constants ______
00160 const real8     SOL             = 299792458.0;  // speed of light in m/s
00161 const real8     EPS             = 1e-13;        // small number
00162 const int32     NaN             = -999;         // Not a Number
00163 const int32     Inf             =  99999;       // Infinity
00164 const real8     PI              = real8(4)*atan(real8(1));
00165 //const int16           EIGHTY          = 80;
00166 const int16     EIGHTY          = 200;// 80 seems to short for ASAR filenames
00167 const int16     ONE27           = 127;
00168 
00169 // ______ Handy for software, IDs have to be enumerated (used in loop) ______
00170 const int16     LOGID           = 1;            // general identifier for log
00171 const int16     MASTERID        = 2;            // general identifier for master
00172 const int16     SLAVEID         = 3;            // general identifier for slave
00173 const int16     INTERFID        = 4;            // general identifier for interferogram
00174 const int16     FORMATCI2       = 11;           // formatflag
00175 const int16     FORMATCR4       = 12;           // formatflag
00176 const int16     FORMATR4        = 13;           // formatflag
00177 const int16     FORMATI2        = 14;           // formatflag
00178 const int16     FORMATI2_BIGENDIAN = 17;        // formatflag
00179 const int16     FORMATHGT       = 15;           // formatflag unwrapped band interleaved ampl(1)/phase(2)
00180 const int16     FORMATR8        = 16;           // formatflag
00181 
00182 // ______ product specifier ______
00183 const int16     SLC_ERS         = 1;            // ERS
00184 const int16     SLC_ASAR        = 2;            // ENVISAT
00185 const int16     SLC_RSAT        = 3;            // RadarSAT (and Atlantis processor??)
00186 const int16     SLC_JERS        = 4;            // JERS (ceos?)
00187 // ______ processor specifier ______
00188 const int16     SARPR_VMP       = 11;            // ESA PAFs SAR processor SLC
00189 const int16     SARPR_ATL       = 12;            // Atlantis created SLC
00190 const int16     SARPR_TUD       = 13;            // TUDelft processor created SLC
00191 
00192 // ====== Unique method selectors for interpolation ======
00193 // ====== For ASAR (only 5 points), spline is not good ======
00194 const int16     ORB_SPLINE      = -11; // else degree of polynomial
00195 const int16     ORB_DEFAULT     = -12; // [degree of polynomial=numpoints-1, max=5]
00196 
00197 
00198 
00199 // ====== class cn for coordinates + functions ======
00200 class cn                                // coordinates
00201   {
00202   public:
00203   real8         x,                      // 
00204                 y,                      //
00205                 z;                      //
00206   // ______ Constructors ______
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   // ______ Copy constructor ______
00212   cn(const cn& P)
00213     {x=P.x; y=P.y; z=P.z;};
00214   // ______ Destructor ______
00215   ~cn()
00216     {;};// nothing to destruct that isn't destructed automatically
00217   // ______ Operators ______
00218   inline cn& operator = (const cn &P)// assignment operator
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)// multiply by scalar
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)// divide by scalar
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 + () // unary plus
00233     {return cn(x,y,z);};
00234   inline cn operator + (const cn &P) // binary plus
00235     {return cn(x,y,z)+=P;};
00236   inline cn operator - ()// unary min
00237     {return cn(-x, -y, -z);};
00238   inline cn operator - (const cn &P)// binary min
00239     {return cn(x,y,z)-=P;};
00240   inline cn operator * (const real8 s) // Q=P*s
00241     {return cn(x,y,z)*=s;};
00242   inline cn operator * (const cn &P) // Q=P*Q
00243     {return cn(x,y,z)*=P;};
00244   inline cn operator / (const real8 s) // Q=P/s
00245     {return cn(x,y,z)/=s;};
00246   inline cn operator / (const cn &P) // Q=P/Q
00247     {return cn(x,y,z)/=P;};
00248   inline bool operator == (const cn &P) const // isequal operator
00249     {return (P.x==x && P.y==y && P.z==z) ? true : false;}
00250   inline bool operator != (const cn &P) const // isnotequal operator
00251     {return (P.x==x && P.y==y && P.z==z) ? false : true;}
00252   // ______ Public function in struct ______
00253   inline real8 in(cn P) const           // scalar product: r=P.in(Q);
00254     {return x*P.x+y*P.y+z*P.z;}
00255   inline cn out(cn P) const             // cross product cn r=P.out(Q);
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         // distance: d=P.dist(Q);
00258     {return sqrt(sqr(x-P.x)+sqr(y-P.y)+sqr(z-P.z));}
00259   inline cn min(cn P) const             // cn r=P.min(Q);
00260     {return cn(x-P.x, y-P.y, z-P.z);}
00261   inline real8 norm2() const            // n=P.norm2();
00262     {return sqr(x)+sqr(y)+sqr(z);}
00263   inline real8 norm() const             // n=P.norm();
00264     {return sqrt(sqr(x)+sqr(y)+sqr(z));}
00265   inline cn normalize() const           // cn R=P.normalize();
00266     {return cn(x,y,z)/norm();}
00267     //{const real8 n=norm(); return cn(x/n, y/n, z/n);}
00268   inline real8 angle(cn A) const        // angle=A.angle(B); //0,pi;
00269     {return acos(in(A)/(norm()*A.norm()));}
00270   inline cn scale(real8 val) const // scaling of a point by a scalar KKM-05
00271     {return cn(x*val, y*val, z*val);}
00272   inline void showdata() const     // displays a point by KKM-05 Mar 9, 2005
00273     {DEBUG << "cn.x=" << x << "; cn.y=" << y << "; cn.z=" << z; DEBUG.print();}
00274   // --- Test program for coordinate class ----------------------------
00275   // --- This test is executed in inittest() --------------------------
00276   inline void test()
00277     {
00278     // constructors
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     // operators
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     // operators
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     // functions
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 // ====== Struct ellips + functions ======
00321 class input_ell                 // ellips a,b   
00322   {
00323   public:
00324   real8         a;                      // semi major
00325   real8         b;                      // semi minor
00326   real8         e2;                     // squared first  eccentricity (derived)
00327   real8         e2b;                    // squared second eccentricity (derived)
00328   char          name[EIGHTY];
00329   // ______ Default constructor ______
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   // ______ Copy constructor ______
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   // ______ Destructor ______
00341   ~input_ell()
00342     {;};// nothing to destruct that isn't destructed automatically
00343   // ______ Public function in struct ______
00344   inline input_ell& operator = (const input_ell &ell)// assignment operator
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()              // first ecc.
00349     {e2=(sqr(a)-sqr(b))/sqr(a);}
00350   inline void ecc2nd_sqr()              // second ecc.
00351     {e2b=(sqr(a)-sqr(b))/sqr(b);}
00352   inline void showdata() const     // displays a point by KKM-05 Mar 9, 2005
00353     {DEBUG << "ELLIPS: "  << name 
00354            << ": ell.a="  << a  << "; ell.b="   << b 
00355            << "; ell.e2=" << e2 << "; ell.e2b=" << e2b;
00356      DEBUG.print();
00357     }
00358   // --- Test program for coordinate class ----------------------------
00359   // --- This test is executed in inittest() --------------------------
00360   inline void test()
00361     {
00362     // constructors
00363     input_ell X;
00364     //DEBUG << "input_ell X:   " << X.showdata();
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     //input_ell Y=X;
00370     //DEBUG << "Y=X:           " << Y.showdata();
00371     }
00372   };
00373 
00374 
00375 
00376 // ====== Struct window + functions ======
00377 // ______ image starts at 1, matrix starts at 0 ______
00378 class window                            // window file={1,N,1,N}
00379   {
00380   public:
00381   uint          linelo,                         // min. line coord.
00382                 linehi,                         // max. line coord.
00383                 pixlo,                          // min. pix coord.
00384                 pixhi;                          // max. pix coord.
00385   // ______ Constructors ______
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   // ______ Copy constructor ______
00391   window(const window& w)
00392     {linelo=w.linelo; linehi=w.linehi; pixlo=w.pixlo; pixhi=w.pixhi;};
00393   // ______ Destructor ______
00394   ~window()
00395     {;};// nothing to destruct that isn't destructed automatically
00396   // ______ Public function in struct ______
00397   inline void disp() const                      // show content
00398     {DEBUG << "window l0, lN, p0, pN: "
00399            << linelo << ", " << linehi << ", "
00400            << pixlo  << ", " << pixhi; DEBUG.print();}; //  << endl;}
00401   inline uint lines() const                     // return number of lines
00402     {return linehi-linelo+1;}
00403   inline uint pixels() const                    // return number of pixels
00404     {return pixhi-pixlo+1;}
00405   inline window& operator = (const window &X)// assignment operator
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   // --- Test program for coordinate class ----------------------------
00416   // --- This test is executed in inittest() --------------------------
00417   inline void test()
00418     {
00419     // constructors
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     // functions
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 

Generated on Fri Apr 22 15:57:48 2005 for Doris by doxygen 1.3.6