Simplify adding new maps

sql-rework
Tomasz Golinski 2019-09-15 12:34:10 +02:00
rodzic 325af6efba
commit 0e51018b9f
2 zmienionych plików z 11 dodań i 15 usunięć

Wyświetl plik

@ -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);

14
maps.h
Wyświetl plik

@ -1,5 +1,7 @@
#pragma once
#include <map>
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<std::string, 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")}
};