236 bool firstItem =
true;
238 double lastLon = 0.0;
239 double lastLat = 0.0;
246 for (
unsigned i=0; i < way.second.size(); ++i) {
247 Key ref = way.second[way.second.size()-1 - i];
250 if (nptr ==
nullptr)
continue;
251 if (nptr->first._lon == 0 && nptr->first._lat == 0)
continue;
254 if (nptr->first._used == 0) {
255 if (firstItem == false) {
256 dist += calcDist(nptr->first._lon, nptr->first._lat, lastLon, lastLat);
257 lastLon = nptr->first._lon;
258 lastLat = nptr->first._lat;
266 if (vptr ==
nullptr) {
269 vertex.first._way = wayosmid;
270 vertex.first._lon = nptr->first._lon;
271 vertex.first._lat = nptr->first._lat;
275 dist +=
calcDist(vertex.first._lon, vertex.first._lat, lastLon, lastLat);
276 vertex.second.push_back(last);
277 distance.second.push_back(dist);
279 lastLon = nptr->first._lon;
280 lastLat = nptr->first._lat;
287 dist +=
calcDist(vptr->first._lon, vptr->first._lat, lastLon, lastLat);
288 vptr->second.push_back(last);
289 dptr->second.push_back(dist);
291 lastLon = nptr->first._lon;
292 lastLat = nptr->first._lat;
308 if (way.first._oneway ==
false) {
309 for (
unsigned i=0; i < way.second.size(); ++i) {
310 Key ref = way.second[i];
313 if (nptr ==
nullptr)
continue;
314 if (nptr->first._lon == 0 && nptr->first._lat == 0)
continue;
317 if (nptr->first._used == 0) {
318 if (firstItem ==
false) {
319 dist +=
calcDist(nptr->first._lon, nptr->first._lat, lastLon, lastLat);
320 lastLon = nptr->first._lon;
321 lastLat = nptr->first._lat;
329 if (vptr ==
nullptr) {
332 vertex.first._way = wayosmid;
333 vertex.first._lon = nptr->first._lon;
334 vertex.first._lat = nptr->first._lat;
338 dist +=
calcDist(vertex.first._lon, vertex.first._lat, lastLon, lastLat);
339 vertex.second.push_back(last);
340 distance.second.push_back(dist);
342 lastLon = nptr->first._lon;
343 lastLat = nptr->first._lat;
350 dist +=
calcDist(vptr->first._lon, vptr->first._lat, lastLon, lastLat);
351 vptr->second.push_back(last);
352 dptr->second.push_back(dist);
354 lastLon = nptr->first._lon;
355 lastLat = nptr->first._lat;
370 uint64_t wayOsmId = 1;
372 pFile = fopen (
"graph.osm",
"w");
375 "<?xml version='1.0' encoding='UTF-8'?>\n"
376 "<osm version='0.6'>\n"
377 "<bounds minlat='%f' minlon='%f' maxlat='%f' maxlon='%f'/>\n",
389 "<node id='%" PRIu64
"'" DEFAULTATTR " lat='%f' lon='%f'/>\n",
390 id, v.first._lat, v.first._lon
399 for (
unsigned i=0; i < v.second.size(); ++i) {
402 "<nd ref='%" PRIu64
"'/>"
403 "<nd ref='%" PRIu64
"'/>"
404 "<tag k='highway' v='secondary'/>"
405 "<tag k='oneway' v='yes'/>"
406 "<tag k='name' v=\"%" PRIu64
"\"/></way>\n",
420 fprintf (pFile,
"</osm>\n");
std::pair< TVALUE, std::vector< TKEY > > Data
Definition: SwappyItems.hpp:52
Data * get(const TKEY &key)
Definition: SwappyItems.hpp:188
bool each(Data &back, std::function< bool(TKEY, Data &)> foo)
Definition: SwappyItems.hpp:790
bool set(TKEY key, TVALUE value)
Definition: SwappyItems.hpp:123
void read_osm_pbf(const std::string &filename, Visitor &visitor, bool wayOnly)
Definition: osmpbfreader.hpp:359
uint64_t Key
Definition: osm2graph.cpp:48
Ways_t * ways
Definition: osm2graph.cpp:84
SwappyItems< Key, Vertex, FILE_ITEMS, FILE_MULTI, RAM_MULTI, BBITS, BMASK > Vertices_t
Definition: osm2graph.cpp:88
#define LAT_BOUND
Definition: osm2graph.cpp:32
#define LON_BOUND_DIF
Definition: osm2graph.cpp:31
SwappyItems< Key, Distance, FILE_ITEMS, FILE_MULTI, RAM_MULTI, BBITS, BMASK > Distance_t
Definition: osm2graph.cpp:90
#define LON_BOUND
Definition: osm2graph.cpp:30
SwappyItems< Key, WayData, FILE_ITEMS, FILE_MULTI, RAM_MULTI, BBITS, BMASK > Ways_t
Definition: osm2graph.cpp:82
Nodes_t * nodes
Definition: osm2graph.cpp:85
#define DEFAULTATTR
build a map file with osmosis: ../osmosis/bin/osmosis –read-xml file=graph.osm –mw file=krefeld_mg....
Definition: osm2graph.cpp:45
Distance_t * distances
Definition: osm2graph.cpp:91
SwappyItems< Key, NodeData, FILE_ITEMS, FILE_MULTI, RAM_MULTI, BBITS, BMASK > Nodes_t
Definition: osm2graph.cpp:83
Key calcDist(double lon1, double lat1, double lon2, double lat2)
Definition: osm2graph.cpp:97
Vertices_t * verticies
Definition: osm2graph.cpp:89
#define LAT_BOUND_DIF
Definition: osm2graph.cpp:33
Definition: osm2graph.cpp:120