Changes between Initial Version and Version 1 of Ticket #17635


Ignore:
Timestamp:
Mar 4, 2012, 1:35:32 AM (12 years ago)
Author:
Aymeric Augustin
Comment:

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.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17635

    • Property Triage Stage UnreviewedDesign decision needed
  • Ticket #17635 – Description

    initial v1  
    1414
    1515Here are some propositions:
    16 - add a way to cast to geometry, that would allow to do: qs.extent(field_name=coordinates__geometry) (the trailing __geometry cast a GeometryField from geography to geometry)
    17 - another way to cast to geometry would be: qs.geometry('coordinates').extent()
     16- add a way to cast to geometry, that would allow to do: `qs.extent(field_name=coordinates__geometry)` (the trailing `__geometry` cast a GeometryField from geography to geometry)
     17- another way to cast to geometry would be: `qs.geometry('coordinates').extent()`
    1818- automatically cast geography to geometry if a function only support geometry (hum...)
Back to Top