Merged for loop changes pulled down from upstream

This commit is contained in:
Sasa Ivetic 2011-10-05 11:19:50 -05:00
commit 5132c84dfa
4 changed files with 24 additions and 40 deletions

View File

@ -171,7 +171,7 @@ private:
cout << "Scanning for useless shortcuts" << endl; cout << "Scanning for useless shortcuts" << endl;
BuildOutgoingGraph(); BuildOutgoingGraph();
#pragma omp parallel for #pragma omp parallel for
for ( int i = 0; i < _graph.size(); i++ ) { for ( int i = 0; i < ( int ) _graph.size(); i++ ) {
for ( unsigned edge = _firstEdge[_graph[i].source]; edge < _firstEdge[_graph[i].source + 1]; ++edge ) { for ( unsigned edge = _firstEdge[_graph[i].source]; edge < _firstEdge[_graph[i].source + 1]; ++edge ) {
if ( edge == i ) if ( edge == i )
continue; continue;

View File

@ -23,7 +23,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <climits> #include <climits>
#include <string> #include <string>
#include "HashTable.h" #include <boost/unordered_map.hpp>
#include "Util.h" #include "Util.h"
struct _PathData { struct _PathData {
@ -31,24 +31,7 @@ struct _PathData {
NodeID node; NodeID node;
}; };
/* Default Speed Profile: typedef boost::unordered_map<std::string, NodeID> StringMap;
motorway 110
motorway_link 90
trunk 90
trunk_link 70
primary 70
primary_link 60
secondary 60
secondary_link 50
tertiary 55
unclassified 25
residential 40
living_street 10
service 30
ferry 5
*/
typedef google::dense_hash_map<std::string, NodeID> StringMap;
struct _Node : NodeInfo{ struct _Node : NodeInfo{
_Node(int _lat, int _lon, unsigned int _id) : NodeInfo(_lat, _lon, _id) {} _Node(int _lat, int _lon, unsigned int _id) : NodeInfo(_lat, _lon, _id) {}
@ -88,7 +71,7 @@ struct _Way {
_Way() : id(UINT_MAX), nameID(UINT_MAX) { _Way() : id(UINT_MAX), nameID(UINT_MAX) {
direction = _Way::notSure; direction = _Way::notSure;
maximumSpeed = -1; speed = -1;
type = -1; type = -1;
useful = false; useful = false;
access = true; access = true;
@ -100,7 +83,7 @@ struct _Way {
unsigned id; unsigned id;
unsigned nameID; unsigned nameID;
std::string name; std::string name;
double maximumSpeed; double speed;
short type; short type;
bool useful:1; bool useful:1;
bool access:1; bool access:1;
@ -140,6 +123,7 @@ struct _Edge {
_Edge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0) {}; _Edge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0) {};
_Edge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0) { } _Edge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0) { }
_Edge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0) { } _Edge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0) { }
_Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid) { }
NodeID start; NodeID start;
NodeID target; NodeID target;
short type; short type;
@ -174,7 +158,6 @@ struct _Restriction {
char unused7:1; char unused7:1;
} flags; } flags;
_Restriction(NodeID vn) : viaNode(vn), fromNode(UINT_MAX), toNode(UINT_MAX) { } _Restriction(NodeID vn) : viaNode(vn), fromNode(UINT_MAX), toNode(UINT_MAX) { }
_Restriction(bool isOnly = false) : viaNode(UINT_MAX), fromNode(UINT_MAX), toNode(UINT_MAX) { _Restriction(bool isOnly = false) : viaNode(UINT_MAX), fromNode(UINT_MAX), toNode(UINT_MAX) {
flags.isOnly = isOnly; flags.isOnly = isOnly;
@ -198,7 +181,6 @@ struct _RawRestrictionContainer {
} }
}; };
struct CmpRestrictionByFrom: public std::binary_function<_RawRestrictionContainer, _RawRestrictionContainer, bool> { struct CmpRestrictionByFrom: public std::binary_function<_RawRestrictionContainer, _RawRestrictionContainer, bool> {
typedef _RawRestrictionContainer value_type; typedef _RawRestrictionContainer value_type;
bool operator () (const _RawRestrictionContainer & a, const _RawRestrictionContainer & b) const { bool operator () (const _RawRestrictionContainer & a, const _RawRestrictionContainer & b) const {
@ -256,17 +238,19 @@ struct CmpWayStartAndEnd : public std::binary_function<_WayIDStartAndEndEdge, _W
}; };
struct Settings { struct Settings {
struct SpeedProfile { Settings() : obeyPollards(false), obeyOneways(false), useRestrictions(false), accessTag("motorcar") {}
vector< double > speed; StringMap speedProfile;
vector< string > names; int operator[](const string & param) const {
} speedProfile; if(speedProfile.find(param) == speedProfile.end())
int indexInAccessListOf( const string & key) { return 0;
for(unsigned i = 0; i< speedProfile.names.size(); i++) { else
if(speedProfile.names[i] == key) return speedProfile.at(param);
return i;
}
return -1;
} }
bool obeyPollards;
bool obeyOneways;
bool useRestrictions;
string accessTag;
}; };
struct Cmp : public std::binary_function<NodeID, NodeID, bool> { struct Cmp : public std::binary_function<NodeID, NodeID, bool> {

View File

@ -92,7 +92,7 @@ private:
_Way _ReadXMLWay( ) { _Way _ReadXMLWay( ) {
_Way way; _Way way;
way.direction = _Way::notSure; way.direction = _Way::notSure;
way.maximumSpeed = -1; way.speed = -1;
way.type = -1; way.type = -1;
way.useful = false; way.useful = false;
way.access = true; way.access = true;

View File

@ -38,15 +38,15 @@ using namespace std;
#endif #endif
#define STXXL_VERBOSE_LEVEL -100 #define STXXL_VERBOSE_LEVEL -100
#define INFO(x) std::cout << "[info " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; #define INFO(x) do {std::cout << "[info " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0);
#define ERR(x) std::cerr << "[error " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; exit(-1); #define ERR(x) do {std::cerr << "[error " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; exit(-1);} while(0);
#define WARN(x) std::cerr << "[warn " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; #define WARN(x) do {std::cerr << "[warn " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0);
#ifdef NDEBUG #ifdef NDEBUG
#define DEBUG(x) #define DEBUG(x)
#else #else
#define DEBUG(x) std::cout << "[debug " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; #define DEBUG(x) do {std::cout << "[debug " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0);
#endif #endif
#define DELETE(x) { if(NULL != x) { delete x; x = NULL; } } #define DELETE(x) do { if(NULL != x) { delete x; x = NULL; } }while(0);
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846