openwisp / django-rest-framework-gis

Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.
http://openwisp.org
MIT License
1.07k stars 200 forks source link

Use GeoFeatureModelSerializer without geometry #282

Closed 3nids closed 5 months ago

3nids commented 1 year ago

Is there a way to use GeoFeatureModelSerializer for a geometry-less table? I am trying to publish a value list table.

Something like geo_field = None is what I was expecting.

Thanks in advance for any feedback!

auvipy commented 1 year ago

can you share the use case more in detail please?

3nids commented 1 year ago

I want to publish a table which has no geometry column as geo json so it can be read in QGIS (as OGC API Feature layer).

Therefore, it would be handy to use the same serializer than for the tables with geometry columns rather than implementing my own serializer to get a valid geo json output.

For the moment, I'm creating an empty geometry column as a hack:

class MyValueList(models.Model):
    id = models.CharField(primary_key=True, max_length=10)
    # Null geometry to satisfy the interface expected from
    # model by GeoFeatureModelSerializer
    geom = gis_models.PointField(null=True, blank=True)
    active = models.BooleanField(default=True)
    value = models.CharField(max_length=255, null=True, blank=True)
    description = models.TextField(null=True, blank=True)
3nids commented 1 year ago

Basically, allowing geometry-less layer in DRF-gis would allow us to be compliant with OGC API Features norm to publish geometry less layers.

auvipy commented 1 year ago

I am open to contributions in this regard.

nemesifier commented 1 year ago

I never had such a use case but we can definitely merge a patch which would add support for it.

3nids commented 5 months ago

🎉

3nids commented 5 months ago

@nemesifier Thanks a lot!
Looking for this to be released: do you know if there is a roadmap or a release schedule?