This commit is contained in:
DennisOSRM 2012-05-09 21:06:35 +02:00
commit bfaab86330
9 changed files with 87 additions and 20 deletions

View File

@ -239,7 +239,8 @@ public:
bool flushedContractor = false;
while ( numberOfContractedNodes < numberOfNodes ) {
if(!flushedContractor && (numberOfContractedNodes > (numberOfNodes*0.75) ) ){
INFO("Flushing memory after " << numberOfContractedNodes << " nodes");
std::vector<_ContractorEdge> newSetOfEdges; //this one is not explicitely cleared since it goes out of scope anywa
std::cout << " [flush " << numberOfContractedNodes << " nodes] " << std::flush;
//Delete old heap data to free memory that we need for the coming operations
for ( unsigned threadNum = 0; threadNum < maxThreads; threadNum++ ) {
@ -264,9 +265,6 @@ public:
remainingNodes[newNodeID].first = newNodeID;
}
//create new _DynamicGraph, goes out of scope after the renumbering
boost::shared_ptr<_DynamicGraph> _newGraph ( new _DynamicGraph(remainingNodes.size()) );
//Write dummy number of edges to temporary file
std::ofstream temporaryEdgeStorage(temporaryEdgeStorageFilename.c_str(), std::ios::binary);
initialFilePosition = temporaryEdgeStorage.tellp();
@ -277,7 +275,6 @@ public:
for(unsigned i = 0; i < _graph->GetNumberOfNodes(); ++i) {
//INFO("Restructuring node " << i << "|" << _graph->GetNumberOfNodes());
const NodeID start = i;
//UINT_MAX indicates that node is already contracted
for(_DynamicGraph::EdgeIterator currentEdge = _graph->BeginEdges(start); currentEdge < _graph->EndEdges(start); ++currentEdge) {
_DynamicGraph::EdgeData & data = _graph->GetEdgeData(currentEdge);
const NodeID target = _graph->GetTarget(currentEdge);
@ -290,10 +287,15 @@ public:
}else {
//node is not yet contracted.
//add (renumbered) outgoing edges to new DynamicGraph.
data.originalViaNodeID = true;
_ContractorEdge newEdge;
newEdge.source = newNodeIDFromOldNodeIDMap[start];
newEdge.target = newNodeIDFromOldNodeIDMap[target];
newEdge.data = data;
newEdge.data.originalViaNodeID = true;
assert(UINT_MAX != newNodeIDFromOldNodeIDMap[start] );
assert(UINT_MAX != newNodeIDFromOldNodeIDMap[target]);
_newGraph->InsertEdge(newNodeIDFromOldNodeIDMap[start], newNodeIDFromOldNodeIDMap[target], data );
// _newGraph->InsertEdge(newNodeIDFromOldNodeIDMap[start], newNodeIDFromOldNodeIDMap[target], data );
newSetOfEdges.push_back(newEdge);
}
}
}
@ -310,17 +312,22 @@ public:
nodePriority.swap(newNodePriority);
//Delete old nodePriority vector
std::vector<double>().swap(newNodePriority);
//Alten Graphen löschen und neuen Graphen speichern.
//old Graph is removed
_graph.reset();
//create new graph
std::sort(newSetOfEdges.begin(), newSetOfEdges.end());
//int nodes, const ContainerT &graph
_graph.reset( new _DynamicGraph(remainingNodes.size(), newSetOfEdges));
flushedContractor = true;
//INFO: MAKE SURE THIS IS THE LAST OPERATION OF THE FLUSH!
//reinitialize heaps and ThreadData objects with appropriate size
for ( unsigned threadNum = 0; threadNum < maxThreads; ++threadNum ) {
threadData.push_back( new _ThreadData( _newGraph->GetNumberOfNodes() ) );
threadData.push_back( new _ThreadData( _graph->GetNumberOfNodes() ) );
}
//old Graph is removed
_graph.swap(_newGraph);
flushedContractor = true;
}
const int last = ( int ) remainingNodes.size();

View File

@ -64,6 +64,7 @@ def write_server_ini osm_file
hsgrData=#{DATA_FOLDER}/#{osm_file}.osrm.hsgr
nodesData=#{DATA_FOLDER}/#{osm_file}.osrm.nodes
edgesData=#{DATA_FOLDER}/#{osm_file}.osrm.edges
ramIndex=#{DATA_FOLDER}/#{osm_file}.osrm.ramIndex
fileIndex=#{DATA_FOLDER}/#{osm_file}.osrm.fileIndex
namesData=#{DATA_FOLDER}/#{osm_file}.osrm.names

View File

@ -58,6 +58,7 @@ Given /^the preprocessed files for "([^"]*)" are present and up to date$/ do |ar
File.exists?("#{area}.osrm.restrictions").should == true
File.exists?("#{area}.osrm.hsgr").should == true
File.exists?("#{area}.osrm.nodes").should == true
File.exists?("#{area}.osrm.edges").should == true
File.exists?("#{area}.osrm.ramIndex").should == true
File.exists?("#{area}.osrm.fileIndex").should == true
end

View File

@ -10,7 +10,7 @@ end
def read_speedprofile profile
@speedprofile = {}
@speedprofile_str = nil
s = File.read "speedprofiles/#{profile}.ini"
s = File.read "test/speedprofiles/#{profile}.ini"
s.scan /(.*)=(.*)/ do |option|
@speedprofile[option[0].strip] = option[1].strip
end
@ -32,6 +32,7 @@ Port = 5000
hsgrData=#{@osm_file}.osrm.hsgr
nodesData=#{@osm_file}.osrm.nodes
edgesData=#{@osm_file}.osrm.edges
ramIndex=#{@osm_file}.osrm.ramIndex
fileIndex=#{@osm_file}.osrm.fileIndex
namesData=#{@osm_file}.osrm.names

View File

@ -6,9 +6,6 @@ Feature: Estimation of travel time
Background: Use specific speeds
Given the speedprofile "bicycle"
And the speedprofile settings
| primary | 15 |
| footway | 5 |
Scenario: Basic travel time, 1m scale
Given a grid size of 1 meters
@ -178,5 +175,4 @@ Feature: Estimation of travel time
| 1 | 4 | ab | 72s |
| 4 | 3 | ab | 24s |
| 4 | 2 | ab | 48s |
| 4 | 1 | ab | 72s |
| 4 | 1 | ab | 72s |

View File

@ -66,7 +66,7 @@ BOOL WINAPI console_ctrl_handler(DWORD ctrl_type)
int main (int argc, char *argv[]) {
#ifdef __linux__
if(!mlockall(MCL_CURRENT | MCL_FUTURE))
ERR("Process " << argv[0] << "could not be locked to RAM");
WARN("Process " << argv[0] << "could not be locked to RAM");
#endif
#ifndef _WIN32

View File

@ -0,0 +1,10 @@
[bicycle]
accessTag = bicycle
obeyOneways = yes
obeyBollards = no
useRestrictions = yes
takeMinimumOfSpeeds = yes
defaultSpeed = 15
primary = 15
cycleway = 15
footway = 5

View File

@ -0,0 +1,23 @@
[car]
accessTag = motorcar
defaultSpeed = 50
obeyOneways = yes
useRestrictions = yes
barrier = bollard
motorway = 100
motorway_link = 90
trunk = 90
trunk_link = 70
primary = 70
primary_link = 60
secondary = 60
secondary_link = 50
tertiary = 50
tertiary_link = 40
road = 40
residential = 40
unclassified = 30
service = 20
living_street = 10

View File

@ -0,0 +1,28 @@
[foot]
accessTag = foot
defaultSpeed = 5
obeyOneways = no
useRestrictions = no
obeyBollards = no
primary = 5
primary_link = 5
secondary = 5
secondary_link = 5
tertiary = 5
residential = 5
unclassified = 5
living_street = 5
road = 5
service = 5
track = 5
path = 5
cycleway = 5
footway = 5
pedestrian = 5
pier = 5
steps = 2
ferry = 5
excludeFromGrid = ferry