The SwappyItems Key-Values Store
Public Member Functions | List of all members
Routing Struct Reference

#include <Routing.hpp>

Public Member Functions

void node_callback (uint64_t osmid, double lon, double lat, const Tags &)
 
void way_callback (uint64_t osmid, const Tags &tags, const std::vector< uint64_t > &refs)
 
void relation_callback (uint64_t, const Tags &, const References &)
 
void node_callback (uint64_t osmid, double lon, double lat, const Tags &)
 
void way_callback (uint64_t osmid, const Tags &tags, const std::vector< uint64_t > &refs)
 
void relation_callback (uint64_t, const Tags &, const References &)
 
void node_callback (uint64_t osmid, double lon, double lat, const Tags &)
 
void way_callback (uint64_t osmid, const Tags &tags, const std::vector< uint64_t > &refs)
 
void relation_callback (uint64_t, const Tags &, const References &)
 
void way_callback (uint64_t osmid, const Tags &tags, const vector< uint64_t > &refs)
 
void node_callback (uint64_t osmid, double lon, double lat, const Tags &tags)
 
void relation_callback (uint64_t, const Tags &, const References &refs)
 
void way_callback (uint64_t osmid, const Tags &tags, const vector< uint64_t > &refs)
 
void relation_callback (uint64_t osmid, const Tags &tags, const References &refs)
 
void node_callback (uint64_t osmid, double lon, double lat, const Tags &tags)
 

Detailed Description

Examples
ReadPbfData.cpp, and osm2graph.cpp.

Member Function Documentation

◆ node_callback() [1/5]

void Routing::node_callback ( uint64_t  osmid,
double  lon,
double  lat,
const Tags  
)
inline
Todo:
not part of my area
Todo:
instead of lat,lon store the complete distance SOMEWHERE
122  {
123  // not valid pos
124  if (lon == 0 && lat == 0) return;
126  double checklon = lon - LON_BOUND;
127  double checklat = lat - LAT_BOUND;
128  if (checklon > LON_BOUND_DIF || checklon < 0.0) return;
129  if (checklat > LAT_BOUND_DIF || checklat < 0.0) return;
130 
131  Nodes_t::Data * nodeptr = nodes->get(osmid);
132  // not a node of my ways (I read node ids from ways first
133  if (nodeptr == nullptr) return;
135  // we only use nodes of connected ways? (ignore sackgasse and links in between -> fail on distance!)
136  //if (nodeptr->first._used == 0) return;
137  nodeptr->first._lon = lon;
138  nodeptr->first._lat = lat;
139  nodes->set(osmid, nodeptr->first);
140  }
std::pair< TVALUE, std::vector< TKEY > > Data
Definition: SwappyItems.hpp:52
Data * get(const TKEY &key)
Definition: SwappyItems.hpp:188
bool set(TKEY key, TVALUE value)
Definition: SwappyItems.hpp:123
#define LAT_BOUND
Definition: osm2graph.cpp:32
#define LON_BOUND_DIF
Definition: osm2graph.cpp:31
#define LON_BOUND
Definition: osm2graph.cpp:30
Nodes_t * nodes
Definition: osm2graph.cpp:85
#define LAT_BOUND_DIF
Definition: osm2graph.cpp:33

◆ node_callback() [2/5]

void Routing::node_callback ( uint64_t  osmid,
double  lon,
double  lat,
const Tags  
)
inline
Todo:
not part of my area
Todo:
instead of lat,lon store the complete distance SOMEWHERE
106  {
107  // not valid pos
108  if (lon == 0 && lat == 0) return;
110  double checklon = lon - LON_BOUND;
111  double checklat = lat - LAT_BOUND;
112  if (checklon > LON_BOUND_DIF || checklon < 0.0) return;
113  if (checklat > LAT_BOUND_DIF || checklat < 0.0) return;
114 
115  Nodes_t::Data * nodeptr = nodes->get(osmid);
116  // not a node of my ways (I read node ids from ways first
117  if (nodeptr == nullptr) return;
119  // we only use nodes of connected ways? (ignore sackgasse and links in between -> fail on distance!)
120  //if (nodeptr->first._used == 0) return;
121  nodeptr->first._lon = lon;
122  nodeptr->first._lat = lat;
123  nodes->set(osmid, nodeptr->first);
124  }
#define LAT_BOUND
Definition: osm2graph_baremetal.cpp:33
#define LON_BOUND_DIF
Definition: osm2graph_baremetal.cpp:32
#define LON_BOUND
Definition: osm2graph_baremetal.cpp:31
Nodes_t * nodes
Definition: osm2graph_baremetal.cpp:73
#define LAT_BOUND_DIF
Definition: osm2graph_baremetal.cpp:34

◆ node_callback() [3/5]

void Routing::node_callback ( uint64_t  osmid,
double  lon,
double  lat,
const Tags  
)
inline
Todo:
not part of my area
Todo:
instead of lat,lon store the complete distance SOMEWHERE
173  {
174  // not valid pos
175  if (lon == 0 && lat == 0) return;
177  double checklon = lon - LON_BOUND;
178  double checklat = lat - LAT_BOUND;
179  if (checklon > LON_BOUND_DIF || checklon < 0.0) return;
180  if (checklat > LAT_BOUND_DIF || checklat < 0.0) return;
181 
182  Nodes_t::Data * nodeptr = nodes->get(osmid);
183  // not a node of my ways (I read node ids from ways first
184  if (nodeptr == nullptr) return;
186  // we only use nodes of connected ways? (ignore sackgasse and links in between -> fail on distance!)
187  //if (nodeptr->first._used == 0) return;
188  nodeptr->first._lon = lon;
189  nodeptr->first._lat = lat;
190  nodes->set(osmid, nodeptr->first);
191  }
#define LAT_BOUND
Definition: osm2graph_bitmap.cpp:42
#define LON_BOUND_DIF
Definition: osm2graph_bitmap.cpp:41
#define LON_BOUND
Definition: osm2graph_bitmap.cpp:40
Nodes_t * nodes
Definition: osm2graph_bitmap.cpp:87
#define LAT_BOUND_DIF
Definition: osm2graph_bitmap.cpp:43

◆ node_callback() [4/5]

void Routing::node_callback ( uint64_t  osmid,
double  lon,
double  lat,
const Tags &  tags 
)
inline
32  {
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  }
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
struct statistic_s getStatistic(void)
Definition: SwappyItems.hpp:288
uint64_t updates
Definition: SwappyItems.hpp:59
void logEntry()
Definition: such.cpp:35
bool catchTown(PlaceData &dummy, const uint64_t &osmid, double &lon, double &lat, const Tags &tags)
Definition: tools.hpp:128

◆ node_callback() [5/5]

void Routing::node_callback ( uint64_t  osmid,
double  lon,
double  lat,
const Tags tags 
)
inline
80  {
81  pair<NodeData, vector<Key> > * nodeptr = nodes->get(osmid);
82 
83  if (osmid < 145849) printf("hurra!\n");
84 
85  if (nodeptr == nullptr) {
86  NodeData nd;
87  nd._used = 1;
88  nd._lon = lon;
89  nd._lat = lat;
90  nodes->set(osmid, nd);
91  } else {
92  nodeptr->first._used++;
93  if (lon != 0) nodeptr->first._lon = lon;
94  if (lat != 0) nodeptr->first._lat = lat;
95  nodes->set(osmid, nodeptr->first);
96  }
97  if ((nodes->getStatistic().size%4096 == 0)) logEntry();
98  }
Definition: osm2graph.cpp:53
double _lon
Definition: osm2graph.cpp:55
uint8_t _used
Definition: osm2graph.cpp:54
double _lat
Definition: osm2graph.cpp:56
uint64_t size
Definition: SwappyItems.hpp:55
SwappyItemsNODES * nodes
Definition: such.cpp:33

◆ relation_callback() [1/5]

void Routing::relation_callback ( uint64_t  osmid,
const Tags tags,
const References refs 
)
inline
78 {}

◆ relation_callback() [2/5]

void Routing::relation_callback ( uint64_t  ,
const Tags ,
const References  
)
inline
212 {}

◆ relation_callback() [3/5]

void Routing::relation_callback ( uint64_t  ,
const Tags ,
const References  
)
inline
196 {}

◆ relation_callback() [4/5]

void Routing::relation_callback ( uint64_t  ,
const Tags ,
const References  
)
inline
263 {}

◆ relation_callback() [5/5]

void Routing::relation_callback ( uint64_t  ,
const Tags &  ,
const References &  refs 
)
inline
61 {}

◆ way_callback() [1/5]

void Routing::way_callback ( uint64_t  osmid,
const Tags tags,
const std::vector< uint64_t > &  refs 
)
inline
142  {
143 
144  if (tags.find("highway") != tags.end()) {
145  int wt = relevance(tags.at("highway"));
146  if (wt == 0) return;
147 
148  std::vector<Key> path;
149  WayData way;
150  unsigned pathlength = refs.size();
151  way._oneway = false;
152  bool rev = false;
153  bool circle = false;
154 
155  if (wt == 2) way._oneway = true; // it is a link! oneway=yes is a default
156 
157  if (tags.find("oneway") != tags.end()) {
158  std::string wt = tags.at("oneway"); // yes, no, reversible, -1, ...
159  if (wt.compare("yes") == 0) way._oneway = true;
160  if (wt.compare("no") == 0) way._oneway = false;
161  if (wt.compare("-1") == 0) {
162  way._oneway = true;
163  rev = true;
164  }
165  }
166  if (pathlength>1) {
167  if (refs[0] == refs[pathlength-1]) circle = true;
168  }
169 
170  Nodes_t::Data * nodeptr;
171  if (circle) {
172  for (unsigned i=1; i < pathlength; ++i) {
173  nodeptr = nodes->get(refs[i]);
174  if (nodeptr == nullptr) {
175  Nodes_t::Data node;
176  node.first._used = 0;
177  node.first._lon = 0.0;
178  node.first._lat = 0.0;
179  nodes->set(refs[i], node.first);
180  } else {
181  // node is also used in another way!
182  nodeptr->first._used++;
183  nodes->set(refs[i], nodeptr->first);
184  }
185  path.push_back(refs[i]);
186  }
187  path.push_back(refs[1]); // add the real firts node additionally to the end
188  } else {
189  for (unsigned i=0; i < pathlength; ++i) {
190  nodeptr = nodes->get(refs[i]);
191  if (nodeptr == nullptr) {
192  Nodes_t::Data node;
193  node.first._used = 0;
194  node.first._lon = 0.0;
195  node.first._lat = 0.0;
196  nodes->set(refs[i], node.first);
197  } else {
198  // node is also used in another way!
199  nodeptr->first._used++;
200  nodes->set(refs[i], nodeptr->first);
201  }
202  path.push_back(refs[i]);
203  }
204  }
205 
206  if (rev) std::reverse(path.begin(), path.end());
207  ways->set(osmid, way, path);
208  }
209  }
Ways_t * ways
Definition: osm2graph.cpp:84
int relevance(const std::string &wt)
Definition: osm2graph.cpp:103
Definition: osm2graph.cpp:60
bool _oneway
Definition: osm2graph.cpp:61

◆ way_callback() [2/5]

void Routing::way_callback ( uint64_t  osmid,
const Tags tags,
const std::vector< uint64_t > &  refs 
)
inline
126  {
127 
128  if (tags.find("highway") != tags.end()) {
129  uint8_t wt = relevance(tags.at("highway"));
130  if (wt == 0) return;
131 
132  std::vector<Key> path;
133  WayData way;
134  unsigned pathlength = refs.size();
135  way._oneway = false;
136  bool rev = false;
137  bool circle = false;
138 
139  if (wt == 2) way._oneway = true; // it is a link! oneway=yes is a default
140 
141  if (tags.find("oneway") != tags.end()) {
142  std::string wt = tags.at("oneway"); // yes, no, reversible, -1, ...
143  if (wt.compare("yes") == 0) way._oneway = true;
144  if (wt.compare("no") == 0) way._oneway = false;
145  if (wt.compare("-1") == 0) {
146  way._oneway = true;
147  rev = true;
148  }
149  }
150  if (pathlength>1) {
151  if (refs[0] == refs[pathlength-1]) circle = true;
152  }
153 
154  Nodes_t::Data * nodeptr;
155  if (circle) {
156  for (unsigned i=1; i < pathlength; ++i) {
157  nodeptr = nodes->get(refs[i]);
158  if (nodeptr == nullptr) {
159  Nodes_t::Data node;
160  node.first._used = 0;
161  node.first._lon = 0.0;
162  node.first._lat = 0.0;
163  nodes->set(refs[i], node.first);
164  } else {
165  // node is also used in another way!
166  nodeptr->first._used++;
167  nodes->set(refs[i], nodeptr->first);
168  }
169  path.push_back(refs[i]);
170  }
171  path.push_back(refs[1]); // add the real firts node additionally to the end
172  } else {
173  for (unsigned i=0; i < pathlength; ++i) {
174  nodeptr = nodes->get(refs[i]);
175  if (nodeptr == nullptr) {
176  Nodes_t::Data node;
177  node.first._used = 0;
178  node.first._lon = 0.0;
179  node.first._lat = 0.0;
180  nodes->set(refs[i], node.first);
181  } else {
182  // node is also used in another way!
183  nodeptr->first._used++;
184  nodes->set(refs[i], nodeptr->first);
185  }
186  path.push_back(refs[i]);
187  }
188  }
189 
190  if (rev) std::reverse(path.begin(), path.end());
191  ways->set(osmid, way, path);
192  }
193  }
Ways_t * ways
Definition: osm2graph_baremetal.cpp:72
uint8_t relevance(const std::string &wt)
Definition: osm2graph_baremetal.cpp:88

◆ way_callback() [3/5]

void Routing::way_callback ( uint64_t  osmid,
const Tags tags,
const std::vector< uint64_t > &  refs 
)
inline
193  {
194 
195  if (tags.find("highway") != tags.end()) {
196  uint8_t wt = relevance(tags.at("highway"));
197  if (wt == 0) return;
198 
199  std::vector<Key> path;
200  WayData way;
201  unsigned pathlength = refs.size();
202  way._oneway = false;
203  bool rev = false;
204  bool circle = false;
205 
206  if (wt == 2) way._oneway = true; // it is a link! oneway=yes is a default
207 
208  if (tags.find("oneway") != tags.end()) {
209  std::string wt = tags.at("oneway"); // yes, no, reversible, -1, ...
210  if (wt.compare("yes") == 0) way._oneway = true;
211  if (wt.compare("no") == 0) way._oneway = false;
212  if (wt.compare("-1") == 0) {
213  way._oneway = true;
214  rev = true;
215  }
216  }
217  if (pathlength>1) {
218  if (refs[0] == refs[pathlength-1]) circle = true;
219  }
220 
221  Nodes_t::Data * nodeptr;
222  if (circle) {
223  for (unsigned i=1; i < pathlength; ++i) {
224  nodeptr = nodes->get(refs[i]);
225  if (nodeptr == nullptr) {
226  Nodes_t::Data node;
227  node.first._used = 0;
228  node.first._lon = 0.0;
229  node.first._lat = 0.0;
230  nodes->set(refs[i], node.first);
231  } else {
232  // node is also used in another way!
233  nodeptr->first._used++;
234  nodes->set(refs[i], nodeptr->first);
235  }
236  path.push_back(refs[i]);
237  }
238  path.push_back(refs[1]); // add the real firts node additionally to the end
239  } else {
240  for (unsigned i=0; i < pathlength; ++i) {
241  nodeptr = nodes->get(refs[i]);
242  if (nodeptr == nullptr) {
243  Nodes_t::Data node;
244  node.first._used = 0;
245  node.first._lon = 0.0;
246  node.first._lat = 0.0;
247  nodes->set(refs[i], node.first);
248  } else {
249  // node is also used in another way!
250  nodeptr->first._used++;
251  nodes->set(refs[i], nodeptr->first);
252  }
253  path.push_back(refs[i]);
254  }
255  }
256 
257  if (rev) std::reverse(path.begin(), path.end());
258  ways->set(osmid, way, path);
259  }
260  }
Ways_t * ways
Definition: osm2graph_bitmap.cpp:86
uint8_t relevance(const std::string &wt)
Definition: osm2graph_bitmap.cpp:105

◆ way_callback() [4/5]

void Routing::way_callback ( uint64_t  osmid,
const Tags &  tags,
const vector< uint64_t > &  refs 
)
inline
4  {
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  }
uint64_t Key
Definition: osm2graph.cpp:48
bool catchWay(WayData &dummy, const uint64_t &osmid, const Tags &tags)
Definition: tools.hpp:158

◆ way_callback() [5/5]

void Routing::way_callback ( uint64_t  osmid,
const Tags tags,
const vector< uint64_t > &  refs 
)
inline
76 {}

The documentation for this struct was generated from the following files: