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


Python Distance.unit_attname方法代码示例

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


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

示例1: get_distance

# 需要导入模块: from django.contrib.gis.measure import Distance [as 别名]
# 或者: from django.contrib.gis.measure.Distance import unit_attname [as 别名]
def get_distance(self, f, value, lookup_type):
        """
        Returns the distance parameters given the value and the lookup type.
        On Oracle, geometry columns with a geodetic coordinate system behave
        implicitly like a geography column, and thus meters will be used as
        the distance parameter on them.
        """
        if not value:
            return []
        value = value[0]
        if isinstance(value, Distance):
            if f.geodetic(self.connection):
                dist_param = value.m
            else:
                dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
        else:
            dist_param = value

        # dwithin lookups on Oracle require a special string parameter
        # that starts with "distance=".
        if lookup_type == 'dwithin':
            dist_param = 'distance=%s' % dist_param

        return [dist_param] 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:26,代码来源:operations.py

示例2: get_distance

# 需要导入模块: from django.contrib.gis.measure import Distance [as 别名]
# 或者: from django.contrib.gis.measure.Distance import unit_attname [as 别名]
def get_distance(self, f, value, lookup_type):
        """
        Returns the distance parameters for the given geometry field,
        lookup value, and lookup type.  SpatiaLite only supports regular
        cartesian-based queries (no spheroid/sphere calculations for point
        geometries like PostGIS).
        """
        if not value:
            return []
        value = value[0]
        if isinstance(value, Distance):
            if f.geodetic(self.connection):
                raise ValueError('SpatiaLite does not support distance queries on '
                                 'geometry fields with a geodetic coordinate system. '
                                 'Distance objects; use a numeric value of your '
                                 'distance in degrees instead.')
            else:
                dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
        else:
            dist_param = value
        return [dist_param] 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:23,代码来源:operations.py

示例3: get_distance

# 需要导入模块: from django.contrib.gis.measure import Distance [as 别名]
# 或者: from django.contrib.gis.measure.Distance import unit_attname [as 别名]
def get_distance(self, f, value, lookup_type, **kwargs):
        """
        Returns the distance parameters given the value and the lookup type.
        On Oracle, geometry columns with a geodetic coordinate system behave
        implicitly like a geography column, and thus meters will be used as
        the distance parameter on them.
        """
        if not value:
            return []
        value = value[0]
        if isinstance(value, Distance):
            if f.geodetic(self.connection):
                dist_param = value.m
            else:
                dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
        else:
            dist_param = value

        # dwithin lookups on Oracle require a special string parameter
        # that starts with "distance=".
        if lookup_type == 'dwithin':
            dist_param = 'distance=%s' % dist_param

        return [dist_param] 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:26,代码来源:operations.py

示例4: get_distance

# 需要导入模块: from django.contrib.gis.measure import Distance [as 别名]
# 或者: from django.contrib.gis.measure.Distance import unit_attname [as 别名]
def get_distance(self, f, value, lookup_type, **kwargs):
        """
        Returns the distance parameters for the given geometry field,
        lookup value, and lookup type.  SpatiaLite only supports regular
        cartesian-based queries (no spheroid/sphere calculations for point
        geometries like PostGIS).
        """
        if not value:
            return []
        value = value[0]
        if isinstance(value, Distance):
            if f.geodetic(self.connection):
                raise ValueError('SpatiaLite does not support distance queries on '
                                 'geometry fields with a geodetic coordinate system. '
                                 'Distance objects; use a numeric value of your '
                                 'distance in degrees instead.')
            else:
                dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
        else:
            dist_param = value
        return [dist_param] 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:23,代码来源:operations.py

示例5: get_distance

# 需要导入模块: from django.contrib.gis.measure import Distance [as 别名]
# 或者: from django.contrib.gis.measure.Distance import unit_attname [as 别名]
def get_distance(self, f, value, lookup_type, **kwargs):
        """
        Returns the distance parameters for the given geometry field,
        lookup value, and lookup type.
        """
        if not value:
            return []
        value = value[0]
        if isinstance(value, Distance):
            if f.geodetic(self.connection):
                if lookup_type == 'dwithin':
                    raise ValueError(
                        'Only numeric values of degree units are allowed on '
                        'geographic DWithin queries.'
                    )
                dist_param = value.m
            else:
                dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
        else:
            dist_param = value
        return [dist_param] 
开发者ID:prakharchoudhary,项目名称:Scrum,代码行数:23,代码来源:operations.py

示例6: get_distance

# 需要导入模块: from django.contrib.gis.measure import Distance [as 别名]
# 或者: from django.contrib.gis.measure.Distance import unit_attname [as 别名]
def get_distance(self, f, value, lookup_type):
        """
        Returns the distance parameters given the value and the lookup type.
        On Oracle, geometry columns with a geodetic coordinate system behave
        implicitly like a geography column, and thus meters will be used as
        the distance parameter on them.
        """
        if not value:
            return []
        value = value[0]
        if isinstance(value, Distance):
            if f.geodetic(self.connection):
                dist_param = value.m
            else:
                dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
        else:
            dist_param = value

        # dwithin lookups on oracle require a special string parameter
        # that starts with "distance=".
        if lookup_type == 'dwithin':
            dist_param = 'distance=%s' % dist_param

        return [dist_param] 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:26,代码来源:operations.py


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