#!/usr/bin/python
#  -*- coding: utf-8 -*-
# ~/bin/olc-2-lat-long.py (executable!) # chmod +x ~/bin/olc-2-lat-long.py
# ------------------------------------------------------------------------------
# Marc Meurrens June 2019
# Convert Open Location Code to (Latitude, Lontitude) of the center 
# ------------------------------------------------------------------------------
# see also : < lat-long-nr-2-olc.py > and < olc.py > and < lat-long-2-olc.py > (by Daniel Debaste)
# all these scripts are located in ~/bin
# ------------------------------------------------------------------------------

import sys

openlocationcode = sys.argv[1] # e.g. 9F26R8P5+2VW (Brussels) # 8C9QPH54+M4R (Málaga)
# print openlocationcode

# sys.path.append('/.geoloc/scripts/python') # obsolete
import olc

coord = olc.decode(openlocationcode)
center = "{lat}, {lon}".format(lat=coord.latitudeCenter, lon=coord.longitudeCenter)
print center

exit(0)

# $ olc-2-lat-long.py 9F26R8P5+2VW
# 50.8351125, 4.309703125
# $ olc-2-lat-long.py 9F26R8P5+
# 50.83625, 4.30875

# $ olc-2-lat-long.py 8C9QPH54+M4R
# 37.7092375, -4.444734375
# $ olc-2-lat-long.py 8C9QPH54+
# 37.70875, -4.44375
# $ olc-2-lat-long.py 8C9QPH54+M4
# 37.7091875, -4.4446875

