submarcos / django-vectortiles

Mapbox VectorTiles for django, with PostGIS or Python
https://django-vectortiles.readthedocs.io
MIT License
38 stars 11 forks source link

:feature: Support fetching multiple layers in a single DB trip #25

Open furious-luke opened 3 years ago

furious-luke commented 3 years ago

When dealing with maps with many layers there can be many API calls, or, many DB hits depending on how the API is structured. These changes allow for a single DB hit to fetch and concatenate all required layers into a single response.

Please note that this work is currently just a proof-of-concept. I would want to add tests, documentation, and clean up the code a bit. I'd like to hear back about whether you think this is valuable or not before comitting to tidying it up. Cheers!

codecov[bot] commented 3 years ago

Codecov Report

Merging #25 (f339fff) into master (dfef1db) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #25   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          156       164    +8     
=========================================
+ Hits           156       164    +8     
Impacted Files Coverage Δ
vectortiles/mixins.py 100.00% <100.00%> (ø)
vectortiles/postgis/mixins.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dfef1db...f339fff. Read the comment docs.

submarcos commented 3 years ago

Thank you for suggestion. I'm already thinking about including multiple layer per tile. I suggest to enhance MTVView to use multiple Layer definitions. And cache each layer tile per model last update. Then concatenate each cached tile in response. I think it would be a better way than execute a single database query which can be so large.