I've encountered the same problem (with point_on_surface
and envelope
) and I didn't even manage to resolve it with Django's public APIs.
Here's what I ended up with:
class ZoneManager(gis_models.GeoManager):
def point_on_surface_and_envelope(self):
# Use a private API to adapt point_on_surface and envelope for a
# geographic field. See django.contrib.gis.db.models.query.GeoQuerySet.
return self.all()._spatial_attribute('point_on_surface', {
'select_field' : GeomField(),
'procedure_fmt': '%(geo_col)s::geometry', # added '::geometry'
})._spatial_attribute('envelope', {
'select_field' : GeomField(),
'procedure_fmt': '%(geo_col)s::geometry', # added '::geometry'
})
Maybe I should have started with geometry fields instead of geography fields, but I didn't expect to need these functions...
While I'm interested in a solution to this problem, I'm not convinced we should allow these kind of approximations.
Marking as DDN for now, the GIS maintainer may have a stronger opinion on this matter.