mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-07 03:33:39 +02:00
Function to get longitude and latitude from certain query to OSM.
This commit is contained in:
parent
c4711310ce
commit
309cd191af
1 changed files with 9 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
import requests, json
|
||||||
|
|
||||||
def get_district(article_headline):
|
def get_district(article_headline):
|
||||||
"""
|
"""
|
||||||
Returns a geo-coded version of a district an article is about, based on its
|
Returns a geo-coded version of a district an article is about, based on its
|
||||||
|
|
@ -23,3 +25,10 @@ def get_categories(article_body):
|
||||||
found_categories = [bad_words[key] for key in bad_words
|
found_categories = [bad_words[key] for key in bad_words
|
||||||
if key in article_body.lower()]
|
if key in article_body.lower()]
|
||||||
return found_categories or ['other']
|
return found_categories or ['other']
|
||||||
|
|
||||||
|
def get_geoloc(query):
|
||||||
|
query.replace(" ", "%20")
|
||||||
|
url = "http://nominatim.openstreetmap.org/search?q=" + query + "%20Berlin" + "&countrycodes=de&format=json&limit=1"
|
||||||
|
r = requests.get(url)
|
||||||
|
|
||||||
|
return(r.json()[0]["lat"], r.json()[0]["lon"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue