~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to django/contrib/gis/admin/options.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    scale_text = True
29
29
    layerswitcher = True
30
30
    scrollable = True
31
 
    admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
32
31
    map_width = 600
33
32
    map_height = 400
34
33
    map_srid = 4326
35
34
    map_template = 'gis/admin/openlayers.html'
36
 
    openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
 
35
    openlayers_url = 'http://openlayers.org/api/2.8/OpenLayers.js'
 
36
    point_zoom = num_zoom - 6
37
37
    wms_url = 'http://labs.metacarta.com/wms/vmap0'
38
38
    wms_layer = 'basic'
39
39
    wms_name = 'OpenLayers WMS'
54
54
        for viewing/editing GeometryFields.
55
55
        """
56
56
        if isinstance(db_field, models.GeometryField):
 
57
            request = kwargs.pop('request', None)
57
58
            # Setting the widget with the newly defined widget.
58
59
            kwargs['widget'] = self.get_map_widget(db_field)
59
60
            return db_field.formfield(**kwargs)
66
67
        in the `widget` attribute) using the settings from the attributes set 
67
68
        in this class.
68
69
        """
69
 
        is_collection = db_field._geom in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
 
70
        is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
70
71
        if is_collection:
71
 
            if db_field._geom == 'GEOMETRYCOLLECTION': collection_type = 'Any'
72
 
            else: collection_type = OGRGeomType(db_field._geom.replace('MULTI', ''))
 
72
            if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any'
 
73
            else: collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
73
74
        else:
74
75
            collection_type = 'None'
75
76
 
76
77
        class OLMap(self.widget):
77
78
            template = self.map_template
78
 
            geom_type = db_field._geom
79
 
            params = {'admin_media_prefix' : self.admin_media_prefix,
80
 
                      'default_lon' : self.default_lon,
 
79
            geom_type = db_field.geom_type
 
80
            params = {'default_lon' : self.default_lon,
81
81
                      'default_lat' : self.default_lat,
82
82
                      'default_zoom' : self.default_zoom,
83
83
                      'display_wkt' : self.debug or self.display_wkt,
84
 
                      'geom_type' : OGRGeomType(db_field._geom),
 
84
                      'geom_type' : OGRGeomType(db_field.geom_type),
85
85
                      'field_name' : db_field.name,
86
86
                      'is_collection' : is_collection,
87
87
                      'scrollable' : self.scrollable,
88
88
                      'layerswitcher' : self.layerswitcher,
89
89
                      'collection_type' : collection_type,
90
 
                      'is_linestring' : db_field._geom in ('LINESTRING', 'MULTILINESTRING'),
91
 
                      'is_polygon' : db_field._geom in ('POLYGON', 'MULTIPOLYGON'),
92
 
                      'is_point' : db_field._geom in ('POINT', 'MULTIPOINT'),
 
90
                      'is_linestring' : db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
 
91
                      'is_polygon' : db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
 
92
                      'is_point' : db_field.geom_type in ('POINT', 'MULTIPOINT'),
93
93
                      'num_zoom' : self.num_zoom,
94
94
                      'max_zoom' : self.max_zoom,
95
95
                      'min_zoom' : self.min_zoom,
101
101
                      'scale_text' : self.scale_text,
102
102
                      'map_width' : self.map_width,
103
103
                      'map_height' : self.map_height,
 
104
                      'point_zoom' : self.point_zoom,
104
105
                      'srid' : self.map_srid,
105
106
                      'display_srid' : self.display_srid,
106
107
                      'wms_url' : self.wms_url,
125
126
        map_srid = 900913
126
127
        max_extent = '-20037508,-20037508,20037508,20037508'
127
128
        max_resolution = 156543.0339
 
129
        point_zoom = num_zoom - 6
128
130
        units = 'm'