diff --git a/geostat.cpp b/geostat.cpp index 7e21196..939bc05 100644 --- a/geostat.cpp +++ b/geostat.cpp @@ -148,16 +148,8 @@ int main(int argc, char** argv) { if (!heat_file.empty()) { const Map* chosen_map; - if (heat_map == "Poland_relief") - chosen_map = &Poland_relief; - else if (heat_map == "Poland" || heat_map.empty()) - chosen_map = &Poland; - else if (heat_map == "Europe") - chosen_map = &Europe; - else if (heat_map == "Podlaskie") - chosen_map = &Podlaskie; - else if (heat_map == "Pomorskie") - chosen_map = &Pomorskie; + if (maps.count(heat_map) > 0) + chosen_map = &maps.at(heat_map); else { std::cout << "Map " << heat_map << " not found.\n"; std::exit(EXIT_FAILURE); diff --git a/maps.h b/maps.h index 487ba35..538bbed 100644 --- a/maps.h +++ b/maps.h @@ -1,5 +1,7 @@ #pragma once +#include + class Map { public: const int size_x; @@ -24,8 +26,10 @@ public: } }; -const Map Poland(1000, 972, 48.7, 55.2, 13.8, 24.5, "Poland.png"); -const Map Poland_relief(1000, 972, 48.7, 55.2, 13.8, 24.5, "Poland_relief.png"); -const Map Europe(1249, 1024, 28, 82, -25, 54, "Europe.png"); -const Map Podlaskie(727, 1024, 52.17, 54.5, 21.45, 24.1, "Podlaskie.png"); -const Map Pomorskie(1000, 785, 53.40, 54.92, 16.65, 19.75, "Pomorskie.png"); +const std::map maps = { + {"Poland", Map(1000, 972, 48.7, 55.2, 13.8, 24.5, "Poland.png")}, + {"Poland_relief", Map(1000, 972, 48.7, 55.2, 13.8, 24.5, "Poland_relief.png")}, + {"Europe", Map(1249, 1024, 28, 82, -25, 54, "Europe.png")}, + {"Podlaskie", Map(727, 1024, 52.17, 54.5, 21.45, 24.1, "Podlaskie.png")}, + {"Pomorskie", Map(1000, 785, 53.40, 54.92, 16.65, 19.75, "Pomorskie.png")} +};