Пример #1
0
//----------------------------------------
void CProductErs::ComputeHighResolutionFields(CDataSet* dataSet, double deltaLat, double deltaLon)
{
  // Save current recordset pointer
  CRecordSet* currentRecordSetOld = dataSet->GetCurrentRecordSet();

  //dataSet->SetCurrentRecordSet(dataSet->GetFirstRecordSet());

  CFieldSetDbl *fieldSetLat = NULL;
  CFieldSetDbl *fieldSetLon = NULL;
  CFieldSetDbl *fieldSetTimeStampSecond = NULL;
  CFieldSetDbl *fieldSetTimeStampMicrosecond = NULL;

  int32_t count = dataSet->size();

  for (int32_t index = 0 ; index < count ; index++)
  {
    dataSet->SetCurrentRecordSet(index);

    fieldSetLat = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_latitudeFieldName) );
    fieldSetLon = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_longitudeFieldName) );
    fieldSetTimeStampSecond = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampSecondFieldName) );
    fieldSetTimeStampMicrosecond = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampMicrosecondFieldName) );

    // Compute latitude
    if (fieldSetLat != NULL)
    {
      fieldSetLat->m_value = CTools::Plus(fieldSetLat->m_value, 
                                          CTools::Multiply(deltaLat, 
                                                           static_cast<double>(index - m_refPoint)));
    }

    // Compute longitude
    if (fieldSetLon != NULL)
    {
      //fieldSetLon->m_value = CTools::NormalizeLongitude(-180,  
      //                                                  CTools::Plus(fieldSetLon->m_value, 
      //                                                               CTools::Multiply(deltaLon, 
      //                                                                                static_cast<double>(index - m_refPoint))));
      fieldSetLon->m_value = CTools::Plus(fieldSetLon->m_value, 
                                          CTools::Multiply(deltaLon, 
                                                           static_cast<double>(index - m_refPoint)));
    }

    // Compute timestamp
    
    // WARNING -  fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond are converted to SI
    // after they have been read. So their value are stated in seconds
    
    // fieldSetTimeStampSecond = number of seconds from reference SI unit (i.e. 1950-01-01 00:00:00.0)
    
    // fieldSetTimeStampMicrosecond = number of museconds  within the seconds ( < 1 second)
    
    double nbSeconds = 0;

    if (fieldSetTimeStampSecond != NULL)
    {
      nbSeconds = CTools::Plus(nbSeconds, fieldSetTimeStampSecond->m_value);
    }

    if (fieldSetTimeStampMicrosecond != NULL)
    {
      nbSeconds = CTools::Plus(nbSeconds, fieldSetTimeStampMicrosecond->m_value);
    }
    
    nbSeconds = CTools::Plus(nbSeconds, 
                             CTools::Multiply(m_deltaTimeHighResolution, 
                                              static_cast<double>(index - m_refPoint)));
    double seconds;
    double muSeconds;

    CDate timeStamp;
    timeStamp.SetDate(nbSeconds);

    //WARNING At this point,
    // fieldSetTimeStampSecond is stated  in number of seconds and fieldSetTimeStampMicrosecond in numbers of microseconds
    timeStamp.Convert2SM(seconds,
                         muSeconds);

    // WARNING -  fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond are converted to SI
    // after they have been read. So their value are stated in seconds
    //
    //WARNING At this point, muSeconds is stated in numbers of microseconds
    //
    // ====> Convert again muSeconds to a number of seconds     

    if (fieldSetTimeStampSecond != NULL)
    {
      fieldSetTimeStampSecond->m_value = seconds;
    }

    if (fieldSetTimeStampMicrosecond != NULL)
    {
      fieldSetTimeStampMicrosecond->m_value = muSeconds / 1.0E+6;
    }
      

    /*  
    // WARNING -  convert fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond in SI
    // after they have been read. So their value are stated in seconds
    CUnit unit = fieldSetTimeStampSecond->GetField()->GetUnit();
    fieldSetTimeStampSecond->m_value = unit.Convert(fieldSetTimeStampSecond->m_value);

    unit = fieldSetTimeStampMicrosecond->GetField()->GetUnit();
    fieldSetTimeStampMicrosecond->m_value = unit.Convert(fieldSetTimeStampMicrosecond->m_value);
    */
  }

  // Restore current recordset pointer
  dataSet->SetCurrentRecordSet(currentRecordSetOld);
}