diff --git a/semantic_map/include/semantic_map/semantic_map_summary_parser.h b/semantic_map/include/semantic_map/semantic_map_summary_parser.h index 8ba601c4..7e462fbe 100644 --- a/semantic_map/include/semantic_map/semantic_map_summary_parser.h +++ b/semantic_map/include/semantic_map/semantic_map_summary_parser.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "constants.h" #include "semantic_map/metaroom_xml_parser.h" @@ -252,6 +253,54 @@ class SemanticMapSummaryParser { } } + // sort according to year, patrol_run_#, room_# + sort(toRet.begin(), toRet.end(), + [](const EntityStruct& a, const EntityStruct& b ) + { + std::string patrol_string = "patrol_run_"; + std::string room_string = "room_"; + std::string date_string = "YYYYMMDD"; + size_t p_pos_1 = a.roomXmlFile.find(patrol_string); + size_t r_pos_1 = a.roomXmlFile.find(room_string) - 1; // remove the / before the room_ + size_t sl_pos_1 = a.roomXmlFile.find("/",r_pos_1+1); + + size_t p_pos_2 = b.roomXmlFile.find(patrol_string); + size_t r_pos_2 = b.roomXmlFile.find(room_string) - 1; // remove the / before the room_ + size_t sl_pos_2 = b.roomXmlFile.find("/",r_pos_2+1); + + // just in case we have some different folder structure (shouldn't happen) + if ((p_pos_1 == std::string::npos) || (r_pos_1 == std::string::npos) || (sl_pos_1 == std::string::npos) || + (p_pos_2 == std::string::npos) || (r_pos_2 == std::string::npos) || (sl_pos_2 == std::string::npos)) + { + return a.roomXmlFile