17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 05:09:20 +02:00

fix flipped ortophot + clear cache

This commit is contained in:
maj00r
2026-10-08 20:20:12 +02:00
parent 14e916e81f
commit c11480ce2e
4 changed files with 30 additions and 0 deletions

View File

@@ -1838,6 +1838,10 @@ void editor_mode::render_orthophoto_ui()
if (!editor_orthophoto::can_download()) if (!editor_orthophoto::can_download())
ImGui::TextDisabled(STR_C("This build has no HTTP client, only cached tiles are shown")); ImGui::TextDisabled(STR_C("This build has no HTTP client, only cached tiles are shown"));
ImGui::TextDisabled(STR_C("Cache: %s"), editor_orthophoto::cache_directory().c_str()); ImGui::TextDisabled(STR_C("Cache: %s"), editor_orthophoto::cache_directory().c_str());
if (ImGui::Button(STR_C("Clear cache")))
m_orthophoto.clear_cache();
if (ImGui::IsItemHovered())
ImGui::SetTooltip(STR_C("Deletes downloaded tiles from disk. They are fetched again around the camera."));
ImGui::TextDisabled(STR_C("Imagery: GUGiK, geoportal.gov.pl")); ImGui::TextDisabled(STR_C("Imagery: GUGiK, geoportal.gov.pl"));
} }

View File

@@ -417,6 +417,9 @@ bool fetch(http_client &Client, std::string const &Url, fs::path const &Path, st
bool decode(std::vector<std::uint8_t> const &Data, image &Out, std::string &Error) bool decode(std::vector<std::uint8_t> const &Data, image &Out, std::string &Error)
{ {
int width{0}, height{0}, components{0}; int width{0}, height{0}, components{0};
// WMS GetMap is north-up. the texture loader sets a process-wide stb flip for OpenGL;
// pin this thread to no flip immediately before load so the first row stays north
stbi_set_flip_vertically_on_load_thread(0);
stbi_uc *pixels = stbi_load_from_memory(Data.data(), static_cast<int>(Data.size()), &width, &height, &components, 4); stbi_uc *pixels = stbi_load_from_memory(Data.data(), static_cast<int>(Data.size()), &width, &height, &components, 4);
if (pixels == nullptr) if (pixels == nullptr)
{ {
@@ -738,6 +741,21 @@ void editor_orthophoto::cancel_pending()
entry.second.requested = 0; entry.second.requested = 0;
} }
void editor_orthophoto::clear_cache()
{
cancel_pending();
for (auto &entry : m_tiles)
release_tile(entry.second);
m_tiles.clear();
++m_generation;
{
std::lock_guard<std::mutex> lock(m_mutex);
m_done.clear();
}
std::error_code ec;
fs::remove_all(cache_root(), ec);
}
void editor_orthophoto::retry_failed() void editor_orthophoto::retry_failed()
{ {
for (auto &entry : m_tiles) for (auto &entry : m_tiles)

View File

@@ -107,6 +107,8 @@ class editor_orthophoto
void draw(glm::mat4 const &ViewProjection, glm::dvec3 const &CameraPos, float ScreenWidth, float ScreenHeight) const; void draw(glm::mat4 const &ViewProjection, glm::dvec3 const &CameraPos, float ScreenWidth, float ScreenHeight) const;
// forgets pending (not yet started) downloads, e.g. when the editor is left // forgets pending (not yet started) downloads, e.g. when the editor is left
void cancel_pending(); void cancel_pending();
// drops resident tiles and deletes the on-disk cache; enabled tiles are fetched again
void clear_cache();
// clears failure state so failed tiles are attempted again // clears failure state so failed tiles are attempted again
void retry_failed(); void retry_failed();

View File

@@ -4057,6 +4057,12 @@ msgstr "Ten build nie ma klienta HTTP, widać tylko kafle z pamięci podręcznej
msgid "Cache: %s" msgid "Cache: %s"
msgstr "Pamięć podręczna: %s" msgstr "Pamięć podręczna: %s"
msgid "Clear cache"
msgstr "Wyczyść cache"
msgid "Deletes downloaded tiles from disk. They are fetched again around the camera."
msgstr "Usuwa pobrane kafle z dysku. Zostaną ponownie pobrane wokół kamery."
msgid "Imagery: GUGiK, geoportal.gov.pl" msgid "Imagery: GUGiK, geoportal.gov.pl"
msgstr "Zdjęcia: GUGiK, geoportal.gov.pl" msgstr "Zdjęcia: GUGiK, geoportal.gov.pl"