Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions siteupdate/cplusplus/classes/GraphGeneration/HGVertex.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,9 +19,6 @@ HGVertex::HGVertex(Waypoint *wpt, const std::string *n, unsigned int numthreads)
// 0: never visible outside of simple graphs
// 1: visible only in traveled graph; hidden in collapsed graph
// 2: visible in both traveled & collapsed graphs
// note: if saving the first waypoint, no longer need
// lat & lng and can replace with methods
first_waypoint = wpt;
if (!wpt->colocated)
{ if (!wpt->is_hidden) visibility = 2;
wpt->route->region->vertices.insert(this);
Expand Down
1 change: 0 additions & 1 deletion siteupdate/cplusplus/classes/GraphGeneration/HGVertex.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,6 @@ class HGVertex
double lat, lng;
const std::string *unique_name;
char visibility;
Waypoint *first_waypoint;
std::list<HGEdge*> incident_s_edges; // simple
std::list<HGEdge*> incident_c_edges; // collapsed
std::list<HGEdge*> incident_t_edges; // traveled
Expand Down
10 changes: 8 additions & 2 deletions siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -346,15 +346,21 @@ void Waypoint::label_invalid_char()
if ((*c == 42 || *c == 43) && c > label.data()
|| (*c < 40) || (*c == 44) || (*c > 57 && *c < 65)
|| (*c == 96) || (*c > 122) || (*c > 90 && *c < 95))
Datacheck::add(route, label, "", "", "LABEL_INVALID_CHAR", "");
{ if (!strncmp(label.data(), "\xEF\xBB\xBF", 3))
Datacheck::add(route, label, "", "", "LABEL_INVALID_CHAR", "UTF-8 BOM");
else Datacheck::add(route, label, "", "", "LABEL_INVALID_CHAR", "");
break;
}
for (std::string& lbl : alt_labels)
if (lbl == "*")
Datacheck::add(route, lbl, "", "", "LABEL_INVALID_CHAR", "");
else for (const char *c = lbl.data(); *c; c++)
if (*c == '+' && c > lbl.data() || *c == '*' && (c > lbl.data()+1 || lbl[0] != '+')
|| (*c < 40) || (*c == 44) || (*c > 57 && *c < 65)
|| (*c == 96) || (*c > 122) || (*c > 90 && *c < 95))
Datacheck::add(route, lbl, "", "", "LABEL_INVALID_CHAR", "");
{ Datacheck::add(route, lbl, "", "", "LABEL_INVALID_CHAR", "");
break;
}
}

bool Waypoint::label_too_long()
Expand Down
4 changes: 2 additions & 2 deletions siteupdate/cplusplus/siteupdate.cpp
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
// Tab Width = 8

// Travel Mapping Project, Jim Teresco and Eric Bryant, 2015-2020
// Travel Mapping Project, Jim Teresco and Eric Bryant, 2015-2021
/* Code to read .csv and .wpt files and prepare for
adding to the Travel Mapping Project database.

(c) 2015-2020, Jim Teresco and Eric Bryant
(c) 2015-2021, Jim Teresco and Eric Bryant
Original Python version by Jim Teresco, with contributions from Eric Bryant and the TravelMapping team
C++ translation by Eric Bryant

Expand Down
31 changes: 16 additions & 15 deletions siteupdate/python-teresco/siteupdate.py
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
# Travel Mapping Project, Jim Teresco, 2015-2020
# Travel Mapping Project, Jim Teresco, 2015-2021
"""Python code to read .csv and .wpt files and prepare for
adding to the Travel Mapping Project database.

(c) 2015-2020, Jim Teresco, Eric Bryant, and Travel Mapping Project contributors
(c) 2015-2021, Jim Teresco, Eric Bryant, and Travel Mapping Project contributors

This module defines classes to represent the contents of a
.csv file that lists the highways within a system, and a
Expand DownExpand Up@@ -1689,9 +1689,6 @@ def __init__(self,wpt,unique_name,datacheckerrors,rg_vset_hash):
# 0: never visible outside of simple graphs
# 1: visible only in traveled graph; hidden in collapsed graph
# 2: visible in both traveled & collapsed graphs
# note: if saving the first waypoint, no longer need
# lat & lng and can replace with methods
self.first_waypoint = wpt
self.incident_s_edges = [] # simple
self.incident_c_edges = [] # collapsed
self.incident_t_edges = [] # traveled
Expand DownExpand Up@@ -2135,7 +2132,7 @@ def __init__(self, all_waypoints, highway_systems, datacheckerrors, et):
# compress edges adjacent to hidden vertices
counter = 0
print("!\n" + et.et() + "Compressing collapsed edges", end="", flush=True)
for label, v in self.vertices.items():
for w, v in self.vertices.items():
if counter % 10000 == 0:
print('.', end="", flush=True)
counter += 1
Expand All@@ -2146,8 +2143,7 @@ def __init__(self, all_waypoints, highway_systems, datacheckerrors, et):
continue
# if >2 edges, flag HIDDEN_JUNCTION, mark as visible, and do not compress
if len(v.incident_c_edges) > 2:
datacheckerrors.append(DatacheckEntry(v.first_waypoint.colocated[0].route,
[v.first_waypoint.colocated[0].label],
datacheckerrors.append(DatacheckEntry(w.colocated[0].route,[w.colocated[0].label],
"HIDDEN_JUNCTION",str(len(v.incident_c_edges))))
v.visibility = 2
continue
Expand DownExpand Up@@ -2308,19 +2304,20 @@ def write_master_graphs_tmg(self, graph_list, path, traveler_lists):
cv = 0
tv = 0
for v in self.vertices.values():
vstr = v.unique_name+' '+str(v.lat)+' '+str(v.lng)+'\n'
# all vertices for simple graph
simplefile.write(v.unique_name+' '+str(v.lat)+' '+str(v.lng)+'\n')
simplefile.write(vstr)
v.s_vertex_num = sv
sv += 1
# visible vertices...
if v.visibility >= 1:
# for traveled graph,
travelfile.write(v.unique_name+' '+str(v.lat)+' '+str(v.lng)+'\n')
travelfile.write(vstr)
v.t_vertex_num = tv
tv += 1
if v.visibility == 2:
# and for collapsed graph
collapfile.write(v.unique_name+' '+str(v.lat)+' '+str(v.lng)+'\n')
collapfile.write(vstr)
v.c_vertex_num = cv
cv += 1
# now edges, only write if not already written
Expand DownExpand Up@@ -2392,19 +2389,20 @@ def write_subgraphs_tmg(self, graph_list, path, root, descr, category, regions,
cv = 0
tv = 0
for v in mv:
vstr = v.unique_name + ' ' + str(v.lat) + ' ' + str(v.lng) + '\n'
# all vertices, for simple graph
simplefile.write(v.unique_name + ' ' + str(v.lat) + ' ' + str(v.lng) + '\n')
simplefile.write(vstr)
v.s_vertex_num = sv
sv += 1
# visible vertices
if v.visibility >= 1:
# for traveled graph
travelfile.write(v.unique_name + ' ' + str(v.lat) + ' ' + str(v.lng) + '\n')
travelfile.write(vstr)
v.t_vertex_num = tv
tv += 1
if v.visibility == 2:
# for collapsed graph
collapfile.write(v.unique_name + ' ' + str(v.lat) + ' ' + str(v.lng) + '\n')
collapfile.write(vstr)
v.c_vertex_num = cv
cv += 1
# write edges
Expand DownExpand Up@@ -3918,7 +3916,10 @@ def run(self):

# look for labels with invalid characters
if not re.fullmatch('\+?\*?[a-zA-Z0-9()/_\-\.]+', w.label):
datacheckerrors.append(DatacheckEntry(r,[w.label],'LABEL_INVALID_CHAR'))
if w.label.encode('utf-8')[0:3] == b'\xef\xbb\xbf':
datacheckerrors.append(DatacheckEntry(r,[w.label],'LABEL_INVALID_CHAR', "UTF-8 BOM"))
else:
datacheckerrors.append(DatacheckEntry(r,[w.label],'LABEL_INVALID_CHAR'))
for a in w.alt_labels:
if not re.fullmatch('\+?\*?[a-zA-Z0-9()/_\-\.]+', a):
datacheckerrors.append(DatacheckEntry(r,[a],'LABEL_INVALID_CHAR'))
Expand Down