This commit is contained in:
Emil Tin 2011-12-01 21:55:02 +01:00
commit d18b648c1e
11 changed files with 107 additions and 144 deletions

View File

@ -66,8 +66,7 @@ public:
NodeID target;
struct EdgeData {
NodeID via;
unsigned nameID1;
unsigned nameID2;
unsigned nameID;
int distance;
bool shortcut;
bool forward;
@ -91,7 +90,7 @@ public:
bool operator== ( const Edge& right ) const {
return ( source == right.source && target == right.target && data.distance == right.data.distance &&
data.shortcut == right.data.shortcut && data.forward == right.data.forward && data.backward == right.data.backward
&& data.via == right.data.via && data.nameID1 == right.data.nameID1 && data.nameID2 == right.data.nameID2
&& data.via == right.data.via && data.nameID == right.data.nameID
);
}
};

View File

@ -304,7 +304,7 @@ public:
newEdge.data.distance = data.distance;
newEdge.data.shortcut = data.shortcut;
newEdge.data.via = data.via;
newEdge.data.nameID1 = data.nameID;
newEdge.data.nameID = data.nameID;
newEdge.data.turnInstruction = data.turnInstruction;
newEdge.data.forward = data.forward;
newEdge.data.backward = data.backward;
@ -495,6 +495,7 @@ private:
bool _UpdateNeighbours( std::vector< double >* priorities, std::vector< _PriorityData >* const nodeData, _ThreadData* const data, NodeID node ) {
std::vector< NodeID >& neighbours = data->neighbours;
neighbours.clear();
std::vector< NodeID>().swap(neighbours);
//find all neighbours
for ( _DynamicGraph::EdgeIterator e = _graph->BeginEdges( node ) ; e < _graph->EndEdges( node ) ; ++e ) {
@ -521,6 +522,7 @@ private:
std::vector< NodeID >& neighbours = data->neighbours;
neighbours.clear();
std::vector< NodeID>().swap(neighbours);
for ( _DynamicGraph::EdgeIterator e = _graph->BeginEdges( node ) ; e < _graph->EndEdges( node ) ; ++e ) {
const NodeID target = _graph->GetTarget( e );

View File

@ -103,7 +103,7 @@ void EdgeBasedGraphFactory::Run() {
//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 ) {
//loop over all adjacent edge (u,v)
while(restrictionIterator->fromNode < u && inputRestrictions.end() != restrictionIterator) {
while(inputRestrictions.end() != restrictionIterator && restrictionIterator->fromNode < u) {
++restrictionIterator;
}
for(_NodeBasedDynamicGraph::EdgeIterator e1 = _nodeBasedGraph->BeginEdges(u); e1 < _nodeBasedGraph->EndEdges(u); ++e1) {
@ -115,7 +115,7 @@ void EdgeBasedGraphFactory::Run() {
//if (u,v,w) is a forbidden turn, continue
bool isTurnProhibited = false;
if( u != w ) { //only add an edge if turn is not a U-turn
if(u == restrictionIterator->fromNode) {
if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) {
std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator;
do {
if( v == secondRestrictionIterator->viaNode && w == secondRestrictionIterator->toNode) {

View File

@ -135,7 +135,7 @@ public:
}
}
if("yes" == accessClass)
if("yes" == accessClass || "designated" == accessClass)
w.access = true;
else if("no" == accessClass)
w.access = false;
@ -164,7 +164,7 @@ public:
w.type = 1;
//Get the unique identifier for the street name
StringMap::const_iterator strit = stringMap->find(w.name);
const StringMap::const_iterator strit = stringMap->find(w.name);
if(strit == stringMap->end()) {
w.nameID = externalMemory->nameVector.size();
externalMemory->nameVector.push_back(w.name);

View File

@ -256,7 +256,7 @@ private:
return false;
} else {
assert(!ed.shortcut);
path.push_back(_PathData(ed.via, ed.nameID1, ed.turnInstruction, ed.distance) );
path.push_back(_PathData(ed.via, ed.nameID, ed.turnInstruction, ed.distance) );
return true;
}
}

View File

@ -58,7 +58,7 @@ struct ObjectsForQueryStruct {
names = new std::vector<std::string>();
char buf[1024];
for(unsigned i = 0; i < size; i++) {
for(unsigned i = 0; i < size; ++i) {
unsigned sizeOfString = 0;
namesInStream.read((char *)&sizeOfString, sizeof(unsigned));
memset(buf, 0, 1024*sizeof(char));

View File

@ -6,7 +6,7 @@ installing dependencies and running make should suffice. Make sure the following
dependencies are installed:
- Boost 1.41+
- sparsehash 1.4+
- sparsehash 1.4+
- g++ 4.2+
- libxml2 2.7+
- scons 2.10+
@ -77,11 +77,12 @@ preprocessing runs in three steps, all done by seperate programs.
necessary, because the osm data is not made to support fast routing out of the
box. The output of the step is a file called 'file.osrm'
'osrm-prepare file.osrm' preprocesses the road network and computes additional
information that is exploited later to speed up the path computation. The output
of this step consists of two file 'file.osrm.hsgr' and 'file.osrm.nodes'. The first
file is the so-called hierarchy that speeds up the path computation while the
latter one carries (among other things) geographical information.
'osrm-prepare file.osrm file.restrictions' preprocesses the road network and
computes additional information that is exploited later to speed up the path
computation. The output of this step consists of two file 'file.osrm.hsgr' and
'file.osrm.nodes'. The first file is the so-called hierarchy that speeds up the
path computation while the latter one carries (among other things) geographical
information.
'osrm-routed' starts the server on TCP Port 5000. The
server communicates over http and can be queried by any browser or http-capable

View File

@ -48,17 +48,17 @@ NodeID readOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
int dir, xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open)
ExternalNodeMap ext2IntNodeMap;
in >> n;
VERBOSE(cout << "Importing n = " << n << " nodes ..." << flush;)
for (NodeID i=0; i<n;i++) {
DEBUG("Importing n = " << n << " nodes ");
for (NodeID i=0; i < n; ++i) {
in >> id >> ycoord >> xcoord;
int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id));
ext2IntNodeMap.insert(make_pair(id, i));
}
in >> m;
VERBOSE(cout << " and " << m << " edges ..." << flush;)
DEBUG(" and " << m << " edges ...");
edgeList.reserve(m);
for (EdgeID i=0; i<m; i++) {
for (EdgeID i=0; i<m; ++i) {
EdgeWeight weight;
short type;
NodeID nameID;
@ -73,23 +73,19 @@ NodeID readOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
if (1 == dir) backward = false;
if (2 == dir) forward = false;
if(length == 0)
{ cerr << "loaded null length edge" << endl; exit(1); }
if(length == 0) { ERR("loaded null length edge"); }
// translate the external NodeIDs to internal IDs
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source);
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end())
{
cerr << "after " << edgeList.size() << " edges" << endl;
cerr << "->" << source << "," << target << "," << length << "," << dir << "," << weight << endl;
cerr << "unresolved source NodeID: " << source << endl; exit(0);
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) {
ERR("after " << edgeList.size() << " edges" << "\n->" << source << "," << target << "," << length << "," << dir << "," << weight << "\n->unresolved source NodeID: " << source );
}
source = intNodeID->second;
intNodeID = ext2IntNodeMap.find(target);
if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { cerr << "unresolved target NodeID : " << target << endl; exit(0); }
if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { ERR("unresolved target NodeID : " << target); }
target = intNodeID->second;
if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); }
if(source == UINT_MAX || target == UINT_MAX) { ERR( "nonexisting source or target" ); }
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type );
edgeList.push_back(inputEdge);
@ -107,8 +103,8 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
int xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open)
ExternalNodeMap ext2IntNodeMap;
in.read((char*)&n, sizeof(NodeID));
VERBOSE(cout << "Importing n = " << n << " nodes ..." << flush;)
for (NodeID i=0; i<n;i++) {
DEBUG("Importing n = " << n << " nodes ");
for (NodeID i=0; i<n; ++i) {
in.read((char*)&id, sizeof(unsigned));
in.read((char*)&ycoord, sizeof(int));
in.read((char*)&xcoord, sizeof(int));
@ -116,27 +112,27 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
ext2IntNodeMap.insert(make_pair(id, i));
}
in.read((char*)&m, sizeof(unsigned));
VERBOSE(cout << " and " << m << " edges ..." << flush;)
DEBUG(" and " << m << " edges ");
for(unsigned i = 0; i < inputRestrictions.size(); ++i) {
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(inputRestrictions[i].fromNode);
if( intNodeID == ext2IntNodeMap.end()) {
DEBUG("Unmapped restriction")
continue;
DEBUG("Unmapped from Node of restriction");
continue;
}
inputRestrictions[i].fromNode = intNodeID->second;
intNodeID = ext2IntNodeMap.find(inputRestrictions[i].viaNode);
if( intNodeID == ext2IntNodeMap.end()) {
DEBUG("Unmapped restriction")
continue;
DEBUG("Unmapped via node of restriction");
continue;
}
inputRestrictions[i].viaNode = intNodeID->second;
intNodeID = ext2IntNodeMap.find(inputRestrictions[i].toNode);
if( intNodeID == ext2IntNodeMap.end()) {
DEBUG("Unmapped restriction")
continue;
DEBUG("Unmapped to node of restriction");
continue;
}
inputRestrictions[i].toNode = intNodeID->second;
}
@ -148,7 +144,7 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
int length;
bool isRoundabout;
for (EdgeID i=0; i<m; i++) {
for (EdgeID i=0; i<m; ++i) {
in.read((char*)&source, sizeof(unsigned));
in.read((char*)&target, sizeof(unsigned));
in.read((char*)&length, sizeof(int));
@ -158,22 +154,20 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
in.read((char*)&nameID, sizeof(unsigned));
in.read((char*)&isRoundabout, sizeof(bool));
assert(length > 0);
assert(weight > 0);
assert(0<=dir && dir<=2);
GUARANTEE(length > 0, "loaded null length edge" );
GUARANTEE(weight > 0, "loaded null weight");
GUARANTEE(0<=dir && dir<=2, "loaded bogus direction");
bool forward = true;
bool backward = true;
if (1 == dir) { backward = false; }
if (2 == dir) { forward = false; }
if(length == 0) { cerr << "loaded null length edge" << endl; exit(1); }
// translate the external NodeIDs to internal IDs
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source);
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) {
#ifndef NDEBUG
cerr << "[warning] unresolved source NodeID: " << source << endl;
WARN(" unresolved source NodeID: " << source );
#endif
continue;
}
@ -181,20 +175,19 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
intNodeID = ext2IntNodeMap.find(target);
if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) {
#ifndef NDEBUG
cerr << "unresolved target NodeID : " << target << endl;
WARN("unresolved target NodeID : " << target );
#endif
continue;
}
target = intNodeID->second;
if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); }
GUARANTEE(source != UINT_MAX && target != UINT_MAX, "nonexisting source or target");
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout );
edgeList.push_back(inputEdge);
}
ext2IntNodeMap.clear();
vector<ImportEdge>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
cout << "ok" << endl;
INFO("Graph loaded ok");
return n;
}
template<typename EdgeT>
@ -204,17 +197,17 @@ NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
int dir, xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open)
ExternalNodeMap ext2IntNodeMap;
in >> n;
VERBOSE(cout << "Importing n = " << n << " nodes ..." << flush;)
for (NodeID i=0; i<n;i++) {
DEBUG("Importing n = " << n << " nodes ");
for (NodeID i=0; i<n;++i) {
in >> id >> ycoord >> xcoord;
int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id));
ext2IntNodeMap.insert(make_pair(id, i));
}
in >> m;
VERBOSE(cout << " and " << m << " edges ..." << flush;)
DEBUG(" and " << m << " edges");
edgeList.reserve(m);
for (EdgeID i=0; i<m; i++) {
for (EdgeID i=0; i<m; ++i) {
EdgeWeight weight;
unsigned speedType(0);
short type(0);
@ -279,7 +272,7 @@ NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
assert(length > 0);
assert(weight > 0);
if(dir <0 || dir > 2)
std::cerr << "[error] direction bogus: " << dir << std::endl;
WARN("direction bogus: " << dir);
assert(0<=dir && dir<=2);
bool forward = true;
@ -287,23 +280,19 @@ NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
if (dir == 1) backward = false;
if (dir == 2) forward = false;
if(length == 0)
{ cerr << "loaded null length edge" << endl; exit(1); }
if(length == 0) { ERR("loaded null length edge"); }
// translate the external NodeIDs to internal IDs
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source);
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end())
{
cerr << "after " << edgeList.size() << " edges" << endl;
cerr << "->" << source << "," << target << "," << length << "," << dir << "," << weight << endl;
cerr << "unresolved source NodeID: " << source << endl; exit(0);
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) {
ERR("after " << edgeList.size() << " edges" << "\n->" << source << "," << target << "," << length << "," << dir << "," << weight << "\n->unresolved source NodeID: " << source);
}
source = intNodeID->second;
intNodeID = ext2IntNodeMap.find(target);
if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { cerr << "unresolved target NodeID : " << target << endl; exit(0); }
if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { ERR("unresolved target NodeID : " << target); }
target = intNodeID->second;
if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); }
if(source == UINT_MAX || target == UINT_MAX) { ERR("nonexisting source or target" ); }
EdgeT inputEdge(source, target, 0, weight, forward, backward, type );
edgeList.push_back(inputEdge);
@ -333,12 +322,9 @@ NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
EdgeWeight weight;
in >> source >> target >> weight >> dir;
// if(dir == 3)
// dir = 0;
assert(weight > 0);
if(dir <0 || dir > 3)
std::cerr << "[error] direction bogus: " << dir << std::endl;
ERR( "[error] direction bogus: " << dir );
assert(0<=dir && dir<=3);
bool forward = true;
@ -347,8 +333,7 @@ NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
if (dir == 2) forward = false;
if (dir == 3) {backward = true; forward = true;}
if(weight == 0)
{ cerr << "loaded null length edge" << endl; exit(1); }
if(weight == 0) { ERR("loaded null length edge"); }
if( nodeMap.find(source) == nodeMap.end()) {
nodeMap.insert(std::make_pair(source, numberOfNodes ));
@ -365,8 +350,6 @@ NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
}
vector<EdgeT>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
// cout << "ok" << endl;
// std::cout << "imported " << numberOfNodes << " nodes and " << edgeList.size() << " edges" << std::endl;
nodeMap.clear();
return numberOfNodes;
}

View File

@ -28,7 +28,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
#undef VERBOSE2
#endif
#include <climits>
#include <boost/foreach.hpp>
#include <fstream>
#include <istream>
#include <iostream>
@ -60,11 +61,10 @@ std::vector<_Restriction> inputRestrictions;
int main (int argc, char *argv[]) {
if(argc < 3) {
cerr << "usage: " << std::endl << argv[0] << " <osrm-data> <osrm-restrictions>" << std::endl;
exit(-1);
ERR("usage: " << std::endl << argv[0] << " <osrm-data> <osrm-restrictions>");
}
INFO("Using restrictions from file: " << argv[2]);
ifstream restrictionsInstream(argv[2], ios::binary);
std::ifstream restrictionsInstream(argv[2], ios::binary);
_Restriction restriction;
unsigned usableRestrictionsCounter(0);
restrictionsInstream.read((char*)&usableRestrictionsCounter, sizeof(unsigned));
@ -83,36 +83,24 @@ int main (int argc, char *argv[]) {
}
omp_set_num_threads(numberOfThreads);
std::cout << "preprocessing data from input file " << argv[1];
INFO("preprocessing data from input file " << argv[1] << " using STL "
#ifdef _GLIBCXX_PARALLEL
std::cout << " using STL parallel mode" << std::endl;
"parallel (GCC)"
#else
std::cout << " using STL serial mode" << std::endl;
"serial"
#endif
" mode");
ifstream in;
in.open (argv[1], ifstream::in | ifstream::binary);
if (!in.is_open()) {
cerr << "Cannot open " << argv[1] << std::endl; exit(-1);
ERR("Cannot open " << argv[1]);
}
char nodeOut[1024];
char edgeOut[1024];
char ramIndexOut[1024];
char fileIndexOut[1024];
char levelInfoOut[1024];
strcpy(nodeOut, argv[1]);
strcpy(edgeOut, argv[1]);
strcpy(ramIndexOut, argv[1]);
strcpy(fileIndexOut, argv[1]);
strcpy(levelInfoOut, argv[1]);
strcat(nodeOut, ".nodes");
strcat(edgeOut, ".hsgr");
strcat(ramIndexOut, ".ramIndex");
strcat(fileIndexOut, ".fileIndex");
strcat(levelInfoOut, ".levels");
char nodeOut[1024]; strcpy(nodeOut, argv[1]); strcat(nodeOut, ".nodes");
char edgeOut[1024]; strcpy(edgeOut, argv[1]); strcat(edgeOut, ".hsgr");
char ramIndexOut[1024]; strcpy(ramIndexOut, argv[1]); strcat(ramIndexOut, ".ramIndex");
char fileIndexOut[1024]; strcpy(fileIndexOut, argv[1]); strcat(fileIndexOut, ".fileIndex");
char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels");
std::vector<ImportEdge> edgeList;
NodeID n = readBinaryOSRMGraphFromStream(in, edgeList, &internalToExternaleNodeMapping, inputRestrictions);
@ -132,24 +120,24 @@ int main (int argc, char *argv[]) {
DELETE(edgeBasedGraphFactory);
WritableGrid * writeableGrid = new WritableGrid();
std::cout << "building grid ..." << std::flush;
INFO("building grid ...");
writeableGrid->ConstructGrid(nodeBasedEdgeList, &internalToExternaleNodeMapping, ramIndexOut, fileIndexOut);
DELETE( writeableGrid );
std::cout << "writing node map ..." << std::flush;
ofstream mapOutFile(nodeOut, ios::binary);
nodeBasedEdgeList.clear();
std::vector<EdgeBasedGraphFactory::EdgeBasedNode>().swap(nodeBasedEdgeList);
for(NodeID i = 0; i < internalToExternaleNodeMapping.size(); i++) {
mapOutFile.write((char *)&(internalToExternaleNodeMapping.at(i)), sizeof(NodeInfo));
INFO("writing node map ...");
std::ofstream mapOutFile(nodeOut, ios::binary);
BOOST_FOREACH(NodeInfo & info, internalToExternaleNodeMapping) {
mapOutFile.write((char *)&(info), sizeof(NodeInfo));
}
mapOutFile.close();
std::cout << "ok" << std::endl;
internalToExternaleNodeMapping.clear();
std::vector<NodeInfo>().swap(internalToExternaleNodeMapping);
inputRestrictions.clear();
std::vector<_Restriction>().swap(inputRestrictions);
std::cout << "initializing contractor ..." << std::flush;
INFO("initializing contractor");
Contractor* contractor = new Contractor( n, edgeBasedEdgeList );
double contractionStartedTimestamp(get_timestamp());
contractor->Run();
@ -160,24 +148,25 @@ int main (int argc, char *argv[]) {
ContractionCleanup * cleanup = new ContractionCleanup(n, contractedEdges);
contractedEdges.clear();
std::vector<ContractionCleanup::Edge>().swap(contractedEdges);
cleanup->Run();
std::vector< InputEdge> cleanedEdgeList;
cleanup->GetData(cleanedEdgeList);
DELETE( cleanup );
std::cout << "Serializing edges " << std::flush;
INFO("Serializing edges ");
ofstream edgeOutFile(edgeOut, ios::binary);
Percent p(cleanedEdgeList.size());
for(std::vector< InputEdge>::iterator it = cleanedEdgeList.begin(); it != cleanedEdgeList.end(); it++) {
BOOST_FOREACH(InputEdge & edge, cleanedEdgeList) {
p.printIncrement();
edgeOutFile.write((char *)&(it->data), sizeof(EdgeData));
edgeOutFile.write((char *)&(it->source), sizeof(NodeID));
edgeOutFile.write((char *)&(it->target), sizeof(NodeID));
edgeOutFile.write((char *)&(edge.data), sizeof(EdgeData));
edgeOutFile.write((char *)&(edge.source), sizeof(NodeID));
edgeOutFile.write((char *)&(edge.target), sizeof(NodeID));
}
edgeOutFile.close();
cleanedEdgeList.clear();
std::cout << "finished" << std::endl;
INFO("finished preprocessing");
return 0;
}

View File

@ -70,19 +70,16 @@ bool removeIfUnused(ClassT n) { return (false == n.used); }
int main (int argc, char *argv[]) {
if(argc <= 1) {
cerr << "usage: " << endl << argv[0] << " <file.osm/.osm.bz2/.osm.pbf>" << endl;
exit(-1);
}
GUARANTEE((argc > 1) ,"usage: \n" << argv[0] << " <file.osm/.osm.bz2/.osm.pbf>");
cout << "[extractor] extracting data from input file " << argv[1] << endl;
bool isPBF = false;
string outputFileName(argv[1]);
string restrictionsFileName(argv[1]);
string::size_type pos = outputFileName.find(".osm.bz2");
if(pos==string::npos) {
INFO("extracting data from input file " << argv[1]);
bool isPBF(false);
std::string outputFileName(argv[1]);
std::string restrictionsFileName(argv[1]);
std::string::size_type pos = outputFileName.find(".osm.bz2");
if(pos==std::string::npos) {
pos = outputFileName.find(".osm.pbf");
if(pos!=string::npos) {
if(pos!=std::string::npos) {
isPBF = true;
}
}
@ -99,7 +96,7 @@ int main (int argc, char *argv[]) {
restrictionsFileName.append(".osrm.restrictions");
}
}
string adressFileName(outputFileName);
std::string adressFileName(outputFileName);
Settings settings;
boost::property_tree::ptree pt;
@ -109,15 +106,15 @@ int main (int argc, char *argv[]) {
INFO("Found the following speed profiles: ");
int profileCounter(0);
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("")) {
string name = v.first;
std::string name = v.first;
cout << " [" << profileCounter << "]" << name << endl;
++profileCounter;
}
string usedSpeedProfile(pt.get_child("").begin()->first);
std::string usedSpeedProfile(pt.get_child("").begin()->first);
INFO("Using profile \"" << usedSpeedProfile << "\"")
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child(usedSpeedProfile)) {
string name = v.first;
string value = v.second.get<string>("");
std::string name = v.first;
std::string value = v.second.get<std::string>("");
DEBUG("inserting " << name << "=" << value);
if(name == "obeyOneways") {
if(value == "no")
@ -150,23 +147,21 @@ int main (int argc, char *argv[]) {
unsigned amountOfRAM = 1;
unsigned installedRAM = GetPhysicalmemory();
if(installedRAM < 2048264) {
cout << "[Warning] Machine has less than 2GB RAM." << endl;
WARN("Machine has less than 2GB RAM.");
}
if(testDataFile("extractor.ini")) {
ExtractorConfiguration extractorConfig("extractor.ini");
unsigned memoryAmountFromFile = atoi(extractorConfig.GetParameter("Memory").c_str());
if( memoryAmountFromFile != 0 && memoryAmountFromFile <= installedRAM/(1024*1024))
amountOfRAM = memoryAmountFromFile;
cout << "[extractor] using " << amountOfRAM << " GB of RAM for buffers" << endl;
INFO("Using " << amountOfRAM << " GB of RAM for buffers");
}
StringMap stringMap;
STXXLContainers externalMemory;
unsigned usedNodeCounter = 0;
unsigned usedEdgeCounter = 0;
StringMap stringMap;
double time = get_timestamp();
stringMap[""] = 0;
@ -178,13 +173,9 @@ int main (int argc, char *argv[]) {
parser = new XMLParser(argv[1]);
}
parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction);
if(parser->Init()) {
parser->Parse();
} else {
cerr << "[error] parser not initialized!" << endl;
exit(-1);
}
delete parser;
GUARANTEE(parser->Init(), "Parser not initialized!");
parser->Parse();
DELETE(parser);
stringMap.clear();
try {

View File

@ -31,8 +31,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
using namespace std;
#define VERBOSE(x) x
#define VERBOSE2(x)
#ifdef STXXL_VERBOSE_LEVEL
#undef STXXL_VERBOSE_LEVEL
#endif
@ -41,12 +39,12 @@ using namespace std;
#define INFO(x) do {std::cout << "[info " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0);
#define ERR(x) do {std::cerr << "[error " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl; exit(-1);} while(0);
#define WARN(x) do {std::cerr << "[warn " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0);
#define GUARANTEE(x,y) do { {do{ if(false == (x)) { ERR(y) } } while(0);} } while(0);
#ifdef NDEBUG
#define DEBUG(x)
#define GUARANTEE(x,y)
#else
#define DEBUG(x) do {std::cout << "[debug " << __FILE__ << ":" << __LINE__ << "] " << x << std::endl;} while(0);
#define GUARANTEE(x,y) do { {do{ if(false == (x)) { ERR(y) } } while(0);} } while(0);
#endif
#define DELETE(x) do { if(NULL != x) { delete x; x = NULL; } }while(0);