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


Python measure.Distance方法代码示例

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


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

示例1: testInit

# 需要导入模块: from django.contrib.gis import measure [as 别名]
# 或者: from django.contrib.gis.measure import Distance [as 别名]
def testInit(self):
        "Testing initialization from valid units"
        d = Distance(m=100)
        self.assertEqual(d.m, 100)

        d1, d2, d3 = D(m=100), D(meter=100), D(metre=100)
        for d in (d1, d2, d3):
            self.assertEqual(d.m, 100)

        d = D(nm=100)
        self.assertEqual(d.m, 185200)

        y1, y2, y3 = D(yd=100), D(yard=100), D(Yard=100)
        for d in (y1, y2, y3):
            self.assertEqual(d.yd, 100)

        mm1, mm2 = D(millimeter=1000), D(MiLLiMeTeR=1000)
        for d in (mm1, mm2):
            self.assertEqual(d.m, 1.0)
            self.assertEqual(d.mm, 1000.0) 
开发者ID:nesdis,项目名称:djongo,代码行数:22,代码来源:test_measure.py

示例2: distance

# 需要导入模块: from django.contrib.gis import measure [as 别名]
# 或者: from django.contrib.gis.measure import Distance [as 别名]
def distance(dist):
    if isinstance(dist, Distance):
        d = dist.m
        unit = "m"

        if d > 1000:
            d = dist.km
            unit = "km"

        ctx = {
            'distance': float('%.2g' % d),
            'unit': unit,
        }
        return u"%(distance)s %(unit)s" % ctx 
开发者ID:dulacp,项目名称:django-accounting,代码行数:16,代码来源:distance_filters.py

示例3: from_db_value

# 需要导入模块: from django.contrib.gis import measure [as 别名]
# 或者: from django.contrib.gis.measure import Distance [as 别名]
def from_db_value(self, value, expression, connection, context):
        if value is not None:
            value = Distance(**{self.distance_att: value})
        return value 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:conversion.py

示例4: testUnitsStr

# 需要导入模块: from django.contrib.gis import measure [as 别名]
# 或者: from django.contrib.gis.measure import Distance [as 别名]
def testUnitsStr(self):
        "Testing conversion to strings"
        d1 = D(m=100)
        d2 = D(km=3.5)

        self.assertEqual(str(d1), '100.0 m')
        self.assertEqual(str(d2), '3.5 km')
        self.assertEqual(repr(d1), 'Distance(m=100.0)')
        self.assertEqual(repr(d2), 'Distance(km=3.5)') 
开发者ID:nesdis,项目名称:djongo,代码行数:11,代码来源:test_measure.py

示例5: vicini

# 需要导入模块: from django.contrib.gis import measure [as 别名]
# 或者: from django.contrib.gis.measure import Distance [as 别名]
def vicini(self, queryset, km):
        """
        Filtra una QuerySet per tutti gli oggetti simili vicini, nei pressi di x KM.
        :param km: Raggio di ricerca in kilometri.
        :return: Una ricerca filtrata.
        """
        if not self.locazione:
            return queryset.none()

        return queryset.filter(locazione__geo__distance_lte=(self.locazione.geo, Distance(km=km))) 
开发者ID:CroceRossaItaliana,项目名称:jorvik,代码行数:12,代码来源:geo.py


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