Implementing logic when route is going against one-way flow (think
bikes!)
This commit is contained in:
parent
9961172d70
commit
cf5c776990
@ -79,6 +79,7 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
|
|||||||
edge.data.type = i->type();
|
edge.data.type = i->type();
|
||||||
edge.data.isAccessRestricted = i->isAccessRestricted();
|
edge.data.isAccessRestricted = i->isAccessRestricted();
|
||||||
edge.data.edgeBasedNodeID = edges.size();
|
edge.data.edgeBasedNodeID = edges.size();
|
||||||
|
edge.data.contraFlow = i->isContraFlow();
|
||||||
edges.push_back( edge );
|
edges.push_back( edge );
|
||||||
if( edge.data.backward ) {
|
if( edge.data.backward ) {
|
||||||
std::swap( edge.source, edge.target );
|
std::swap( edge.source, edge.target );
|
||||||
@ -342,6 +343,13 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID
|
|||||||
_NodeBasedDynamicGraph::EdgeData & data1 = _nodeBasedGraph->GetEdgeData(edge1);
|
_NodeBasedDynamicGraph::EdgeData & data1 = _nodeBasedGraph->GetEdgeData(edge1);
|
||||||
_NodeBasedDynamicGraph::EdgeData & data2 = _nodeBasedGraph->GetEdgeData(edge2);
|
_NodeBasedDynamicGraph::EdgeData & data2 = _nodeBasedGraph->GetEdgeData(edge2);
|
||||||
|
|
||||||
|
if(!data1.contraFlow && data2.contraFlow) {
|
||||||
|
return TurnInstructions.EnterAgainstAllowedDirection;
|
||||||
|
}
|
||||||
|
if(data1.contraFlow && !data2.contraFlow) {
|
||||||
|
return TurnInstructions.LeaveAgainstAllowedDirection;
|
||||||
|
}
|
||||||
|
|
||||||
//roundabouts need to be handled explicitely
|
//roundabouts need to be handled explicitely
|
||||||
if(data1.roundabout && data2.roundabout) {
|
if(data1.roundabout && data2.roundabout) {
|
||||||
//Is a turn possible? If yes, we stay on the roundabout!
|
//Is a turn possible? If yes, we stay on the roundabout!
|
||||||
@ -363,10 +371,13 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If street names stay the same and if we are certain that it is not a roundabout, we skip it.
|
//If street names stay the same and if we are certain that it is not a roundabout, we skip it.
|
||||||
if( (data1.nameID == data2.nameID) && (0 != data1.nameID))
|
if( (data1.nameID == data2.nameID) && (0 != data1.nameID)) {
|
||||||
return TurnInstructions.NoTurn;
|
return TurnInstructions.NoTurn;
|
||||||
if( (data1.nameID == data2.nameID) && (0 == data1.nameID) && (_nodeBasedGraph->GetOutDegree(v) <= 2) )
|
}
|
||||||
|
if( (data1.nameID == data2.nameID) && (0 == data1.nameID) && (_nodeBasedGraph->GetOutDegree(v) <= 2) ) {
|
||||||
|
ERR("should not happen");
|
||||||
return TurnInstructions.NoTurn;
|
return TurnInstructions.NoTurn;
|
||||||
|
}
|
||||||
|
|
||||||
double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
|
double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
|
||||||
return TurnInstructions.GetTurnDirectionOfInstruction(angle);
|
return TurnInstructions.GetTurnDirectionOfInstruction(angle);
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -48,34 +49,7 @@
|
|||||||
#include "../DataStructures/TurnInstructions.h"
|
#include "../DataStructures/TurnInstructions.h"
|
||||||
#include "../Util/BaseConfiguration.h"
|
#include "../Util/BaseConfiguration.h"
|
||||||
|
|
||||||
class EdgeBasedGraphFactory {
|
class EdgeBasedGraphFactory : boost::noncopyable {
|
||||||
private:
|
|
||||||
struct _NodeBasedEdgeData {
|
|
||||||
int distance;
|
|
||||||
unsigned edgeBasedNodeID;
|
|
||||||
unsigned nameID;
|
|
||||||
short type;
|
|
||||||
bool isAccessRestricted;
|
|
||||||
bool shortcut:1;
|
|
||||||
bool forward:1;
|
|
||||||
bool backward:1;
|
|
||||||
bool roundabout:1;
|
|
||||||
bool ignoreInGrid:1;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _EdgeBasedEdgeData {
|
|
||||||
int distance;
|
|
||||||
unsigned via;
|
|
||||||
unsigned nameID;
|
|
||||||
bool forward;
|
|
||||||
bool backward;
|
|
||||||
TurnInstruction turnInstruction;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef DynamicGraph< _NodeBasedEdgeData > _NodeBasedDynamicGraph;
|
|
||||||
typedef _NodeBasedDynamicGraph::InputEdge _NodeBasedEdge;
|
|
||||||
std::vector<NodeInfo> inputNodeInfoList;
|
|
||||||
unsigned numberOfTurnRestrictions;
|
|
||||||
public:
|
public:
|
||||||
struct EdgeBasedNode {
|
struct EdgeBasedNode {
|
||||||
bool operator<(const EdgeBasedNode & other) const {
|
bool operator<(const EdgeBasedNode & other) const {
|
||||||
@ -95,13 +69,41 @@ public:
|
|||||||
bool ignoreInGrid:1;
|
bool ignoreInGrid:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct SpeedProfileProperties{
|
struct SpeedProfileProperties{
|
||||||
SpeedProfileProperties() : trafficSignalPenalty(0), uTurnPenalty(0) {}
|
SpeedProfileProperties() : trafficSignalPenalty(0), uTurnPenalty(0) {}
|
||||||
int trafficSignalPenalty;
|
int trafficSignalPenalty;
|
||||||
int uTurnPenalty;
|
int uTurnPenalty;
|
||||||
} speedProfile;
|
} speedProfile;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct _NodeBasedEdgeData {
|
||||||
|
int distance;
|
||||||
|
unsigned edgeBasedNodeID;
|
||||||
|
unsigned nameID;
|
||||||
|
short type;
|
||||||
|
bool isAccessRestricted;
|
||||||
|
bool shortcut:1;
|
||||||
|
bool forward:1;
|
||||||
|
bool backward:1;
|
||||||
|
bool roundabout:1;
|
||||||
|
bool ignoreInGrid:1;
|
||||||
|
bool contraFlow;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _EdgeBasedEdgeData {
|
||||||
|
int distance;
|
||||||
|
unsigned via;
|
||||||
|
unsigned nameID;
|
||||||
|
bool forward;
|
||||||
|
bool backward;
|
||||||
|
TurnInstruction turnInstruction;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef DynamicGraph< _NodeBasedEdgeData > _NodeBasedDynamicGraph;
|
||||||
|
typedef _NodeBasedDynamicGraph::InputEdge _NodeBasedEdge;
|
||||||
|
std::vector<NodeInfo> inputNodeInfoList;
|
||||||
|
unsigned numberOfTurnRestrictions;
|
||||||
|
|
||||||
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
|
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
|
||||||
boost::unordered_map<NodeID, bool> _barrierNodes;
|
boost::unordered_map<NodeID, bool> _barrierNodes;
|
||||||
boost::unordered_map<NodeID, bool> _trafficLights;
|
boost::unordered_map<NodeID, bool> _trafficLights;
|
||||||
@ -113,7 +115,6 @@ private:
|
|||||||
std::vector<EmanatingRestrictionsVector> _restrictionBucketVector;
|
std::vector<EmanatingRestrictionsVector> _restrictionBucketVector;
|
||||||
RestrictionMap _restrictionMap;
|
RestrictionMap _restrictionMap;
|
||||||
|
|
||||||
|
|
||||||
DeallocatingVector<EdgeBasedEdge> edgeBasedEdges;
|
DeallocatingVector<EdgeBasedEdge> edgeBasedEdges;
|
||||||
DeallocatingVector<EdgeBasedNode> edgeBasedNodes;
|
DeallocatingVector<EdgeBasedNode> edgeBasedNodes;
|
||||||
std::vector<OriginalEdgeData> originalEdgeData;
|
std::vector<OriginalEdgeData> originalEdgeData;
|
||||||
@ -127,8 +128,6 @@ private:
|
|||||||
bool belongsToTinyComponent);
|
bool belongsToTinyComponent);
|
||||||
template<class CoordinateT>
|
template<class CoordinateT>
|
||||||
double GetAngleBetweenTwoEdges(const CoordinateT& A, const CoordinateT& C, const CoordinateT& B) const;
|
double GetAngleBetweenTwoEdges(const CoordinateT& A, const CoordinateT& C, const CoordinateT& B) const;
|
||||||
// SRTMLookup srtmLookup;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template< class InputEdgeT >
|
template< class InputEdgeT >
|
||||||
|
@ -40,12 +40,8 @@ public:
|
|||||||
return (source() < e.source());
|
return (source() < e.source());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Default constructor. target and weight are set to 0.*/
|
explicit NodeBasedEdge(NodeID s, NodeID t, NodeID n, EdgeWeight w, bool f, bool b, short ty, bool ra, bool ig, bool ar, bool cf) :
|
||||||
NodeBasedEdge() :
|
_source(s), _target(t), _name(n), _weight(w), forward(f), backward(b), _type(ty), _roundabout(ra), _ignoreInGrid(ig), _accessRestricted(ar), _contraFlow(cf) { if(ty < 0) {ERR("Type: " << ty);}; }
|
||||||
_source(0), _target(0), _name(0), _weight(0), forward(0), backward(0), _type(0), _roundabout(false), _ignoreInGrid(false), _accessRestricted(false) { assert(false); } //shall not be used.
|
|
||||||
|
|
||||||
explicit NodeBasedEdge(NodeID s, NodeID t, NodeID n, EdgeWeight w, bool f, bool b, short ty, bool ra, bool ig, bool ar) :
|
|
||||||
_source(s), _target(t), _name(n), _weight(w), forward(f), backward(b), _type(ty), _roundabout(ra), _ignoreInGrid(ig), _accessRestricted(ar) { if(ty < 0) {ERR("Type: " << ty);}; }
|
|
||||||
|
|
||||||
NodeID target() const {return _target; }
|
NodeID target() const {return _target; }
|
||||||
NodeID source() const {return _source; }
|
NodeID source() const {return _source; }
|
||||||
@ -59,6 +55,7 @@ public:
|
|||||||
bool isRoundabout() const { return _roundabout; }
|
bool isRoundabout() const { return _roundabout; }
|
||||||
bool ignoreInGrid() const { return _ignoreInGrid; }
|
bool ignoreInGrid() const { return _ignoreInGrid; }
|
||||||
bool isAccessRestricted() const { return _accessRestricted; }
|
bool isAccessRestricted() const { return _accessRestricted; }
|
||||||
|
bool isContraFlow() const { return _contraFlow; }
|
||||||
|
|
||||||
NodeID _source;
|
NodeID _source;
|
||||||
NodeID _target;
|
NodeID _target;
|
||||||
@ -70,6 +67,13 @@ public:
|
|||||||
bool _roundabout;
|
bool _roundabout;
|
||||||
bool _ignoreInGrid;
|
bool _ignoreInGrid;
|
||||||
bool _accessRestricted;
|
bool _accessRestricted;
|
||||||
|
bool _contraFlow;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** Default constructor. target and weight are set to 0.*/
|
||||||
|
NodeBasedEdge() :
|
||||||
|
_source(0), _target(0), _name(0), _weight(0), forward(0), backward(0), _type(0), _roundabout(false), _ignoreInGrid(false), _accessRestricted(false), _contraFlow(false) { assert(false); } //shall not be used.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class EdgeBasedEdge {
|
class EdgeBasedEdge {
|
||||||
|
@ -231,17 +231,17 @@ void ExtractionContainers::PrepareData(const std::string & outputFileName, const
|
|||||||
fout.write((char*)&edgeIT->target, sizeof(unsigned));
|
fout.write((char*)&edgeIT->target, sizeof(unsigned));
|
||||||
fout.write((char*)&intDist, sizeof(int));
|
fout.write((char*)&intDist, sizeof(int));
|
||||||
switch(edgeIT->direction) {
|
switch(edgeIT->direction) {
|
||||||
case _Way::notSure:
|
case ExtractionWay::notSure:
|
||||||
fout.write((char*)&zero, sizeof(short));
|
fout.write((char*)&zero, sizeof(short));
|
||||||
break;
|
break;
|
||||||
case _Way::oneway:
|
case ExtractionWay::oneway:
|
||||||
fout.write((char*)&one, sizeof(short));
|
fout.write((char*)&one, sizeof(short));
|
||||||
break;
|
break;
|
||||||
case _Way::bidirectional:
|
case ExtractionWay::bidirectional:
|
||||||
fout.write((char*)&zero, sizeof(short));
|
fout.write((char*)&zero, sizeof(short));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case _Way::opposite:
|
case ExtractionWay::opposite:
|
||||||
fout.write((char*)&one, sizeof(short));
|
fout.write((char*)&one, sizeof(short));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -256,6 +256,7 @@ void ExtractionContainers::PrepareData(const std::string & outputFileName, const
|
|||||||
fout.write((char*)&edgeIT->isRoundabout, sizeof(bool));
|
fout.write((char*)&edgeIT->isRoundabout, sizeof(bool));
|
||||||
fout.write((char*)&edgeIT->ignoreInGrid, sizeof(bool));
|
fout.write((char*)&edgeIT->ignoreInGrid, sizeof(bool));
|
||||||
fout.write((char*)&edgeIT->isAccessRestricted, sizeof(bool));
|
fout.write((char*)&edgeIT->isAccessRestricted, sizeof(bool));
|
||||||
|
fout.write((char*)&edgeIT->isContraFlow, sizeof(bool));
|
||||||
}
|
}
|
||||||
++usedEdgeCounter;
|
++usedEdgeCounter;
|
||||||
++edgeIT;
|
++edgeIT;
|
||||||
|
@ -31,7 +31,7 @@ class ExtractionContainers {
|
|||||||
public:
|
public:
|
||||||
typedef stxxl::vector<NodeID> STXXLNodeIDVector;
|
typedef stxxl::vector<NodeID> STXXLNodeIDVector;
|
||||||
typedef stxxl::vector<_Node> STXXLNodeVector;
|
typedef stxxl::vector<_Node> STXXLNodeVector;
|
||||||
typedef stxxl::vector<_Edge> STXXLEdgeVector;
|
typedef stxxl::vector<InternalExtractorEdge> STXXLEdgeVector;
|
||||||
typedef stxxl::vector<std::string> STXXLStringVector;
|
typedef stxxl::vector<std::string> STXXLStringVector;
|
||||||
typedef stxxl::vector<_RawRestrictionContainer> STXXLRestrictionsVector;
|
typedef stxxl::vector<_RawRestrictionContainer> STXXLRestrictionsVector;
|
||||||
typedef stxxl::vector<_WayIDStartAndEndEdge> STXXLWayIDStartEndVector;
|
typedef stxxl::vector<_WayIDStartAndEndEdge> STXXLWayIDStartEndVector;
|
||||||
|
@ -64,7 +64,7 @@ bool ExtractorCallbacks::restrictionFunction(_RawRestrictionContainer &r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** warning: caller needs to take care of synchronization! */
|
/** warning: caller needs to take care of synchronization! */
|
||||||
bool ExtractorCallbacks::wayFunction(_Way &parsed_way) {
|
bool ExtractorCallbacks::wayFunction(ExtractionWay &parsed_way) {
|
||||||
if ( parsed_way.speed > 0 ) { //Only true if the way is specified by the speed profile
|
if ( parsed_way.speed > 0 ) { //Only true if the way is specified by the speed profile
|
||||||
if(parsed_way.id == UINT_MAX){
|
if(parsed_way.id == UINT_MAX){
|
||||||
WARN("found bogus way with id: " << parsed_way.id << " of size " << parsed_way.path.size());
|
WARN("found bogus way with id: " << parsed_way.id << " of size " << parsed_way.path.size());
|
||||||
@ -80,20 +80,20 @@ bool ExtractorCallbacks::wayFunction(_Way &parsed_way) {
|
|||||||
parsed_way.nameID = string_map_iterator->second;
|
parsed_way.nameID = string_map_iterator->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parsed_way.direction == _Way::opposite ){
|
if ( parsed_way.direction == ExtractionWay::opposite ){
|
||||||
std::reverse( parsed_way.path.begin(), parsed_way.path.end() );
|
std::reverse( parsed_way.path.begin(), parsed_way.path.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( parsed_way.backward_speed > 0 && parsed_way.direction == _Way::bidirectional) {
|
if( parsed_way.backward_speed > 0 && parsed_way.direction == ExtractionWay::bidirectional) {
|
||||||
parsed_way.direction == _Way::oneway;
|
parsed_way.direction = ExtractionWay::oneway;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) {
|
for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) {
|
||||||
externalMemory->allEdges.push_back(
|
externalMemory->allEdges.push_back(
|
||||||
_Edge(parsed_way.path[n],
|
InternalExtractorEdge(parsed_way.path[n],
|
||||||
parsed_way.path[n+1],
|
parsed_way.path[n+1],
|
||||||
parsed_way.type,
|
parsed_way.type,
|
||||||
(_Way::bidirectional == parsed_way.direction && parsed_way.backward_speed > 0 ? _Way::oneway : parsed_way.direction),
|
(ExtractionWay::bidirectional == parsed_way.direction && parsed_way.backward_speed > 0 ? ExtractionWay::oneway : parsed_way.direction),
|
||||||
parsed_way.speed,
|
parsed_way.speed,
|
||||||
parsed_way.nameID,
|
parsed_way.nameID,
|
||||||
parsed_way.roundabout,
|
parsed_way.roundabout,
|
||||||
@ -113,17 +113,17 @@ bool ExtractorCallbacks::wayFunction(_Way &parsed_way) {
|
|||||||
std::reverse( parsed_way.path.begin(), parsed_way.path.end() );
|
std::reverse( parsed_way.path.begin(), parsed_way.path.end() );
|
||||||
for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) {
|
for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) {
|
||||||
externalMemory->allEdges.push_back(
|
externalMemory->allEdges.push_back(
|
||||||
_Edge(parsed_way.path[n],
|
InternalExtractorEdge(parsed_way.path[n],
|
||||||
parsed_way.path[n+1],
|
parsed_way.path[n+1],
|
||||||
parsed_way.type,
|
parsed_way.type,
|
||||||
_Way::oneway,
|
ExtractionWay::oneway,
|
||||||
parsed_way.backward_speed,
|
parsed_way.backward_speed,
|
||||||
parsed_way.nameID,
|
parsed_way.nameID,
|
||||||
parsed_way.roundabout,
|
parsed_way.roundabout,
|
||||||
parsed_way.ignoreInGrid,
|
parsed_way.ignoreInGrid,
|
||||||
parsed_way.isDurationSet,
|
parsed_way.isDurationSet,
|
||||||
parsed_way.isAccessRestricted,
|
parsed_way.isAccessRestricted,
|
||||||
(_Way::oneway == parsed_way.direction)
|
(ExtractionWay::oneway == parsed_way.direction)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
bool restrictionFunction(_RawRestrictionContainer &r);
|
bool restrictionFunction(_RawRestrictionContainer &r);
|
||||||
|
|
||||||
/** warning: caller needs to take care of synchronization! */
|
/** warning: caller needs to take care of synchronization! */
|
||||||
bool wayFunction(_Way &w);
|
bool wayFunction(ExtractionWay &w);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
typedef boost::unordered_map<std::string, NodeID > StringMap;
|
typedef boost::unordered_map<std::string, NodeID > StringMap;
|
||||||
typedef boost::unordered_map<std::string, std::pair<int, short> > StringToIntPairMap;
|
typedef boost::unordered_map<std::string, std::pair<int, short> > StringToIntPairMap;
|
||||||
|
|
||||||
struct _Way {
|
struct ExtractionWay {
|
||||||
_Way() {
|
ExtractionWay() {
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ struct _Way {
|
|||||||
nameID = UINT_MAX;
|
nameID = UINT_MAX;
|
||||||
path.clear();
|
path.clear();
|
||||||
keyVals.EraseAll();
|
keyVals.EraseAll();
|
||||||
direction = _Way::notSure;
|
direction = ExtractionWay::notSure;
|
||||||
speed = -1;
|
speed = -1;
|
||||||
backward_speed = -1;
|
backward_speed = -1;
|
||||||
type = -1;
|
type = -1;
|
||||||
@ -79,22 +79,22 @@ struct _Way {
|
|||||||
HashTable<std::string, std::string> keyVals;
|
HashTable<std::string, std::string> keyVals;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Relation {
|
struct ExtractorRelation {
|
||||||
_Relation() : type(unknown){}
|
ExtractorRelation() : type(unknown){}
|
||||||
enum {
|
enum {
|
||||||
unknown = 0, ferry, turnRestriction
|
unknown = 0, ferry, turnRestriction
|
||||||
} type;
|
} type;
|
||||||
HashTable<std::string, std::string> keyVals;
|
HashTable<std::string, std::string> keyVals;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Edge {
|
struct InternalExtractorEdge {
|
||||||
_Edge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) {};
|
InternalExtractorEdge() : start(0), target(0), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) {};
|
||||||
_Edge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) { }
|
InternalExtractorEdge(NodeID s, NodeID t) : start(s), target(t), type(0), direction(0), speed(0), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) { }
|
||||||
_Edge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) { }
|
InternalExtractorEdge(NodeID s, NodeID t, short tp, short d, double sp): start(s), target(t), type(tp), direction(d), speed(sp), nameID(0), isRoundabout(false), ignoreInGrid(false), isDurationSet(false), isAccessRestricted(false), isContraFlow(false) { }
|
||||||
_Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(false) {
|
InternalExtractorEdge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(false) {
|
||||||
assert(0 <= type);
|
assert(0 <= type);
|
||||||
}
|
}
|
||||||
_Edge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar, bool icf): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(icf) {
|
InternalExtractorEdge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar, bool icf): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(icf) {
|
||||||
assert(0 <= type);
|
assert(0 <= type);
|
||||||
}
|
}
|
||||||
NodeID start;
|
NodeID start;
|
||||||
@ -112,15 +112,16 @@ struct _Edge {
|
|||||||
_Coordinate startCoord;
|
_Coordinate startCoord;
|
||||||
_Coordinate targetCoord;
|
_Coordinate targetCoord;
|
||||||
|
|
||||||
static _Edge min_value() {
|
static InternalExtractorEdge min_value() {
|
||||||
return _Edge(0,0);
|
return InternalExtractorEdge(0,0);
|
||||||
}
|
}
|
||||||
static _Edge max_value() {
|
static InternalExtractorEdge max_value() {
|
||||||
return _Edge((std::numeric_limits<unsigned>::max)(), (std::numeric_limits<unsigned>::max)());
|
return InternalExtractorEdge((std::numeric_limits<unsigned>::max)(), (std::numeric_limits<unsigned>::max)());
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct _WayIDStartAndEndEdge {
|
struct _WayIDStartAndEndEdge {
|
||||||
unsigned wayID;
|
unsigned wayID;
|
||||||
NodeID firstStart;
|
NodeID firstStart;
|
||||||
@ -177,34 +178,29 @@ struct CmpNodeByID : public std::binary_function<_Node, _Node, bool> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmpEdgeByStartID : public std::binary_function<_Edge, _Edge, bool>
|
struct CmpEdgeByStartID : public std::binary_function<InternalExtractorEdge, InternalExtractorEdge, bool> {
|
||||||
{
|
typedef InternalExtractorEdge value_type;
|
||||||
typedef _Edge value_type;
|
bool operator () (const InternalExtractorEdge & a, const InternalExtractorEdge & b) const {
|
||||||
bool operator () (const _Edge & a, const _Edge & b) const {
|
|
||||||
return a.start < b.start;
|
return a.start < b.start;
|
||||||
}
|
}
|
||||||
value_type max_value() {
|
value_type max_value() {
|
||||||
return _Edge::max_value();
|
return InternalExtractorEdge::max_value();
|
||||||
}
|
}
|
||||||
value_type min_value() {
|
value_type min_value() {
|
||||||
return _Edge::min_value();
|
return InternalExtractorEdge::min_value();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmpEdgeByTargetID : public std::binary_function<_Edge, _Edge, bool>
|
struct CmpEdgeByTargetID : public std::binary_function<InternalExtractorEdge, InternalExtractorEdge, bool> {
|
||||||
{
|
typedef InternalExtractorEdge value_type;
|
||||||
typedef _Edge value_type;
|
bool operator () (const InternalExtractorEdge & a, const InternalExtractorEdge & b) const {
|
||||||
bool operator () (const _Edge & a, const _Edge & b) const
|
|
||||||
{
|
|
||||||
return a.target < b.target;
|
return a.target < b.target;
|
||||||
}
|
}
|
||||||
value_type max_value()
|
value_type max_value() {
|
||||||
{
|
return InternalExtractorEdge::max_value();
|
||||||
return _Edge::max_value();
|
|
||||||
}
|
}
|
||||||
value_type min_value()
|
value_type min_value() {
|
||||||
{
|
return InternalExtractorEdge::min_value();
|
||||||
return _Edge::min_value();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -332,8 +332,8 @@ inline void PBFParser::parseRelation(_ThreadData * threadData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void PBFParser::parseWay(_ThreadData * threadData) {
|
inline void PBFParser::parseWay(_ThreadData * threadData) {
|
||||||
_Way w;
|
ExtractionWay w;
|
||||||
std::vector<_Way> waysToParse(threadData->PBFprimitiveBlock.primitivegroup( threadData->currentGroupID ).ways_size());
|
std::vector<ExtractionWay> waysToParse(threadData->PBFprimitiveBlock.primitivegroup( threadData->currentGroupID ).ways_size());
|
||||||
for(int i = 0, ways_size = threadData->PBFprimitiveBlock.primitivegroup( threadData->currentGroupID ).ways_size(); i < ways_size; ++i) {
|
for(int i = 0, ways_size = threadData->PBFprimitiveBlock.primitivegroup( threadData->currentGroupID ).ways_size(); i < ways_size; ++i) {
|
||||||
w.Clear();
|
w.Clear();
|
||||||
const OSMPBF::Way& inputWay = threadData->PBFprimitiveBlock.primitivegroup( threadData->currentGroupID ).ways( i );
|
const OSMPBF::Way& inputWay = threadData->PBFprimitiveBlock.primitivegroup( threadData->currentGroupID ).ways( i );
|
||||||
@ -356,7 +356,7 @@ inline void PBFParser::parseWay(_ThreadData * threadData) {
|
|||||||
unsigned endi_ways = waysToParse.size();
|
unsigned endi_ways = waysToParse.size();
|
||||||
#pragma omp parallel for schedule ( guided )
|
#pragma omp parallel for schedule ( guided )
|
||||||
for(unsigned i = 0; i < endi_ways; ++i) {
|
for(unsigned i = 0; i < endi_ways; ++i) {
|
||||||
_Way & w = waysToParse[i];
|
ExtractionWay & w = waysToParse[i];
|
||||||
/** Pass the unpacked way to the LUA call back **/
|
/** Pass the unpacked way to the LUA call back **/
|
||||||
try {
|
try {
|
||||||
luabind::call_function<int>(
|
luabind::call_function<int>(
|
||||||
@ -376,7 +376,7 @@ inline void PBFParser::parseWay(_ThreadData * threadData) {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(_Way & w, waysToParse) {
|
BOOST_FOREACH(ExtractionWay & w, waysToParse) {
|
||||||
if(!externalMemory->wayFunction(w)) {
|
if(!externalMemory->wayFunction(w)) {
|
||||||
std::cerr << "[PBFParser] way not parsed" << std::endl;
|
std::cerr << "[PBFParser] way not parsed" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "ExtractorStructs.h"
|
#include "ExtractorStructs.h"
|
||||||
#include "ScriptingEnvironment.h"
|
#include "ScriptingEnvironment.h"
|
||||||
|
|
||||||
class PBFParser : public BaseParser<ExtractorCallbacks, _Node, _RawRestrictionContainer, _Way> {
|
class PBFParser : public BaseParser<ExtractorCallbacks, _Node, _RawRestrictionContainer, ExtractionWay> {
|
||||||
|
|
||||||
enum EntityType {
|
enum EntityType {
|
||||||
TypeNode = 1,
|
TypeNode = 1,
|
||||||
|
@ -65,19 +65,19 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
luabind::module(myLuaState) [
|
luabind::module(myLuaState) [
|
||||||
luabind::class_<_Way>("Way")
|
luabind::class_<ExtractionWay>("Way")
|
||||||
.def(luabind::constructor<>())
|
.def(luabind::constructor<>())
|
||||||
.def_readwrite("name", &_Way::name)
|
.def_readwrite("name", &ExtractionWay::name)
|
||||||
.def_readwrite("backward_speed", &_Way::backward_speed)
|
.def_readwrite("backward_speed", &ExtractionWay::backward_speed)
|
||||||
.def_readwrite("speed", &_Way::speed)
|
.def_readwrite("speed", &ExtractionWay::speed)
|
||||||
.def_readwrite("type", &_Way::type)
|
.def_readwrite("type", &ExtractionWay::type)
|
||||||
.def_readwrite("access", &_Way::access)
|
.def_readwrite("access", &ExtractionWay::access)
|
||||||
.def_readwrite("roundabout", &_Way::roundabout)
|
.def_readwrite("roundabout", &ExtractionWay::roundabout)
|
||||||
.def_readwrite("is_duration_set", &_Way::isDurationSet)
|
.def_readwrite("is_duration_set", &ExtractionWay::isDurationSet)
|
||||||
.def_readwrite("is_access_restricted", &_Way::isAccessRestricted)
|
.def_readwrite("is_access_restricted", &ExtractionWay::isAccessRestricted)
|
||||||
.def_readwrite("ignore_in_grid", &_Way::ignoreInGrid)
|
.def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid)
|
||||||
.def_readwrite("tags", &_Way::keyVals)
|
.def_readwrite("tags", &ExtractionWay::keyVals)
|
||||||
.def_readwrite("direction", &_Way::direction)
|
.def_readwrite("direction", &ExtractionWay::direction)
|
||||||
.enum_("constants")
|
.enum_("constants")
|
||||||
[
|
[
|
||||||
luabind::value("notSure", 0),
|
luabind::value("notSure", 0),
|
||||||
|
@ -100,7 +100,7 @@ bool XMLParser::Parse() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( xmlStrEqual( currentName, ( const xmlChar* ) "way" ) == 1 ) {
|
if ( xmlStrEqual( currentName, ( const xmlChar* ) "way" ) == 1 ) {
|
||||||
_Way way = _ReadXMLWay( );
|
ExtractionWay way = _ReadXMLWay( );
|
||||||
|
|
||||||
/** Pass the unpacked way to the LUA call back **/
|
/** Pass the unpacked way to the LUA call back **/
|
||||||
try {
|
try {
|
||||||
@ -222,8 +222,8 @@ _RawRestrictionContainer XMLParser::_ReadXMLRestriction() {
|
|||||||
return restriction;
|
return restriction;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Way XMLParser::_ReadXMLWay() {
|
ExtractionWay XMLParser::_ReadXMLWay() {
|
||||||
_Way way;
|
ExtractionWay way;
|
||||||
if ( xmlTextReaderIsEmptyElement( inputReader ) != 1 ) {
|
if ( xmlTextReaderIsEmptyElement( inputReader ) != 1 ) {
|
||||||
const int depth = xmlTextReaderDepth( inputReader );
|
const int depth = xmlTextReaderDepth( inputReader );
|
||||||
while ( xmlTextReaderRead( inputReader ) == 1 ) {
|
while ( xmlTextReaderRead( inputReader ) == 1 ) {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "ExtractorCallbacks.h"
|
#include "ExtractorCallbacks.h"
|
||||||
#include "ScriptingEnvironment.h"
|
#include "ScriptingEnvironment.h"
|
||||||
|
|
||||||
class XMLParser : public BaseParser<ExtractorCallbacks, _Node, _RawRestrictionContainer, _Way> {
|
class XMLParser : public BaseParser<ExtractorCallbacks, _Node, _RawRestrictionContainer, ExtractionWay> {
|
||||||
public:
|
public:
|
||||||
XMLParser(const char * filename);
|
XMLParser(const char * filename);
|
||||||
virtual ~XMLParser();
|
virtual ~XMLParser();
|
||||||
@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
_RawRestrictionContainer _ReadXMLRestriction();
|
_RawRestrictionContainer _ReadXMLRestriction();
|
||||||
_Way _ReadXMLWay();
|
ExtractionWay _ReadXMLWay();
|
||||||
ImportNode _ReadXMLNode( );
|
ImportNode _ReadXMLNode( );
|
||||||
/* Input Reader */
|
/* Input Reader */
|
||||||
xmlTextReaderPtr inputReader;
|
xmlTextReaderPtr inputReader;
|
||||||
|
@ -101,7 +101,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
|
|||||||
short type;
|
short type;
|
||||||
NodeID nameID;
|
NodeID nameID;
|
||||||
int length;
|
int length;
|
||||||
bool isRoundabout, ignoreInGrid, isAccessRestricted;
|
bool isRoundabout, ignoreInGrid, isAccessRestricted, isContraFlow;
|
||||||
|
|
||||||
for (EdgeID i=0; i<m; ++i) {
|
for (EdgeID i=0; i<m; ++i) {
|
||||||
in.read((char*)&source, sizeof(unsigned));
|
in.read((char*)&source, sizeof(unsigned));
|
||||||
@ -114,6 +114,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
|
|||||||
in.read((char*)&isRoundabout, sizeof(bool));
|
in.read((char*)&isRoundabout, sizeof(bool));
|
||||||
in.read((char*)&ignoreInGrid, sizeof(bool));
|
in.read((char*)&ignoreInGrid, sizeof(bool));
|
||||||
in.read((char*)&isAccessRestricted, sizeof(bool));
|
in.read((char*)&isAccessRestricted, sizeof(bool));
|
||||||
|
in.read((char*)&isContraFlow, sizeof(bool));
|
||||||
|
|
||||||
GUARANTEE(length > 0, "loaded null length edge" );
|
GUARANTEE(length > 0, "loaded null length edge" );
|
||||||
GUARANTEE(weight > 0, "loaded null weight");
|
GUARANTEE(weight > 0, "loaded null weight");
|
||||||
@ -150,7 +151,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
|
|||||||
std::swap(forward, backward);
|
std::swap(forward, backward);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout, ignoreInGrid, isAccessRestricted );
|
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout, ignoreInGrid, isAccessRestricted, isContraFlow );
|
||||||
edgeList.push_back(inputEdge);
|
edgeList.push_back(inputEdge);
|
||||||
}
|
}
|
||||||
std::sort(edgeList.begin(), edgeList.end());
|
std::sort(edgeList.begin(), edgeList.end());
|
||||||
|
@ -58,7 +58,6 @@ int main (int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
omp_set_num_threads(numberOfThreads);
|
omp_set_num_threads(numberOfThreads);
|
||||||
|
|
||||||
|
|
||||||
INFO("extracting data from input file " << argv[1]);
|
INFO("extracting data from input file " << argv[1]);
|
||||||
bool isPBF(false);
|
bool isPBF(false);
|
||||||
std::string outputFileName(argv[1]);
|
std::string outputFileName(argv[1]);
|
||||||
@ -93,10 +92,9 @@ int main (int argc, char *argv[]) {
|
|||||||
StringMap stringMap;
|
StringMap stringMap;
|
||||||
ExtractionContainers externalMemory;
|
ExtractionContainers externalMemory;
|
||||||
|
|
||||||
|
|
||||||
stringMap[""] = 0;
|
stringMap[""] = 0;
|
||||||
extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap);
|
extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap);
|
||||||
BaseParser<ExtractorCallbacks, _Node, _RawRestrictionContainer, _Way> * parser;
|
BaseParser<ExtractorCallbacks, _Node, _RawRestrictionContainer, ExtractionWay> * parser;
|
||||||
if(isPBF) {
|
if(isPBF) {
|
||||||
parser = new PBFParser(argv[1]);
|
parser = new PBFParser(argv[1]);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user