00001 #pragma ident "$Id: Antenna.cpp 1769 2009-03-04 08:03:19Z architest $"
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "Antenna.hpp"
00032
00033
00034
00035 namespace gpstk
00036 {
00037
00038
00039
00040
00041
00042
00043
00044 Antenna::Antenna( const Triple& eccL1,
00045 const Triple& eccL2 )
00046 {
00047
00048 addAntennaEcc(G01, eccL1);
00049 addAntennaEcc(G02, eccL2);
00050
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 Antenna::Antenna( double NorthEccL1,
00065 double EastEccL1,
00066 double UpEccL1,
00067 double NorthEccL2,
00068 double EastEccL2,
00069 double UpEccL2 )
00070 {
00071
00072 addAntennaEcc(G01, NorthEccL1, EastEccL1, UpEccL1);
00073 addAntennaEcc(G02, NorthEccL2, EastEccL2, UpEccL2);
00074
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 std::string Antenna::getAntennaData( AntennaDataType dataType ) const
00084 throw(InvalidRequest)
00085 {
00086
00087
00088
00089 AntennaDataMap::const_iterator it( antennaData.find(dataType) );
00090 if( it != antennaData.end() )
00091 {
00092
00093 return (*it).second;
00094 }
00095 else
00096 {
00097 InvalidRequest e("No data was found for provided data type.");
00098 GPSTK_THROW(e);
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 Triple Antenna::getAntennaEccentricity( frequencyType freq ) const
00112 throw(InvalidRequest)
00113 {
00114
00115
00116
00117 AntennaEccDataMap::const_iterator it( antennaEccMap.find(freq) );
00118 if( it != antennaEccMap.end() )
00119 {
00120
00121
00122 Triple toReturn( (*it).second[2], (*it).second[1], (*it).second[0] );
00123 return toReturn;
00124 }
00125 else
00126 {
00127 InvalidRequest e("No eccentricities were found for this frequency.");
00128 GPSTK_THROW(e);
00129 }
00130
00131 }
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 Triple Antenna::getAntennaPCVariation( frequencyType freq,
00147 double elevation ) const
00148 throw(InvalidRequest)
00149 {
00150
00151
00152 double angle( 90.0 - elevation );
00153
00154
00155 if( ( angle < zen1 ) ||
00156 ( angle > zen2 ) )
00157 {
00158 InvalidRequest e("Elevation is out of allowed range.");
00159 GPSTK_THROW(e);
00160 }
00161
00162
00163
00164 NoAziDataMap::const_iterator it( noAziMap.find(freq) );
00165 if( it != noAziMap.end() )
00166 {
00167
00168 double normalizedAngle( (angle-zen1)/dzen );
00169
00170
00171 Triple result( linearInterpol( (*it).second, normalizedAngle ),
00172 0.0,
00173 0.0 );
00174
00175 return result;
00176 }
00177 else
00178 {
00179 InvalidRequest e("No data was found for this frequency.");
00180 GPSTK_THROW(e);
00181 }
00182
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 Triple Antenna::getAntennaPCVariation( frequencyType freq,
00199 double elevation,
00200 double azimuth ) const
00201 throw(InvalidRequest)
00202 {
00203
00204
00205 double angle( 90.0 - elevation );
00206
00207
00208 if( ( angle < zen1 ) ||
00209 ( angle > zen2 ) )
00210 {
00211 InvalidRequest e("Elevation is out of allowed range.");
00212 GPSTK_THROW(e);
00213 }
00214
00215
00216 while( azimuth < 0.0 )
00217 {
00218 azimuth += 360.0;
00219 }
00220 while( azimuth >= 360.0 )
00221 {
00222 azimuth -= 360.0;
00223 }
00224
00225
00226
00227 PCDataMap::const_iterator it( pcMap.find(freq) );
00228 if( it != pcMap.end() )
00229 {
00230
00231
00232 const double lowerAzimuth( std::floor(azimuth/dazi) * dazi );
00233 const double upperAzimuth( lowerAzimuth + dazi );
00234
00235
00236 AzimuthDataMap::const_iterator it2( (*it).second.find(lowerAzimuth) );
00237 AzimuthDataMap::const_iterator it3( (*it).second.find(upperAzimuth) );
00238
00239
00240 const double fractionalAzimuth( ( azimuth - lowerAzimuth ) /
00241 ( upperAzimuth - lowerAzimuth ) );
00242
00243
00244 if( fractionalAzimuth == 0.0 )
00245 {
00246
00247 if( it2 != (*it).second.end() )
00248 {
00249
00250 const double normalizedAngle( (angle-zen1)/dzen );
00251
00252
00253 Triple result( linearInterpol( (*it2).second, normalizedAngle ),
00254 0.0,
00255 0.0 );
00256
00257 return result;
00258
00259 }
00260 else
00261 {
00262 InvalidRequest e("No data was found for this azimuth.");
00263 GPSTK_THROW(e);
00264 }
00265 }
00266 else
00267 {
00268
00269
00270 if( it2 != (*it).second.end() &&
00271 it3 != (*it).second.end() )
00272 {
00273
00274 const double normalizedAngle( (angle-zen1)/dzen );
00275
00276
00277 double val1( linearInterpol( (*it2).second, normalizedAngle ) );
00278 double val2( linearInterpol( (*it3).second, normalizedAngle ) );
00279
00280
00281 Triple result( ( val1 + (val2-val1) * fractionalAzimuth ),
00282 0.0,
00283 0.0 );
00284
00285 return result;
00286
00287 }
00288 else
00289 {
00290 InvalidRequest e("Not enough data was found for this azimuth.");
00291 GPSTK_THROW(e);
00292 }
00293 }
00294
00295 }
00296 else
00297 {
00298
00299 InvalidRequest e("No data was found for this frequency.");
00300 GPSTK_THROW(e);
00301
00302 }
00303
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 Antenna Antenna::addAntennaEcc( frequencyType freq,
00316 double northEcc,
00317 double eastEcc,
00318 double upEcc )
00319 {
00320
00321
00322 Triple ecc(northEcc, eastEcc, upEcc);
00323
00324
00325 antennaEccMap[freq] = ecc;
00326
00327
00328 return (*this);
00329
00330 }
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 Antenna Antenna::addAntennaRMSEcc( frequencyType freq,
00342 double northRMS,
00343 double eastRMS,
00344 double upRMS )
00345 {
00346
00347
00348 Triple ecc(northRMS, eastRMS, upRMS);
00349
00350
00351 antennaRMSEccMap[freq] = ecc;
00352
00353
00354 return (*this);
00355
00356 }
00357
00358
00359
00360
00361
00362 bool Antenna::isValid() const
00363 {
00364
00365 if( getAntennaDataSize() > 0 &&
00366 getAntennaEccMapSize() > 0 )
00367 {
00368 return true;
00369 }
00370 else
00371 {
00372 return false;
00373 }
00374
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387 double Antenna::linearInterpol( const std::vector<double>& dataVector,
00388 double normalizedAngle ) const
00389 {
00390
00391
00392 int index( static_cast<int>( std::floor(normalizedAngle) ) );
00393
00394
00395 double fraction( normalizedAngle - std::floor(normalizedAngle) );
00396
00397
00398 if( fraction == 0.0 )
00399 {
00400
00401 return dataVector[index];
00402 }
00403 else
00404 {
00405
00406 double val1( dataVector[index] );
00407 double val2( dataVector[index+1] );
00408
00409
00410 return ( val1 + (val2-val1) * fraction );
00411 }
00412
00413 }
00414
00415
00416
00417 }