submarcos / django-vectortiles

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

Write a custom Aggregate for AsMVT #1

Open submarcos opened 3 years ago

submarcos commented 3 years ago

-> 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))

StefanBrand commented 3 years ago

Stackoverflow has a question on this here: https://stackoverflow.com/questions/65508291/how-to-create-mapbox-vector-tiles-with-django-orm-and-postgis

submarcos commented 3 years ago

It's possible to write a custom aggregate, but

It seems not to be simple to resolve that, because aggregation and column rename are define in SQLAggregate Compiler which can't be override