Skip to content

Commit

Permalink
Fixed geocode-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Dec 19, 2018
2 parents 85cac0a + 31e5023 commit a35cf87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lbsntransform/classes/helper_functions.py
Expand Up @@ -385,16 +385,18 @@ def AddRelationshipToDict(self,newrelationship):
self.update_keyHash(newrelationship) # update keyHash only necessary for new record

class GeocodeLocations():
"""Class for geocoding of text to lat/lng values.
"""
def __init__(self):
self.geocodeDict = dict()
self.geocode_dict = dict()

def load_geocodelist(self,file):
def load_geocodelist(self, file):
with open(file, newline='', encoding='utf8') as f: #read each unsorted file and sort lines based on datetime (as string)
#next(f) #Skip Headerrow
locationfile_list = csv.reader(f, delimiter=',', quotechar='', quoting=csv.QUOTE_NONE)
for location_geocode in locationfile_list:
self.geocodeDict[location_geocode[2].replace(';',',')] = (float(location_geocode[0]),location_geocode[1]) # lat/lng
print(f'Loaded {len(self.geocodeDict)} geocodes.')
self.geocode_dict[location_geocode[2].replace(';',',')] = (float(location_geocode[0]),location_geocode[1]) # lat/lng
print(f'Loaded {len(self.geocode_dict)} geocodes.')

class TimeMonitor():
def __init__(self):
Expand Down
3 changes: 2 additions & 1 deletion lbsntransform/classes/load_data.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from .db_connection import DBConnection
from .helper_functions import HelperFunctions as HF
from .helper_functions import GeocodeLocations
from glob import glob
from json import loads as json_loads, decoder as json_decoder
import os
Expand Down Expand Up @@ -180,7 +181,7 @@ def read_local_files(config):

def load_geocodes(geo_config):
"""Loads coordinates-string tuples for geocoding text locations (Optional)"""
locationsgeocode_dict = geocodeLocations()
locationsgeocode_dict = GeocodeLocations()
locationsgeocode_dict.load_geocodelist(geo_config)
geocode_dict = locationsgeocode_dict.geocode_dict
return geocode_dict
Expand Down

0 comments on commit a35cf87

Please sign in to comment.