当前位置: 首页>>代码示例>>Python>>正文


Python widgets.OpenLayersWidget方法代码示例

本文整理汇总了Python中django.contrib.gis.admin.widgets.OpenLayersWidget方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.OpenLayersWidget方法的具体用法?Python widgets.OpenLayersWidget怎么用?Python widgets.OpenLayersWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.gis.admin.widgets的用法示例。


在下文中一共展示了widgets.OpenLayersWidget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: formfield_for_dbfield

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def formfield_for_dbfield(self, db_field, request, **kwargs):
        """
        Overloaded from ModelAdmin so that an OpenLayersWidget is used
        for viewing/editing 2D GeometryFields (OpenLayers 2 does not support
        3D editing).
        """
        if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
            if not HAS_GDAL and db_field.srid != self.map_srid:
                raise ImproperlyConfigured(
                    "Map SRID is %s and SRID of `%s` is %s. GDAL must be "
                    "installed to perform the transformation."
                    % (self.map_srid, db_field, db_field.srid)
                )
            # Setting the widget with the newly defined widget.
            kwargs['widget'] = self.get_map_widget(db_field)
            return db_field.formfield(**kwargs)
        else:
            return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, request, **kwargs) 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:20,代码来源:options.py

示例2: formfield_for_dbfield

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def formfield_for_dbfield(self, db_field, **kwargs):
        """
        Overloaded from ModelAdmin so that an OpenLayersWidget is used
        for viewing/editing 2D GeometryFields (OpenLayers 2 does not support
        3D editing).
        """
        if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
            kwargs.pop('request', None)
            # Setting the widget with the newly defined widget.
            kwargs['widget'] = self.get_map_widget(db_field)
            return db_field.formfield(**kwargs)
        else:
            return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:15,代码来源:options.py

示例3: formfield_for_dbfield

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def formfield_for_dbfield(self, db_field, request, **kwargs):
        """
        Overloaded from ModelAdmin so that an OpenLayersWidget is used
        for viewing/editing 2D GeometryFields (OpenLayers 2 does not support
        3D editing).
        """
        if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
            # Setting the widget with the newly defined widget.
            kwargs['widget'] = self.get_map_widget(db_field)
            return db_field.formfield(**kwargs)
        else:
            return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, request, **kwargs) 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:14,代码来源:options.py

示例4: formfield_for_dbfield

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def formfield_for_dbfield(self, db_field, **kwargs):
        """
        Overloaded from ModelAdmin so that an OpenLayersWidget is used
        for viewing/editing 2D GeometryFields (OpenLayers 2 does not support
        3D editing).
        """
        if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
            request = kwargs.pop('request', None)
            # Setting the widget with the newly defined widget.
            kwargs['widget'] = self.get_map_widget(db_field)
            return db_field.formfield(**kwargs)
        else:
            return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:15,代码来源:options.py

示例5: get_map_widget

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def get_map_widget(self, db_field):
        """
        Returns a subclass of the OpenLayersWidget (or whatever was specified
        in the `widget` attribute) using the settings from the attributes set
        in this class.
        """
        is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
        if is_collection:
            if db_field.geom_type == 'GEOMETRYCOLLECTION':
                collection_type = 'Any'
            else:
                collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
        else:
            collection_type = 'None'

        class OLMap(self.widget):
            template = self.map_template
            geom_type = db_field.geom_type

            wms_options = ''
            if self.wms_options:
                wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()]
                wms_options = ', %s' % ', '.join(wms_options)

            params = {'default_lon': self.default_lon,
                      'default_lat': self.default_lat,
                      'default_zoom': self.default_zoom,
                      'display_wkt': self.debug or self.display_wkt,
                      'geom_type': OGRGeomType(db_field.geom_type),
                      'field_name': db_field.name,
                      'is_collection': is_collection,
                      'scrollable': self.scrollable,
                      'layerswitcher': self.layerswitcher,
                      'collection_type': collection_type,
                      'is_generic': db_field.geom_type == 'GEOMETRY',
                      'is_linestring': db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
                      'is_polygon': db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
                      'is_point': db_field.geom_type in ('POINT', 'MULTIPOINT'),
                      'num_zoom': self.num_zoom,
                      'max_zoom': self.max_zoom,
                      'min_zoom': self.min_zoom,
                      'units': self.units,  # likely should get from object
                      'max_resolution': self.max_resolution,
                      'max_extent': self.max_extent,
                      'modifiable': self.modifiable,
                      'mouse_position': self.mouse_position,
                      'scale_text': self.scale_text,
                      'map_width': self.map_width,
                      'map_height': self.map_height,
                      'point_zoom': self.point_zoom,
                      'srid': self.map_srid,
                      'display_srid': self.display_srid,
                      'wms_url': self.wms_url,
                      'wms_layer': self.wms_layer,
                      'wms_name': self.wms_name,
                      'wms_options': wms_options,
                      'debug': self.debug,
                      }
        return OLMap 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:61,代码来源:options.py

示例6: get_map_widget

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def get_map_widget(self, db_field):
        """
        Returns a subclass of the OpenLayersWidget (or whatever was specified
        in the `widget` attribute) using the settings from the attributes set
        in this class.
        """
        is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
        if is_collection:
            if db_field.geom_type == 'GEOMETRYCOLLECTION':
                collection_type = 'Any'
            else:
                collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
        else:
            collection_type = 'None'

        class OLMap(self.widget):
            template_name = self.map_template
            geom_type = db_field.geom_type

            wms_options = ''
            if self.wms_options:
                wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()]
                wms_options = ', %s' % ', '.join(wms_options)

            params = {'default_lon': self.default_lon,
                      'default_lat': self.default_lat,
                      'default_zoom': self.default_zoom,
                      'display_wkt': self.debug or self.display_wkt,
                      'geom_type': OGRGeomType(db_field.geom_type),
                      'field_name': db_field.name,
                      'is_collection': is_collection,
                      'scrollable': self.scrollable,
                      'layerswitcher': self.layerswitcher,
                      'collection_type': collection_type,
                      'is_generic': db_field.geom_type == 'GEOMETRY',
                      'is_linestring': db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
                      'is_polygon': db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
                      'is_point': db_field.geom_type in ('POINT', 'MULTIPOINT'),
                      'num_zoom': self.num_zoom,
                      'max_zoom': self.max_zoom,
                      'min_zoom': self.min_zoom,
                      'units': self.units,  # likely should get from object
                      'max_resolution': self.max_resolution,
                      'max_extent': self.max_extent,
                      'modifiable': self.modifiable,
                      'mouse_position': self.mouse_position,
                      'scale_text': self.scale_text,
                      'map_width': self.map_width,
                      'map_height': self.map_height,
                      'point_zoom': self.point_zoom,
                      'srid': self.map_srid,
                      'display_srid': self.display_srid,
                      'wms_url': self.wms_url,
                      'wms_layer': self.wms_layer,
                      'wms_name': self.wms_name,
                      'wms_options': wms_options,
                      'debug': self.debug,
                      }
        return OLMap 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:61,代码来源:options.py

示例7: get_map_widget

# 需要导入模块: from django.contrib.gis.admin import widgets [as 别名]
# 或者: from django.contrib.gis.admin.widgets import OpenLayersWidget [as 别名]
def get_map_widget(self, db_field):
        """
        Returns a subclass of the OpenLayersWidget (or whatever was specified
        in the `widget` attribute) using the settings from the attributes set
        in this class.
        """
        is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
        if is_collection:
            if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any'
            else: collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
        else:
            collection_type = 'None'

        class OLMap(self.widget):
            template = self.map_template
            geom_type = db_field.geom_type

            wms_options = ''
            if self.wms_options:
                wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()]
                wms_options = ', %s' % ', '.join(wms_options)

            params = {'default_lon' : self.default_lon,
                      'default_lat' : self.default_lat,
                      'default_zoom' : self.default_zoom,
                      'display_wkt' : self.debug or self.display_wkt,
                      'geom_type' : OGRGeomType(db_field.geom_type),
                      'field_name' : db_field.name,
                      'is_collection' : is_collection,
                      'scrollable' : self.scrollable,
                      'layerswitcher' : self.layerswitcher,
                      'collection_type' : collection_type,
                      'is_generic' : db_field.geom_type == 'GEOMETRY',
                      'is_linestring' : db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
                      'is_polygon' : db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
                      'is_point' : db_field.geom_type in ('POINT', 'MULTIPOINT'),
                      'num_zoom' : self.num_zoom,
                      'max_zoom' : self.max_zoom,
                      'min_zoom' : self.min_zoom,
                      'units' : self.units, #likely shoud get from object
                      'max_resolution' : self.max_resolution,
                      'max_extent' : self.max_extent,
                      'modifiable' : self.modifiable,
                      'mouse_position' : self.mouse_position,
                      'scale_text' : self.scale_text,
                      'map_width' : self.map_width,
                      'map_height' : self.map_height,
                      'point_zoom' : self.point_zoom,
                      'srid' : self.map_srid,
                      'display_srid' : self.display_srid,
                      'wms_url' : self.wms_url,
                      'wms_layer' : self.wms_layer,
                      'wms_name' : self.wms_name,
                      'wms_options' : wms_options,
                      'debug' : self.debug,
                      }
        return OLMap 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:59,代码来源:options.py


注:本文中的django.contrib.gis.admin.widgets.OpenLayersWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。