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


Python geohash.decode方法代码示例

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


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

示例1: decode

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def decode(self, words):
        """Decode `words` to latitude and longitude"""
        words = words.split("-")
        if len(words) == 3:
            i = self.rugbits_to_int([self.three_wordlist.index(w) for w in words])

        elif len(words) == 4:
            i = self.quads_to_int([self.four_wordlist.index(w) for w in words])
            i = self.unpad(i)

        elif len(words) == 6:
            i = self.bytes_to_int([self.six_wordlist.index(w) for w in words])
            i = self.unpad(i)

        else:
            raise RuntimeError("Do not know how to decode a set of %i words."%(len(words)))

        geo_hash = self.int_to_geo(i)
        return geohash.decode(geo_hash) 
开发者ID:Placeware,项目名称:ThisPlace,代码行数:21,代码来源:thisplace.py

示例2: geohash_decode

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def geohash_decode(
    df: DataFrame, geohash: str, longitude: str, latitude: str
) -> DataFrame:
    """
    Decode a geohash column into longitude and latitude

    :param df: DataFrame containing geohash data
    :param geohash: Name of source column containing geohash location.
    :param longitude: Name of new column to be created containing longitude.
    :param latitude: Name of new column to be created containing latitude.
    :return: DataFrame with decoded longitudes and latitudes
    """
    try:
        lonlat_df = DataFrame()
        lonlat_df["latitude"], lonlat_df["longitude"] = zip(
            *df[geohash].apply(geohash_lib.decode)
        )
        return _append_columns(
            df, lonlat_df, {"latitude": latitude, "longitude": longitude}
        )
    except ValueError:
        raise QueryObjectValidationError(_("Invalid geohash string")) 
开发者ID:apache,项目名称:incubator-superset,代码行数:24,代码来源:pandas_postprocessing.py

示例3: search

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def search(ghash):
    latitude, longitude = geohash.decode(ghash)
    return _search(latitude, longitude) 
开发者ID:uol,项目名称:geo-br,代码行数:5,代码来源:sapp.py

示例4: test_decode

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def test_decode(self):
    for test, expect in self.test_geohashes:
      value = geohash.decode(test)
      self.assertAlmostEqual(value[0], expect[0])
      self.assertAlmostEqual(value[1], expect[1]) 
开发者ID:transitland,项目名称:mapzen-geohash,代码行数:7,代码来源:test_geohash.py

示例5: test_roundtrip

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def test_roundtrip(self):
    for test, expect in self.test_geohashes:
      encoded = geohash.decode(test)
      decoded = geohash.encode(encoded)
      assert test == decoded 
开发者ID:transitland,项目名称:mapzen-geohash,代码行数:7,代码来源:test_geohash.py

示例6: reverse_geohash_decode

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def reverse_geohash_decode(geohash_code: str) -> Tuple[str, str]:
        lat, lng = geohash.decode(geohash_code)
        return (lng, lat) 
开发者ID:apache,项目名称:incubator-superset,代码行数:5,代码来源:viz.py

示例7: reverse_geohash_decode

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def reverse_geohash_decode(geohash_code):
        lat, lng = geohash.decode(geohash_code)
        return (lng, lat) 
开发者ID:apache,项目名称:incubator-superset,代码行数:5,代码来源:viz_sip38.py

示例8: from_python

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def from_python(self, value, validate=False):
        try:
            return base64.b64encode(value).decode()
        except (ValueError, TypeError):
            if validate:
                raise ValidationError(
                    'Cannot decode value from base64: {!r}'.format(value)
                )
            else:
                raise 
开发者ID:anti-social,项目名称:elasticmagic,代码行数:12,代码来源:types.py

示例9: to_python

# 需要导入模块: import geohash [as 别名]
# 或者: from geohash import decode [as 别名]
def to_python(self, value):
        if value is None:
            return None
        if isinstance(value, (list, tuple)):
            value = list(reversed(value))
        if isinstance(value, string_types):
            if self.LAT_LON_SEPARATOR in value:
                value = list(value.split(self.LAT_LON_SEPARATOR))
            elif GEOHASH_IMPORTED:
                value = list(geohash.decode(value))
        elif isinstance(value, dict):
            value = [value.get('lat'), value.get('lon')]
        return {'lat': float(value[0]), 'lon': float(value[1])} 
开发者ID:anti-social,项目名称:elasticmagic,代码行数:15,代码来源:types.py


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