Skip to content
Snippets Groups Projects
Commit ae93ccd2 authored by Gaëlle USSEGLIO's avatar Gaëlle USSEGLIO
Browse files

BUG : Remove strptime from C++ code (issue #9) with std::get_time

parent dd2dfc31
No related branches found
No related tags found
1 merge request!38Fix strptime
......@@ -2,13 +2,11 @@ cmake_minimum_required(VERSION 2.8.9)
project(DiapOTBModule)
if(NOT OTB_SOURCE_DIR)
find_package(Boost COMPONENTS date_time)
find_package(OTB REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${OTB_CMAKE_DIR})
include(${OTB_USE_FILE})
include(OTBModuleExternal)
else()
find_package(Boost COMPONENTS date_time)
otb_module_impl()
endif()
......
......@@ -102,7 +102,7 @@ OTB_CREATE_APPLICATION(NAME SARCorrelationRough
OTB_CREATE_APPLICATION(NAME SARMetadataCorrection
SOURCES otbSARMetadataCorrection.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${Boost_LIBRARIES}
LINK_LIBRARIES ${${otb-module}_LIBRARIES}
)
OTB_CREATE_APPLICATION(NAME SAROrthoInterferogram
......
......@@ -24,6 +24,7 @@
#include "otbSARStreamingDEMClosestHgtFilter.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <complex>
......@@ -33,8 +34,6 @@
#include "otb_tinyxml.h"
#include "itksys/SystemTools.hxx"
#include "boost/date_time/posix_time/posix_time.hpp"
// include ossim
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
......@@ -378,27 +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;
UTC_first.replace(UTC_first.find("T"), 1, " ");
tm1 = boost::posix_time::to_tm(boost::posix_time::time_from_string(UTC_first.c_str()));
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);
UTC_last.replace(UTC_last.find("T"), 1, " ");
tm2 = boost::posix_time::to_tm(boost::posix_time::time_from_string(UTC_last.c_str()));
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;
std::string UTC_i = vector_time->at(i); // Copy of UTC at ind i to keep original time into our vector
UTC_i.replace(UTC_i.find("T"), 1, " ");
tm = boost::posix_time::to_tm(boost::posix_time::time_from_string(UTC_i.c_str()));
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment