Commit e0ab86e0 authored by Gaëlle USSEGLIO's avatar Gaëlle USSEGLIO
Browse files

Merge branch 'fix_strptime' into 'master'

Fix strptime

See merge request remote_modules/diapotb!38
parents 7d7b143c 25603d84
......@@ -6,7 +6,7 @@ if(NOT OTB_SOURCE_DIR)
list(APPEND CMAKE_MODULE_PATH ${OTB_CMAKE_DIR})
include(${OTB_USE_FILE})
include(OTBModuleExternal)
else()
else()
otb_module_impl()
endif()
......
......@@ -99,6 +99,7 @@ OTB_CREATE_APPLICATION(NAME SARCorrelationRough
LINK_LIBRARIES ${${otb-module}_LIBRARIES}
)
OTB_CREATE_APPLICATION(NAME SARMetadataCorrection
SOURCES otbSARMetadataCorrection.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES}
......
......@@ -24,6 +24,7 @@
#include "otbSARStreamingDEMClosestHgtFilter.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <complex>
......@@ -33,7 +34,6 @@
#include "otb_tinyxml.h"
#include "itksys/SystemTools.hxx"
// include ossim
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
......@@ -51,6 +51,7 @@
#endif
enum
{
Mode_UserDefined,
......@@ -376,20 +377,28 @@ int selectOrbits(std::vector<std::string> * vector_time,
std::string UTC_last = inKWL.GetMetadataByKey(std::string (prefix_last));
// Transform string to t_time (in seconds)
struct tm tm1;
struct tm tm2;
strptime(UTC_first.c_str(), "%Y-%m-%dT%H:%M:%SZ", &tm1);
strptime(UTC_last.c_str(), "%Y-%m-%dT%H:%M:%SZ", &tm2);
std::tm tm1 ={};
std::tm tm2 ={};
std::istringstream UTC_first_ss (UTC_first);
UTC_first_ss.imbue(std::locale(setlocale(LC_ALL, nullptr)));
UTC_first_ss >> std::get_time(&tm1, "%Y-%m-%dT%H:%M:%SZ");
time_t t_first = mktime(&tm1);
std::istringstream UTC_last_ss (UTC_last);
UTC_last_ss.imbue(std::locale(setlocale(LC_ALL, nullptr)));
UTC_last_ss >> std::get_time(&tm2, "%Y-%m-%dT%H:%M:%SZ");
time_t t_last = mktime(&tm2);
// Selection of indexes into vector_time
// ind_first = last elt to be inferior to t_first
// ind_last = first elt to be superior to t_last
for (unsigned int i = 0; i < vector_time->size(); i++)
{
struct tm tm;
strptime(vector_time->at(i).c_str(), "%Y-%m-%dT%H:%M:%SZ", &tm);
std::tm tm;
std::istringstream UTC_ss (vector_time->at(i));
UTC_ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%SZ");
time_t t = mktime(&tm);
if (difftime(t, t_first) > 0 && ind_first == 0)
......
......@@ -361,17 +361,17 @@ public:
// Free Memory
delete w;
delete [] w;
w = 0;
for (unsigned int i = 0; i < m_SizeTiles; i++)
{
delete wf[i];
delete [] wf[i];
wf[i] = 0;
}
delete wf;
delete [] wf;
wf = 0;
delete bufAmp;
delete [] bufAmp;
bufAmp = 0;
}
......
......@@ -156,9 +156,9 @@ protected:
unsigned int firstTileIndexL, unsigned int firstTileIndexC,
itk::ThreadIdType threadId);
void BeforeThreadedGenerateData();
void BeforeThreadedGenerateData() override;
void AfterThreadedGenerateData();
void AfterThreadedGenerateData() override;
/** Static function used as a "callback" by the MultiThreader. The threading
* library will call this routine for each thread, which will delegate the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment