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