Skip to content

Commit

Permalink
google api and minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pizzibee committed Jul 19, 2018
1 parent 108d823 commit ae9e9c3
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 378 deletions.
Binary file not shown.
44 changes: 0 additions & 44 deletions backend/api/management/commands/geocode/geocode.py

This file was deleted.

16 changes: 9 additions & 7 deletions backend/api/management/commands/importDetailedHospitals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
from api.models import Hospital
from django.conf import settings
from datetime import date
from api.utils import geocode

def isInt(value):
try:
int(eval(value))
int(eval(str(value)))
return True
except:
return False
Expand All @@ -38,20 +39,21 @@ def parse_hospital_data():

def transform_hospital_data(row):
geolocator = Nominatim()
location = geolocator.geocode(row["ADRES"] + " " + str(row["POST"]) + " " + row["GEMEENTE "])
location = geolocator.geocode(row["ADRES"] + " " + str(row["POST"]) + " " + row["GEMEENTE "] + " " + ", Belgium")
if not location:
lat = "" #todo : add google api in case Nominatim does not work
long = ""
googleResponse = geocode.get_google_results(row["ADRES"] + " " + str(row["POST"]) + " " + row["GEMEENTE "] + " " + ", Belgium", "AIzaSyC9D0vXh84s4FYro6IiZDA08xDOf5ac6Z8")
lat = googleResponse["latitude"]
long = googleResponse["longitude"]
else:
lat = location.latitude
long = location.longitude
if not isInt(row['TOTAAL BEDDEN']):
if not isInt(str(row['TOTAAL BEDDEN'])):
beds = 0
else:
beds = int(eval(row["TOTAAL BEDDEN"]))
beds = int(eval(str(row["TOTAAL BEDDEN"])))
try:
p = Hospital(name=row['ZIEKENHUIS '], latitude=lat, longitude=long, nbBeds=beds,
siteNbr=int(eval(row["VESTIGINGSNR"])), address=row["ADRES"], postalCode=int(eval(row["POST"])),
siteNbr=int(eval(str(row["VESTIGINGSNR"]))), address=row["ADRES"], postalCode=int(eval(str(row["POST"]))),
town=row["GEMEENTE "], website=row["WEBSITE"], telephone=row["TELEFOON"], province=row["PROVINCIE "], type=row["SOORT ZIEKENHUIS"])
yield p
except:
Expand Down
42 changes: 0 additions & 42 deletions backend/api/management/commands/importhospitals.py

This file was deleted.

3 changes: 0 additions & 3 deletions backend/api/management/commands/main.py

This file was deleted.

Binary file removed backend/api/source-data/example_geocode.xlsx
Binary file not shown.
Loading

0 comments on commit ae9e9c3

Please sign in to comment.