Compare commits

..

No commits in common. "8445b404bbf638a21b949ae2740e6f7cfe28b8bb" and "ab5959075d380fa2dd598b2ab31fb5f43283f5c6" have entirely different histories.

2 changed files with 1 additions and 7 deletions

View File

@ -4,7 +4,6 @@ version = "0.1.0"
description = ""
authors = ["Chris <chris@chrisproctor.net>"]
license = "MIT"
packages = [ { include = "weather"} ]
[tool.poetry.dependencies]
python = "^3.10"

View File

@ -13,13 +13,8 @@
# You will need to use these functions, but you don't need to edit this file.
import geocoder
from geocoder.osm import OsmQuery
import requests
class OsmQueryWithHeaders(OsmQuery):
def _build_headers(self, provider_key, **kwargs):
return {"User-Agent": "Making With Code CS Curriculum"}
def geocode_location(location_string):
"""Translates a location string into latitude and longitude coordinates.
Uses the OpenStreetMap API. Returns a dict with keys 'lat' and 'lng'
@ -28,7 +23,7 @@ def geocode_location(location_string):
>>> geocode_location('11 Wall Street, New York')
{"lat": -74.010865, "lng": 40.7071407}
"""
result = OsmQueryWithHeaders(location_string)
result = geocoder.osm(location_string)
if result:
lat, lng = result.latlng
return {'lat': lat, 'lng': lng}