Minor changes
This commit is contained in:
parent
5236fb8c0e
commit
9abb317e6d
@ -58,7 +58,7 @@ struct ObjectsForQueryStruct {
|
|||||||
names = new std::vector<std::string>();
|
names = new std::vector<std::string>();
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
for(unsigned i = 0; i < size; i++) {
|
for(unsigned i = 0; i < size; ++i) {
|
||||||
unsigned sizeOfString = 0;
|
unsigned sizeOfString = 0;
|
||||||
namesInStream.read((char *)&sizeOfString, sizeof(unsigned));
|
namesInStream.read((char *)&sizeOfString, sizeof(unsigned));
|
||||||
memset(buf, 0, 1024*sizeof(char));
|
memset(buf, 0, 1024*sizeof(char));
|
||||||
|
@ -104,7 +104,7 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
|
|||||||
ExternalNodeMap ext2IntNodeMap;
|
ExternalNodeMap ext2IntNodeMap;
|
||||||
in.read((char*)&n, sizeof(NodeID));
|
in.read((char*)&n, sizeof(NodeID));
|
||||||
DEBUG("Importing n = " << n << " nodes ");
|
DEBUG("Importing n = " << n << " nodes ");
|
||||||
for (NodeID i=0; i<n;i++) {
|
for (NodeID i=0; i<n; ++i) {
|
||||||
in.read((char*)&id, sizeof(unsigned));
|
in.read((char*)&id, sizeof(unsigned));
|
||||||
in.read((char*)&ycoord, sizeof(int));
|
in.read((char*)&ycoord, sizeof(int));
|
||||||
in.read((char*)&xcoord, sizeof(int));
|
in.read((char*)&xcoord, sizeof(int));
|
||||||
@ -113,25 +113,25 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
|
|||||||
}
|
}
|
||||||
in.read((char*)&m, sizeof(unsigned));
|
in.read((char*)&m, sizeof(unsigned));
|
||||||
DEBUG(" and " << m << " edges ");
|
DEBUG(" and " << m << " edges ");
|
||||||
|
|
||||||
for(unsigned i = 0; i < inputRestrictions.size(); ++i) {
|
for(unsigned i = 0; i < inputRestrictions.size(); ++i) {
|
||||||
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(inputRestrictions[i].fromNode);
|
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(inputRestrictions[i].fromNode);
|
||||||
if( intNodeID == ext2IntNodeMap.end()) {
|
if( intNodeID == ext2IntNodeMap.end()) {
|
||||||
DEBUG("Unmapped restriction")
|
DEBUG("Unmapped from Node of restriction");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
inputRestrictions[i].fromNode = intNodeID->second;
|
inputRestrictions[i].fromNode = intNodeID->second;
|
||||||
|
|
||||||
intNodeID = ext2IntNodeMap.find(inputRestrictions[i].viaNode);
|
intNodeID = ext2IntNodeMap.find(inputRestrictions[i].viaNode);
|
||||||
if( intNodeID == ext2IntNodeMap.end()) {
|
if( intNodeID == ext2IntNodeMap.end()) {
|
||||||
DEBUG("Unmapped restriction")
|
DEBUG("Unmapped via node of restriction");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
inputRestrictions[i].viaNode = intNodeID->second;
|
inputRestrictions[i].viaNode = intNodeID->second;
|
||||||
|
|
||||||
intNodeID = ext2IntNodeMap.find(inputRestrictions[i].toNode);
|
intNodeID = ext2IntNodeMap.find(inputRestrictions[i].toNode);
|
||||||
if( intNodeID == ext2IntNodeMap.end()) {
|
if( intNodeID == ext2IntNodeMap.end()) {
|
||||||
DEBUG("Unmapped restriction")
|
DEBUG("Unmapped to node of restriction");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
inputRestrictions[i].toNode = intNodeID->second;
|
inputRestrictions[i].toNode = intNodeID->second;
|
||||||
@ -144,7 +144,7 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
|
|||||||
int length;
|
int length;
|
||||||
bool isRoundabout;
|
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*)&source, sizeof(unsigned));
|
||||||
in.read((char*)&target, sizeof(unsigned));
|
in.read((char*)&target, sizeof(unsigned));
|
||||||
in.read((char*)&length, sizeof(int));
|
in.read((char*)&length, sizeof(int));
|
||||||
@ -154,17 +154,15 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
|
|||||||
in.read((char*)&nameID, sizeof(unsigned));
|
in.read((char*)&nameID, sizeof(unsigned));
|
||||||
in.read((char*)&isRoundabout, sizeof(bool));
|
in.read((char*)&isRoundabout, sizeof(bool));
|
||||||
|
|
||||||
assert(length > 0);
|
GUARANTEE(length > 0, "loaded null length edge" );
|
||||||
assert(weight > 0);
|
GUARANTEE(weight > 0, "loaded null weight");
|
||||||
assert(0<=dir && dir<=2);
|
GUARANTEE(0<=dir && dir<=2, "loaded bogus direction");
|
||||||
|
|
||||||
bool forward = true;
|
bool forward = true;
|
||||||
bool backward = true;
|
bool backward = true;
|
||||||
if (1 == dir) { backward = false; }
|
if (1 == dir) { backward = false; }
|
||||||
if (2 == dir) { forward = false; }
|
if (2 == dir) { forward = false; }
|
||||||
|
|
||||||
if(length == 0) { ERR("loaded null length edge" ); }
|
|
||||||
|
|
||||||
// translate the external NodeIDs to internal IDs
|
// translate the external NodeIDs to internal IDs
|
||||||
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source);
|
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source);
|
||||||
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) {
|
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) {
|
||||||
@ -182,15 +180,14 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
target = intNodeID->second;
|
target = intNodeID->second;
|
||||||
|
GUARANTEE(source != UINT_MAX && target != UINT_MAX, "nonexisting source or target");
|
||||||
if(source == UINT_MAX || target == UINT_MAX) { ERR("nonexisting source or target"); }
|
|
||||||
|
|
||||||
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout );
|
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout );
|
||||||
edgeList.push_back(inputEdge);
|
edgeList.push_back(inputEdge);
|
||||||
}
|
}
|
||||||
ext2IntNodeMap.clear();
|
ext2IntNodeMap.clear();
|
||||||
vector<ImportEdge>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
|
vector<ImportEdge>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
|
||||||
cout << "ok" << endl;
|
INFO("Graph loaded ok");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
template<typename EdgeT>
|
template<typename EdgeT>
|
||||||
|
@ -70,19 +70,16 @@ bool removeIfUnused(ClassT n) { return (false == n.used); }
|
|||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main (int argc, char *argv[]) {
|
||||||
if(argc <= 1) {
|
GUARANTEE((argc > 1) ,"usage: \n" << argv[0] << " <file.osm/.osm.bz2/.osm.pbf>");
|
||||||
cerr << "usage: " << endl << argv[0] << " <file.osm/.osm.bz2/.osm.pbf>" << endl;
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "[extractor] extracting data from input file " << argv[1] << endl;
|
INFO("extracting data from input file " << argv[1]);
|
||||||
bool isPBF = false;
|
bool isPBF(false);
|
||||||
string outputFileName(argv[1]);
|
std::string outputFileName(argv[1]);
|
||||||
string restrictionsFileName(argv[1]);
|
std::string restrictionsFileName(argv[1]);
|
||||||
string::size_type pos = outputFileName.find(".osm.bz2");
|
std::string::size_type pos = outputFileName.find(".osm.bz2");
|
||||||
if(pos==string::npos) {
|
if(pos==std::string::npos) {
|
||||||
pos = outputFileName.find(".osm.pbf");
|
pos = outputFileName.find(".osm.pbf");
|
||||||
if(pos!=string::npos) {
|
if(pos!=std::string::npos) {
|
||||||
isPBF = true;
|
isPBF = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +96,7 @@ int main (int argc, char *argv[]) {
|
|||||||
restrictionsFileName.append(".osrm.restrictions");
|
restrictionsFileName.append(".osrm.restrictions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string adressFileName(outputFileName);
|
std::string adressFileName(outputFileName);
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
||||||
boost::property_tree::ptree pt;
|
boost::property_tree::ptree pt;
|
||||||
@ -109,15 +106,15 @@ int main (int argc, char *argv[]) {
|
|||||||
INFO("Found the following speed profiles: ");
|
INFO("Found the following speed profiles: ");
|
||||||
int profileCounter(0);
|
int profileCounter(0);
|
||||||
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child("")) {
|
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;
|
cout << " [" << profileCounter << "]" << name << endl;
|
||||||
++profileCounter;
|
++profileCounter;
|
||||||
}
|
}
|
||||||
string usedSpeedProfile(pt.get_child("").begin()->first);
|
std::string usedSpeedProfile(pt.get_child("").begin()->first);
|
||||||
INFO("Using profile \"" << usedSpeedProfile << "\"")
|
INFO("Using profile \"" << usedSpeedProfile << "\"")
|
||||||
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child(usedSpeedProfile)) {
|
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child(usedSpeedProfile)) {
|
||||||
string name = v.first;
|
std::string name = v.first;
|
||||||
string value = v.second.get<string>("");
|
std::string value = v.second.get<std::string>("");
|
||||||
DEBUG("inserting " << name << "=" << value);
|
DEBUG("inserting " << name << "=" << value);
|
||||||
if(name == "obeyOneways") {
|
if(name == "obeyOneways") {
|
||||||
if(value == "no")
|
if(value == "no")
|
||||||
@ -150,23 +147,21 @@ int main (int argc, char *argv[]) {
|
|||||||
unsigned amountOfRAM = 1;
|
unsigned amountOfRAM = 1;
|
||||||
unsigned installedRAM = GetPhysicalmemory();
|
unsigned installedRAM = GetPhysicalmemory();
|
||||||
if(installedRAM < 2048264) {
|
if(installedRAM < 2048264) {
|
||||||
cout << "[Warning] Machine has less than 2GB RAM." << endl;
|
WARN("Machine has less than 2GB RAM.");
|
||||||
}
|
}
|
||||||
if(testDataFile("extractor.ini")) {
|
if(testDataFile("extractor.ini")) {
|
||||||
ExtractorConfiguration extractorConfig("extractor.ini");
|
ExtractorConfiguration extractorConfig("extractor.ini");
|
||||||
unsigned memoryAmountFromFile = atoi(extractorConfig.GetParameter("Memory").c_str());
|
unsigned memoryAmountFromFile = atoi(extractorConfig.GetParameter("Memory").c_str());
|
||||||
if( memoryAmountFromFile != 0 && memoryAmountFromFile <= installedRAM/(1024*1024))
|
if( memoryAmountFromFile != 0 && memoryAmountFromFile <= installedRAM/(1024*1024))
|
||||||
amountOfRAM = memoryAmountFromFile;
|
amountOfRAM = memoryAmountFromFile;
|
||||||
cout << "[extractor] using " << amountOfRAM << " GB of RAM for buffers" << endl;
|
INFO("Using " << amountOfRAM << " GB of RAM for buffers");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringMap stringMap;
|
||||||
STXXLContainers externalMemory;
|
STXXLContainers externalMemory;
|
||||||
|
|
||||||
unsigned usedNodeCounter = 0;
|
unsigned usedNodeCounter = 0;
|
||||||
unsigned usedEdgeCounter = 0;
|
unsigned usedEdgeCounter = 0;
|
||||||
|
|
||||||
StringMap stringMap;
|
|
||||||
|
|
||||||
double time = get_timestamp();
|
double time = get_timestamp();
|
||||||
|
|
||||||
stringMap[""] = 0;
|
stringMap[""] = 0;
|
||||||
@ -178,13 +173,9 @@ int main (int argc, char *argv[]) {
|
|||||||
parser = new XMLParser(argv[1]);
|
parser = new XMLParser(argv[1]);
|
||||||
}
|
}
|
||||||
parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction);
|
parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction);
|
||||||
if(parser->Init()) {
|
GUARANTEE(parser->Init(), "Parser not initialized!");
|
||||||
parser->Parse();
|
parser->Parse();
|
||||||
} else {
|
DELETE(parser);
|
||||||
cerr << "[error] parser not initialized!" << endl;
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
delete parser;
|
|
||||||
stringMap.clear();
|
stringMap.clear();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user