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


Python fields.BaseSpatialField方法代码示例

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


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

示例1: column_sql

# 需要导入模块: from django.contrib.gis.db.models import fields [as 别名]
# 或者: from django.contrib.gis.db.models.fields import BaseSpatialField [as 别名]
def column_sql(self, model, field, include_default=False):
        from django.contrib.gis.db.models.fields import BaseSpatialField
        if not isinstance(field, BaseSpatialField):
            return super(PostGISSchemaEditor, self).column_sql(model, field, include_default)

        column_sql = super(PostGISSchemaEditor, self).column_sql(model, field, include_default)

        if field.spatial_index:
            # Spatial indexes created the same way for both Geometry and
            # Geography columns.
            field_column = self.quote_name(field.column)
            if field.geom_type == 'RASTER':
                # For raster fields, wrap index creation SQL statement with ST_ConvexHull.
                # Indexes on raster columns are based on the convex hull of the raster.
                field_column = self.rast_index_wrapper % field_column
                index_ops = ''
            elif field.geography:
                index_ops = ''
            else:
                # Use either "nd" ops  which are fast on multidimensional cases
                # or just plain gist index for the 2d case.
                if field.dim > 2:
                    index_ops = self.geom_index_ops_nd
                else:
                    index_ops = ''
            self.geometry_sql.append(
                self.sql_add_spatial_index % {
                    "index": self.quote_name('%s_%s_id' % (model._meta.db_table, field.column)),
                    "table": self.quote_name(model._meta.db_table),
                    "column": field_column,
                    "index_type": self.geom_index_type,
                    "ops": index_ops,
                }
            )
        return column_sql 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:37,代码来源:schema.py

示例2: _check_geo_field

# 需要导入模块: from django.contrib.gis.db.models import fields [as 别名]
# 或者: from django.contrib.gis.db.models.fields import BaseSpatialField [as 别名]
def _check_geo_field(cls, opts, lookup):
        """
        Utility for checking the given lookup with the given model options.
        The lookup is a string either specifying the geographic field, e.g.
        'point, 'the_geom', or a related lookup on a geographic field like
        'address__point'.

        If a BaseSpatialField exists according to the given lookup on the model
        options, it will be returned. Otherwise return None.
        """
        from django.contrib.gis.db.models.fields import BaseSpatialField
        # This takes into account the situation where the lookup is a
        # lookup to a related geographic field, e.g., 'address__point'.
        field_list = lookup.split(LOOKUP_SEP)

        # Reversing so list operates like a queue of related lookups,
        # and popping the top lookup.
        field_list.reverse()
        fld_name = field_list.pop()

        try:
            geo_fld = opts.get_field(fld_name)
            # If the field list is still around, then it means that the
            # lookup was for a geometry field across a relationship --
            # thus we keep on getting the related model options and the
            # model field associated with the next field in the list
            # until there's no more left.
            while len(field_list):
                opts = geo_fld.remote_field.model._meta
                geo_fld = opts.get_field(field_list.pop())
        except (FieldDoesNotExist, AttributeError):
            return False

        # Finally, make sure we got a Geographic field and return.
        if isinstance(geo_fld, BaseSpatialField):
            return geo_fld
        else:
            return False 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:40,代码来源:lookups.py


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