diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b9ad5f566ef7a622d5ea452abb7f5bfa77d02cf..354922fb1656a34b6a8f0ffa5f7b12f04446fb41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,12 @@ 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() +else() otb_module_impl() endif() diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index f7095ffd8bf3bcc420a7bae4e989892c6d06c6ca..620bff6f2c197b7db63bf212975dfb46f1fdbde8 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -99,9 +99,10 @@ OTB_CREATE_APPLICATION(NAME SARCorrelationRough LINK_LIBRARIES ${${otb-module}_LIBRARIES} ) + OTB_CREATE_APPLICATION(NAME SARMetadataCorrection SOURCES otbSARMetadataCorrection.cxx - LINK_LIBRARIES ${${otb-module}_LIBRARIES} + LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${Boost_LIBRARIES} ) OTB_CREATE_APPLICATION(NAME SAROrthoInterferogram diff --git a/app/otbSARMetadataCorrection.cxx b/app/otbSARMetadataCorrection.cxx index f83320ea2f54ce8f7034ded711160745958d0376..05154f33b94b651e47ef2eeff4c65706a6c49b5d 100644 --- a/app/otbSARMetadataCorrection.cxx +++ b/app/otbSARMetadataCorrection.cxx @@ -33,6 +33,7 @@ #include "otb_tinyxml.h" #include "itksys/SystemTools.hxx" +#include "boost/date_time/posix_time/posix_time.hpp" // include ossim #if defined(__GNUC__) || defined(__clang__) @@ -51,6 +52,7 @@ #endif + enum { Mode_UserDefined, @@ -378,18 +380,25 @@ int selectOrbits(std::vector<std::string> * vector_time, // 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); + + UTC_first.replace(UTC_first.find("T"), 1, " "); + tm1 = boost::posix_time::to_tm(boost::posix_time::time_from_string(UTC_first.c_str())); 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())); 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::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())); time_t t = mktime(&tm); if (difftime(t, t_first) > 0 && ind_first == 0)