Small performance fixes
This commit is contained in:
parent
1fb34be11e
commit
5274af7730
@ -167,13 +167,13 @@ public:
|
|||||||
w.nameID = strit->second;
|
w.nameID = strit->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUARANTEE(w.id != UINT_MAX, "found way with unknown type");
|
||||||
|
GUARANTEE(-1 != w.speed, "found way with unknown speed");
|
||||||
|
|
||||||
if ( w.direction == _Way::opposite ){
|
if ( w.direction == _Way::opposite ){
|
||||||
std::reverse( w.path.begin(), w.path.end() );
|
std::reverse( w.path.begin(), w.path.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
GUARANTEE(w.id != UINT_MAX, "found way with unknown type");
|
|
||||||
GUARANTEE(-1 != w.speed, "found way with unknown speed");
|
|
||||||
|
|
||||||
for(vector< NodeID >::size_type n = 0; n < w.path.size()-1; ++n) {
|
for(vector< NodeID >::size_type n = 0; n < w.path.size()-1; ++n) {
|
||||||
externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID));
|
externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID));
|
||||||
externalMemory->usedNodeIDs.push_back(w.path[n]);
|
externalMemory->usedNodeIDs.push_back(w.path[n]);
|
||||||
|
@ -229,11 +229,11 @@ int main (int argc, char *argv[]) {
|
|||||||
|
|
||||||
while(wayStartAndEndEdgeIT != externalMemory.wayStartEndVector.end() && restrictionsIT != externalMemory.restrictionsVector.end()) {
|
while(wayStartAndEndEdgeIT != externalMemory.wayStartEndVector.end() && restrictionsIT != externalMemory.restrictionsVector.end()) {
|
||||||
if(wayStartAndEndEdgeIT->wayID < restrictionsIT->fromWay){
|
if(wayStartAndEndEdgeIT->wayID < restrictionsIT->fromWay){
|
||||||
wayStartAndEndEdgeIT++;
|
++wayStartAndEndEdgeIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(wayStartAndEndEdgeIT->wayID > restrictionsIT->fromWay) {
|
if(wayStartAndEndEdgeIT->wayID > restrictionsIT->fromWay) {
|
||||||
restrictionsIT++;
|
++restrictionsIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assert(wayStartAndEndEdgeIT->wayID == restrictionsIT->fromWay);
|
assert(wayStartAndEndEdgeIT->wayID == restrictionsIT->fromWay);
|
||||||
@ -248,7 +248,7 @@ int main (int argc, char *argv[]) {
|
|||||||
} else if(wayStartAndEndEdgeIT->lastTarget == viaNode) {
|
} else if(wayStartAndEndEdgeIT->lastTarget == viaNode) {
|
||||||
restrictionsIT->restriction.fromNode = wayStartAndEndEdgeIT->lastStart;
|
restrictionsIT->restriction.fromNode = wayStartAndEndEdgeIT->lastStart;
|
||||||
}
|
}
|
||||||
restrictionsIT++;
|
++restrictionsIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
||||||
@ -266,11 +266,11 @@ int main (int argc, char *argv[]) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
if(wayStartAndEndEdgeIT->wayID > restrictionsIT->toWay) {
|
if(wayStartAndEndEdgeIT->wayID > restrictionsIT->toWay) {
|
||||||
restrictionsIT++;
|
++restrictionsIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NodeID viaNode = restrictionsIT->restriction.viaNode;
|
NodeID viaNode = restrictionsIT->restriction.viaNode;
|
||||||
@ -285,9 +285,9 @@ 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;
|
||||||
}
|
}
|
||||||
restrictionsIT++;
|
++restrictionsIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
||||||
@ -295,7 +295,7 @@ int main (int argc, char *argv[]) {
|
|||||||
ofstream restrictionsOutstream;
|
ofstream restrictionsOutstream;
|
||||||
restrictionsOutstream.open(restrictionsFileName.c_str(), ios::binary);
|
restrictionsOutstream.open(restrictionsFileName.c_str(), ios::binary);
|
||||||
restrictionsOutstream.write((char*)&usableRestrictionsCounter, sizeof(unsigned));
|
restrictionsOutstream.write((char*)&usableRestrictionsCounter, sizeof(unsigned));
|
||||||
for(restrictionsIT = externalMemory.restrictionsVector.begin(); restrictionsIT != externalMemory.restrictionsVector.end(); restrictionsIT++) {
|
for(restrictionsIT = externalMemory.restrictionsVector.begin(); restrictionsIT != externalMemory.restrictionsVector.end(); ++restrictionsIT) {
|
||||||
if(UINT_MAX != restrictionsIT->restriction.fromNode && UINT_MAX != restrictionsIT->restriction.toNode) {
|
if(UINT_MAX != restrictionsIT->restriction.fromNode && UINT_MAX != restrictionsIT->restriction.toNode) {
|
||||||
restrictionsOutstream.write((char *)&(restrictionsIT->restriction), sizeof(_Restriction));
|
restrictionsOutstream.write((char *)&(restrictionsIT->restriction), sizeof(_Restriction));
|
||||||
}
|
}
|
||||||
@ -311,20 +311,20 @@ int main (int argc, char *argv[]) {
|
|||||||
STXXLNodeIDVector::iterator usedNodeIDsIT = externalMemory.usedNodeIDs.begin();
|
STXXLNodeIDVector::iterator usedNodeIDsIT = externalMemory.usedNodeIDs.begin();
|
||||||
while(usedNodeIDsIT != externalMemory.usedNodeIDs.end() && nodesIT != externalMemory.allNodes.end()) {
|
while(usedNodeIDsIT != externalMemory.usedNodeIDs.end() && nodesIT != externalMemory.allNodes.end()) {
|
||||||
if(*usedNodeIDsIT < nodesIT->id){
|
if(*usedNodeIDsIT < nodesIT->id){
|
||||||
usedNodeIDsIT++;
|
++usedNodeIDsIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(*usedNodeIDsIT > nodesIT->id) {
|
if(*usedNodeIDsIT > nodesIT->id) {
|
||||||
nodesIT++;
|
++nodesIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(*usedNodeIDsIT == nodesIT->id) {
|
if(*usedNodeIDsIT == nodesIT->id) {
|
||||||
fout.write((char*)&(nodesIT->id), sizeof(unsigned));
|
fout.write((char*)&(nodesIT->id), sizeof(unsigned));
|
||||||
fout.write((char*)&(nodesIT->lon), sizeof(int));
|
fout.write((char*)&(nodesIT->lon), sizeof(int));
|
||||||
fout.write((char*)&(nodesIT->lat), sizeof(int));
|
fout.write((char*)&(nodesIT->lat), sizeof(int));
|
||||||
usedNodeCounter++;
|
++usedNodeCounter;
|
||||||
usedNodeIDsIT++;
|
++usedNodeIDsIT;
|
||||||
nodesIT++;
|
++nodesIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ int main (int argc, char *argv[]) {
|
|||||||
STXXLEdgeVector::iterator edgeIT = externalMemory.allEdges.begin();
|
STXXLEdgeVector::iterator edgeIT = externalMemory.allEdges.begin();
|
||||||
while(edgeIT != externalMemory.allEdges.end() && nodesIT != externalMemory.allNodes.end()) {
|
while(edgeIT != externalMemory.allEdges.end() && nodesIT != externalMemory.allNodes.end()) {
|
||||||
if(edgeIT->start < nodesIT->id){
|
if(edgeIT->start < nodesIT->id){
|
||||||
edgeIT++;
|
++edgeIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(edgeIT->start > nodesIT->id) {
|
if(edgeIT->start > nodesIT->id) {
|
||||||
@ -363,7 +363,7 @@ int main (int argc, char *argv[]) {
|
|||||||
if(edgeIT->start == nodesIT->id) {
|
if(edgeIT->start == nodesIT->id) {
|
||||||
edgeIT->startCoord.lat = nodesIT->lat;
|
edgeIT->startCoord.lat = nodesIT->lat;
|
||||||
edgeIT->startCoord.lon = nodesIT->lon;
|
edgeIT->startCoord.lon = nodesIT->lon;
|
||||||
edgeIT++;
|
++edgeIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
||||||
@ -381,11 +381,11 @@ int main (int argc, char *argv[]) {
|
|||||||
edgeIT = externalMemory.allEdges.begin();
|
edgeIT = externalMemory.allEdges.begin();
|
||||||
while(edgeIT != externalMemory.allEdges.end() && nodesIT != externalMemory.allNodes.end()) {
|
while(edgeIT != externalMemory.allEdges.end() && nodesIT != externalMemory.allNodes.end()) {
|
||||||
if(edgeIT->target < nodesIT->id){
|
if(edgeIT->target < nodesIT->id){
|
||||||
edgeIT++;
|
++edgeIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(edgeIT->target > nodesIT->id) {
|
if(edgeIT->target > nodesIT->id) {
|
||||||
nodesIT++;
|
++nodesIT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(edgeIT->target == nodesIT->id) {
|
if(edgeIT->target == nodesIT->id) {
|
||||||
@ -430,8 +430,8 @@ int main (int argc, char *argv[]) {
|
|||||||
fout.write((char*)&edgeType, sizeof(short));
|
fout.write((char*)&edgeType, sizeof(short));
|
||||||
fout.write((char*)&edgeIT->nameID, sizeof(unsigned));
|
fout.write((char*)&edgeIT->nameID, sizeof(unsigned));
|
||||||
}
|
}
|
||||||
usedEdgeCounter++;
|
++usedEdgeCounter;
|
||||||
edgeIT++;
|
++edgeIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
cout << "ok, after " << get_timestamp() - time << "s" << endl;
|
||||||
@ -494,7 +494,7 @@ bool adressFunction(_Node n, HashTable<string, string> keyVals){
|
|||||||
|
|
||||||
bool restrictionFunction(_RawRestrictionContainer r) {
|
bool restrictionFunction(_RawRestrictionContainer r) {
|
||||||
extractCallBacks->restrictionFunction(r);
|
extractCallBacks->restrictionFunction(r);
|
||||||
globalRestrictionCounter++;
|
++globalRestrictionCounter;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool wayFunction(_Way w) {
|
bool wayFunction(_Way w) {
|
||||||
|
Loading…
Reference in New Issue
Block a user