From 3d83594feeb5696fea57a22368a927301fd764e2 Mon Sep 17 00:00:00 2001 From: Eric Bryant Date: Sat, 29 Dec 2018 01:31:00 -0500 Subject: [PATCH 1/2] ignore invalid waypoints Invalid waypoints are denoted by coords of (0,0). For now, only produced by INVALID_URL datacheck. Discussion at #57. --- siteupdate/python-teresco/siteupdate.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/siteupdate/python-teresco/siteupdate.py b/siteupdate/python-teresco/siteupdate.py index 1e62695e..1e4d9c09 100755 --- a/siteupdate/python-teresco/siteupdate.py +++ b/siteupdate/python-teresco/siteupdate.py @@ -267,6 +267,7 @@ def __init__(self,line,route,datacheckerrors): # last has the URL, which needs more work to get lat/lng url_parts = parts[-1].split('=') if len(url_parts) < 3: + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) self.lat = 0 self.lng = 0 @@ -283,18 +284,21 @@ def __init__(self,line,route,datacheckerrors): if lat_string[c] == '.': point_count += 1 if point_count > 1: + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) lat_string = "0" lng_string = "0" break # check for minus sign not at beginning if lat_string[c] == '-' and c > 0: + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) lat_string = "0" lng_string = "0" break # check for invalid characters if lat_string[c] not in "-.0123456789": + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) lat_string = "0" lng_string = "0" @@ -307,18 +311,21 @@ def __init__(self,line,route,datacheckerrors): if lng_string[c] == '.': point_count += 1 if point_count > 1: + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) lat_string = "0" lng_string = "0" break # check for minus sign not at beginning if lng_string[c] == '-' and c > 0: + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) lat_string = "0" lng_string = "0" break # check for invalid characters if lng_string[c] not in "-.0123456789": + #print("\nWARNING: Malformed URL in " + route.root + ", line: " + line, end="", flush=True) datacheckerrors.append(DatacheckEntry(route,[self.label],'MALFORMED_URL', parts[-1])) lat_string = "0" lng_string = "0" @@ -644,6 +651,9 @@ def is_or_colocated_with_active_or_preview(self): return True return False + def is_valid(self): + return self.lat != 0.0 or self.lng != 0.0 + class HighwaySegment: """This class represents one highway segment: the connection between two Waypoints connected by one or more routes""" @@ -770,6 +780,9 @@ def read_wpt(self,all_waypoints,all_waypoints_lock,datacheckerrors,el,path="../. if len(line) > 0: previous_point = w w = Waypoint(line,self,datacheckerrors) + if w.is_valid() == False: + w = previous_point + continue self.point_list.append(w) # populate unused alt labels for label in w.alt_labels: From 2a8714a410c0aac5e447264dc96b57a40031d375 Mon Sep 17 00:00:00 2001 From: Eric Bryant Date: Tue, 1 Jan 2019 04:42:06 -0500 Subject: [PATCH 2/2] system graphs from systemgraphs.csv (#88) --- siteupdate/python-teresco/siteupdate.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/siteupdate/python-teresco/siteupdate.py b/siteupdate/python-teresco/siteupdate.py index f9d9f9fb..832a768d 100755 --- a/siteupdate/python-teresco/siteupdate.py +++ b/siteupdate/python-teresco/siteupdate.py @@ -2878,7 +2878,7 @@ def run(self): 'These graphs contain all routes currently plotted in the Travel Mapping project.']) # graphs restricted by place/area - from areagraphs.csv file - print(et.et() + "Creating area data graphs.", flush=True) + print(et.et() + "\nCreating area data graphs.", flush=True) with open(args.highwaydatapath+"/graphs/areagraphs.csv", "rt",encoding='utf-8') as file: lines = file.readlines() lines.pop(0); # ignore header line @@ -2920,16 +2920,19 @@ def run(self): 'These graphs contain all routes currently plotted within the given region.']) print("!") - # Graphs restricted by system + # Graphs restricted by system - from systemgraphs.csv file print(et.et() + "Creating system data graphs.", flush=True) # We will create graph data and a graph file for only a few interesting # systems, as many are not useful on their own h = None - for hname in ['usai', 'usaus', 'cantch', 'eure']: + with open(args.highwaydatapath+"/graphs/systemgraphs.csv", "rt",encoding='utf-8') as file: + lines = file.readlines() + lines.pop(0); # ignore header line + for hname in lines: h = None for hs in highway_systems: - if hs.systemname == hname: + if hs.systemname == hname.strip(): h = hs break if h is not None: