django-vectortiles
django-vectortiles copied to clipboard
Mapbox VectorTiles for django, with PostGIS or Python
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...
Add examples: * Usages of annotated fields in tiles (and JSONField cases) * Usages of get_vector_tile_queryset to simplify geometries by zoom level * Usage of cache policies on get_tile
* see django Aggregate class * see django Subquery class -> Feature.objects.filter(xxx).annotate(geom_prepared=AsMVTGeom('geom', xxx)).aggregate(tile=AsMVT(xxx)) -> Layer.objects.values('name').aggregate(tile=AsMVT(Feature.objects.annotate(geom_prepared=AsMVTGeom('geom', xxx)).filter(layer_id=OuterRef('pk')), xxx))
ex: ```python class MetaMVTView(View): content_type = "application/x-protobuf" vector_layers = (MVTView1, MVTView2) def get_vector_layers(): return self.vector_layers def get(request, z, x, y): content = b'' for layer in self.get_vector_layers(): content += layer.get_tile(z,...
Actually tilejson generate a single relative url in list. To work wirh mapbox, we need to define possible values to generate absolute urls. Ex : From ```json tiles : ["/features/tile/{z}/{x}/{y}"]...
v1 introduced the `layer_classes` class variable, together with a `get_layer_class_kwargs`. Previously I was able to directly use the `request.query_params` and `kwargs` when filtering the queryset. Unfortunately `get_layer_class_kwargs` only receives `self`,...
I wrote this up for our purposes but perhaps you can incorporate it in a cleaner way than I could: ```python @dataclass class VectorLayerQueryset: layer_name: str queryset: QuerySet queryset_limit =...