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


Python sql.AreaField方法代码示例

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


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

示例1: as_sql

# 需要导入模块: from django.contrib.gis.db.models import sql [as 别名]
# 或者: from django.contrib.gis.db.models.sql import AreaField [as 别名]
def as_sql(self, compiler, connection):
        if connection.ops.geography:
            # Geography fields support area calculation, returns square meters.
            self.output_field = AreaField('sq_m')
        elif not self.output_field.geodetic(connection):
            # Getting the area units of the geographic field.
            units = self.output_field.units_name(connection)
            if units:
                self.output_field = AreaField(
                    AreaMeasure.unit_attname(self.output_field.units_name(connection))
                )
            else:
                self.output_field = FloatField()
        else:
            # TODO: Do we want to support raw number areas for geodetic fields?
            raise NotImplementedError('Area on geodetic coordinate systems not supported.')
        return super(Area, self).as_sql(compiler, connection) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:19,代码来源:functions.py

示例2: as_oracle

# 需要导入模块: from django.contrib.gis.db.models import sql [as 别名]
# 或者: from django.contrib.gis.db.models.sql import AreaField [as 别名]
def as_oracle(self, compiler, connection):
        self.output_field = AreaField('sq_m')  # Oracle returns area in units of meters.
        return super(Area, self).as_oracle(compiler, connection) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:5,代码来源:functions.py

示例3: area

# 需要导入模块: from django.contrib.gis.db.models import sql [as 别名]
# 或者: from django.contrib.gis.db.models.sql import AreaField [as 别名]
def area(self, tolerance=0.05, **kwargs):
        """
        Returns the area of the geographic field in an `area` attribute on
        each element of this GeoQuerySet.
        """
        # Peforming setup here rather than in `_spatial_attribute` so that
        # we can get the units for `AreaField`.
        procedure_args, geo_field = self._spatial_setup('area', field_name=kwargs.get('field_name', None))
        s = {'procedure_args' : procedure_args,
             'geo_field' : geo_field,
             'setup' : False,
             }
        connection = connections[self.db]
        backend = connection.ops
        if backend.oracle:
            s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s'
            s['procedure_args']['tolerance'] = tolerance
            s['select_field'] = AreaField('sq_m') # Oracle returns area in units of meters.
        elif backend.postgis or backend.spatialite:
            if backend.geography:
                # Geography fields support area calculation, returns square meters.
                s['select_field'] = AreaField('sq_m')
            elif not geo_field.geodetic(connection):
                # Getting the area units of the geographic field.
                s['select_field'] = AreaField(Area.unit_attname(geo_field.units_name(connection)))
            else:
                # TODO: Do we want to support raw number areas for geodetic fields?
                raise Exception('Area on geodetic coordinate systems not supported.')
        return self._spatial_attribute('area', s, **kwargs) 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:31,代码来源:query.py


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