fixing ticket 20. stxxl should not complain any more. also, there should be no compiler warnings.

This commit is contained in:
Dennis Luxen 2011-01-14 16:54:42 +00:00
parent 46a690dfc2
commit e32ba24b6a
11 changed files with 286 additions and 218 deletions

View File

@ -54,7 +54,7 @@ public:
private:
struct _EdgeData {
int distance;
unsigned distance;
unsigned originalEdges : 29;
bool shortcut : 1;
bool forward : 1;
@ -250,15 +250,15 @@ public:
}
//merge edges (s,t) and (t,s) into bidirectional edge
if ( forwardEdge.data.distance == backwardEdge.data.distance ) {
if ( forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
if ( (int)forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
forwardEdge.data.backward = true;
edges[edge++] = forwardEdge;
}
} else { //insert seperate edges
if ( forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
if ( (int)forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
edges[edge++] = forwardEdge;
}
if ( backwardEdge.data.distance != std::numeric_limits< int >::max() ) {
if ( (int)backwardEdge.data.distance != std::numeric_limits< int >::max() ) {
edges[edge++] = backwardEdge;
}
}

View File

@ -0,0 +1,193 @@
/*
open source routing machine
Copyright (C) Dennis Luxen, others 2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
#ifndef EXTRACTORCALLBACKS_H_
#define EXTRACTORCALLBACKS_H_
#include <stxxl.h>
#include "ExtractorStructs.h"
typedef stxxl::vector<NodeID> STXXLNodeIDVector;
typedef stxxl::vector<_Node> STXXLNodeVector;
typedef stxxl::vector<_Edge> STXXLEdgeVector;
typedef stxxl::vector<string> STXXLStringVector;
class ExtractorCallbacks{
private:
STXXLNodeVector * allNodes;
STXXLNodeIDVector * usedNodes;
STXXLEdgeVector * allEdges;
STXXLStringVector * nameVector;
Settings settings;
StringMap * stringMap;
public:
ExtractorCallbacks(STXXLNodeVector * aNodes, STXXLNodeIDVector * uNodes, STXXLEdgeVector * aEdges, STXXLStringVector * nVector, Settings s, StringMap * strMap){
allNodes = aNodes;
usedNodes = uNodes;
allEdges = aEdges;
nameVector = nVector;
settings = s;
stringMap = strMap;
}
~ExtractorCallbacks() {
delete allNodes;
delete usedNodes;
delete allEdges;
delete nameVector;
delete stringMap;
}
bool nodeFunction(_Node &n) {
allNodes->push_back(n);
return true;
}
bool relationFunction(_Relation &r) {
//do nothing;
return true;
}
bool wayFunction(_Way &w) {
std::string highway( w.keyVals.Find("highway") );
std::string name( w.keyVals.Find("name") );
std::string ref( w.keyVals.Find("ref"));
std::string oneway( w.keyVals.Find("oneway"));
std::string junction( w.keyVals.Find("junction") );
std::string route( w.keyVals.Find("route") );
std::string maxspeed( w.keyVals.Find("maxspeed") );
std::string access( w.keyVals.Find("access") );
std::string motorcar( w.keyVals.Find("motorcar") );
if ( name != "" ) {
w.name = name;
} else if ( ref != "" ) {
w.name = ref;
}
if ( oneway != "" ) {
if ( oneway == "no" || oneway == "false" || oneway == "0" ) {
w.direction = _Way::bidirectional;
} else {
if ( oneway == "yes" || oneway == "true" || oneway == "1" ) {
w.direction = _Way::oneway;
} else {
if (oneway == "-1" )
w.direction = _Way::opposite;
}
}
}
if ( junction == "roundabout" ) {
if ( w.direction == _Way::notSure ) {
w.direction = _Way::oneway;
}
w.useful = true;
if(w.type == -1)
w.type = 9;
}
if ( route == "ferry") {
for ( unsigned i = 0; i < settings.speedProfile.names.size(); i++ ) {
if ( route == settings.speedProfile.names[i] ) {
w.type = i;
w.maximumSpeed = settings.speedProfile.speed[i];
w.useful = true;
w.direction = _Way::bidirectional;
break;
}
}
}
if ( highway != "" ) {
for ( unsigned i = 0; i < settings.speedProfile.names.size(); i++ ) {
if ( highway == settings.speedProfile.names[i] ) {
w.maximumSpeed = settings.speedProfile.speed[i];
w.type = i;
w.useful = true;
break;
}
}
if ( highway == "motorway" ) {
if ( w.direction == _Way::notSure ) {
w.direction = _Way::oneway;
}
} else if ( highway == "motorway_link" ) {
if ( w.direction == _Way::notSure ) {
w.direction = _Way::oneway;
}
}
}
if ( maxspeed != "" ) {
double maxspeedNumber = atof( maxspeed.c_str() );
if(maxspeedNumber != 0) {
w.maximumSpeed = maxspeedNumber;
}
}
if ( access != "" ) {
if ( access == "private" || access == "no" || access == "agricultural" || access == "forestry" || access == "delivery") {
w.access = false;
}
if ( access == "yes" || access == "designated" || access == "official" || access == "permissive") {
w.access = true;
}
}
if ( motorcar == "yes" ) {
w.access = true;
} else if ( motorcar == "no" ) {
w.access = false;
}
if ( w.useful && w.access && w.path.size() ) {
StringMap::iterator strit = stringMap->find(w.name);
if(strit == stringMap->end())
{
w.nameID = nameVector->size();
nameVector->push_back(w.name);
stringMap->insert(std::make_pair(w.name, w.nameID) );
} else {
w.nameID = strit->second;
}
for ( unsigned i = 0; i < w.path.size(); ++i ) {
usedNodes->push_back(w.path[i]);
}
if ( w.direction == _Way::opposite ){
std::reverse( w.path.begin(), w.path.end() );
}
vector< NodeID > & path = w.path;
assert(w.type > -1 || w.maximumSpeed != -1);
assert(path.size()>0);
if(w.maximumSpeed == -1)
w.maximumSpeed = settings.speedProfile.speed[w.type];
for(vector< NodeID >::size_type n = 0; n < path.size()-1; n++) {
_Edge e;
e.start = w.path[n];
e.target = w.path[n+1];
e.type = w.type;
e.direction = w.direction;
e.speed = w.maximumSpeed;
e.nameID = w.nameID;
allEdges->push_back(e);
}
}
return true;
}
};
#endif /* EXTRACTORCALLBACKS_H_ */

View File

@ -257,5 +257,6 @@ string GetRandomString() {
return string(s);
}
typedef google::dense_hash_map<NodeID, _Node> NodeMap;
#endif /* EXTRACTORSTRUCTS_H_ */

View File

@ -246,7 +246,7 @@ public:
}
entriesInFileWithRAMSameIndex.push_back(*vt);
}
unsigned numberOfBytesInCell = FillCell(entriesInFileWithRAMSameIndex, lastPositionInIndexFile);
/*unsigned numberOfBytesInCell = */FillCell(entriesInFileWithRAMSameIndex, lastPositionInIndexFile);
ramIndexTable[indexInRamTable] = lastPositionInIndexFile;
numberOfUsedCells++;
entriesInFileWithRAMSameIndex.clear();
@ -402,7 +402,7 @@ private:
// start in cellIndex vermerken
int localFileIndex = entriesWithSameFileIndex.begin()->fileIndex;
int localCellIndex = cellMap->find(localFileIndex)->second;
int localRamIndex = getRAMIndexFromFileIndex(localFileIndex);
/*int localRamIndex = */getRAMIndexFromFileIndex(localFileIndex);
assert(cellMap->find(entriesWithSameFileIndex.begin()->fileIndex) != cellMap->end());
cellIndex[localCellIndex] = indexIntoTmpBuffer + fileOffset;
@ -416,7 +416,7 @@ private:
assert(cellMap->find(entriesWithSameFileIndex.begin()->fileIndex) != cellMap->end());
int localFileIndex = entriesWithSameFileIndex.begin()->fileIndex;
int localCellIndex = cellMap->find(localFileIndex)->second;
int localRamIndex = getRAMIndexFromFileIndex(localFileIndex);
/*int localRamIndex = */getRAMIndexFromFileIndex(localFileIndex);
cellIndex[localCellIndex] = indexIntoTmpBuffer + fileOffset;
indexIntoTmpBuffer += FlushEntriesWithSameFileIndexToBuffer(entriesWithSameFileIndex, tmpBuffer, indexIntoTmpBuffer);

View File

@ -46,6 +46,7 @@ template<typename EdgeData, typename GraphT, typename NodeHelperT = NodeInformat
class SearchEngine {
private:
const GraphT * _graph;
NodeHelperT * nodeHelpDesk;
std::vector<string> * _names;
inline double absDouble(double input) { if(input < 0) return input*(-1); else return input;}
public:
@ -186,7 +187,7 @@ public:
pathNode = _forwardHeap->GetData( pathNode ).parent;
packedPath.push_front( pathNode );
}
NodeID realStart = pathNode;
// NodeID realStart = pathNode;
packedPath.push_back( middle );
pathNode = middle;
@ -238,11 +239,14 @@ public:
inline unsigned int findNearestNodeForLatLon(const _Coordinate& coord, _Coordinate& result) const
{
nodeHelpDesk->findNearestNodeCoordForLatLon( coord, result );
return 0;
}
inline bool FindRoutingStarts(const _Coordinate start, const _Coordinate target, PhantomNodes * routingStarts)
{
nodeHelpDesk->FindRoutingStarts(start, target, routingStarts);
return true;
}
inline NodeID GetNameIDForOriginDestinationNodeID(NodeID s, NodeID t) const {
@ -274,7 +278,6 @@ public:
nodeHelpDesk->RegisterThread(k,v);
}
private:
NodeHelperT * nodeHelpDesk;
void _RoutingStep(_Heap * _forwardHeap, _Heap *_backwardHeap, const bool& forwardDirection, NodeID * middle, unsigned int * _upperbound)
{

View File

@ -102,15 +102,15 @@ public:
}
//merge edges (s,t) and (t,s) into bidirectional edge
if ( forwardEdge.data.distance == backwardEdge.data.distance ) {
if ( forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
if ( (int)forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
forwardEdge.data.backward = true;
edges[edge++] = forwardEdge;
}
} else { //insert seperate edges
if ( forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
if ( (int)forwardEdge.data.distance != std::numeric_limits< int >::max() ) {
edges[edge++] = forwardEdge;
}
if ( backwardEdge.data.distance != std::numeric_limits< int >::max() ) {
if ( (int)backwardEdge.data.distance != std::numeric_limits< int >::max() ) {
edges[edge++] = backwardEdge;
}
}

View File

@ -34,7 +34,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../Util/StrIngUtil.h"
typedef ContractionCleanup::Edge::EdgeData EdgeData;
typedef StaticGraph<EdgeData>::InputEdge GridEdge;
typedef StaticGraph<EdgeData>::InputEdge InputEdge;
class RoutePlugin : public BasePlugin {
public:
@ -46,10 +46,9 @@ public:
nodeHelpDesk->initNNGrid(nodesInStream);
//Deserialize road network graph
std::vector< GridEdge> * edgeList = new std::vector< GridEdge>();
std::vector< InputEdge> * edgeList = new std::vector< InputEdge>();
readHSGRFromStream(hsgrInStream, edgeList);
hsgrInStream.close();
graph = new StaticGraph<EdgeData>(nodeHelpDesk->getNumberOfNodes()-1, *edgeList);
delete edgeList;

View File

@ -72,7 +72,7 @@ struct ServerFactory {
if(serverConfig.GetParameter("Port") == "")
serverConfig.SetParameter("Port", "5000");
if(atoi(serverConfig.GetParameter("Threads").c_str()) != 0 && atoi(serverConfig.GetParameter("Threads").c_str()) <= threads)
if(atoi(serverConfig.GetParameter("Threads").c_str()) != 0 && (unsigned)atoi(serverConfig.GetParameter("Threads").c_str()) <= threads)
threads = atoi( serverConfig.GetParameter("Threads").c_str() );
Server * server = new Server(serverConfig.GetParameter("IP"), serverConfig.GetParameter("Port"), threads);

View File

@ -45,7 +45,6 @@ template<typename EdgeT>
NodeID readOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<NodeInfo> * int2ExtNodeMap) {
NodeID n, source, target, id;
EdgeID m;
short locatable;
int dir, xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open)
ExternalNodeMap ext2IntNodeMap;
ext2IntNodeMap.set_empty_key(UINT_MAX);

View File

@ -53,17 +53,15 @@ or see http://www.gnu.org/licenses/agpl.txt.
using namespace std;
typedef ContractionCleanup::Edge::EdgeData EdgeData;
typedef DynamicGraph<EdgeData>::InputEdge GridEdge;
typedef DynamicGraph<EdgeData>::InputEdge InputEdge;
typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
typedef NNGrid::NNGrid<true> WritableGrid;
typedef BaseConfiguration ContractorConfiguration;
vector<NodeInfo> * int2ExtNodeMap = new vector<NodeInfo>();
int main (int argc, char *argv[])
{
if(argc <= 1)
{
int main (int argc, char *argv[]) {
if(argc <= 1) {
cerr << "usage: " << endl << argv[0] << " <osmr-data>" << endl;
exit(-1);
}
@ -72,8 +70,8 @@ int main (int argc, char *argv[])
unsigned numberOfThreads = omp_get_num_procs();
if(testDataFile("contractor.ini")) {
ContractorConfiguration contractorConfig("contractor.ini");
if(atoi(contractorConfig.GetParameter("Threads").c_str()) != 0 && atoi(contractorConfig.GetParameter("Threads").c_str()) <= numberOfThreads)
numberOfThreads = atoi( contractorConfig.GetParameter("Threads").c_str() );
if(atoi(contractorConfig.GetParameter("Threads").c_str()) != 0 && (unsigned)atoi(contractorConfig.GetParameter("Threads").c_str()) <= numberOfThreads)
numberOfThreads = (unsigned)atoi( contractorConfig.GetParameter("Threads").c_str() );
}
omp_set_num_threads(numberOfThreads);
@ -112,8 +110,7 @@ int main (int argc, char *argv[])
WritableGrid * g = new WritableGrid();
cout << "building grid ..." << flush;
Percent p(edgeList.size());
for(NodeID i = 0; i < edgeList.size(); i++)
{
for(NodeID i = 0; i < edgeList.size(); i++) {
p.printIncrement();
if(!edgeList[i].isLocatable())
continue;
@ -160,7 +157,7 @@ int main (int argc, char *argv[])
ContractionCleanup * cleanup = new ContractionCleanup(n, contractedEdges);
cleanup->Run();
std::vector< GridEdge> cleanedEdgeList;
std::vector< InputEdge> cleanedEdgeList;
cleanup->GetData(cleanedEdgeList);
ofstream edgeOutFile(edgeOut, ios::binary);
@ -168,7 +165,7 @@ int main (int argc, char *argv[])
//Serializing the edge list.
cout << "Serializing edges " << flush;
p.reinit(cleanedEdgeList.size());
for(std::vector< GridEdge>::iterator it = cleanedEdgeList.begin(); it != cleanedEdgeList.end(); it++)
for(std::vector< InputEdge>::iterator it = cleanedEdgeList.begin(); it != cleanedEdgeList.end(); it++)
{
p.printIncrement();
int distance= it->data.distance;

View File

@ -38,165 +38,17 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "typedefs.h"
#include "DataStructures/InputReaderFactory.h"
#include "DataStructures/ExtractorCallBacks.h"
#include "DataStructures/ExtractorStructs.h"
#include "DataStructures/PBFParser.h"
#include "DataStructures/XMLParser.h"
typedef google::dense_hash_map<NodeID, _Node> NodeMap;
typedef stxxl::vector<NodeID> STXXLNodeIDVector;
typedef stxxl::vector<_Node> STXXLNodeVector;
typedef stxxl::vector<_Edge> STXXLEdgeVector;
typedef stxxl::vector<string> STXXLStringVector;
NodeMap * nodeMap = new NodeMap();
StringMap * stringMap = new StringMap();
unsigned globalRelationCounter = 0;
Settings settings;
ExtractorCallbacks * extractCallBacks;
STXXLNodeIDVector usedNodes;
STXXLNodeVector allNodes;
STXXLNodeVector confirmedNodes;
STXXLEdgeVector allEdges;
STXXLEdgeVector confirmedEdges;
STXXLStringVector nameVector;
bool nodeFunction(_Node n) {
allNodes.push_back(n);
return true;
}
bool relationFunction(_Relation r) {
globalRelationCounter++;
return true;
}
bool wayFunction(_Way w) {
std::string highway( w.keyVals.Find("highway") );
std::string name( w.keyVals.Find("name") );
std::string ref( w.keyVals.Find("ref"));
std::string oneway( w.keyVals.Find("oneway"));
std::string junction( w.keyVals.Find("junction") );
std::string route( w.keyVals.Find("route") );
std::string maxspeed( w.keyVals.Find("maxspeed") );
std::string access( w.keyVals.Find("access") );
std::string motorcar( w.keyVals.Find("motorcar") );
if ( name != "" ) {
w.name = name;
} else if ( ref != "" ) {
w.name = ref;
}
if ( oneway != "" ) {
if ( oneway == "no" || oneway == "false" || oneway == "0" ) {
w.direction = _Way::bidirectional;
} else {
if ( oneway == "yes" || oneway == "true" || oneway == "1" ) {
w.direction = _Way::oneway;
} else {
if (oneway == "-1" )
w.direction = _Way::opposite;
}
}
}
if ( junction == "roundabout" ) {
if ( w.direction == _Way::notSure ) {
w.direction = _Way::oneway;
}
w.useful = true;
if(w.type == -1)
w.type = 9;
}
if ( route == "ferry") {
for ( unsigned i = 0; i < settings.speedProfile.names.size(); i++ ) {
if ( route == settings.speedProfile.names[i] ) {
w.type = i;
w.maximumSpeed = settings.speedProfile.speed[i];
w.useful = true;
w.direction = _Way::bidirectional;
break;
}
}
}
if ( highway != "" ) {
for ( unsigned i = 0; i < settings.speedProfile.names.size(); i++ ) {
if ( highway == settings.speedProfile.names[i] ) {
w.maximumSpeed = settings.speedProfile.speed[i];
w.type = i;
w.useful = true;
break;
}
}
if ( highway == "motorway" ) {
if ( w.direction == _Way::notSure ) {
w.direction = _Way::oneway;
}
} else if ( highway == "motorway_link" ) {
if ( w.direction == _Way::notSure ) {
w.direction = _Way::oneway;
}
}
}
if ( maxspeed != "" ) {
double maxspeedNumber = atof( maxspeed.c_str() );
if(maxspeedNumber != 0) {
w.maximumSpeed = maxspeedNumber;
}
}
if ( access != "" ) {
if ( access == "private" || access == "no" || access == "agricultural" || access == "forestry" || access == "delivery") {
w.access = false;
}
if ( access == "yes" || access == "designated" || access == "official" || access == "permissive") {
w.access = true;
}
}
if ( motorcar == "yes" ) {
w.access = true;
} else if ( motorcar == "no" ) {
w.access = false;
}
if ( w.useful && w.access && w.path.size() ) {
// std::cout << "[debug] looking for name: " << w.name << std::endl;
StringMap::iterator strit = stringMap->find(w.name);
if(strit == stringMap->end())
{
w.nameID = nameVector.size();
nameVector.push_back(w.name);
stringMap->insert(std::make_pair(w.name, w.nameID) );
// if(w.name != "")
// cout << "[debug] found new name ID: " << w.nameID << " (" << w.name << ")" << endl;
} else {
w.nameID = strit->second;
// std::cout << "[debug] name with ID " << w.nameID << " already existing (" << w.name << ")" << endl;
}
for ( unsigned i = 0; i < w.path.size(); ++i ) {
// std::cout << "[debug] using node " << w.path[i] << std::endl;
usedNodes.push_back(w.path[i]);
}
if ( w.direction == _Way::opposite ){
std::reverse( w.path.begin(), w.path.end() );
}
vector< NodeID > & path = w.path;
assert(w.type > -1 || w.maximumSpeed != -1);
assert(path.size()>0);
if(w.maximumSpeed == -1)
w.maximumSpeed = settings.speedProfile.speed[w.type];
for(vector< NodeID >::size_type n = 0; n < path.size()-1; n++) {
_Edge e;
e.start = w.path[n];
e.target = w.path[n+1];
e.type = w.type;
e.direction = w.direction;
e.speed = w.maximumSpeed;
e.nameID = w.nameID;
allEdges.push_back(e);
}
}
return true;
}
bool nodeFunction(_Node n);
bool relationFunction(_Relation r);
bool wayFunction(_Way w);
int main (int argc, char *argv[]) {
if(argc <= 1) {
@ -211,7 +63,6 @@ int main (int argc, char *argv[]) {
if(pos==string::npos) {
pos = outputFileName.find(".osm.pbf");
if(pos!=string::npos) {
// std::cout << "[debug] found pbf file" << std::endl;
isPBF = true;
}
}
@ -226,6 +77,16 @@ int main (int argc, char *argv[]) {
}
}
STXXLNodeIDVector * usedNodes = new STXXLNodeIDVector();
STXXLNodeVector * allNodes = new STXXLNodeVector();
STXXLNodeVector * confirmedNodes = new STXXLNodeVector();
STXXLEdgeVector * allEdges = new STXXLEdgeVector();
STXXLEdgeVector * confirmedEdges = new STXXLEdgeVector();
STXXLStringVector * nameVector = new STXXLStringVector();
NodeMap * nodeMap = new NodeMap();
StringMap * stringMap = new StringMap();
Settings settings;
settings.speedProfile.names.insert(settings.speedProfile.names.begin(), names, names+14);
settings.speedProfile.speed.insert(settings.speedProfile.speed.begin(), speeds, speeds+14);
@ -234,6 +95,8 @@ int main (int argc, char *argv[]) {
nodeMap->set_empty_key(UINT_MAX);
stringMap->set_empty_key(GetRandomString());
stringMap->insert(std::make_pair("", 0));
extractCallBacks = new ExtractorCallbacks(allNodes, usedNodes, allEdges, nameVector, settings, stringMap);
BaseParser<_Node, _Relation, _Way> * parser;
if(isPBF)
parser = new PBFParser(argv[1]);
@ -248,28 +111,28 @@ int main (int argc, char *argv[]) {
}
try {
std::cout << "[info] raw no. of names: " << nameVector.size() << std::endl;
std::cout << "[info] raw no. of nodes: " << allNodes.size() << std::endl;
std::cout << "[info] no. of used nodes: " << usedNodes.size() << std::endl;
std::cout << "[info] raw no. of edges: " << allEdges.size() << std::endl;
std::cout << "[info] raw no. of names: " << nameVector->size() << std::endl;
std::cout << "[info] raw no. of nodes: " << allNodes->size() << std::endl;
std::cout << "[info] no. of used nodes: " << usedNodes->size() << std::endl;
std::cout << "[info] raw no. of edges: " << allEdges->size() << std::endl;
std::cout << "[info] raw no. of relations: " << globalRelationCounter << std::endl;
std::cout << "[info] parsing throug input file took " << get_timestamp() - time << "seconds" << std::endl;
std::cout << "[info] parsing through input file took " << get_timestamp() - time << "seconds" << std::endl;
time = get_timestamp();
unsigned memory_to_use = 1024 * 1024 * 1024;
std::cout << "[extractor] Sorting used nodes ... " << std::flush;
stxxl::sort(usedNodes.begin(), usedNodes.end(), Cmp(), memory_to_use);
stxxl::sort(usedNodes->begin(), usedNodes->end(), Cmp(), memory_to_use);
std::cout << "ok, after " << get_timestamp() - time << "s" << std::endl;
time = get_timestamp();
std::cout << "[extractor] Erasing duplicate entries ... " << std::flush;
stxxl::vector<NodeID>::iterator NewEnd = unique ( usedNodes.begin(),usedNodes.end() ) ;
usedNodes.resize ( NewEnd - usedNodes.begin() );
stxxl::vector<NodeID>::iterator NewEnd = unique ( usedNodes->begin(),usedNodes->end() ) ;
usedNodes->resize ( NewEnd - usedNodes->begin() );
cout << "ok, after " << get_timestamp() - time << "s" << endl;
time = get_timestamp();
std::cout << "[extractor] Sorting all nodes ... " << std::flush;
stxxl::sort(allNodes.begin(), allNodes.end(), CmpNodeByID(), memory_to_use);
stxxl::sort(allNodes->begin(), allNodes->end(), CmpNodeByID(), memory_to_use);
std::cout << "ok, after " << get_timestamp() - time << "s" << std::endl;
time = get_timestamp();
@ -277,9 +140,9 @@ int main (int argc, char *argv[]) {
fout.open(outputFileName.c_str());
cout << "[extractor] Confirming used nodes ... " << flush;
STXXLNodeVector::iterator nvit = allNodes.begin();
STXXLNodeIDVector::iterator niit = usedNodes.begin();
while(niit != usedNodes.end() && nvit != allNodes.end()) {
STXXLNodeVector::iterator nvit = allNodes->begin();
STXXLNodeIDVector::iterator niit = usedNodes->begin();
while(niit != usedNodes->end() && nvit != allNodes->end()) {
if(*niit < nvit->id){
niit++;
continue;
@ -289,7 +152,7 @@ int main (int argc, char *argv[]) {
continue;
}
if(*niit == nvit->id) {
confirmedNodes.push_back(*nvit);
confirmedNodes->push_back(*nvit);
nodeMap->insert(std::make_pair(nvit->id, *nvit));
niit++;
nvit++;
@ -299,8 +162,8 @@ int main (int argc, char *argv[]) {
time = get_timestamp();
cout << "[extractor] Writing used nodes ... " << flush;
fout << confirmedNodes.size() << endl;
for(STXXLNodeVector::iterator ut = confirmedNodes.begin(); ut != confirmedNodes.end(); ut++) {
fout << confirmedNodes->size() << endl;
for(STXXLNodeVector::iterator ut = confirmedNodes->begin(); ut != confirmedNodes->end(); ut++) {
fout << ut->id<< " " << ut->lon << " " << ut->lat << "\n";
}
@ -308,7 +171,7 @@ int main (int argc, char *argv[]) {
time = get_timestamp();
cout << "[extractor] confirming used ways ... " << flush;
for(STXXLEdgeVector::iterator eit = allEdges.begin(); eit != allEdges.end(); eit++) {
for(STXXLEdgeVector::iterator eit = allEdges->begin(); eit != allEdges->end(); eit++) {
assert(eit->type > -1 || eit->speed != -1);
NodeMap::iterator startit = nodeMap->find(eit->start);
@ -322,14 +185,14 @@ int main (int argc, char *argv[]) {
{
continue;
}
confirmedEdges.push_back(*eit);
confirmedEdges->push_back(*eit);
}
fout << confirmedEdges.size() << "\n";
fout << confirmedEdges->size() << "\n";
cout << "ok, after " << get_timestamp() - time << "s" << endl;
time = get_timestamp();
cout << "[extractor] writing confirmed ways ... " << flush;
for(STXXLEdgeVector::iterator eit = confirmedEdges.begin(); eit != confirmedEdges.end(); eit++) {
for(STXXLEdgeVector::iterator eit = confirmedEdges->begin(); eit != confirmedEdges->end(); eit++) {
NodeMap::iterator startit = nodeMap->find(eit->start);
if(startit == nodeMap->end()) {
continue;
@ -375,13 +238,16 @@ int main (int argc, char *argv[]) {
time = get_timestamp();
std::cout << "[extractor] writing street name index ... " << std::flush;
std::vector<unsigned> * nameIndex = new std::vector<unsigned>(nameVector.size()+1, 0);
std::vector<unsigned> * nameIndex = new std::vector<unsigned>(nameVector->size()+1, 0);
unsigned currentNameIndex = 0;
for(unsigned i = 0; i < nameVector.size(); i++) {
nameIndex->at(i) = currentNameIndex;
currentNameIndex += nameVector[i].length();
unsigned elementCounter(0);
for(STXXLStringVector::iterator it = nameVector->begin(); it != nameVector->end(); it++) {
// for(unsigned i = 0; i < nameVector->size(); i++) {
nameIndex->at(elementCounter) = currentNameIndex;
currentNameIndex += it->length();
elementCounter++;
}
nameIndex->at(nameVector.size()) = currentNameIndex;
nameIndex->at(nameVector->size()) = currentNameIndex;
ofstream nameOutFile(outputFileName.c_str(), ios::binary);
unsigned sizeOfNameIndex = nameIndex->size();
nameOutFile.write((char *)&(sizeOfNameIndex), sizeof(unsigned));
@ -389,8 +255,8 @@ int main (int argc, char *argv[]) {
for(unsigned i = 0; i < nameIndex->size(); i++) {
nameOutFile.write((char *)&(nameIndex->at(i)), sizeof(unsigned));
}
for(unsigned i = 0; i < nameVector.size(); i++){
nameOutFile << nameVector[i];
for(STXXLStringVector::iterator it = nameVector->begin(); it != nameVector->end(); it++) {
nameOutFile << *it;
}
nameOutFile.close();
@ -404,18 +270,28 @@ int main (int argc, char *argv[]) {
std::cout << "[info] Statistics:" << std::endl;
std::cout << "[info] -----------" << std::endl;
std::cout << "[info] Usable Nodes: " << confirmedNodes.size() << std::endl;
std::cout << "[info] Usable Edges: " << confirmedEdges.size() << std::endl;
std::cout << "[info] Usable Nodes: " << confirmedNodes->size() << std::endl;
std::cout << "[info] Usable Edges: " << confirmedEdges->size() << std::endl;
usedNodes.clear();
allNodes.clear();
confirmedNodes.clear();
allEdges.clear();
confirmedEdges.clear();
nameVector.clear();
delete extractCallBacks;
delete nodeMap;
delete stringMap;
delete confirmedNodes;
delete confirmedEdges;
delete parser;
cout << "[extractor] finished." << endl;
return 0;
}
bool nodeFunction(_Node n) {
extractCallBacks->nodeFunction(n);
return true;
}
bool relationFunction(_Relation r) {
globalRelationCounter++;
return true;
}
bool wayFunction(_Way w) {
extractCallBacks->wayFunction(w);
return true;
}