OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimEnvisatAsarModel.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 //
5 // License: LGPL
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 #include <cmath>
13 #include <cstdio>
14 
15 #include <ossim/base/ossimTrace.h>
17 
18 #include <ossimEnvisatAsarModel.h>
19 #include <otb/GalileanEphemeris.h>
21 
22 #include <otb/GMSTDateTime.h>
23 #include <otb/CivilDateTime.h>
24 #include <otb/MJDDateTime.h>
25 
26 #include <otb/PlatformPosition.h>
27 #include <otb/SensorParams.h>
28 #include <otb/RefPoint.h>
29 #include <otb/SarSensor.h>
30 
31 namespace ossimplugins
32 {
33 
34 
35  RTTI_DEF1(ossimEnvisatAsarModel, "ossimEnvisatAsarModel", ossimGeometricSarSensorModel);
36 
37 // Static trace for debugging
38  static ossimTrace traceDebug("ossimEnvisatAsarModel:debug");
39 
41  _n_srgr(0),
42  _pixel_spacing(0),
43  _EnvisatAsarData(NULL)
44  {
45  }
46 
47 
48 
50  {
51  if(_EnvisatAsarData != NULL)
52  {
53  delete _EnvisatAsarData;
54  }
55  }
56 
58  {
59  return ossimString("ossimEnvisatAsarModel");
60  }
61 
63  {
64  return new ossimEnvisatAsarModel(*this);
65  }
66 
68  {
69  // const double CLUM = 2.99792458e+8 ;
70 
71  double GR, GR0, relativeGroundRange, slantRange; // , slantrangetime;
72 
73  if (_n_srgr==0) return(-1) ;
74 
75  std::vector<double> coefset = FindSRGRSetNumber((_refPoint->get_ephemeris())->get_date()) ;
76 
77  GR = _sensor->get_col_direction() * (col)* _pixel_spacing ;
78  GR0 = coefset[0];
79  relativeGroundRange = GR-GR0;
80  slantRange = coefset[1]
81  + coefset[2]*relativeGroundRange
82  + coefset[3]*pow(relativeGroundRange,2)
83  + coefset[4]*pow(relativeGroundRange,3)
84  + coefset[5]*pow(relativeGroundRange,4);
85 
86  // slantrangetime = 2.0*slantRange / (CLUM);
87  return slantRange ;
88  }
89 
90 
92  {
93  bool retValue = true;
94 
95  if (traceDebug())
96  {
97  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimEnvisatAsarTileSource::open(filename) DEBUG: entered..." << std::endl
98  << "Attempting to open file " << file << std::endl;
99  }
100 
101  /*
102  * Creation of the class allowing to store EnvisatAsarData file metadata
103  */
104  if (_EnvisatAsarData != NULL)
105  {
106  delete _EnvisatAsarData;
107  _EnvisatAsarData = NULL;
108  }
109 
110  /*
111  * Opening and test of the file
112  */
113  ossimFilename Filename = file;
114  ifstream dataFile(Filename.c_str(), ios::in | ios::binary);
115  if (dataFile.eof())
116  {
117  dataFile.close();
118  retValue = false;
119  }
120  else
121  {
122  mph mph_rec;
123  dataFile >> mph_rec;
124 
125  // test if it is an ENVISAT Data file
126  if (mph_rec.is_valid())
127  {
128  if (traceDebug())
129  {
130  ossimNotify(ossimNotifyLevel_DEBUG) << "Begin reading EnvisatAsar file" << std::endl;
131  }
132  /*
133  * Reading EnvisatAsarData file data
134  */
135  dataFile.seekg(0);
137  dataFile >> *_EnvisatAsarData;
138  dataFile.close();
139  if (traceDebug())
140  {
141  ossimNotify(ossimNotifyLevel_DEBUG) << "End reading EnvisatAsar file" << std::endl;
142  }
143  }
144  else
145  {
146  dataFile.close();
147  retValue = false;
148  }
149  }
150 
151  if (traceDebug())
152  {
153  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimEnvisatAsarTileSource::open() DEBUG: returning..." << std::endl;
154  }
155 
156  return retValue;
157  }
158 
159 
161  const char* prefix) const
162  {
163  char name[64];
164 
165  kwl.add(prefix, ossimKeywordNames::TYPE_KW, "ossimEnvisatAsarModel", true);
166 
167  /*
168  * Adding metadata necessary to the sensor model into the keywordlist
169  * Data derived from the SPH record
170  */
171  sph* sph_rec = _EnvisatAsarData->get_sph();
172  if(sph_rec != NULL)
173  {
174  kwl.add(prefix, "pixel_spacing", sph_rec->get_range_spacing().c_str(), true );
175  kwl.add(prefix, "line_time_interval", sph_rec->get_line_time_interval().c_str(), true );
176  }
177  else
178  {
179  return false;
180  }
181  /*
182  * Adding metadata necessary to the sensor model into the keywordlist
183  * Data derived from the Main Processing Parameters record
184  */
186  if(MPP_rec != NULL)
187  {
188  kwl.add(prefix, "num_pix", (double)MPP_rec->get_num_samples_per_line(), true );
189  kwl.add(prefix, "num_lines", (double)MPP_rec->get_num_output_lines(), true );
190  kwl.add(prefix, "wave_length", MPP_rec->get_radar_freq(), true );
191  kwl.add(prefix, "range_sampling_rate", MPP_rec->get_range_samp_rate(), true );
192  kwl.add(prefix, "prf", MPP_rec->get_prf(), true );
193  kwl.add(prefix, "avg_scene_height", MPP_rec->get_avg_scene_height_ellpsoid(), true );
194  kwl.add(prefix, "is_groundrange", MPP_rec->get_srgr_flag(), true );
195  kwl.add(prefix, "state_vector_time_1_day", (double)MPP_rec->get_state_vector_time_1_day(), true );
196  kwl.add(prefix, "state_vector_time_1_sec", (double)MPP_rec->get_state_vector_time_1_sec(), true );
197  kwl.add(prefix, "state_vector_time_1_microsec", (double)MPP_rec->get_state_vector_time_1_microsec(), true );
198  kwl.add(prefix, "x_pos_1", (double)MPP_rec->get_x_pos_1(), true );
199  kwl.add(prefix, "y_pos_1", (double)MPP_rec->get_y_pos_1(), true );
200  kwl.add(prefix, "z_pos_1", (double)MPP_rec->get_z_pos_1(), true );
201  kwl.add(prefix, "x_vel_1", (double)MPP_rec->get_x_vel_1(), true );
202  kwl.add(prefix, "y_vel_1", (double)MPP_rec->get_y_vel_1(), true );
203  kwl.add(prefix, "z_vel_1", (double)MPP_rec->get_z_vel_1(), true );
204  kwl.add(prefix, "state_vector_time_2_day",(double) MPP_rec->get_state_vector_time_2_day(), true );
205  kwl.add(prefix, "state_vector_time_2_sec", (double)MPP_rec->get_state_vector_time_2_sec(), true );
206  kwl.add(prefix, "state_vector_time_2_microsec", (double)MPP_rec->get_state_vector_time_2_microsec(), true );
207  kwl.add(prefix, "x_pos_2", (double)MPP_rec->get_x_pos_2(), true );
208  kwl.add(prefix, "y_pos_2", (double)MPP_rec->get_y_pos_2(), true );
209  kwl.add(prefix, "z_pos_2", (double)MPP_rec->get_z_pos_2(), true );
210  kwl.add(prefix, "x_vel_2", (double)MPP_rec->get_x_vel_2(), true );
211  kwl.add(prefix, "y_vel_2", (double)MPP_rec->get_y_vel_2(), true );
212  kwl.add(prefix, "z_vel_2", (double)MPP_rec->get_z_vel_2(), true );
213  kwl.add(prefix, "state_vector_time_3_day", (double)MPP_rec->get_state_vector_time_3_day(), true );
214  kwl.add(prefix, "state_vector_time_3_sec", (double)MPP_rec->get_state_vector_time_3_sec(), true );
215  kwl.add(prefix, "state_vector_time_3_microsec", (double)MPP_rec->get_state_vector_time_3_microsec(), true );
216  kwl.add(prefix, "x_pos_3", (double)MPP_rec->get_x_pos_3(), true );
217  kwl.add(prefix, "y_pos_3", (double)MPP_rec->get_y_pos_3(), true );
218  kwl.add(prefix, "z_pos_3", (double)MPP_rec->get_z_pos_3(), true );
219  kwl.add(prefix, "x_vel_3", (double)MPP_rec->get_x_vel_3(), true );
220  kwl.add(prefix, "y_vel_3", (double)MPP_rec->get_y_vel_3(), true );
221  kwl.add(prefix, "z_vel_3", (double)MPP_rec->get_z_vel_3(), true );
222  kwl.add(prefix, "state_vector_time_4_day", (double)MPP_rec->get_state_vector_time_4_day(), true );
223  kwl.add(prefix, "state_vector_time_4_sec", (double)MPP_rec->get_state_vector_time_4_sec(), true );
224  kwl.add(prefix, "state_vector_time_4_microsec", (double)MPP_rec->get_state_vector_time_4_microsec(), true );
225  kwl.add(prefix, "x_pos_4", (double)MPP_rec->get_x_pos_4(), true );
226  kwl.add(prefix, "y_pos_4", (double)MPP_rec->get_y_pos_4(), true );
227  kwl.add(prefix, "z_pos_4", (double)MPP_rec->get_z_pos_4(), true );
228  kwl.add(prefix, "x_vel_4", (double)MPP_rec->get_x_vel_4(), true );
229  kwl.add(prefix, "y_vel_4", (double)MPP_rec->get_y_vel_4(), true );
230  kwl.add(prefix, "z_vel_4", (double)MPP_rec->get_z_vel_4(), true );
231  kwl.add(prefix, "state_vector_time_5_day", (double)MPP_rec->get_state_vector_time_5_day(), true );
232  kwl.add(prefix, "state_vector_time_5_sec", (double)MPP_rec->get_state_vector_time_5_sec(), true );
233  kwl.add(prefix, "state_vector_time_5_microsec", (double)MPP_rec->get_state_vector_time_5_microsec(), true );
234  kwl.add(prefix, "x_pos_5", (double)MPP_rec->get_x_pos_5(), true );
235  kwl.add(prefix, "y_pos_5",(double) MPP_rec->get_y_pos_5(), true );
236  kwl.add(prefix, "z_pos_5", (double)MPP_rec->get_z_pos_5(), true );
237  kwl.add(prefix, "x_vel_5", (double)MPP_rec->get_x_vel_5(), true );
238  kwl.add(prefix, "y_vel_5", (double)MPP_rec->get_y_vel_5(), true );
239  kwl.add(prefix, "z_vel_5", (double)MPP_rec->get_z_vel_5(), true );
240  }
241  else
242  {
243  return false;
244  }
245  /*
246  * Adding metadata necessary to the sensor model into the keywordlist
247  * Data derived from the Geolocation Grid record - Reference Point
248  */
250  if(GG_rec != NULL)
251  {
252  kwl.add(prefix, "first_zero_doppler_time_day", (double)GG_rec->get_first_zero_doppler_time_day(), true );
253  kwl.add(prefix, "first_zero_doppler_time_sec", (double)GG_rec->get_first_zero_doppler_time_sec(), true );
254  kwl.add(prefix, "first_zero_doppler_time_microsec", (double)GG_rec->get_first_zero_doppler_time_microsec(), true );
255  kwl.add(prefix, "line_num", (double)GG_rec->get_line_num(), true );
256  kwl.add(prefix, "samp_num", (double)(GG_rec->get_samp_numbers())[0], true );
257  kwl.add(prefix, "slant_range_time", (double)(GG_rec->get_slant_range_times())[0], true );
258  }
259  else
260  {
261  return false;
262  }
263  /*
264  * Adding metadata necessary to the sensor model into the keywordlist
265  * Data derived from the Geolocation Grid record - Corners
266  */
268  if(GG_rec != NULL)
269  {
270  kwl.add(prefix, "UL_line", (double)GG_rec->get_line_num(), true );
271  kwl.add(prefix, "UL_col", (double)(GG_rec->get_samp_numbers())[0], true );
272  kwl.add(prefix, "UL_lat", (double)(GG_rec->get_lats())[0], true );
273  kwl.add(prefix, "UL_lon", (double)(GG_rec->get_longs())[0], true );
274  kwl.add(prefix, "UR_line", (double)GG_rec->get_line_num(), true );
275  kwl.add(prefix, "UR_col", (double)(GG_rec->get_samp_numbers())[10], true );
276  kwl.add(prefix, "UR_lat", (double)(GG_rec->get_lats())[10], true );
277  kwl.add(prefix, "UR_lon", (double)(GG_rec->get_longs())[10], true );
278  }
279  else
280  {
281  return false;
282  }
284  if(GG_rec != NULL)
285  {
286  kwl.add(prefix, "LL_line", (double)GG_rec->get_line_num(), true );
287  kwl.add(prefix, "LL_col", (double)(GG_rec->get_samp_numbers())[0], true );
288  kwl.add(prefix, "LL_lat", (double)(GG_rec->get_lats())[0], true );
289  kwl.add(prefix, "LL_lon", (double)(GG_rec->get_longs())[0], true );
290  kwl.add(prefix, "LR_line", (double)GG_rec->get_line_num(), true );
291  kwl.add(prefix, "LR_col", (double)(GG_rec->get_samp_numbers())[10], true );
292  kwl.add(prefix, "LR_lat", (double)(GG_rec->get_lats())[10], true );
293  kwl.add(prefix, "LR_lon", (double)(GG_rec->get_longs())[10], true );
294  }
295  else
296  {
297  return false;
298  }
299 
300  /*
301  * Adding metadata necessary to the sensor model into the keywordlist
302  */
303  int n_srgr = 0;
305  if(SRGRParameters != NULL)
306  {
307  n_srgr = _EnvisatAsarData->get_num_ds(SRGRParameters);
308 
309  for (int i=0;i<n_srgr;i++)
310  {
312 
313  sprintf(name,"srgr_update_day%i",i);
314  kwl.add(prefix, name, (double)SRGR->get_first_zero_doppler_time_day(),true);
315 
316  sprintf(name,"srgr_update_sec%i",i);
317  kwl.add(prefix, name, (double)SRGR->get_first_zero_doppler_time_sec(),true);
318 
319  sprintf(name,"srgr_update_microsec%i",i);
320  kwl.add(prefix, name, (double)SRGR->get_first_zero_doppler_time_microsec(),true);
321 
322  sprintf(name,"srgr_coef%iA",i);
323  kwl.add(prefix, name,(double)SRGR->get_ground_range_origin(),true);
324 
325  sprintf(name,"srgr_coef%iB",i);
326  kwl.add(prefix, name,(double)SRGR->get_srgr_coef()[0],true);
327  sprintf(name,"srgr_coef%iC",i);
328  kwl.add(prefix, name,(double)SRGR->get_srgr_coef()[1],true);
329  sprintf(name,"srgr_coef%iD",i);
330  kwl.add(prefix, name,(double)SRGR->get_srgr_coef()[2],true);
331  sprintf(name,"srgr_coef%iE",i);
332  kwl.add(prefix, name,(double)SRGR->get_srgr_coef()[3]*1e10,true);
333  sprintf(name,"srgr_coef%iF",i);
334  kwl.add(prefix, name,(double)SRGR->get_srgr_coef()[4]*1e10,true);
335  }
336  }
337 
338  kwl.add(prefix, "n_srgr" , n_srgr,true);
339 
340  return true;
341  }
342 
344  const char *prefix)
345  {
346  InitSensorParams(kwl, prefix);
347  InitPlatformPosition(kwl, prefix);
348  InitRefPoint(kwl, prefix);
349  InitSRGR(kwl, prefix);
350  return true;
351  }
352 
354  {
355  // Capture the original flags.
356  std::ios_base::fmtflags f = out.flags();
357 
358  out << setprecision(15) << setiosflags(ios::fixed)
359  << "\nossimEnvisatAsarModel data members:\n"
360  << "_pixel_spacing: " << _pixel_spacing << "\n"
361  << "_n_srgr: " << _n_srgr << "\n";
362 
364 
365  // Reset flags.
366  out.setf(f);
367 
368 
369  return out;
370  }
371 
372  bool ossimEnvisatAsarModel::InitSensorParams(const ossimKeywordlist &kwl, const char *prefix)
373  {
374  const double CLUM = 2.99792458e+8;
375  const char* wave_length_str = kwl.find(prefix,"wave_length");
376  double wave_length = CLUM / atof(wave_length_str);
377  const char* fr_str = kwl.find(prefix,"range_sampling_rate");
378  double fr = atof(fr_str);
379 
380  // product type : Slant Range or Ground Range
381  _isProductGeoreferenced = atoi(kwl.find(prefix,"is_groundrange"));
382  double fa;
384  {
385  const char* fa_str = kwl.find(prefix,"prf");
386  fa = atof(fa_str);
387  }
388  else
389  {
390  const char* fa_str = kwl.find(prefix,"line_time_interval");
391  fa = 1.0/atof(fa_str);
392  }
393 
394  // TODO : v�rifier que ceci est ok pour les produits IMP
395  const char* time_dir_pix = "INCREASE";
396  const char* time_dir_lin = "INCREASE";
397 
398  if(_sensor != NULL)
399  {
400  delete _sensor;
401  }
402 
403  _sensor = new SensorParams();
404 
405  if(strcmp(time_dir_pix, "INCREASE") == 0)
406  {
408  }
409  else
410  {
412  }
413 
414  if(strcmp(time_dir_lin, "INCREASE") == 0)
415  {
417  }
418  else
419  {
421  }
422 
423  _sensor->set_prf(fa);
424  _sensor->set_sf(fr);
425  _sensor->set_rwl(wave_length);
426 
427  return true;
428  }
429 
431  {
432  const int neph = 5;
433  // long val_long;
434  // unsigned long val_ulong1;
435  // unsigned long val_ulong2;
436  CivilDateTime ref_civil_date;
437 
438  Ephemeris** ephemeris = new Ephemeris*[neph];
439 
440  for (int i=1;i<=neph;i++)
441  {
442  double pos[3];
443  double vel[3];
444  char name[64];
445 
446  /*
447  * Date de l'ephemeride
448  */
449  sprintf(name,"state_vector_time_%i_day",i);
450  long day = (long) atof(kwl.find(prefix,name));
451  sprintf(name,"state_vector_time_%i_sec",i);
452  unsigned long sec = (unsigned long) atof(kwl.find(prefix,name));
453  sprintf(name,"state_vector_time_%i_microsec",i);
454  unsigned long microsec = (unsigned long) atof(kwl.find(prefix,name));
455  MJDDateTime mjdDate(day, sec, microsec);
456  JSDDateTime jsd_date(mjdDate);
457  /*
458  * Position de l'ephemeride
459  */
460  sprintf(name,"x_pos_%i",i);
461  pos[0] = (double) atoi(kwl.find(prefix,name)) * 1.0e-2;
462  sprintf(name,"y_pos_%i",i);
463  pos[1] = (double) atoi(kwl.find(prefix,name)) * 1.0e-2;
464  sprintf(name,"z_pos_%i",i);
465  pos[2] = (double) atoi(kwl.find(prefix,name)) * 1.0e-2;
466  /*
467  * Vitesse de l'ephemeride
468  */
469  sprintf(name,"x_vel_%i",i);
470  vel[0] = (double) atoi(kwl.find(prefix,name)) * 1.0e-5;
471  sprintf(name,"y_vel_%i",i);
472  vel[1] = (double) atoi(kwl.find(prefix,name)) * 1.0e-5;
473  sprintf(name,"z_vel_%i",i);
474  vel[2] = (double) atoi(kwl.find(prefix,name)) * 1.0e-5;
475 
476  GeographicEphemeris* eph = new GeographicEphemeris(jsd_date, pos, vel);
477 
478  ephemeris[i-1] = eph;
479  }
480 
481  if (_platformPosition != NULL)
482  {
483  delete _platformPosition;
484  }
485  _platformPosition = new PlatformPosition(ephemeris,neph);
486 
487  /*
488  * Liberation de la memoire utilis�e par la liste des ephemerides
489  * ->Le constructeur effectue une copie des ephemerides
490  */
491  for (int i=0;i<neph;i++)
492  {
493  delete ephemeris[i];
494  }
495  delete[] ephemeris;
496 
497  return true;
498  }
499 
500 
501 
502  bool ossimEnvisatAsarModel::InitRefPoint(const ossimKeywordlist &kwl, const char *prefix)
503  {
504 
505  // Reference image position
506  if(_refPoint == NULL)
507  {
508  _refPoint = new RefPoint();
509  }
510  double sc_pix = atof(kwl.find(prefix,"samp_num")) - 1.0;
511  _refPoint->set_pix_col(sc_pix);
512  double sc_lin = atof(kwl.find(prefix,"line_num")) - 1.0;
513  _refPoint->set_pix_line(sc_lin);
514 
515  // Reference Point distance
516  double c = 2.99792458e+8;
517  double distance = atof(kwl.find(prefix,"slant_range_time")) * (c/2.0) * 1.0e-9;
519 
520 
521  // Reference Point Ephemeris
522  long day_ref = (long)atof(kwl.find(prefix,"first_zero_doppler_time_day"));
523  unsigned long sec_ref = (unsigned long)atof(kwl.find(prefix,"first_zero_doppler_time_sec"));
524  unsigned long microsec_ref = (unsigned long)atof(kwl.find(prefix,"first_zero_doppler_time_microsec"));
525 
526  MJDDateTime mjdDate_ref(day_ref, sec_ref, microsec_ref);
527  JSDDateTime jsd_date_ref(mjdDate_ref);
528 
529  if(_platformPosition != NULL)
530  {
531  Ephemeris * ephemeris = _platformPosition->Interpolate(jsd_date_ref);
532  if (ephemeris == NULL) return false ;
533  _refPoint->set_ephemeris(ephemeris);
534  delete ephemeris;
535  }
536  else return false;
537 
538  // Adjustement of the model using the four corner points
539  // in order to use ossimSensorModel::lineSampleToWorld
540  const char* nbCol_str = kwl.find(prefix,"num_pix");
541  const char* nbLin_str = kwl.find(prefix,"num_lines");
542  theImageSize.x = atoi(nbCol_str);
543  theImageSize.y = atoi(nbLin_str);
545 
546  // Ground Control Points extracted from the model : corner points
547  std::list<ossimGpt> groundGcpCoordinates ;
548  std::list<ossimDpt> imageGcpCoordinates ;
549  double h = atof(kwl.find("avg_scene_height"));
550 
551  // first line first pix
552  double line = atof(kwl.find("UL_line")) - 1;
553  double col = atof(kwl.find("UL_col")) - 1;
554  double lon = atof(kwl.find("UL_lon")) * 1e-6;
555  double lat = atof(kwl.find("UL_lat")) * 1e-6;
556  if (lon > 180.0) lon -= 360.0;
557  ossimDpt imageGCP1(col,line);
558  ossimGpt groundGCP1(lat, lon, h);
559  groundGcpCoordinates.push_back(groundGCP1) ;
560  imageGcpCoordinates.push_back(imageGCP1) ;
561  // first line last pix
562  line = atof(kwl.find("UR_line")) - 1;
563  col = atof(kwl.find("UR_col")) - 1;
564  lon = atof(kwl.find("UR_lon")) * 1e-6;
565  lat = atof(kwl.find("UR_lat")) * 1e-6;
566  if (lon > 180.0) lon -= 360.0;
567  ossimDpt imageGCP2(col,line);
568  ossimGpt groundGCP2(lat, lon, h);
569  groundGcpCoordinates.push_back(groundGCP2) ;
570  imageGcpCoordinates.push_back(imageGCP2) ;
571  // last line last pix
572  line = atof(kwl.find("LR_line")) - 1;
573  col = atof(kwl.find("LR_col")) - 1;
574  lon = atof(kwl.find("LR_lon")) * 1e-6;
575  lat = atof(kwl.find("LR_lat")) * 1e-6;
576  if (lon > 180.0) lon -= 360.0;
577  ossimDpt imageGCP3(col,line);
578  ossimGpt groundGCP3(lat, lon, h);
579  groundGcpCoordinates.push_back(groundGCP3) ;
580  imageGcpCoordinates.push_back(imageGCP3) ;
581  // last line first pix
582  line = atof(kwl.find("LL_line")) - 1;
583  col = atof(kwl.find("LL_col")) - 1;
584  lon = atof(kwl.find("LL_lon")) * 1e-6;
585  lat = atof(kwl.find("LL_lat")) * 1e-6;
586  if (lon > 180.0) lon -= 360.0;
587  ossimDpt imageGCP4(col,line);
588  ossimGpt groundGCP4(lat, lon, h);
589  groundGcpCoordinates.push_back(groundGCP4) ;
590  imageGcpCoordinates.push_back(imageGCP4) ;
591 
592  // Default optimization
593  optimizeModel(groundGcpCoordinates, imageGcpCoordinates) ;
594 
595  return true;
596  }
597  bool ossimEnvisatAsarModel::InitSRGR(const ossimKeywordlist &kwl, const char *prefix)
598  {
599  // product type : Slant Range or Ground Range
600  _isProductGeoreferenced = atoi(kwl.find(prefix,"is_groundrange"));
601 
602  // pixel spacing
603  _pixel_spacing = atof(kwl.find(prefix,"pixel_spacing"));
604 
605  // number of SRGR sets
606  _n_srgr = atoi(kwl.find(prefix,"n_srgr"));
607 
608 
609  char name[64];
610  for (int i=0;i<_n_srgr;i++)
611  {
612  // SRGR update time
613  sprintf(name,"srgr_update_day%i",i);
614  long day_ref = (long)atof(kwl.find(prefix,name));
615  sprintf(name,"srgr_update_sec%i",i);
616  unsigned long sec_ref = (unsigned long)atof(kwl.find(prefix,name));
617  sprintf(name,"srgr_update_microsec%i",i);
618  unsigned long microsec_ref = (unsigned long)atof(kwl.find(prefix,name));
619  MJDDateTime mjdDate_ref(day_ref, sec_ref, microsec_ref);
620  JSDDateTime jsd_date_ref(mjdDate_ref);
621  _srgr_update.push_back(jsd_date_ref);
622 
623  std::vector<double> srgr_set;
624  // SRGR coefficients
625  sprintf(name,"srgr_coef%iA",i);
626  const char* srgr_coef_strA = kwl.find(prefix,name);
627  srgr_set.push_back(atof(srgr_coef_strA));
628  sprintf(name,"srgr_coef%iB",i);
629  const char* srgr_coef_strB = kwl.find(prefix,name);
630  srgr_set.push_back(atof(srgr_coef_strB));
631  sprintf(name,"srgr_coef%iC",i);
632  const char* srgr_coef_strC = kwl.find(prefix,name);
633  srgr_set.push_back(atof(srgr_coef_strC));
634  sprintf(name,"srgr_coef%iD",i);
635  const char* srgr_coef_strD = kwl.find(prefix,name);
636  srgr_set.push_back(atof(srgr_coef_strD));
637  sprintf(name,"srgr_coef%iE",i);
638  const char* srgr_coef_strE = kwl.find(prefix,name);
639  srgr_set.push_back(atof(srgr_coef_strE)*1e-10);
640  sprintf(name,"srgr_coef%iF",i);
641  const char* srgr_coef_strF = kwl.find(prefix,name);
642  srgr_set.push_back(atof(srgr_coef_strF)*1e-10);
643 
644  _srgr_coefset.push_back(srgr_set);
645  }
646 
647 
648  return true;
649  }
650 
651 
653  {
654  //if (_n_srgr==0) return NULL ;
655 
656  std::vector<double> delays;
657  double delay;
658  for (int i=0;i<_n_srgr;i++)
659  {
660  JSDDateTime datetmp(_srgr_update.at(i));
661  delay = date.get_second()+date.get_decimal() - (datetmp.get_second() + datetmp.get_decimal());
662  delays.push_back( fabs(delay) );
663  }
664 
665  int setNumber = 0 ;
666  double min_delay = delays[0] ;
667  for (int i=1;i<_n_srgr;i++)
668  {
669  if (delays[i]<min_delay) {
670  setNumber = i ;
671  min_delay = delays[i] ;
672  }
673  }
674 
675  return _srgr_coefset[setNumber];
676  }
677 }
This class represent an ephemeris in Geographic coordinates system.
unsigned int get_num_samples_per_line()
num_samples_per_line
This class is able to read the SAR sph record of the ASAR file.
Definition: sph.h:27
float get_ground_range_origin()
input_std_dev_flag
virtual ossimString getClassName() const
Method to return the class name.
unsigned int get_state_vector_time_3_sec()
state_vector_time_3 sec
This class represents a date and time in the civil format.
Definition: CivilDateTime.h:30
MainProcessingParameters * get_MainProcessingParameters()
void set_rwl(double rwl)
Definition: SensorParams.h:83
virtual bool InitSRGR(const ossimKeywordlist &kwl, const char *prefix)
Initializes the Slant Range for each Ground Range data sets : _n_srgr,_srgr_coefset,_srgr_update,_pixel_spacing,_isProductGeoreferenced.
int get_state_vector_time_3_day()
state_vector_time_3 day
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save object state to a keyword list.
This class handles the platform position.
RTTI_DEF1(ossimAlosPalsarModel, "ossimAlosPalsarModel", ossimGeometricSarSensorModel)
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
Ephemeris * get_ephemeris()
Definition: RefPoint.cpp:90
unsigned int get_state_vector_time_4_microsec()
state_vector_time_4 microsec
const char * find(const char *key) const
unsigned int get_state_vector_time_4_sec()
state_vector_time_1 sec
int get_first_zero_doppler_time_day()
first_zero_doppler_time day
unsigned int get_first_zero_doppler_time_microsec()
first_zero_doppler_time micro sec
This class handles the referential point.
Definition: RefPoint.h:29
void set_lin_direction(int dir)
Definition: SensorParams.h:128
int get_state_vector_time_5_day()
state_vector_time_5 day
GeolocationGrid * get_GeolocationGrid(int num_ds=0)
unsigned int get_num_output_lines()
num_output_lines
This class represents an MJD date (Modified Julian date)
Definition: MJDDateTime.h:25
virtual std::ostream & print(std::ostream &out) const
unsigned int * get_samp_numbers()
samp_numbvers
std::vector< double > FindSRGRSetNumber(JSDDateTime date) const
Finds the SRGR data set which update time is the closest to the center scene time.
unsigned int get_state_vector_time_2_sec()
state_vector_time_2 sec
This class handles the sensor parameters.
Definition: SensorParams.h:29
virtual double getSlantRangeFromGeoreferenced(double col) const
This function associates an image column number to a slant range when the image is georeferenced (gro...
float * get_slant_range_times()
slant_range_times
Ephemeris * Interpolate(JSDDateTime date) const
This function interpolates its ephemeris to create a new ephemeris at the given date and time...
void set_pix_line(double pix_line)
Definition: RefPoint.cpp:80
static const char * TYPE_KW
void set_pix_col(double pix_col)
Definition: RefPoint.cpp:85
bool _isProductGeoreferenced
True iff the product is ground range.
unsigned int get_state_vector_time_2_microsec()
state_vector_time_1 microsec
int _n_srgr
Slant Range to Ground Range (SRGR) number of coefficients sets.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int get_state_vector_time_1_sec()
state_vector_time_1 sec
This class represents an ephemeris.
Definition: Ephemeris.h:28
std::string get_line_time_interval()
line_time_interval
Definition: sph.h:610
int get_state_vector_time_1_day()
state_vector_time_1 day
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of the object from a keyword list.
bool open(const ossimFilename &file)
Method to intantial model from a file.
This class is able to read the ASAR MainProcessingParameters record.
This class is able to read the Envisat file structure.
double get_second() const
Definition: JSDDateTime.h:76
unsigned int get_state_vector_time_5_sec()
state_vector_time_5 sec
float get_avg_scene_height_ellpsoid()
avg_scene_height_ellpsoid
std::string get_range_spacing()
range_spacing
Definition: sph.h:568
TYPE_DATA EnvisatAsarData * _EnvisatAsarData
List of metadata contained in the Data file.
std::vector< std::vector< double > > _srgr_coefset
SRGR coefficient sets.
unsigned int get_first_zero_doppler_time_microsec()
first_zero_doppler_time micro sec
int get_state_vector_time_2_day()
state_vector_time_2 day
This class is able to read the ASAR mph record of the leader file.
Definition: mph.h:25
virtual bool InitRefPoint(const ossimKeywordlist &kwl, const char *prefix)
Initializes the Reference Point from a projection keywordlist.
int get_state_vector_time_4_day()
state_vector_time_4 day
unsigned int get_state_vector_time_1_microsec()
state_vector_time_1 microsec
unsigned int get_first_zero_doppler_time_sec()
first_zero_doppler_time second
unsigned int get_state_vector_time_5_microsec()
state_vector_time_5 microsec
unsigned int get_state_vector_time_3_microsec()
state_vector_time_3 microsec
unsigned int get_line_num()
line_num
virtual std::ostream & print(std::ostream &out) const
ossimDrect theImageClipRect
PlatformPosition * _platformPosition
Handle the position of the platform.
This class is able to read the ASAR SRGRConversionParameters record.
virtual bool InitSensorParams(const ossimKeywordlist &kwl, const char *prefix)
Initializes the Sensor Params from a projection keywordlist.
ossim_int32 y
Definition: ossimIpt.h:142
double get_decimal() const
Definition: JSDDateTime.h:81
SRGRConversionParameters * get_SRGRConversionParameters(int pos=0)
std::vector< JSDDateTime > _srgr_update
SRGR coefficient sets update times.
virtual bool InitPlatformPosition(const ossimKeywordlist &kwl, const char *prefix)
Initializes the Platform Position from a projection keywordlist.
virtual ossimObject * dup() const
Returns pointer to a new instance, copy of this.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
int get_first_zero_doppler_time_day()
first_zero_doppler_time day
ossim_int32 x
Definition: ossimIpt.h:141
virtual bool optimizeModel(const std::list< ossimGpt > &groundCoordinates, const std::list< ossimDpt > &imageCoordinates)
This function optimizes the model according to a list of Ground Control Points.
void set_prf(double prf)
Definition: SensorParams.h:73
void set_ephemeris(Ephemeris *ephemeris)
Definition: RefPoint.cpp:65
void set_col_direction(int dir)
Definition: SensorParams.h:123
This class represents a date.
Definition: JSDDateTime.h:30
unsigned int get_first_zero_doppler_time_sec()
first_zero_doppler_time second
float distance(double lat1, double lon1, double lat2, double lon2, int units)
This class is able to read the ASAR GeolocationGrid record.
void set_distance(double distance)
Definition: RefPoint.cpp:75
void set_sf(double sf)
Definition: SensorParams.h:78
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int get_num_ds(EnvisatAsarRecord *record)