-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmultiregion.cpp
More file actions
38 lines (37 loc) · 1.71 KB
/
multiregion.cpp
File metadata and controls
38 lines (37 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Some additional interesting graphs, the "multiregion" graphs
file.open(Args::datapath+"/graphs/multiregion.csv");
getline(file, line); // ignore header line
while (getline(file, line))
{ if (line.empty()) continue;
vector<char*> fields;
char *cline = new char[line.size()+1];
// deleted @ end of this while loop after tokens are processed
strcpy(cline, line.data());
for (char *token = strtok(cline, ";"); token; token = strtok(0, ";")) fields.push_back(token);
if (fields.size() != 3)
{ el.add_error("Could not parse multiregion.csv line: [" + line
+ "], expected 3 fields, found " + std::to_string(fields.size()));
delete[] cline;
continue;
}
if (fields[1]-fields[0]-1 > DBFieldLength::graphDescr)
el.add_error("description > " + std::to_string(DBFieldLength::graphDescr)
+ " bytes in multiregion.csv line: " + line);
if (fields[2]-fields[1] > DBFieldLength::graphFilename-13)
el.add_error("title > " + std::to_string(DBFieldLength::graphFilename-14)
+ " bytes in multiregion.csv line: " + line);
regions = new vector<Region*>;
// deleted @ end of HighwayGraph::write_subgraphs_tmg
// or when aborting due to ErrorList errors
for(char* rg = strtok(fields[2], ","); rg; rg = strtok(0, ","))
try { regions->push_back(Region::code_hash.at(rg));
}
catch (const out_of_range&)
{ el.add_error("unrecognized region code "+string(rg)+" in multiregion.csv line: "+line);
}
if (regions->size()) GraphListEntry::add_group(fields[1], fields[0], 'R', regions, nullptr, nullptr);
else delete regions;
delete[] cline;
}
file.close();
graph_types.push_back({"multiregion", "Routes Within Multiple Regions", "These graphs contain the routes within a set of regions."});