Merge branch 'master' of https://github.com/DennisOSRM/Project-OSRM
This commit is contained in:
commit
c1676a90d2
@ -144,7 +144,7 @@ private:
|
|||||||
try {
|
try {
|
||||||
_firstEdge.resize( _numNodes + 1 );
|
_firstEdge.resize( _numNodes + 1 );
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
cerr << "Not enough RAM on machine" << endl;
|
ERR("Not enough RAM on machine");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_firstEdge[0] = 0;
|
_firstEdge[0] = 0;
|
||||||
@ -164,7 +164,7 @@ private:
|
|||||||
threadData.push_back( new _ThreadData( _numNodes ) );
|
threadData.push_back( new _ThreadData( _numNodes ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Scanning for useless shortcuts" << endl;
|
INFO("Scanning for useless shortcuts");
|
||||||
BuildOutgoingGraph();
|
BuildOutgoingGraph();
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for ( int i = 0; i < ( int ) _graph.size(); i++ ) {
|
for ( int i = 0; i < ( int ) _graph.size(); i++ ) {
|
||||||
@ -202,7 +202,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Removing edges" << endl;
|
INFO("Removing edges");
|
||||||
int useful = 0;
|
int useful = 0;
|
||||||
for ( int i = 0; i < ( int ) _graph.size(); i++ ) {
|
for ( int i = 0; i < ( int ) _graph.size(); i++ ) {
|
||||||
if ( !_graph[i].data.forward && !_graph[i].data.backward && _graph[i].data.shortcut )
|
if ( !_graph[i].data.forward && !_graph[i].data.backward && _graph[i].data.shortcut )
|
||||||
@ -210,7 +210,7 @@ private:
|
|||||||
_graph[useful] = _graph[i];
|
_graph[useful] = _graph[i];
|
||||||
useful++;
|
useful++;
|
||||||
}
|
}
|
||||||
cout << "Removed " << _graph.size() - useful << " useless shortcuts" << endl;
|
INFO("Removed " << _graph.size() - useful << " useless shortcuts");
|
||||||
_graph.resize( useful );
|
_graph.resize( useful );
|
||||||
|
|
||||||
for ( int threadNum = 0; threadNum < maxThreads; ++threadNum ) {
|
for ( int threadNum = 0; threadNum < maxThreads; ++threadNum ) {
|
||||||
@ -223,6 +223,11 @@ private:
|
|||||||
const NodeID node = heapForward->DeleteMin();
|
const NodeID node = heapForward->DeleteMin();
|
||||||
const int distance = heapForward->GetKey( node );
|
const int distance = heapForward->GetKey( node );
|
||||||
|
|
||||||
|
if ( distance > *targetDistance ) {
|
||||||
|
heapForward->DeleteAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( heapBackward->WasInserted( node ) ) {
|
if ( heapBackward->WasInserted( node ) ) {
|
||||||
const int newDistance = heapBackward->GetKey( node ) + distance;
|
const int newDistance = heapBackward->GetKey( node ) + distance;
|
||||||
if ( newDistance < *targetDistance ) {
|
if ( newDistance < *targetDistance ) {
|
||||||
@ -231,11 +236,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( distance > *targetDistance ) {
|
for ( int edge = _firstEdge[node], endEdges = _firstEdge[node + 1]; edge != endEdges; ++edge ) {
|
||||||
heapForward->DeleteAll();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for ( int edge = _firstEdge[node], endEdges = _firstEdge[node + 1]; edge != endEdges; ++edge ) {
|
|
||||||
const NodeID to = _graph[edge].target;
|
const NodeID to = _graph[edge].target;
|
||||||
const int edgeWeight = _graph[edge].data.distance;
|
const int edgeWeight = _graph[edge].data.distance;
|
||||||
assert( edgeWeight > 0 );
|
assert( edgeWeight > 0 );
|
||||||
@ -256,15 +257,15 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _ComputeDistance( NodeID source, NodeID target, _ThreadData * data, std::vector< NodeID >* path = NULL ) {
|
int _ComputeDistance( NodeID source, NodeID target, _ThreadData * data ) {
|
||||||
data->_heapForward->Clear();
|
data->_heapForward->Clear();
|
||||||
data->_heapBackward->Clear();
|
data->_heapBackward->Clear();
|
||||||
//insert source into heap
|
//insert source into heap
|
||||||
data->_heapForward->Insert( source, 0, source );
|
data->_heapForward->Insert( source, 0, source );
|
||||||
data->_heapBackward->Insert( target, 0, target );
|
data->_heapBackward->Insert( target, 0, target );
|
||||||
|
|
||||||
int targetDistance = (std::numeric_limits< int >::max)();
|
int targetDistance = std::numeric_limits< int >::max();
|
||||||
NodeID middle = (std::numeric_limits<NodeID>::max)();
|
NodeID middle = std::numeric_limits<NodeID>::max();
|
||||||
|
|
||||||
while ( data->_heapForward->Size() + data->_heapBackward->Size() > 0 ) {
|
while ( data->_heapForward->Size() + data->_heapBackward->Size() > 0 ) {
|
||||||
if ( data->_heapForward->Size() > 0 ) {
|
if ( data->_heapForward->Size() > 0 ) {
|
||||||
|
@ -99,6 +99,7 @@ void EdgeBasedGraphFactory::Run() {
|
|||||||
Percent p(_nodeBasedGraph->GetNumberOfNodes());
|
Percent p(_nodeBasedGraph->GetNumberOfNodes());
|
||||||
int numberOfResolvedRestrictions(0);
|
int numberOfResolvedRestrictions(0);
|
||||||
int nodeBasedEdgeCounter(0);
|
int nodeBasedEdgeCounter(0);
|
||||||
|
NodeID onlyToNode(0);
|
||||||
|
|
||||||
//Loop over all nodes u. Three nested loop look super-linear, but we are dealing with a number linear in the turns only.
|
//Loop over all nodes u. Three nested loop look super-linear, but we are dealing with a number linear in the turns only.
|
||||||
for(_NodeBasedDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) {
|
for(_NodeBasedDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) {
|
||||||
@ -110,29 +111,56 @@ void EdgeBasedGraphFactory::Run() {
|
|||||||
++nodeBasedEdgeCounter;
|
++nodeBasedEdgeCounter;
|
||||||
_NodeBasedDynamicGraph::NodeIterator v = _nodeBasedGraph->GetTarget(e1);
|
_NodeBasedDynamicGraph::NodeIterator v = _nodeBasedGraph->GetTarget(e1);
|
||||||
//loop over all reachable edges (v,w)
|
//loop over all reachable edges (v,w)
|
||||||
|
bool isOnlyAllowed(false);
|
||||||
|
|
||||||
|
//Check every turn restriction originating from this edge if it is an 'only_*'-turn.
|
||||||
|
if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) {
|
||||||
|
std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator;
|
||||||
|
do {
|
||||||
|
if(v == secondRestrictionIterator->viaNode) {
|
||||||
|
if(secondRestrictionIterator->flags.isOnly) {
|
||||||
|
isOnlyAllowed = true;
|
||||||
|
onlyToNode = secondRestrictionIterator->toNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++secondRestrictionIterator;
|
||||||
|
} while(u == secondRestrictionIterator->fromNode);
|
||||||
|
}
|
||||||
|
|
||||||
for(_NodeBasedDynamicGraph::EdgeIterator e2 = _nodeBasedGraph->BeginEdges(v); e2 < _nodeBasedGraph->EndEdges(v); ++e2) {
|
for(_NodeBasedDynamicGraph::EdgeIterator e2 = _nodeBasedGraph->BeginEdges(v); e2 < _nodeBasedGraph->EndEdges(v); ++e2) {
|
||||||
_NodeBasedDynamicGraph::NodeIterator w = _nodeBasedGraph->GetTarget(e2);
|
_NodeBasedDynamicGraph::NodeIterator w = _nodeBasedGraph->GetTarget(e2);
|
||||||
//if (u,v,w) is a forbidden turn, continue
|
//if (u,v,w) is a forbidden turn, continue
|
||||||
bool isTurnProhibited = false;
|
bool isTurnRestricted(false);
|
||||||
|
if(isOnlyAllowed && w != onlyToNode) {
|
||||||
|
// INFO("skipped turn <" << u << "," << v << "," << w << ">, only allowing <" << u << "," << v << "," << onlyToNode << ">");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if( u != w ) { //only add an edge if turn is not a U-turn
|
if( u != w ) { //only add an edge if turn is not a U-turn
|
||||||
if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) {
|
if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) {
|
||||||
std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator;
|
std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator;
|
||||||
do {
|
do {
|
||||||
if( v == secondRestrictionIterator->viaNode && w == secondRestrictionIterator->toNode) {
|
if(v == secondRestrictionIterator->viaNode) {
|
||||||
isTurnProhibited = true;
|
if(w == secondRestrictionIterator->toNode) {
|
||||||
|
isTurnRestricted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++secondRestrictionIterator;
|
++secondRestrictionIterator;
|
||||||
} while(u == secondRestrictionIterator->fromNode);
|
} while(u == secondRestrictionIterator->fromNode);
|
||||||
}
|
}
|
||||||
if( !isTurnProhibited ) { //only add an edge if turn is not prohibited
|
|
||||||
|
if( !isTurnRestricted || (isOnlyAllowed && w == onlyToNode) ) { //only add an edge if turn is not prohibited
|
||||||
|
if(isOnlyAllowed && w == onlyToNode) {
|
||||||
|
// INFO("Adding 'only_*'-turn <" << u << "," << v << "," << w << ">");
|
||||||
|
} else if(isOnlyAllowed && w != onlyToNode) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
//new costs for edge based edge (e1, e2) = cost (e1) + tc(e1,e2)
|
//new costs for edge based edge (e1, e2) = cost (e1) + tc(e1,e2)
|
||||||
const _NodeBasedDynamicGraph::NodeIterator edgeBasedSource = _nodeBasedGraph->GetEdgeData(e1).edgeBasedNodeID;
|
const _NodeBasedDynamicGraph::NodeIterator edgeBasedSource = _nodeBasedGraph->GetEdgeData(e1).edgeBasedNodeID;
|
||||||
// INFO("edgeBasedSource: " << edgeBasedSource);
|
|
||||||
if(edgeBasedSource > _nodeBasedGraph->GetNumberOfEdges()) {
|
if(edgeBasedSource > _nodeBasedGraph->GetNumberOfEdges()) {
|
||||||
ERR("edgeBasedTarget" << edgeBasedSource << ">" << _nodeBasedGraph->GetNumberOfEdges());
|
ERR("edgeBasedTarget" << edgeBasedSource << ">" << _nodeBasedGraph->GetNumberOfEdges());
|
||||||
}
|
}
|
||||||
const _NodeBasedDynamicGraph::NodeIterator edgeBasedTarget = _nodeBasedGraph->GetEdgeData(e2).edgeBasedNodeID;
|
const _NodeBasedDynamicGraph::NodeIterator edgeBasedTarget = _nodeBasedGraph->GetEdgeData(e2).edgeBasedNodeID;
|
||||||
// INFO("edgeBasedTarget: " << edgeBasedTarget);
|
|
||||||
if(edgeBasedTarget > _nodeBasedGraph->GetNumberOfEdges()) {
|
if(edgeBasedTarget > _nodeBasedGraph->GetNumberOfEdges()) {
|
||||||
ERR("edgeBasedTarget" << edgeBasedTarget << ">" << _nodeBasedGraph->GetNumberOfEdges());
|
ERR("edgeBasedTarget" << edgeBasedTarget << ">" << _nodeBasedGraph->GetNumberOfEdges());
|
||||||
}
|
}
|
||||||
@ -145,7 +173,6 @@ void EdgeBasedGraphFactory::Run() {
|
|||||||
short turnInstruction = AnalyzeTurn(u, v, w);
|
short turnInstruction = AnalyzeTurn(u, v, w);
|
||||||
|
|
||||||
//create edge-based graph edge
|
//create edge-based graph edge
|
||||||
//EdgeBasedEdge(NodeID s, NodeID t, NodeID v, unsigned n1, EdgeWeight w, bool f, bool b, short ty)
|
|
||||||
EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction);
|
EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction);
|
||||||
edgeBasedEdges.push_back(newEdge);
|
edgeBasedEdges.push_back(newEdge);
|
||||||
EdgeBasedNode currentNode;
|
EdgeBasedNode currentNode;
|
||||||
|
@ -121,7 +121,7 @@ public:
|
|||||||
//Is the highway tag listed as usable way?
|
//Is the highway tag listed as usable way?
|
||||||
if(0 < settings[highway]) {
|
if(0 < settings[highway]) {
|
||||||
|
|
||||||
if(0 != maxspeed)
|
if(0 < maxspeed)
|
||||||
w.speed = maxspeed;
|
w.speed = maxspeed;
|
||||||
else
|
else
|
||||||
w.speed = settings[highway];
|
w.speed = settings[highway];
|
||||||
@ -154,7 +154,6 @@ public:
|
|||||||
//Is the route tag listed as usable way in the profile?
|
//Is the route tag listed as usable way in the profile?
|
||||||
if(settings[route] > 0 || settings[man_made] > 0) {
|
if(settings[route] > 0 || settings[man_made] > 0) {
|
||||||
w.useful = true;
|
w.useful = true;
|
||||||
w.direction = _Way::oneway;
|
|
||||||
w.speed = settings[route];
|
w.speed = settings[route];
|
||||||
w.direction = _Way::bidirectional;
|
w.direction = _Way::bidirectional;
|
||||||
}
|
}
|
||||||
@ -178,7 +177,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(w.id == UINT_MAX) {
|
if(w.id == UINT_MAX) {
|
||||||
WARN("found way with unknown type" << w.id);
|
WARN("found way with unknown type: " << w.id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,10 +177,10 @@ struct _RawRestrictionContainer {
|
|||||||
_Restriction restriction;
|
_Restriction restriction;
|
||||||
EdgeID fromWay;
|
EdgeID fromWay;
|
||||||
EdgeID toWay;
|
EdgeID toWay;
|
||||||
unsigned viaWay;
|
unsigned viaNode;
|
||||||
|
|
||||||
_RawRestrictionContainer(EdgeID f, EdgeID t, NodeID vn, unsigned vw) : fromWay(f), toWay(t), viaWay(vw) { restriction.viaNode = vn;}
|
_RawRestrictionContainer(EdgeID f, EdgeID t, NodeID vn, unsigned vw) : fromWay(f), toWay(t), viaNode(vw) { restriction.viaNode = vn;}
|
||||||
_RawRestrictionContainer(bool isOnly = false) : fromWay(UINT_MAX), toWay(UINT_MAX), viaWay(UINT_MAX) { restriction.flags.isOnly = isOnly;}
|
_RawRestrictionContainer(bool isOnly = false) : fromWay(UINT_MAX), toWay(UINT_MAX), viaNode(UINT_MAX) { restriction.flags.isOnly = isOnly;}
|
||||||
|
|
||||||
static _RawRestrictionContainer min_value() {
|
static _RawRestrictionContainer min_value() {
|
||||||
return _RawRestrictionContainer((numeric_limits<unsigned>::min)(), (numeric_limits<unsigned>::min)(), (numeric_limits<unsigned>::min)(), (numeric_limits<unsigned>::min)());
|
return _RawRestrictionContainer((numeric_limits<unsigned>::min)(), (numeric_limits<unsigned>::min)(), (numeric_limits<unsigned>::min)(), (numeric_limits<unsigned>::min)());
|
||||||
@ -233,7 +233,7 @@ struct _WayIDStartAndEndEdge {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmpWayStartAndEnd : public std::binary_function<_WayIDStartAndEndEdge, _WayIDStartAndEndEdge, bool> {
|
struct CmpWayByID : public std::binary_function<_WayIDStartAndEndEdge, _WayIDStartAndEndEdge, bool> {
|
||||||
typedef _WayIDStartAndEndEdge value_type;
|
typedef _WayIDStartAndEndEdge value_type;
|
||||||
bool operator () (const _WayIDStartAndEndEdge & a, const _WayIDStartAndEndEdge & b) const {
|
bool operator () (const _WayIDStartAndEndEdge & a, const _WayIDStartAndEndEdge & b) const {
|
||||||
return a.wayID < b.wayID;
|
return a.wayID < b.wayID;
|
||||||
|
@ -329,14 +329,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// INFO("startcoord: " << smallestEdge.startCoord << ", tgtcoord" << smallestEdge.targetCoord << "result: " << newEndpoint);
|
// INFO("startcoord: " << smallestEdge.startCoord << ", tgtcoord" << smallestEdge.targetCoord << "result: " << newEndpoint);
|
||||||
// INFO("length of old edge: " << LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord));
|
// INFO("length of old edge: " << LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord));
|
||||||
// INFO("Length of new edge: " << LengthOfVector(smallestEdge.startCoord, newEndpoint));
|
// INFO("Length of new edge: " << LengthOfVector(smallestEdge.startCoord, newEndpoint));
|
||||||
// assert(!resultNode.isBidirected || (resultNode.weight1 == resultNode.weight2));
|
// assert(!resultNode.isBidirected() || (resultNode.weight1 == resultNode.weight2));
|
||||||
// if(resultNode.weight1 != resultNode.weight2) {
|
// if(resultNode.weight1 != resultNode.weight2) {
|
||||||
// INFO("-> Weight1: " << resultNode.weight1 << ", weight2: " << resultNode.weight2);
|
// INFO("-> Weight1: " << resultNode.weight1 << ", weight2: " << resultNode.weight2);
|
||||||
// INFO("-> node: " << resultNode.edgeBasedNode << ", bidir: " << (resultNode.isBidirected ? "yes" : "no"));
|
// INFO("-> node: " << resultNode.edgeBasedNode << ", bidir: " << (resultNode.isBidirected() ? "yes" : "no"));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
double ratio = std::min(1., LengthOfVector(smallestEdge.startCoord, newEndpoint)/LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord) );
|
double ratio = std::min(1., LengthOfVector(smallestEdge.startCoord, newEndpoint)/LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord) );
|
||||||
assert(ratio >= 0 && ratio <=1);
|
assert(ratio >= 0 && ratio <=1);
|
||||||
@ -547,6 +547,11 @@ private:
|
|||||||
if(!localStream.get() || !localStream->is_open()) {
|
if(!localStream.get() || !localStream->is_open()) {
|
||||||
localStream.reset(new std::ifstream(iif.c_str(), std::ios::in | std::ios::binary));
|
localStream.reset(new std::ifstream(iif.c_str(), std::ios::in | std::ios::binary));
|
||||||
}
|
}
|
||||||
|
if(!localStream->good()) {
|
||||||
|
localStream->clear(std::ios::goodbit);
|
||||||
|
DEBUG("Resetting stale filestream");
|
||||||
|
}
|
||||||
|
|
||||||
localStream->seekg(startIndexInFile);
|
localStream->seekg(startIndexInFile);
|
||||||
localStream->read((char*) &cellIndex[0], 32*32*sizeof(unsigned));
|
localStream->read((char*) &cellIndex[0], 32*32*sizeof(unsigned));
|
||||||
assert(cellMap.find(fileIndex) != cellMap.end());
|
assert(cellMap.find(fileIndex) != cellMap.end());
|
||||||
|
@ -270,9 +270,9 @@ private:
|
|||||||
if("from" == role || "to" == role) //Only via should be a node
|
if("from" == role || "to" == role) //Only via should be a node
|
||||||
continue;
|
continue;
|
||||||
assert("via" == role);
|
assert("via" == role);
|
||||||
if(UINT_MAX != currentRestrictionContainer.viaWay)
|
if(UINT_MAX != currentRestrictionContainer.viaNode)
|
||||||
currentRestrictionContainer.viaWay = UINT_MAX;
|
currentRestrictionContainer.viaNode = UINT_MAX;
|
||||||
assert(UINT_MAX == currentRestrictionContainer.viaWay);
|
assert(UINT_MAX == currentRestrictionContainer.viaNode);
|
||||||
currentRestrictionContainer.restriction.viaNode = lastRef;
|
currentRestrictionContainer.restriction.viaNode = lastRef;
|
||||||
break;
|
break;
|
||||||
case 1: //way
|
case 1: //way
|
||||||
@ -285,7 +285,7 @@ private:
|
|||||||
}
|
}
|
||||||
if ("via" == role) {
|
if ("via" == role) {
|
||||||
assert(currentRestrictionContainer.restriction.toNode == UINT_MAX);
|
assert(currentRestrictionContainer.restriction.toNode == UINT_MAX);
|
||||||
currentRestrictionContainer.viaWay = lastRef;
|
currentRestrictionContainer.viaNode = lastRef;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: //relation, not used. relations relating to relations are evil.
|
case 2: //relation, not used. relations relating to relations are evil.
|
||||||
|
@ -31,7 +31,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
class XMLParser : public BaseParser<_Node, _RawRestrictionContainer, _Way> {
|
class XMLParser : public BaseParser<_Node, _RawRestrictionContainer, _Way> {
|
||||||
public:
|
public:
|
||||||
XMLParser(const char * filename) {
|
XMLParser(const char * filename) : nodeCallback(NULL), wayCallback(NULL), restrictionCallback(NULL){
|
||||||
WARN("Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf");
|
WARN("Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf");
|
||||||
inputReader = inputReaderFactory(filename);
|
inputReader = inputReaderFactory(filename);
|
||||||
}
|
}
|
||||||
@ -72,9 +72,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( xmlStrEqual( currentName, ( const xmlChar* ) "relation" ) == 1 ) {
|
if ( xmlStrEqual( currentName, ( const xmlChar* ) "relation" ) == 1 ) {
|
||||||
_Relation r;
|
_RawRestrictionContainer r = _ReadXMLRestriction();
|
||||||
r.type = _Relation::unknown;
|
if(r.fromWay != UINT_MAX) {
|
||||||
//todo: parse relation
|
if(!(*restrictionCallback)(r)) {
|
||||||
|
std::cerr << "[XMLParser] restriction not parsed" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xmlFree( currentName );
|
xmlFree( currentName );
|
||||||
}
|
}
|
||||||
@ -82,11 +85,69 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_Relation _ReadXMLRelation ( ) {
|
_RawRestrictionContainer _ReadXMLRestriction ( ) {
|
||||||
_Relation relation;
|
_RawRestrictionContainer restriction;
|
||||||
relation.type = _Relation::unknown;
|
|
||||||
|
|
||||||
return relation;
|
if ( xmlTextReaderIsEmptyElement( inputReader ) != 1 ) {
|
||||||
|
const int depth = xmlTextReaderDepth( inputReader );while ( xmlTextReaderRead( inputReader ) == 1 ) {
|
||||||
|
const int childType = xmlTextReaderNodeType( inputReader );
|
||||||
|
if ( childType != 1 && childType != 15 )
|
||||||
|
continue;
|
||||||
|
const int childDepth = xmlTextReaderDepth( inputReader );
|
||||||
|
xmlChar* childName = xmlTextReaderName( inputReader );
|
||||||
|
if ( childName == NULL )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( depth == childDepth && childType == 15 && xmlStrEqual( childName, ( const xmlChar* ) "relation" ) == 1 ) {
|
||||||
|
xmlFree( childName );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( childType != 1 ) {
|
||||||
|
xmlFree( childName );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( xmlStrEqual( childName, ( const xmlChar* ) "tag" ) == 1 ) {
|
||||||
|
xmlChar* k = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "k" );
|
||||||
|
xmlChar* value = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "v" );
|
||||||
|
if ( k != NULL && value != NULL ) {
|
||||||
|
if(xmlStrEqual(k, ( const xmlChar* ) "restriction" )){
|
||||||
|
if(0 == std::string((const char *) value).find("only_"))
|
||||||
|
restriction.restriction.flags.isOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if ( k != NULL )
|
||||||
|
xmlFree( k );
|
||||||
|
if ( value != NULL )
|
||||||
|
xmlFree( value );
|
||||||
|
} else if ( xmlStrEqual( childName, ( const xmlChar* ) "member" ) == 1 ) {
|
||||||
|
xmlChar* ref = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "ref" );
|
||||||
|
if ( ref != NULL ) {
|
||||||
|
xmlChar * role = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "role" );
|
||||||
|
xmlChar * type = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "type" );
|
||||||
|
if(xmlStrEqual(role, (const xmlChar *) "to") && xmlStrEqual(type, (const xmlChar *) "way")) {
|
||||||
|
restriction.toWay = atoi((const char*) ref);
|
||||||
|
}
|
||||||
|
if(xmlStrEqual(role, (const xmlChar *) "from") && xmlStrEqual(type, (const xmlChar *) "way")) {
|
||||||
|
restriction.fromWay = atoi((const char*) ref);
|
||||||
|
}
|
||||||
|
if(xmlStrEqual(role, (const xmlChar *) "via") && xmlStrEqual(type, (const xmlChar *) "node")) {
|
||||||
|
restriction.restriction.viaNode = atoi((const char*) ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NULL != type)
|
||||||
|
xmlFree( type );
|
||||||
|
if(NULL != role)
|
||||||
|
xmlFree( role );
|
||||||
|
if(NULL != ref)
|
||||||
|
xmlFree( ref );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlFree( childName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return restriction;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Way _ReadXMLWay( ) {
|
_Way _ReadXMLWay( ) {
|
||||||
@ -109,6 +170,9 @@ private:
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( depth == childDepth && childType == 15 && xmlStrEqual( childName, ( const xmlChar* ) "way" ) == 1 ) {
|
if ( depth == childDepth && childType == 15 && xmlStrEqual( childName, ( const xmlChar* ) "way" ) == 1 ) {
|
||||||
|
xmlChar* id = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "id" );
|
||||||
|
way.id = atoi((char*)id);
|
||||||
|
xmlFree(id);
|
||||||
xmlFree( childName );
|
xmlFree( childName );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public:
|
|||||||
distance = searchEngine->ComputeRoute(segmentPhantomNodes, path);
|
distance = searchEngine->ComputeRoute(segmentPhantomNodes, path);
|
||||||
|
|
||||||
if(INT_MAX == distance ) {
|
if(INT_MAX == distance ) {
|
||||||
INFO( "Error occurred, single path not found" );
|
DEBUG( "Error occurred, single path not found" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//put segments at correct position of routes raw data
|
//put segments at correct position of routes raw data
|
||||||
|
@ -208,7 +208,7 @@ int main (int argc, char *argv[]) {
|
|||||||
time = get_timestamp();
|
time = get_timestamp();
|
||||||
|
|
||||||
cout << "[extractor] Sorting used ways ... " << flush;
|
cout << "[extractor] Sorting used ways ... " << flush;
|
||||||
stxxl::sort(externalMemory.wayStartEndVector.begin(), externalMemory.wayStartEndVector.end(), CmpWayStartAndEnd(), memory_to_use);
|
stxxl::sort(externalMemory.wayStartEndVector.begin(), externalMemory.wayStartEndVector.end(), CmpWayByID(), memory_to_use);
|
||||||
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
||||||
|
|
||||||
cout << "[extractor] Sorting restrctns. by from... " << flush;
|
cout << "[extractor] Sorting restrctns. by from... " << flush;
|
||||||
@ -255,8 +255,7 @@ int main (int argc, char *argv[]) {
|
|||||||
cout << "[extractor] Fixing restriction ends ... " << flush;
|
cout << "[extractor] Fixing restriction ends ... " << flush;
|
||||||
restrictionsIT = externalMemory.restrictionsVector.begin();
|
restrictionsIT = externalMemory.restrictionsVector.begin();
|
||||||
wayStartAndEndEdgeIT = externalMemory.wayStartEndVector.begin();
|
wayStartAndEndEdgeIT = externalMemory.wayStartEndVector.begin();
|
||||||
while(wayStartAndEndEdgeIT != externalMemory.wayStartEndVector.end() &&
|
while(wayStartAndEndEdgeIT != externalMemory.wayStartEndVector.end() && restrictionsIT != externalMemory.restrictionsVector.end()) {
|
||||||
restrictionsIT != externalMemory.restrictionsVector.end()) {
|
|
||||||
if(wayStartAndEndEdgeIT->wayID < restrictionsIT->toWay){
|
if(wayStartAndEndEdgeIT->wayID < restrictionsIT->toWay){
|
||||||
++wayStartAndEndEdgeIT;
|
++wayStartAndEndEdgeIT;
|
||||||
continue;
|
continue;
|
||||||
@ -278,11 +277,13 @@ int main (int argc, char *argv[]) {
|
|||||||
|
|
||||||
if(UINT_MAX != restrictionsIT->restriction.fromNode && UINT_MAX != restrictionsIT->restriction.toNode) {
|
if(UINT_MAX != restrictionsIT->restriction.fromNode && UINT_MAX != restrictionsIT->restriction.toNode) {
|
||||||
++usableRestrictionsCounter;
|
++usableRestrictionsCounter;
|
||||||
|
} else {
|
||||||
|
INFO("Restriction from: " << restrictionsIT->restriction.fromNode << ", to: " << restrictionsIT->restriction.toNode);
|
||||||
}
|
}
|
||||||
++restrictionsIT;
|
++restrictionsIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
||||||
|
INFO("usable restrictions: " << usableRestrictionsCounter);
|
||||||
//serialize restrictions
|
//serialize restrictions
|
||||||
ofstream restrictionsOutstream;
|
ofstream restrictionsOutstream;
|
||||||
restrictionsOutstream.open(restrictionsFileName.c_str(), ios::binary);
|
restrictionsOutstream.open(restrictionsFileName.c_str(), ios::binary);
|
||||||
|
Loading…
Reference in New Issue
Block a user