Skip to content

Commit 387c99b

Browse files
committed
graph fixes for -e mode
no graph gen, yes CSV checks (plus path cleanup for Datacheck static functions)
1 parent 7b432be commit 387c99b

17 files changed

Lines changed: 77 additions & 183 deletions

File tree

siteupdate/cplusplus/classes/Datacheck/Datacheck.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Datacheck.h"
2+
#include "../Args/Args.h"
23
#include "../ElapsedTime/ElapsedTime.h"
34
#include "../ErrorList/ErrorList.h"
45
#include "../Route/Route.h"
@@ -40,9 +41,9 @@ std::string Datacheck::str() const
4041
{ return route->root + ";" + label1 + ";" + label2 + ";" + label3 + ";" + code + ";" + info;
4142
}
4243

43-
void Datacheck::read_fps(std::string& path, ErrorList &el)
44+
void Datacheck::read_fps(ErrorList &el)
4445
{ // read in the datacheck false positives list
45-
std::ifstream file(path+"/datacheckfps.csv");
46+
std::ifstream file(Args::datapath+"/datacheckfps.csv");
4647
std::string line;
4748
getline(file, line); // ignore header line
4849
while (getline(file, line))
@@ -71,9 +72,9 @@ void Datacheck::read_fps(std::string& path, ErrorList &el)
7172
file.close();
7273
}
7374

74-
void Datacheck::mark_fps(std::string& path, ElapsedTime &et)
75+
void Datacheck::mark_fps(ElapsedTime &et)
7576
{ errors.sort();
76-
std::ofstream fpfile(path+"/nearmatchfps.log");
77+
std::ofstream fpfile(Args::logfilepath+"/nearmatchfps.log");
7778
time_t timestamp = time(0);
7879
fpfile << "Log file created at: " << ctime(&timestamp);
7980
unsigned int counter = 0;
@@ -102,9 +103,9 @@ void Datacheck::mark_fps(std::string& path, ElapsedTime &et)
102103
std::cout << et.et() << "Found " << Datacheck::errors.size() << " datacheck errors and matched " << fpcount << " FP entries." << std::endl;
103104
}
104105

105-
void Datacheck::unmatchedfps_log(std::string& path)
106+
void Datacheck::unmatchedfps_log()
106107
{ // write log of unmatched false positives from datacheckfps.csv
107-
std::ofstream fpfile(path+"/unmatchedfps.log");
108+
std::ofstream fpfile(Args::logfilepath+"/unmatchedfps.log");
108109
time_t timestamp = time(0);
109110
fpfile << "Log file created at: " << ctime(&timestamp);
110111
if (fps.empty()) fpfile << "No unmatched FP entries.\n";
@@ -115,8 +116,8 @@ void Datacheck::unmatchedfps_log(std::string& path)
115116
fpfile.close();
116117
}
117118

118-
void Datacheck::datacheck_log(std::string& path)
119-
{ std::ofstream logfile(path+"/datacheck.log");
119+
void Datacheck::datacheck_log()
120+
{ std::ofstream logfile(Args::logfilepath+"/datacheck.log");
120121
time_t timestamp = time(0);
121122
logfile << "Log file created at: " << ctime(&timestamp);
122123
logfile << "Datacheck errors that have been flagged as false positives are not included.\n";

siteupdate/cplusplus/classes/Datacheck/Datacheck.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ class Datacheck
7474

7575
static std::list<Datacheck> errors;
7676
static void add(Route*, std::string, std::string, std::string, std::string, std::string);
77-
static void read_fps(std::string&, ErrorList &);
78-
static void mark_fps(std::string&, ElapsedTime &);
79-
static void unmatchedfps_log(std::string&);
80-
static void datacheck_log(std::string&);
77+
static void read_fps(ErrorList &);
78+
static void mark_fps(ElapsedTime &);
79+
static void unmatchedfps_log();
80+
static void datacheck_log();
8181

8282
Datacheck(Route*, std::string, std::string, std::string, std::string, std::string);
8383

siteupdate/cplusplus/classes/GraphGeneration/GraphListEntry.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
std::vector<GraphListEntry> GraphListEntry::entries;
77
size_t GraphListEntry::num; // iterator for entries
88

9-
// master graph constructor
10-
GraphListEntry::GraphListEntry(char f, unsigned int v, unsigned int e, unsigned int t):
11-
root("tm-master"), descr("All Travel Mapping Data"),
12-
vertices(v), edges(e), travelers(t),
13-
form(f), cat('M') {}
14-
15-
// subgraph constructor
169
GraphListEntry::GraphListEntry(std::string r, std::string d, char f, char c, std::list<Region*> *rg, std::list<HighwaySystem*> *sys, PlaceRadius *pr):
1710
regions(rg), systems(sys), placeradius(pr),
1811
root(r), descr(d), form(f), cat(c) {}

siteupdate/cplusplus/classes/GraphGeneration/GraphListEntry.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class GraphListEntry
2929
static size_t num; // iterator for entries
3030
std::string tag();
3131

32-
GraphListEntry(char, unsigned int, unsigned int, unsigned int); // < master graph ctor | v----- subgraph ctor -----v
3332
GraphListEntry(std::string, std::string, char, char, std::list<Region*>*, std::list<HighwaySystem*>*, PlaceRadius*);
3433
static void add_group(std::string&&, std::string&&, char, std::list<Region*>*, std::list<HighwaySystem*>*, PlaceRadius*);
3534
};

siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ void HighwayGraph::write_master_graphs_tmg()
257257
simplefile.close();
258258
collapfile.close();
259259
travelfile.close();
260+
GraphListEntry* g = GraphListEntry::entries.data();
261+
g[0].vertices = vertices.size(); g[0].edges = se; g[0].travelers = 0;
262+
g[1].vertices = cv; g[1].edges = ce; g[1].travelers = 0;
263+
g[2].vertices = tv; g[2].edges = te; g[2].travelers = TravelerList::allusers.size;
260264
}
261265

262266
// write a subset of the data,
@@ -286,9 +290,9 @@ void HighwayGraph::write_subgraphs_tmg
286290
}
287291
#ifdef threading_enabled
288292
term->lock();
293+
#endif
289294
if (g->cat != g[-1].cat)
290295
std::cout << '\n' << et->et() << "Writing " << g->category() << " graphs.\n";
291-
#endif
292296
std::cout << g->tag()
293297
<< '(' << mv.size() << ',' << mse.size() << ") "
294298
<< '(' << cv_count << ',' << mce.size() << ") "

siteupdate/cplusplus/functions/sql_file.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,6 @@ void sqlfile1
425425
delete[] systemupdate;
426426
}
427427
sqlfile << ";\n";
428-
sqlfile.close();
429-
#ifdef threading_enabled
430-
term_mtx->lock();
431-
std::cout << '\n' << et->et() << "Pause writing database file " << Args::databasename << ".sql.\n" << std::flush;
432-
term_mtx->unlock();
433-
#endif
434-
}
435-
436-
void sqlfile2(ElapsedTime *et, std::list<std::array<std::string,3>> *graph_types)
437-
{ std::ofstream sqlfile(Args::databasename+".sql", std::ios::app);
438428

439429
// datacheck errors into the db
440430
#ifndef threading_enabled
@@ -459,6 +449,16 @@ void sqlfile2(ElapsedTime *et, std::list<std::array<std::string,3>> *graph_types
459449
}
460450
}
461451
sqlfile << ";\n";
452+
sqlfile.close();
453+
#ifdef threading_enabled
454+
term_mtx->lock();
455+
std::cout << '\n' << et->et() << "Pause writing database file " << Args::databasename << ".sql.\n" << std::flush;
456+
term_mtx->unlock();
457+
#endif
458+
}
459+
460+
void sqlfile2(ElapsedTime *et, std::list<std::array<std::string,3>> *graph_types)
461+
{ std::ofstream sqlfile(Args::databasename+".sql", std::ios::app);
462462

463463
// update graph info in DB if graphs were generated
464464
if (!Args::skipgraphs)

siteupdate/cplusplus/siteupdate.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,24 @@ int main(int argc, char *argv[])
175175
#include "tasks/threaded/StatsCsv.cpp"
176176

177177
cout << et.et() << "Reading datacheckfps.csv." << endl;
178-
Datacheck::read_fps(Args::datapath, el);
178+
Datacheck::read_fps(el);
179+
cout << et.et() << "Marking datacheck false positives." << flush;
180+
Datacheck::mark_fps(et);
181+
cout << et.et() << "Writing log of unmatched datacheck FP entries." << endl;
182+
Datacheck::unmatchedfps_log();
183+
cout << et.et() << "Writing datacheck.log" << endl;
184+
Datacheck::datacheck_log();
185+
186+
cout << et.et() << "Reading subgraph descriptions and checking for errors." << endl;
187+
#include "tasks/graph_setup.cpp"
188+
189+
// See if we have any errors that should be fatal to the site update process
190+
if (el.error_list.size())
191+
{ cout << et.et() << "ABORTING due to " << el.error_list.size() << " errors:" << endl;
192+
for (unsigned int i = 0; i < el.error_list.size(); i++)
193+
cout << i+1 << ": " << el.error_list[i] << endl;
194+
return 1;
195+
}
179196

180197
#ifdef threading_enabled
181198
thread sqlthread;
@@ -185,14 +202,10 @@ int main(int argc, char *argv[])
185202
}
186203
#endif
187204

188-
#include "tasks/graph_generation.cpp"
189-
190-
cout << et.et() << "Marking datacheck false positives." << flush;
191-
Datacheck::mark_fps(Args::logfilepath, et);
192-
cout << et.et() << "Writing log of unmatched datacheck FP entries." << endl;
193-
Datacheck::unmatchedfps_log(Args::logfilepath);
194-
cout << et.et() << "Writing datacheck.log" << endl;
195-
Datacheck::datacheck_log(Args::logfilepath);
205+
if (!Args::skipgraphs && !Args::errorcheck)
206+
{ // Build a graph structure out of all highway data in active and preview systems
207+
#include "tasks/graph_generation.cpp"
208+
} else cout << et.et() << "SKIPPING generation of graphs." << endl;
196209

197210
if (Args::errorcheck)
198211
cout << et.et() << "SKIPPING database file." << endl;
@@ -207,14 +220,6 @@ int main(int argc, char *argv[])
207220
sqlfile2(&et, &graph_types);
208221
}
209222

210-
// See if we have any errors that should be fatal to the site update process
211-
if (el.error_list.size())
212-
{ cout << et.et() << "ABORTING due to " << el.error_list.size() << " errors:" << endl;
213-
for (unsigned int i = 0; i < el.error_list.size(); i++)
214-
cout << i+1 << ": " << el.error_list[i] << endl;
215-
return 1;
216-
}
217-
218223
// print some statistics
219224
cout << et.et() << "Processed " << HighwaySystem::syslist.size << " highway systems." << endl;
220225
unsigned int routes = 0;
Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Build a graph structure out of all highway data in active and
2-
// preview systems
31
cout << et.et() << "Setting up for graphs of highway data." << endl;
42
HighwayGraph graph_data(all_waypoints, et);
53

@@ -10,19 +8,8 @@ for (string& line : graph_data.waypoint_naming_log)
108
wslogfile.close();
119
graph_data.waypoint_naming_log.clear();
1210

13-
// create list of graph information for the DB
14-
list<array<string,3>> graph_types;
15-
1611
// start generating graphs and making entries for graph DB table
17-
if (Args::skipgraphs || Args::errorcheck)
18-
cout << et.et() << "SKIPPING generation of subgraphs." << endl;
19-
else { list<Region*> *regions;
20-
list<HighwaySystem*> *systems;
21-
GraphListEntry::entries.emplace_back('s', graph_data.vertices.size(), graph_data.se, 0);
22-
GraphListEntry::entries.emplace_back('c', graph_data.cv, graph_data.ce, 0);
23-
GraphListEntry::entries.emplace_back('t', graph_data.tv, graph_data.te, TravelerList::allusers.size);
24-
graph_types.push_back({"master", "All Travel Mapping Data",
25-
"These graphs contain all routes currently plotted in the Travel Mapping project."});
12+
{ // Let's keep these braces here, for easily commenting out subgraph generation when developing waypoint simplification routines
2613
GraphListEntry::num = 3;
2714

2815
cout << et.et() << "Writing master TM graph files." << endl;
@@ -31,30 +18,21 @@ else { list<Region*> *regions;
3118
std::cout << "Collapsed graph has " << graph_data.cv << " vertices, " << graph_data.ce << " edges." << std::endl;
3219
std::cout << " Traveled graph has " << graph_data.tv << " vertices, " << graph_data.te << " edges." << std::endl;
3320

34-
#ifndef threading_enabled
35-
graph_data.write_master_graphs_tmg();
36-
#else
37-
cout << et.et() << "Setting up subgraphs." << endl;
38-
#endif
39-
HighwaySystem *h, *const sys_end = HighwaySystem::syslist.end();
40-
#include "subgraphs/continent.cpp"
41-
#include "subgraphs/multisystem.cpp"
42-
#include "subgraphs/system.cpp"
43-
#include "subgraphs/country.cpp"
44-
#include "subgraphs/multiregion.cpp"
45-
#include "subgraphs/fullcustom.cpp"
46-
#include "subgraphs/region.cpp"
47-
#include "subgraphs/area.cpp"
48-
#ifdef threading_enabled
4921
// write graph vector entries to disk
22+
#ifdef threading_enabled
5023
thr[0] = thread(MasterTmgThread, &graph_data, &list_mtx, &term_mtx, &all_waypoints, &et);
5124
// start at t=1, because MasterTmgThread will spawn another SubgraphThread when finished
5225
for (unsigned int t = 1; t < thr.size(); t++)
5326
thr[t] = thread(SubgraphThread, t, &list_mtx, &term_mtx, &graph_data, &all_waypoints, &et);
5427
THREADLOOP thr[t].join();
55-
cout << '!' << endl;
28+
#else
29+
for ( graph_data.write_master_graphs_tmg();
30+
GraphListEntry::num < GraphListEntry::entries.size();
31+
GraphListEntry::num += 3
32+
) graph_data.write_subgraphs_tmg(GraphListEntry::num, 0, &all_waypoints, &et, &term_mtx);
5633
#endif
57-
}
34+
cout << '!' << endl;
35+
} //*/
5836

5937
cout << et.et() << "Clearing HighwayGraph contents from memory." << endl;
6038
graph_data.clear();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
list<Region*> *regions;
2+
list<HighwaySystem*> *systems;
3+
list<array<string,3>> graph_types; // create list of graph information for the DB
4+
graph_types.push_back({"master", "All Travel Mapping Data",
5+
"These graphs contain all routes currently plotted in the Travel Mapping project."});
6+
GraphListEntry::add_group("tm-master", "All Travel Mapping Data", 'M', nullptr, nullptr, nullptr);
7+
HighwaySystem *h, *const sys_end = HighwaySystem::syslist.end();
8+
#include "subgraphs/continent.cpp"
9+
#include "subgraphs/multisystem.cpp"
10+
#include "subgraphs/system.cpp"
11+
#include "subgraphs/country.cpp"
12+
#include "subgraphs/multiregion.cpp"
13+
#include "subgraphs/fullcustom.cpp"
14+
#include "subgraphs/region.cpp"
15+
#include "subgraphs/area.cpp"

siteupdate/cplusplus/tasks/subgraphs/area.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
// graphs restricted by place/area - from areagraphs.csv file
2-
#ifndef threading_enabled
3-
cout << et.et() << "Creating area data graphs." << endl;
4-
#endif
52
file.open(Args::datapath+"/graphs/areagraphs.csv");
63
getline(file, line); // ignore header line
74

8-
// add entries to graph vector
95
while (getline(file, line))
106
{ if (line.empty()) continue;
117
vector<char*> fields;
@@ -44,13 +40,5 @@ while (getline(file, line))
4440
delete[] cline;
4541
}
4642
file.close();
47-
#ifndef threading_enabled
48-
// write new graph vector entries to disk
49-
while (GraphListEntry::num < GraphListEntry::entries.size())
50-
{ graph_data.write_subgraphs_tmg(GraphListEntry::num, 0, &all_waypoints, &et, &term_mtx);
51-
GraphListEntry::num += 3;
52-
}
53-
cout << '!' << endl;
54-
#endif
5543
graph_types.push_back({"area", "Routes Within a Given Radius of a Place",
5644
"These graphs contain all routes currently plotted within the given distance radius of the given place."});

0 commit comments

Comments
 (0)