Commit a94935c2 authored by Min Gao's avatar Min Gao
Browse files

add identifySubrubMapquest

parent 55d57a20
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
COMP90024 Cluster and Cloud Computing Assignment 2
Australian City Analytics
Team : Team 19
City :
Names :
Student IDs :
PURPOSE : identify coordinate in which suburb by mapquest API
VERSION : 1
DATE : 4/2017
"""
import requests
KEY = 'X2ud5g0q6mkeGgnPOAgFP3BhNcXy2Vo3'
def identifySub(lat, lon):
url = ('http://open.mapquestapi.com/nominatim/v1/reverse.php?' +
'key=%s&format=json&lat=%f&lon=%f'% (KEY, float(lat), float(lon)))
try:
feedback = requests.get(url).json()['address']
return feedback['suburb']
except:
return None
if __name__ == '__main__':
print(identifySub(-37.823715, 144.963305)) #southbank
print(identifySub(-37.797353, 144.960854)) #melbourne
print(identifySub(0, 0)) #None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment