Amsterdam / django-gisserver

Django speaking WFS 2.0 to expose geo data
Mozilla Public License 2.0
41 stars 10 forks source link

Allow GeneratedField as geometry field #32

Open tomdtp opened 4 months ago

tomdtp commented 4 months ago

We have some larger polygons in our database and in order to simplify calculations etc we have a GeneratedField, which builds a simplified version of the polygon.

geometry = models.MultiPolygonField(default=None, null=True)
geometry_simplified = models.GeneratedField(
    expression=Multi(SimplifyPreserveTopology("geometry", 0.0001)),
    output_field=models.MultiPolygonField(),
    db_persist=True,
)

I would really like to use this as geometry column for our WFS, but it is throwing an error:

django.core.exceptions.ImproperlyConfigured: FeatureType 'model' does not expose a geometry field.

I looked at the code and could not quickly come up with a PR, maybe someone of the team can look into this?

vdboor commented 2 months ago

Hi! Thanks for reporting this issue. I didn't see this option before.

It will take some time to have this issue scheduled. Totally understand it was tricky to find the source of the Django field translation into the internal XSD definitions. For anyone who likes to take a look, it happens here: https://github.com/Amsterdam/django-gisserver/blob/c8aec75c9c07373e5e1af108c47a486bf919e64a/gisserver/features.py#L93