Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a custom Aggregate for AsMVT #1

Open
submarcos opened this issue Oct 20, 2020 · 2 comments
Open

Write a custom Aggregate for AsMVT #1

submarcos opened this issue Oct 20, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@submarcos
Copy link
Owner

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

@StefanBrand
Copy link
Contributor

@submarcos submarcos added the enhancement New feature or request label Feb 25, 2021
@submarcos
Copy link
Owner Author

submarcos commented Mar 3, 2021

It's possible to write a custom aggregate, but

  • by default django use a subquery, and if we pass ST_ASMVT((geom, some_field), extent, xxx), ST_ASMVT generate tile with automatic field name for properties (don't keep alias or column names) ST_ASMVT bug ? (properties are named f1, f2 etc)
  • if we use ST_ASMVT(subquery.*, extent, xxx), it's ok, ST_ASMVT keep alias for column names, but... django ORM rename column on joins, so ... properties are named __col1, __col2 etc ...

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants