Skip to content

Commit

Permalink
Merge pull request #21 from pblottiere/mapproxy_optim_raster_cache
Browse files Browse the repository at this point in the history
Optimize raster cache config
  • Loading branch information
pblottiere authored May 16, 2024
2 parents 3f8f38d + 1201ccd commit 547a3e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions qsa-api/qsa_api/mapproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = {}
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion qsa-api/qsa_api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""
Expand Down

0 comments on commit 547a3e9

Please sign in to comment.