Commit 3d90ae7f2eb4ebeb95bc87d03d96ca03842eea06

Authored by Jordi Inglada
1 parent ead0df82
Exists in master

Find the best tile and dept

Showing 2 changed files with 25 additions and 0 deletions   Show diff stats
include/maassp_utils.h
... ... @@ -101,4 +101,27 @@ void print_total_areas(AreaPerTilePerDept aptpd, std::ostream& stream = std::cou
101 101 }
102 102 }
103 103  
  104 +struct TileDept{
  105 + std::string tile_name;
  106 + std::string code_dept;
  107 +};
  108 +
  109 +TileDept best_tile_dept(AreaPerTilePerDept aptpd)
  110 +{
  111 + double max_area{0};
  112 + TileDept result;
  113 + for(const auto& dept : aptpd)
  114 + {
  115 + auto code_dept = dept.first;
  116 + for(const auto& t : dept.second)
  117 + {
  118 + if(t.second > max_area)
  119 + {
  120 + max_area = t.second;
  121 + result = TileDept{t.first, code_dept};
  122 + }
  123 + }
  124 + }
  125 + return result;
  126 +}
104 127 #endif //MAASSP_UTILS_H
... ...
src/select.cxx
... ... @@ -45,6 +45,8 @@ int main()
45 45 }
46 46 std::ofstream outfile("/tmp/stats.txt");
47 47 print_total_areas(aptpd, outfile);
  48 + auto bt = best_tile_dept(aptpd);
  49 + std::cout << "Best tile: " << bt.tile_name << " in Departement " << bt.code_dept << '\n';
48 50  
49 51 return EXIT_SUCCESS;
50 52 }
... ...