Пример #1
0
//----------------------------------------
void CProductJason::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 *fieldSetTimeStampDay = NULL;
    CFieldSetDbl *fieldSetTimeStampSecond = NULL;
    CFieldSetDbl *fieldSetTimeStampMicrosecond = NULL;

    size_t count = dataSet->size();

    for (size_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) );
        fieldSetTimeStampDay = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampDayFieldName) );
        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 -  fieldSetTimeStampDay, fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond are converted to SI
        // after they have been read. So their value are stated in seconds

        // fieldSetTimeStampDay = number of seconds from reference SI unit (i.e. 1950-01-01 00:00:00.0)

        // fieldSetTimeStampSecond = number of seconds within the day

        // fieldSetTimeStampMicrosecond = number of seconds  within the seconds ( < 1 second)


        double nbSeconds = 0;

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

        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)));

        CDate timeStamp;
        //timeStamp.SetDate(nbSeconds, m_refDate);
        timeStamp.SetDate(nbSeconds);


        double days;
        double seconds;
        double muSeconds;

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

        //std::string str = timeStamp.AsString();


        // WARNING -  convert fieldSetTimeStampDay, fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond in SI
        // after they have been read. So their value are stated in seconds
        //
        //WARNING At this point, days is stated in number of day,
        // seconds in number of seconds and muSeconds in numbers of microseconds
        //
        // ====> Convert again days to number of seconds from reference SI unit (i.e. 1950-01-01 00:00:00.0)
        // ====> Convert again muSeconds to a number of seconds


        if (fieldSetTimeStampDay != NULL)
        {
            CDate date1950(days, 0.0, 0.0);
            fieldSetTimeStampDay->m_value = date1950.Value();
        }

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


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

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

            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);
}