mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 09:49:19 +02:00
The location picker now shows the real topographic map instead of a hand-drawn outline, fetched as one WMS image for whatever box is on screen; the schematic border is gone and only the city list remains, to jump the view somewhere recognisable. Under the plan itself a georeferenced map gets the orthophoto, tiled through the layout library's own EPSG:2180 grid and cache. What a native build was missing is here: the download (WinHTTP, on worker threads), the decode and the texture. Finished transfers are handed back on the thread that drains them, so both the library's cache and the graphics API stay on one thread. The imagery service turns down browser user agents and fails the odd request even for a plain one, so requests go out as curl and are retried a few times. Starting a new map now drops the loaded scenery and comes back on empty ground, instead of leaving the previous scenery's contents under a plan that has nothing to do with them. The reload is deferred to the top of the frame: taking the editor off the mode stack while it is drawing its own panels would pull the ground out from under them.
80 lines
2.6 KiB
C++
80 lines
2.6 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "editor/polandmap.h"
|
|
|
|
#include "editor/puwg1992.h"
|
|
|
|
namespace editor
|
|
{
|
|
|
|
namespace
|
|
{
|
|
|
|
// geographic coordinates, degrees, as (latitude, longitude); projected to EPSG:2180 on first use so
|
|
// the numbers stay readable and there is a single place where the frame is decided
|
|
struct geo_point
|
|
{
|
|
double latitude;
|
|
double longitude;
|
|
};
|
|
|
|
// the country's corners, wide enough to hold all of it: the Odra in the west, the Bug in the east,
|
|
// the Tatras in the south and the coast in the north
|
|
constexpr geo_point kSouthWest{49.00, 14.10};
|
|
constexpr geo_point kNorthEast{54.90, 24.20};
|
|
|
|
struct named_geo_point
|
|
{
|
|
char const *name;
|
|
geo_point position;
|
|
};
|
|
|
|
constexpr named_geo_point kPlaces[]{
|
|
{"Warszawa", {52.23, 21.01}}, {"Krakow", {50.06, 19.94}}, {"Lodz", {51.77, 19.46}},
|
|
{"Wroclaw", {51.11, 17.03}}, {"Poznan", {52.41, 16.93}}, {"Gdansk", {54.35, 18.65}},
|
|
{"Szczecin", {53.43, 14.55}}, {"Bydgoszcz", {53.12, 18.01}}, {"Lublin", {51.25, 22.57}},
|
|
{"Bialystok", {53.13, 23.16}}, {"Katowice", {50.26, 19.02}}, {"Rzeszow", {50.04, 22.00}},
|
|
{"Olsztyn", {53.78, 20.49}}, {"Kielce", {50.87, 20.63}}, {"Zielona Gora", {51.94, 15.51}},
|
|
{"Opole", {50.67, 17.93}}, {"Torun", {53.02, 18.61}}, {"Gorzow Wlkp.", {52.73, 15.24}},
|
|
{"Koszalin", {54.19, 16.18}}, {"Czestochowa", {50.81, 19.12}}};
|
|
|
|
} // namespace
|
|
|
|
void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max)
|
|
{
|
|
// the projection is not axis-aligned with the graticule, so the extreme corners come from
|
|
// projecting all four of them and taking the outermost values
|
|
auto const sw = puwg1992(kSouthWest.latitude, kSouthWest.longitude);
|
|
auto const se = puwg1992(kSouthWest.latitude, kNorthEast.longitude);
|
|
auto const nw = puwg1992(kNorthEast.latitude, kSouthWest.longitude);
|
|
auto const ne = puwg1992(kNorthEast.latitude, kNorthEast.longitude);
|
|
|
|
Min = {std::min({sw.x, se.x, nw.x, ne.x}), std::min({sw.y, se.y, nw.y, ne.y})};
|
|
Max = {std::max({sw.x, se.x, nw.x, ne.x}), std::max({sw.y, se.y, nw.y, ne.y})};
|
|
}
|
|
|
|
std::vector<map_place> const &poland_places()
|
|
{
|
|
static std::vector<map_place> const places = []() {
|
|
std::vector<map_place> result;
|
|
result.reserve(std::size(kPlaces));
|
|
for (auto const &place : kPlaces)
|
|
{
|
|
result.push_back({place.name, puwg1992(place.position.latitude, place.position.longitude)});
|
|
}
|
|
return result;
|
|
}();
|
|
|
|
return places;
|
|
}
|
|
|
|
} // namespace editor
|