Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create_delta_list_hero(file, city, province):
- with open(file) as json_file:
- json_data = json.load(json_file)
- lista = []
- link = "https://geocode.search.hereapi.com/v1/geocode?q="
- key = "&apiKey=ZNdP6ytzdqUuIaTudctEdR4Zv-L0_s8mhJoI6k1AF1s"
- for p in json_data['features']:
- s = pref_via(p['pref_via'])
- if s == "":
- continue
- else:
- via = s + "+" + p['nome_via'] + "+" + str(p['num_civico']) + "+" + city + "+" + province
- uri = link + via + key
- x = requests.get(uri)
- data = x.json()
- wgs84 = parse_tuple(p['coord_wgs84'])
- lat = wgs84[1]
- lng = wgs84[0]
- if data["items"] == []:
- continue
- print("warning")
- #print(data["items"][0]["scoring"]["queryScore"])
- if data["items"][0]["scoring"]["queryScore"] > 0.98:
- print(data["items"][0]["scoring"]["queryScore"])
- delta_x = data["items"][0]["position"]["lng"] - lng
- delta_y = data["items"][0]["position"]["lat"] - lat
- lista.append([delta_x, delta_y])
- #print(delta_x, delta_y)
- return lista
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement