Esempio n. 1
0
void ossimGeometricSarSensorModel::clearGCPlist() {
   _optimizationGCPsGroundCoordinates.clear();
   _optimizationGCPsImageCoordinates.clear();

   // optimization model update
   optimizeModel(_optimizationGCPsGroundCoordinates, _optimizationGCPsImageCoordinates) ;
}
Esempio n. 2
0
bool ossimErsSarModel::InitRefPoint(const ossimKeywordlist &kwl, const char *prefix)
{
  const char* sc_lin_str = kwl.find(prefix, "sc_lin");
  double sc_lin = atof(sc_lin_str);

  const char* sc_pix_str = kwl.find(prefix, "sc_pix");
  double sc_pix = atof(sc_pix_str);

  const char* inp_sctim_str = kwl.find(prefix, "inp_sctim");

  const char* rng_gate_str = kwl.find(prefix, "zero_dop_range_time_f_pixel");
  double rng_gate = atof(rng_gate_str);

  if (_refPoint == NULL)
  {
    _refPoint = new RefPoint();
  }

  _refPoint->set_pix_col(sc_pix);
  _refPoint->set_pix_line(sc_lin);

  char year_str[5];
  for (int i = 0; i < 4; i++)
  {
    year_str[i] = inp_sctim_str[i];
  }
  year_str[4] = '\0';

  char month_str[3];
  for (int i = 4; i < 6; i++)
  {
    month_str[i-4] = inp_sctim_str[i];
  }
  month_str[2] = '\0';

  char day_str[3];
  for (int i = 6; i < 8; i++)
  {
    day_str[i-6] = inp_sctim_str[i];
  }
  day_str[2] = '\0';

  char hour_str[3];
  for (int i = 8; i < 10; i++)
  {
    hour_str[i-8] = inp_sctim_str[i];
  }
  hour_str[2] = '\0';

  char min_str[3];
  for (int i = 10; i < 12; i++)
  {
    min_str[i-10] = inp_sctim_str[i];
  }
  min_str[2] = '\0';

  char sec_str[3];
  for (int i = 12; i < 14; i++)
  {
    sec_str[i-12] = inp_sctim_str[i];
  }
  sec_str[2] = '\0';

  char mili_str[4];
  for (int i = 14; i < 17; i++)
  {
    mili_str[i-14] = inp_sctim_str[i];
  }
  mili_str[3] = '\0';

  int year = atoi(year_str);
  int month = atoi(month_str);
  int day = atoi(day_str);
  int hour = atoi(hour_str);
  int min = atoi(min_str);
  int sec = atoi(sec_str);
  double mili = atof(mili_str);


  CivilDateTime date(year, month, day, hour * 3600 + min * 60 + sec, mili / 1000.0);

  if (_platformPosition != NULL)
  {
    Ephemeris * ephemeris = _platformPosition->Interpolate((JSDDateTime)date);
    if (ephemeris == NULL) return false ;
    _refPoint->set_ephemeris(ephemeris);

    delete ephemeris;
  }
  else
  {
    return false;
  }

  double c = 2.99792458e+8;

  double distance = (rng_gate * 1e-3 + ((double)sc_pix) * _sensor->get_nRangeLook() / _sensor->get_sf()) * (c / 2.0);

  _refPoint->set_distance(distance);

  // in order to use ossimSensorModel::lineSampleToWorld
  const char* nbCol_str = kwl.find(prefix, "num_pix");
  const char* nbLin_str = kwl.find(prefix, "num_lines");
  theImageSize.x      = atoi(nbCol_str);
  theImageSize.y      = atoi(nbLin_str);
  theImageClipRect    = ossimDrect(0, 0, theImageSize.x - 1, theImageSize.y - 1);

  // Ground Control Points extracted from the model : corner points
  std::list<ossimGpt> groundGcpCoordinates ;
  std::list<ossimDpt> imageGcpCoordinates ;
  // first line first pix
  const char* lon_str = kwl.find("first_line_first_pixel_lon");
  double lon = atof(lon_str);
  const char* lat_str = kwl.find("first_line_first_pixel_lat");
  double lat = atof(lat_str);
  if (lon > 180.0) lon -= 360.0;
  ossimDpt imageGCP1(0, 0);
  ossimGpt groundGCP1(lat, lon, 0.0);
  groundGcpCoordinates.push_back(groundGCP1) ;
  imageGcpCoordinates.push_back(imageGCP1) ;
  // first line last pix
  lon_str = kwl.find("first_line_last_pixel_lon");
  lon = atof(lon_str);
  lat_str = kwl.find("first_line_last_pixel_lat");
  lat = atof(lat_str);
  if (lon > 180.0) lon -= 360.0;
  ossimDpt imageGCP2(theImageSize.x - 1, 0);
  ossimGpt groundGCP2(lat, lon, 0.0);
  groundGcpCoordinates.push_back(groundGCP2) ;
  imageGcpCoordinates.push_back(imageGCP2) ;
  // last line last pix
  lon_str = kwl.find("last_line_last_pixel_lon");
  lon = atof(lon_str);
  lat_str = kwl.find("last_line_last_pixel_lat");
  lat = atof(lat_str);
  if (lon > 180.0) lon -= 360.0;
  ossimDpt imageGCP3(theImageSize.x - 1, theImageSize.y - 1);
  ossimGpt groundGCP3(lat, lon, 0.0);
  groundGcpCoordinates.push_back(groundGCP3) ;
  imageGcpCoordinates.push_back(imageGCP3) ;
  // last line first pix
  lon_str = kwl.find("last_line_first_pixel_lon");
  lon = atof(lon_str);
  lat_str = kwl.find("last_line_first_pixel_lat");
  lat = atof(lat_str);
  if (lon > 180.0) lon -= 360.0;
  ossimDpt imageGCP4(0, theImageSize.y - 1);
  ossimGpt groundGCP4(lat, lon, 0.0);
  groundGcpCoordinates.push_back(groundGCP4) ;
  imageGcpCoordinates.push_back(imageGCP4) ;

  // Default optimization
  optimizeModel(groundGcpCoordinates, imageGcpCoordinates) ;

  return true;
}
bool ossimCosmoSkymedModel::InitRefPoint(const ossimKeywordlist &kwl, const char *prefix)
{
  const char* sc_lin_str = kwl.find(prefix,"sc_lin");
  double sc_lin = atof(sc_lin_str);

  const char* sc_pix_str = kwl.find(prefix,"sc_pix");
  double sc_pix = atof(sc_pix_str);

  // const char* pixel_spacing_str = kwl.find(prefix,"pixel_spacing");
  // double pixel_spacing = atof(pixel_spacing_str);

  const char* azimuthStartTime_str = kwl.find(prefix,"azimuthStartTime");
  double azimuthStartTime = atof(azimuthStartTime_str);

  const char* rng_gate_str = kwl.find(prefix,"rng_gate");
  double rng_gate = atof(rng_gate_str);

  const char* referenceUTC_str = kwl.find(prefix,"referenceUTC");
  std::string referenceUTC(referenceUTC_str) ;
  CivilDateTime ref_civil_date;
  if (! UtcDateTimeStringToCivilDate(referenceUTC, ref_civil_date)) return false;

  if(_refPoint == NULL)
  {
    _refPoint = new RefPoint();
  }

  _refPoint->set_pix_col(sc_pix);
  _refPoint->set_pix_line(sc_lin);

  double relative_date = (azimuthStartTime + sc_lin/_sensor->get_prf());
  int second = (int) relative_date ;
  double decimal = relative_date - second ;
  CivilDateTime * date = new CivilDateTime(ref_civil_date.get_year(), ref_civil_date.get_month(), ref_civil_date.get_day(), second, decimal);

  if(_platformPosition != NULL)
  {
    Ephemeris * ephemeris = _platformPosition->Interpolate((JSDDateTime)*date);
    if (ephemeris == NULL) 
      {
      delete date;
      return false ;
      }

    _refPoint->set_ephemeris(ephemeris);

    delete ephemeris;
  }
  else
  {
    delete date;
    return false;
  }

  double c = 2.99792458e+8;
  double distance = (rng_gate + sc_pix*_sensor->get_nRangeLook()/_sensor->get_sf()) * (c/2.0);

  // in the case of Georeferenced images, the "relative" ground range is stored in place of the slant range
  // (used for SlantRange computation relative to reference point, necessary for optimization)
  // here, the pixelDirection is ignored since the CSKS reference point is always at the scene centre
  if (_isProductGeoreferenced) {
    distance = _refPoint->get_pix_col() * _pixel_spacing ;
  }

  _refPoint->set_distance(distance);


  // in order to use ossimSensorModel::lineSampleToWorld
  const char* nbCol_str = kwl.find(prefix,"nbCol");
  const char* nbLin_str = kwl.find(prefix,"nbLin");
  theImageSize.x      = atoi(nbCol_str);
   theImageSize.y      = atoi(nbLin_str);
   theImageClipRect    = ossimDrect(0, 0, theImageSize.x-1, theImageSize.y-1);


  // Ground Control Points extracted from the model : scene center and corners
  std::list<ossimGpt> groundGcpCoordinates ;
  std::list<ossimDpt> imageGcpCoordinates ;
  char name[64];
  for (int k=0 ; k<5 ; k++) {
    sprintf(name,"cornersCol%i",k);
    const char* i_str = kwl.find(name);
    int i = atoi(i_str);
    sprintf(name,"cornersLin%i",k);
    const char* j_str = kwl.find(name);
    int j = atoi(j_str);
    sprintf(name,"cornersLon%i",k);
    const char* lon_str = kwl.find(name);
    double lon = atof(lon_str);
    sprintf(name,"cornersLat%i",k);
    const char* lat_str = kwl.find(name);
    double lat = atof(lat_str);
    sprintf(name,"cornersHeight%i",k);
    const char* height_str = kwl.find(name);
    double height = atof(height_str) ;

    ossimDpt imageGCP(i,j);
    ossimGpt groundGCP(lat, lon, height);
    groundGcpCoordinates.push_back(groundGCP) ;
    imageGcpCoordinates.push_back(imageGCP) ;
  }

  // Default optimization
  optimizeModel(groundGcpCoordinates, imageGcpCoordinates) ;

  delete date;

  return true;
}