fixing ticket 20. stxxl should not complain any more. also, there should be no compiler warnings.
This commit is contained in:
@@ -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_ */
|
||||
@@ -257,5 +257,6 @@ string GetRandomString() {
|
||||
return string(s);
|
||||
}
|
||||
|
||||
typedef google::dense_hash_map<NodeID, _Node> NodeMap;
|
||||
|
||||
#endif /* EXTRACTORSTRUCTS_H_ */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user