本文整理汇总了Python中ichnaea.geocode.GEOCODER.region_max_radius方法的典型用法代码示例。如果您正苦于以下问题:Python GEOCODER.region_max_radius方法的具体用法?Python GEOCODER.region_max_radius怎么用?Python GEOCODER.region_max_radius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ichnaea.geocode.GEOCODER
的用法示例。
在下文中一共展示了GEOCODER.region_max_radius方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: radius
# 需要导入模块: from ichnaea.geocode import GEOCODER [as 别名]
# 或者: from ichnaea.geocode.GEOCODER import region_max_radius [as 别名]
def radius(self, code, subs=None, city=None, default=REGION_RADIUS):
"""
Return the best radius guess for the given region code.
:param code: A two-letter region code.
:type code: str
:param subs: A list of ISO subdivision codes.
:type code: list
:param city: A geoname_id from a city record or None.
:type city: int
:returns: A tuple of radius/region radius guesses in meters.
:rtype: tuple
"""
region_radius = GEOCODER.region_max_radius(code)
if region_radius is None:
# No region code or no successful radius lookup
region_radius = default
# Use region radius as an upper bound for city / subdivision
# radius for really small regions. E.g. Vatican City cannot
# be larger than the Vatican as a region.
radius = region_radius
if subs:
radius = min(SUB_RADII.get(code, SUB_RADIUS), radius)
if city:
radius = min(CITY_RADII.get(city, CITY_RADIUS), radius)
return (radius, region_radius)
示例2: test_max_radius_fail
# 需要导入模块: from ichnaea.geocode import GEOCODER [as 别名]
# 或者: from ichnaea.geocode.GEOCODER import region_max_radius [as 别名]
def test_max_radius_fail(self):
for invalid in (None, 42, 'A', 'us', 'USA', 'AA'):
self.assertTrue(GEOCODER.region_max_radius(invalid) is None)
示例3: test_max_radius
# 需要导入模块: from ichnaea.geocode import GEOCODER [as 别名]
# 或者: from ichnaea.geocode.GEOCODER import region_max_radius [as 别名]
def test_max_radius(self):
self.assertEqual(GEOCODER.region_max_radius('US'), 2971000.0)
self.assertEqual(GEOCODER.region_max_radius('LI'), 14000.0)
self.assertEqual(GEOCODER.region_max_radius('VA'), 1000.0)
示例4:
# 需要导入模块: from ichnaea.geocode import GEOCODER [as 别名]
# 或者: from ichnaea.geocode.GEOCODER import region_max_radius [as 别名]
'ratelimit_expire': '60',
'ratelimit_interval': '5',
'cache_expire': '60',
},
})
GEOIP_DATA = {
'London': {
'city': True,
'region_code': 'GB',
'region_name': 'United Kingdom',
'ip': '81.2.69.192',
'latitude': 51.5142,
'longitude': -0.0931,
'radius': CITY_RADII[2643743],
'region_radius': GEOCODER.region_max_radius('GB'),
'score': 0.8,
},
'Bhutan': {
'city': False,
'region_code': 'BT',
'region_name': 'Bhutan',
'ip': '67.43.156.1',
'latitude': 27.5,
'longitude': 90.5,
'radius': GEOCODER.region_max_radius('BT'),
'region_radius': GEOCODER.region_max_radius('BT'),
'score': 0.9,
},
}
示例5: test_max_radius
# 需要导入模块: from ichnaea.geocode import GEOCODER [as 别名]
# 或者: from ichnaea.geocode.GEOCODER import region_max_radius [as 别名]
def test_max_radius(self):
assert GEOCODER.region_max_radius('US') == 2971000.0
assert GEOCODER.region_max_radius('LI') == 14000.0
assert GEOCODER.region_max_radius('VA') == 1000.0