當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。