Geohash/geohash.py
def decode_exactly(geohash):
    """
    Decode the geohash to its exact values, including the error
    margins of the result.  Returns four float values: latitude,
    longitude, the plus/minus error for latitude (as a positive
    number) and the plus/minus error for longitude (as a positive
    number).
    """
    lat_interval, lon_interval = (-90.0, 90.0), (-180.0, 180.0)
    lat_err, lon_err = 90.0, 180.0
    is_even = True
    for c in geohash:
        cd = __decodemap[c]
        for mask in [16, 8, 4, 2, 1]:
            if is_even: # adds longitude info
                lon_err /= 2
                if cd & mask:
                    lon_interval = ((lon_interval[0]+lon_interval[1])/2, lon_interval[1])
                else:
                    lon_interval = (lon_interval[0], (lon_interval[0]+lon_interval[1])/2)
            else:      # adds latitude info
                lat_err /= 2
                if cd & mask:
                    lat_interval = ((lat_interval[0]+lat_interval[1])/2, lat_interval[1])
                else:
                    lat_interval = (lat_interval[0], (lat_interval[0]+lat_interval[1])/2)
            is_even = not is_even
    lat = (lat_interval[0] + lat_interval[1]) / 2
    lon = (lon_interval[0] + lon_interval[1]) / 2
    return lat, lon, lat_err, lon_err
def decode_exactly(geohash):
    """
    Decode the geohash to its exact values, including the error
    margins of the result.  Returns four float values: latitude,
    longitude, the plus/minus error for latitude (as a positive
    number) and the plus/minus error for longitude (as a positive
    number).
    """
    lat_interval, lon_interval = (-90.0, 90.0), (-180.0, 180.0)
    lat_err, lon_err = 90.0, 180.0
    is_even = True
    for c in geohash:
        cd = __decodemap[c]
        for mask in [16, 8, 4, 2, 1]:
            if is_even: # adds longitude info
                lon_err /= 2
                if cd & mask:
                    lon_interval = ((lon_interval[0]+lon_interval[1])/2, lon_interval[1])
                else:
                    lon_interval = (lon_interval[0], (lon_interval[0]+lon_interval[1])/2)
            else:      # adds latitude info
                lat_err /= 2
                if cd & mask:
                    lat_interval = ((lat_interval[0]+lat_interval[1])/2, lat_interval[1])
                else:
                    lat_interval = (lat_interval[0], (lat_interval[0]+lat_interval[1])/2)
            is_even = not is_even
    lat = (lat_interval[0] + lat_interval[1]) / 2
    lon = (lon_interval[0] + lon_interval[1]) / 2
    return lat, lon, lat_err, lon_err
def decode_exactly ( geohash ) : lat_interval , lon_interval = ( - 90.0 , 90.0 ) , ( - 180.0 , 180.0 ) lat_err , lon_err = 90.0 , 180.0 is_even = True for c in geohash : cd = __decodemap [ c ] for mask in [ 16 , 8 , 4 , 2 , 1 ] : if is_even : # adds longitude info lon_err /= 2 if cd & mask : lon_interval = ( ( lon_interval [ 0 ] + lon_interval [ 1 ] ) / 2 , lon_interval [ 1 ] ) else : lon_interval = ( lon_interval [ 0 ] , ( lon_interval [ 0 ] + lon_interval [ 1 ] ) / 2 ) else : # adds latitude info lat_err /= 2 if cd & mask : lat_interval = ( ( lat_interval [ 0 ] + lat_interval [ 1 ] ) / 2 , lat_interval [ 1 ] ) else : lat_interval = ( lat_interval [ 0 ] , ( lat_interval [ 0 ] + lat_interval [ 1 ] ) / 2 ) is_even = not is_even lat = ( lat_interval [ 0 ] + lat_interval [ 1 ] ) / 2 lon = ( lon_interval [ 0 ] + lon_interval [ 1 ] ) / 2 return lat , lon , lat_err , lon_err
Decode the geohash to its exact values, including the error
    margins of the result.  Returns four float values: latitude,
    longitude, the plus/minus error for latitude (as a positive
    number) and the plus/minus error for longitude (as a positive
    number).
Decode the geohash to its exact values including the error margins of the result . Returns four float values : latitude longitude the plus / minus error for latitude ( as a positive number ) and the plus / minus error for longitude ( as a positive number ) .