From 1201ccd4f9e6b0f516c7ce654311cc3e5c04fc7e Mon Sep 17 00:00:00 2001 From: Blottiere Paul Date: Thu, 16 May 2024 01:13:00 +0200 Subject: [PATCH] Optimize raster cache config --- qsa-api/qsa_api/mapproxy.py | 11 +++++++++-- qsa-api/qsa_api/project.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/qsa-api/qsa_api/mapproxy.py b/qsa-api/qsa_api/mapproxy.py index 953913f..46b5eab 100644 --- a/qsa-api/qsa_api/mapproxy.py +++ b/qsa-api/qsa_api/mapproxy.py @@ -35,7 +35,7 @@ def clear_cache(self, layer_name: str) -> None: for d in cache_dir.glob(f"**/{layer_name}_cache_*"): shutil.rmtree(d) - def add_layer(self, name: str, bbox: list, srs: int) -> None: + def add_layer(self, name: str, bbox: list, srs: int, is_raster: bool) -> None: if "layers" not in self.cfg: self.cfg["layers"] = [] self.cfg["caches"] = {} @@ -44,7 +44,14 @@ def add_layer(self, name: str, bbox: list, srs: int) -> None: lyr = {"name": name, "title": name, "sources": [f"{name}_cache"]} self.cfg["layers"].append(lyr) - c = {"grids": ["webmercator"], "sources": [f"{name}_wms"]} + c = { + "grids": ["webmercator"], + "sources": [f"{name}_wms"] + } + if is_raster: + c["use_direct_from_level"] = 14 + c["meta_size"] = [1, 1] + c["meta_buffer"] = 0 self.cfg["caches"][f"{name}_cache"] = c s = { diff --git a/qsa-api/qsa_api/project.py b/qsa-api/qsa_api/project.py index a7d343a..b16280f 100644 --- a/qsa-api/qsa_api/project.py +++ b/qsa-api/qsa_api/project.py @@ -374,7 +374,7 @@ def add_layer( mp = QSAMapProxy(self.name) mp.read() - mp.add_layer(name, bbox, epsg_code) + mp.add_layer(name, bbox, epsg_code, t == Qgis.LayerType.Raster) mp.write() return True, ""