The SwappyItems Key-Values Store
Routing.hpp
Go to the documentation of this file.
1 
2 struct Routing {
3 
4  void way_callback (uint64_t osmid, const Tags & tags, const vector<uint64_t> & refs) {
5  pair<WayData, vector<Key> > way;
6 
7  if (catchWay(way.first, osmid, tags)) { // fills in basis way data
8 
9  for (Key r : refs) {
10  way.second.push_back(r);
11  pair<NodeData, vector<Key> > * nodeptr = nodes->get(r);
12  if (nodeptr == nullptr) {
13  pair<NodeData, vector<Key> > node;
14  node.first._used = 0;
15  node.first._lon = 0.0;
16  node.first._lat = 0.0;
17  nodes->set(r, node.first);
18  } else {
19  // node is also used in another way!
20  nodeptr->first._used++;
21  nodes->set(r, nodeptr->first);
22  isPrinted = false;
23  }
24  }
25  // tests: osmid of the way is always new OR you read a 2nd time because of hibernate!
26  ways->set(osmid, way.first, way.second);
27 
28  if ((nodes->getStatistic().updates%1024 == 0) && (isPrinted == false)) logEntry(mseconds, start, isPrinted);
29  }
30  }
31 
32  void node_callback (uint64_t osmid, double lon, double lat, const Tags & tags) {
33  pair<NodeData, vector<Key> > * nodeptr = nodes->get(osmid);
34  pair<PlaceData, vector<Key> > place;
35 
36  if (nodeptr == nullptr) {
37  // it seams to be not a way: we store it as place?
38  if (catchTown(place.first, osmid, lon, lat, tags)) {
39  places->set(osmid, place.first);
40  }
41  } else {
42  // this osmid node is part of a way, because we read way first and it exist now
43  // -> set lon and lat!
44  nodeptr->first._used++;
45  nodeptr->first._lon = lon;
46  nodeptr->first._lat = lat;
47 
48  // for testing ------------------------------------------------------
49  //if (osmid%16 == 0) {
50  // nodes->del(osmid);
51  //} else {
52  nodes->set(osmid, nodeptr->first);
53  //}
54 
55  isPrinted = false;
56  }
57 
58  if ((nodes->getStatistic().updates%1024 == 0) && (isPrinted == false)) logEntry(mseconds, start, isPrinted);
59  }
60 
61  void relation_callback (uint64_t /*osmid*/, const Tags &/*tags*/, const References & refs){}
62 };
SwappyItemsPLACES * places
Definition: ReadPbfData.cpp:56
atomic< bool > isPrinted
Definition: ReadPbfData.cpp:62
double mseconds
Definition: ReadPbfData.cpp:61
std::chrono::time_point< std::chrono::system_clock > start
Definition: ReadPbfData.cpp:60
Data * get(const TKEY &key)
Definition: SwappyItems.hpp:188
struct statistic_s getStatistic(void)
Definition: SwappyItems.hpp:288
bool set(TKEY key, TVALUE value)
Definition: SwappyItems.hpp:123
std::vector< Reference > References
Definition: osmpbfreader.hpp:65
std::map< std::string, std::string > Tags
Definition: osmpbfreader.hpp:51
uint64_t Key
Definition: osm2graph.cpp:48
Ways_t * ways
Definition: osm2graph.cpp:84
Nodes_t * nodes
Definition: osm2graph.cpp:85
Definition: osm2graph.cpp:120
void way_callback(uint64_t osmid, const Tags &tags, const vector< uint64_t > &refs)
Definition: Routing.hpp:4
void node_callback(uint64_t osmid, double lon, double lat, const Tags &tags)
Definition: Routing.hpp:32
void relation_callback(uint64_t, const Tags &, const References &refs)
Definition: Routing.hpp:61
uint64_t updates
Definition: SwappyItems.hpp:59
void logEntry()
Definition: such.cpp:35
bool catchWay(WayData &dummy, const uint64_t &osmid, const Tags &tags)
Definition: tools.hpp:158
bool catchTown(PlaceData &dummy, const uint64_t &osmid, double &lon, double &lat, const Tags &tags)
Definition: tools.hpp:128