Merge branch 'master' of https://DennisOSRM@github.com/DennisOSRM/Project-OSRM.git
This commit is contained in:
commit
c4dc85f607
@ -29,7 +29,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
class PolylineCompressor {
|
class PolylineCompressor {
|
||||||
private:
|
private:
|
||||||
inline void encodeVectorSignedNumber(vector<int> & numbers, string & output) {
|
inline void encodeVectorSignedNumber(std::vector<int> & numbers, std::string & output) {
|
||||||
for(unsigned i = 0; i < numbers.size(); ++i) {
|
for(unsigned i = 0; i < numbers.size(); ++i) {
|
||||||
numbers[i] <<= 1;
|
numbers[i] <<= 1;
|
||||||
if (numbers[i] < 0) {
|
if (numbers[i] < 0) {
|
||||||
@ -41,7 +41,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void encodeNumber(int numberToEncode, string & output) {
|
inline void encodeNumber(int numberToEncode, std::string & output) {
|
||||||
while (numberToEncode >= 0x20) {
|
while (numberToEncode >= 0x20) {
|
||||||
int nextValue = (0x20 | (numberToEncode & 0x1f)) + 63;
|
int nextValue = (0x20 | (numberToEncode & 0x1f)) + 63;
|
||||||
output += (static_cast<char> (nextValue));
|
output += (static_cast<char> (nextValue));
|
||||||
@ -57,8 +57,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline void printEncodedString(const vector<SegmentInformation>& polyline, string &output) {
|
inline void printEncodedString(const std::vector<SegmentInformation>& polyline, std::string &output) {
|
||||||
vector<int> deltaNumbers;
|
std::vector<int> deltaNumbers;
|
||||||
output += "\"";
|
output += "\"";
|
||||||
if(!polyline.empty()) {
|
if(!polyline.empty()) {
|
||||||
_Coordinate lastCoordinate = polyline[0].location;
|
_Coordinate lastCoordinate = polyline[0].location;
|
||||||
@ -77,8 +77,8 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void printEncodedString(const vector<_Coordinate>& polyline, string &output) {
|
inline void printEncodedString(const std::vector<_Coordinate>& polyline, std::string &output) {
|
||||||
vector<int> deltaNumbers(2*polyline.size());
|
std::vector<int> deltaNumbers(2*polyline.size());
|
||||||
output += "\"";
|
output += "\"";
|
||||||
if(!polyline.empty()) {
|
if(!polyline.empty()) {
|
||||||
deltaNumbers[0] = polyline[0].lat;
|
deltaNumbers[0] = polyline[0].lat;
|
||||||
@ -92,9 +92,9 @@ public:
|
|||||||
output += "\"";
|
output += "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void printUnencodedString(vector<_Coordinate> & polyline, string & output) {
|
inline void printUnencodedString(std::vector<_Coordinate> & polyline, std::string & output) {
|
||||||
output += "[";
|
output += "[";
|
||||||
string tmp;
|
std::string tmp;
|
||||||
for(unsigned i = 0; i < polyline.size(); i++) {
|
for(unsigned i = 0; i < polyline.size(); i++) {
|
||||||
convertInternalLatLonToString(polyline[i].lat, tmp);
|
convertInternalLatLonToString(polyline[i].lat, tmp);
|
||||||
output += "[";
|
output += "[";
|
||||||
@ -110,9 +110,9 @@ public:
|
|||||||
output += "]";
|
output += "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void printUnencodedString(vector<SegmentInformation> & polyline, string & output) {
|
inline void printUnencodedString(std::vector<SegmentInformation> & polyline, std::string & output) {
|
||||||
output += "[";
|
output += "[";
|
||||||
string tmp;
|
std::string tmp;
|
||||||
for(unsigned i = 0; i < polyline.size(); i++) {
|
for(unsigned i = 0; i < polyline.size(); i++) {
|
||||||
if(!polyline[i].necessary)
|
if(!polyline[i].necessary)
|
||||||
continue;
|
continue;
|
||||||
|
@ -21,11 +21,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#ifndef CONTRACTIONCLEANUP_H_INCLUDED
|
#ifndef CONTRACTIONCLEANUP_H_INCLUDED
|
||||||
#define CONTRACTIONCLEANUP_H_INCLUDED
|
#define CONTRACTIONCLEANUP_H_INCLUDED
|
||||||
|
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
#include <parallel/algorithm>
|
|
||||||
#else
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#endif
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
@ -120,11 +116,7 @@ public:
|
|||||||
edges.push_back( newEdge );
|
edges.push_back( newEdge );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
__gnu_parallel::sort( edges.begin(), edges.end() );
|
|
||||||
#else
|
|
||||||
sort( edges.begin(), edges.end() );
|
sort( edges.begin(), edges.end() );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -119,8 +119,9 @@ public:
|
|||||||
edge.data.backward = currentEdge.isForward();
|
edge.data.backward = currentEdge.isForward();
|
||||||
edges.push_back( edge );
|
edges.push_back( edge );
|
||||||
}
|
}
|
||||||
//remove data from memory
|
//clear input vector and trim the current set of edges with the well-known swap trick
|
||||||
std::vector< InputEdge >().swap( inputEdges );
|
std::vector< InputEdge >().swap( inputEdges );
|
||||||
|
|
||||||
sort( edges.begin(), edges.end() );
|
sort( edges.begin(), edges.end() );
|
||||||
NodeID edge = 0;
|
NodeID edge = 0;
|
||||||
for ( NodeID i = 0; i < edges.size(); ) {
|
for ( NodeID i = 0; i < edges.size(); ) {
|
||||||
@ -168,8 +169,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "ok" << std::endl << "merged " << edges.size() - edge << " edges out of " << edges.size() << std::endl;
|
std::cout << "ok" << "merged " << edges.size() - edge << " edges out of " << edges.size() << std::endl;
|
||||||
edges.resize( edge );
|
edges.resize( edge );
|
||||||
|
std::vector<_ImportEdge>(edges).swap(edges);
|
||||||
|
|
||||||
_graph.reset( new _DynamicGraph( nodes, edges ) );
|
_graph.reset( new _DynamicGraph( nodes, edges ) );
|
||||||
std::vector< _ImportEdge >().swap( edges );
|
std::vector< _ImportEdge >().swap( edges );
|
||||||
// unsigned maxdegree = 0;
|
// unsigned maxdegree = 0;
|
||||||
@ -188,10 +191,10 @@ public:
|
|||||||
// INFO(" ->(" << highestNode << "," << _graph->GetTarget(i) << "); via: " << _graph->GetEdgeData(i).via);
|
// INFO(" ->(" << highestNode << "," << _graph->GetTarget(i) << "); via: " << _graph->GetEdgeData(i).via);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
//Create temporary file
|
//Create temporary file
|
||||||
|
|
||||||
GetTemporaryFileName(temporaryEdgeStorageFilename);
|
GetTemporaryFileName(temporaryEdgeStorageFilename);
|
||||||
|
std::cout << "contractor finished initalization" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Contractor() {
|
~Contractor() {
|
||||||
|
@ -260,8 +260,12 @@ void EdgeBasedGraphFactory::Run() {
|
|||||||
}
|
}
|
||||||
p.printIncrement();
|
p.printIncrement();
|
||||||
}
|
}
|
||||||
|
INFO("Sorting edge-based Nodes");
|
||||||
std::sort(edgeBasedNodes.begin(), edgeBasedNodes.end());
|
std::sort(edgeBasedNodes.begin(), edgeBasedNodes.end());
|
||||||
|
INFO("Removing duplicate nodes (if any)");
|
||||||
edgeBasedNodes.erase( std::unique(edgeBasedNodes.begin(), edgeBasedNodes.end()), edgeBasedNodes.end() );
|
edgeBasedNodes.erase( std::unique(edgeBasedNodes.begin(), edgeBasedNodes.end()), edgeBasedNodes.end() );
|
||||||
|
INFO("Applying vector self-swap trick to free up memory");
|
||||||
|
edgeBasedNodes.swap(edgeBasedNodes);
|
||||||
INFO("Node-based graph contains " << nodeBasedEdgeCounter << " edges");
|
INFO("Node-based graph contains " << nodeBasedEdgeCounter << " edges");
|
||||||
INFO("Edge-based graph contains " << edgeBasedEdges.size() << " edges, blowup is " << (double)edgeBasedEdges.size()/(double)nodeBasedEdgeCounter);
|
INFO("Edge-based graph contains " << edgeBasedEdges.size() << " edges, blowup is " << (double)edgeBasedEdges.size()/(double)nodeBasedEdgeCounter);
|
||||||
INFO("Edge-based graph skipped " << numberOfSkippedTurns << " turns, defined by " << numberOfTurnRestrictions << " restrictions.");
|
INFO("Edge-based graph skipped " << numberOfSkippedTurns << " turns, defined by " << numberOfTurnRestrictions << " restrictions.");
|
||||||
|
@ -49,7 +49,7 @@ class DynamicGraph {
|
|||||||
m_nodes.reserve( m_numNodes );
|
m_nodes.reserve( m_numNodes );
|
||||||
m_nodes.resize( m_numNodes );
|
m_nodes.resize( m_numNodes );
|
||||||
|
|
||||||
m_edges.reserve( m_numNodes * 1.2 );
|
m_edges.reserve( m_numNodes * 1.1 );
|
||||||
m_edges.resize( m_numNodes );
|
m_edges.resize( m_numNodes );
|
||||||
}
|
}
|
||||||
DynamicGraph( int nodes, const std::vector< InputEdge > &graph )
|
DynamicGraph( int nodes, const std::vector< InputEdge > &graph )
|
||||||
@ -69,7 +69,7 @@ class DynamicGraph {
|
|||||||
m_nodes[node].edges = edge - lastEdge;
|
m_nodes[node].edges = edge - lastEdge;
|
||||||
position += m_nodes[node].edges;
|
position += m_nodes[node].edges;
|
||||||
}
|
}
|
||||||
m_edges.reserve( position * 1.2 );
|
m_edges.reserve( position * 1.1 );
|
||||||
m_edges.resize( position );
|
m_edges.resize( position );
|
||||||
edge = 0;
|
edge = 0;
|
||||||
for ( NodeIterator node = 0; node < m_numNodes; ++node ) {
|
for ( NodeIterator node = 0; node < m_numNodes; ++node ) {
|
||||||
@ -136,7 +136,7 @@ class DynamicGraph {
|
|||||||
m_edges[node.firstEdge] = m_edges[node.firstEdge + node.edges];
|
m_edges[node.firstEdge] = m_edges[node.firstEdge + node.edges];
|
||||||
} else {
|
} else {
|
||||||
EdgeIterator newFirstEdge = ( EdgeIterator ) m_edges.size();
|
EdgeIterator newFirstEdge = ( EdgeIterator ) m_edges.size();
|
||||||
unsigned newSize = node.edges * 1.2 + 2;
|
unsigned newSize = node.edges * 1.1 + 2;
|
||||||
EdgeIterator requiredCapacity = newSize + m_edges.size();
|
EdgeIterator requiredCapacity = newSize + m_edges.size();
|
||||||
EdgeIterator oldCapacity = m_edges.capacity();
|
EdgeIterator oldCapacity = m_edges.capacity();
|
||||||
if ( requiredCapacity >= oldCapacity ) {
|
if ( requiredCapacity >= oldCapacity ) {
|
||||||
|
@ -46,7 +46,7 @@ struct _Node : NodeInfo{
|
|||||||
return _Node(0,0,0, false, false);
|
return _Node(0,0,0, false, false);
|
||||||
}
|
}
|
||||||
static _Node max_value() {
|
static _Node max_value() {
|
||||||
return _Node((numeric_limits<int>::max)(), (numeric_limits<int>::max)(), (numeric_limits<unsigned int>::max)(), false, false);
|
return _Node((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)(), (std::numeric_limits<unsigned int>::max)(), false, false);
|
||||||
}
|
}
|
||||||
NodeID key() const {
|
NodeID key() const {
|
||||||
return id;
|
return id;
|
||||||
|
@ -100,6 +100,7 @@ public:
|
|||||||
|
|
||||||
template<typename EdgeT>
|
template<typename EdgeT>
|
||||||
void ConstructGrid(std::vector<EdgeT> & edgeList, char * ramIndexOut, char * fileIndexOut) {
|
void ConstructGrid(std::vector<EdgeT> & edgeList, char * ramIndexOut, char * fileIndexOut) {
|
||||||
|
//TODO: Implement this using STXXL-Streams
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
Percent p(edgeList.size());
|
Percent p(edgeList.size());
|
||||||
BOOST_FOREACH(EdgeT & edge, edgeList) {
|
BOOST_FOREACH(EdgeT & edge, edgeList) {
|
||||||
@ -240,7 +241,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_Coordinate tmp;
|
_Coordinate tmp;
|
||||||
double dist = (numeric_limits<double>::max)();
|
double dist = (std::numeric_limits<double>::max)();
|
||||||
BOOST_FOREACH(_GridEdge candidate, candidates) {
|
BOOST_FOREACH(_GridEdge candidate, candidates) {
|
||||||
double r = 0.;
|
double r = 0.;
|
||||||
double tmpDist = ComputeDistance(inputCoordinate, candidate.startCoord, candidate.targetCoord, tmp, &r);
|
double tmpDist = ComputeDistance(inputCoordinate, candidate.startCoord, candidate.targetCoord, tmp, &r);
|
||||||
@ -264,7 +265,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_Coordinate tmp;
|
_Coordinate tmp;
|
||||||
double dist = (numeric_limits<double>::max)();
|
double dist = (std::numeric_limits<double>::max)();
|
||||||
BOOST_FOREACH(_GridEdge candidate, candidates) {
|
BOOST_FOREACH(_GridEdge candidate, candidates) {
|
||||||
double r = 0.;
|
double r = 0.;
|
||||||
double tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r);
|
double tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r);
|
||||||
@ -298,13 +299,13 @@ private:
|
|||||||
return (std::fabs(d1 - d2) < 0.0001);
|
return (std::fabs(d1 - d2) < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned FillCell(std::vector<GridEntry>& entriesWithSameRAMIndex, unsigned long fileOffset ) {
|
unsigned FillCell(std::vector<GridEntry>& entriesWithSameRAMIndex, const unsigned long fileOffset ) {
|
||||||
vector<char> tmpBuffer(32*32*4096,0);
|
std::vector<char> tmpBuffer(32*32*4096,0);
|
||||||
unsigned long indexIntoTmpBuffer = 0;
|
unsigned long indexIntoTmpBuffer = 0;
|
||||||
unsigned numberOfWrittenBytes = 0;
|
unsigned numberOfWrittenBytes = 0;
|
||||||
assert(indexOutFile.is_open());
|
assert(indexOutFile.is_open());
|
||||||
|
|
||||||
vector<unsigned long> cellIndex(32*32,ULONG_MAX);
|
std::vector<unsigned long> cellIndex(32*32,ULONG_MAX);
|
||||||
boost::unordered_map< unsigned, unsigned, IdenticalHashFunction > cellMap(1024);
|
boost::unordered_map< unsigned, unsigned, IdenticalHashFunction > cellMap(1024);
|
||||||
|
|
||||||
unsigned ramIndex = entriesWithSameRAMIndex.begin()->ramIndex;
|
unsigned ramIndex = entriesWithSameRAMIndex.begin()->ramIndex;
|
||||||
@ -354,7 +355,7 @@ private:
|
|||||||
return numberOfWrittenBytes;
|
return numberOfWrittenBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned FlushEntriesWithSameFileIndexToBuffer( std::vector<GridEntry> &vectorWithSameFileIndex, vector<char> & tmpBuffer, const unsigned long index) {
|
unsigned FlushEntriesWithSameFileIndexToBuffer( std::vector<GridEntry> &vectorWithSameFileIndex, std::vector<char> & tmpBuffer, const unsigned long index) {
|
||||||
tmpBuffer.resize(tmpBuffer.size()+(sizeof(_GridEdge)*vectorWithSameFileIndex.size()) + sizeof(unsigned) );
|
tmpBuffer.resize(tmpBuffer.size()+(sizeof(_GridEdge)*vectorWithSameFileIndex.size()) + sizeof(unsigned) );
|
||||||
unsigned counter = 0;
|
unsigned counter = 0;
|
||||||
|
|
||||||
@ -373,7 +374,7 @@ private:
|
|||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(GridEntry entry, vectorWithSameFileIndex) {
|
BOOST_FOREACH(const GridEntry & entry, vectorWithSameFileIndex) {
|
||||||
char * data = (char *)&(entry.edge);
|
char * data = (char *)&(entry.edge);
|
||||||
for(unsigned i = 0; i < sizeof(_GridEdge); ++i) {
|
for(unsigned i = 0; i < sizeof(_GridEdge); ++i) {
|
||||||
tmpBuffer[index+counter] = data[i];
|
tmpBuffer[index+counter] = data[i];
|
||||||
@ -419,7 +420,7 @@ private:
|
|||||||
localStream->read((char *)&result[currentSizeOfResult], lengthOfBucket*sizeof(_GridEdge));
|
localStream->read((char *)&result[currentSizeOfResult], lengthOfBucket*sizeof(_GridEdge));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddEdge(_GridEdge edge) {
|
void AddEdge(const _GridEdge & edge) {
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
std::vector<BresenhamPixel> indexList;
|
std::vector<BresenhamPixel> indexList;
|
||||||
GetListOfIndexesForEdgeAndGridSize(edge.startCoord, edge.targetCoord, indexList);
|
GetListOfIndexesForEdgeAndGridSize(edge.startCoord, edge.targetCoord, indexList);
|
||||||
@ -468,7 +469,7 @@ private:
|
|||||||
return (p-x)*(p-x) + (q-y)*(q-y);
|
return (p-x)*(p-x) + (q-y)*(q-y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetListOfIndexesForEdgeAndGridSize(_Coordinate& start, _Coordinate& target, std::vector<BresenhamPixel> &indexList) {
|
void GetListOfIndexesForEdgeAndGridSize(const _Coordinate& start, const _Coordinate& target, std::vector<BresenhamPixel> &indexList) {
|
||||||
double lat1 = start.lat/100000.;
|
double lat1 = start.lat/100000.;
|
||||||
double lon1 = start.lon/100000.;
|
double lon1 = start.lon/100000.;
|
||||||
|
|
||||||
@ -523,8 +524,8 @@ private:
|
|||||||
|
|
||||||
const static unsigned long END_OF_BUCKET_DELIMITER = UINT_MAX;
|
const static unsigned long END_OF_BUCKET_DELIMITER = UINT_MAX;
|
||||||
|
|
||||||
ofstream indexOutFile;
|
std::ofstream indexOutFile;
|
||||||
ifstream ramInFile;
|
std::ifstream ramInFile;
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
stxxl::vector<GridEntry> entries;
|
stxxl::vector<GridEntry> entries;
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,13 +39,13 @@ struct NodeCoords {
|
|||||||
NodeT id;
|
NodeT id;
|
||||||
|
|
||||||
static NodeCoords<NodeT> min_value() {
|
static NodeCoords<NodeT> min_value() {
|
||||||
return NodeCoords<NodeT>(-90*100000,-180*100000,numeric_limits<NodeT>::min());
|
return NodeCoords<NodeT>(-90*100000,-180*100000,std::numeric_limits<NodeT>::min());
|
||||||
}
|
}
|
||||||
static NodeCoords<NodeT> max_value() {
|
static NodeCoords<NodeT> max_value() {
|
||||||
return NodeCoords<NodeT>(90*100000, 180*100000, numeric_limits<NodeT>::max());
|
return NodeCoords<NodeT>(90*100000, 180*100000, std::numeric_limits<NodeT>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type operator[](size_t n) const {
|
value_type operator[](std::size_t n) const {
|
||||||
switch(n) {
|
switch(n) {
|
||||||
case 1:
|
case 1:
|
||||||
return lat;
|
return lat;
|
||||||
|
@ -33,24 +33,25 @@ class NodeInformationHelpDesk{
|
|||||||
public:
|
public:
|
||||||
NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput, const unsigned _numberOfNodes, const unsigned crc) : numberOfNodes(_numberOfNodes), checkSum(crc) {
|
NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput, const unsigned _numberOfNodes, const unsigned crc) : numberOfNodes(_numberOfNodes), checkSum(crc) {
|
||||||
readOnlyGrid = new ReadOnlyGrid(ramIndexInput,fileIndexInput);
|
readOnlyGrid = new ReadOnlyGrid(ramIndexInput,fileIndexInput);
|
||||||
coordinateVector.reserve(numberOfNodes);
|
|
||||||
assert(0 == coordinateVector.size());
|
assert(0 == coordinateVector.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Todo: Shared memory mechanism
|
//Todo: Shared memory mechanism
|
||||||
NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput, const unsigned crc) : checkSum(crc) {
|
// NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput, const unsigned crc) : checkSum(crc) {
|
||||||
readOnlyGrid = new ReadOnlyGrid(ramIndexInput,fileIndexInput);
|
// readOnlyGrid = new ReadOnlyGrid(ramIndexInput,fileIndexInput);
|
||||||
}
|
// }
|
||||||
|
|
||||||
~NodeInformationHelpDesk() {
|
~NodeInformationHelpDesk() {
|
||||||
delete readOnlyGrid;
|
delete readOnlyGrid;
|
||||||
}
|
}
|
||||||
void initNNGrid(ifstream& in) {
|
void initNNGrid(std::ifstream& in) {
|
||||||
while(!in.eof()) {
|
|
||||||
NodeInfo b;
|
NodeInfo b;
|
||||||
in.read((char *)&b, sizeof(b));
|
while(!in.eof()) {
|
||||||
|
in.read((char *)&b, sizeof(NodeInfo));
|
||||||
coordinateVector.push_back(_Coordinate(b.lat, b.lon));
|
coordinateVector.push_back(_Coordinate(b.lat, b.lon));
|
||||||
}
|
}
|
||||||
|
std::vector<_Coordinate>(coordinateVector).swap(coordinateVector);
|
||||||
|
numberOfNodes = coordinateVector.size();
|
||||||
in.close();
|
in.close();
|
||||||
readOnlyGrid->OpenIndexFiles();
|
readOnlyGrid->OpenIndexFiles();
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,14 @@ class SearchEngine {
|
|||||||
private:
|
private:
|
||||||
const GraphT * _graph;
|
const GraphT * _graph;
|
||||||
NodeInformationHelpDesk * nodeHelpDesk;
|
NodeInformationHelpDesk * nodeHelpDesk;
|
||||||
std::vector<string> * _names;
|
std::vector<string> & _names;
|
||||||
static HeapPtr _forwardHeap;
|
static HeapPtr _forwardHeap;
|
||||||
static HeapPtr _backwardHeap;
|
static HeapPtr _backwardHeap;
|
||||||
static HeapPtr _forwardHeap2;
|
static HeapPtr _forwardHeap2;
|
||||||
static HeapPtr _backwardHeap2;
|
static HeapPtr _backwardHeap2;
|
||||||
inline double absDouble(double input) { if(input < 0) return input*(-1); else return input;}
|
inline double absDouble(double input) { if(input < 0) return input*(-1); else return input;}
|
||||||
public:
|
public:
|
||||||
SearchEngine(GraphT * g, NodeInformationHelpDesk * nh, std::vector<string> * n = new std::vector<string>()) : _graph(g), nodeHelpDesk(nh), _names(n) {}
|
SearchEngine(GraphT * g, NodeInformationHelpDesk * nh, std::vector<string> & n) : _graph(g), nodeHelpDesk(nh), _names(n) {}
|
||||||
~SearchEngine() {}
|
~SearchEngine() {}
|
||||||
|
|
||||||
inline const void GetCoordinatesForNodeID(NodeID id, _Coordinate& result) const {
|
inline const void GetCoordinatesForNodeID(NodeID id, _Coordinate& result) const {
|
||||||
@ -377,7 +377,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline std::string GetEscapedNameForNameID(const NodeID nameID) const {
|
inline std::string GetEscapedNameForNameID(const NodeID nameID) const {
|
||||||
return ((nameID >= _names->size() || nameID == 0) ? std::string("") : HTMLEntitize(_names->at(nameID)));
|
return ((nameID >= _names.size() || nameID == 0) ? std::string("") : HTMLEntitize(_names.at(nameID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string GetEscapedNameForEdgeBasedEdgeID(const unsigned edgeID) const {
|
inline std::string GetEscapedNameForEdgeBasedEdgeID(const unsigned edgeID) const {
|
||||||
|
@ -22,11 +22,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#define STATICGRAPH_H_INCLUDED
|
#define STATICGRAPH_H_INCLUDED
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
#include <parallel/algorithm>
|
|
||||||
#else
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
#include "ImportEdge.h"
|
#include "ImportEdge.h"
|
||||||
|
@ -24,11 +24,7 @@ KD Tree coded by Christian Vetter, Monav Project
|
|||||||
#define STATICKDTREE_H_INCLUDED
|
#define STATICKDTREE_H_INCLUDED
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
#include <parallel/algorithm>
|
|
||||||
#else
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#endif
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
@ -119,11 +115,7 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Iterator middle = tree.left + ( tree.right - tree.left ) / 2;
|
Iterator middle = tree.left + ( tree.right - tree.left ) / 2;
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
__gnu_parallel::nth_element( kdtree + tree.left, kdtree + middle, kdtree + tree.right, Less( tree.dimension ) );
|
|
||||||
#else
|
|
||||||
std::nth_element( kdtree + tree.left, kdtree + middle, kdtree + tree.right, Less( tree.dimension ) );
|
std::nth_element( kdtree + tree.left, kdtree + middle, kdtree + tree.right, Less( tree.dimension ) );
|
||||||
#endif
|
|
||||||
s.push( Tree( tree.left, middle, ( tree.dimension + 1 ) % k ) );
|
s.push( Tree( tree.left, middle, ( tree.dimension + 1 ) % k ) );
|
||||||
s.push( Tree( middle + 1, tree.right, ( tree.dimension + 1 ) % k ) );
|
s.push( Tree( middle + 1, tree.right, ( tree.dimension + 1 ) % k ) );
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "ObjectForPluginStruct.h"
|
#include "../Server/DataStructures/QueryObjectsStorage.h"
|
||||||
#include "BasePlugin.h"
|
#include "BasePlugin.h"
|
||||||
#include "RouteParameters.h"
|
#include "RouteParameters.h"
|
||||||
#include "../Util/StringUtil.h"
|
#include "../Util/StringUtil.h"
|
||||||
@ -34,7 +34,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
*/
|
*/
|
||||||
class LocatePlugin : public BasePlugin {
|
class LocatePlugin : public BasePlugin {
|
||||||
public:
|
public:
|
||||||
LocatePlugin(ObjectsForQueryStruct * objects) {
|
LocatePlugin(QueryObjectsStorage * objects) {
|
||||||
nodeHelpDesk = objects->nodeHelpDesk;
|
nodeHelpDesk = objects->nodeHelpDesk;
|
||||||
}
|
}
|
||||||
std::string GetDescriptor() const { return std::string("locate"); }
|
std::string GetDescriptor() const { return std::string("locate"); }
|
||||||
|
@ -26,7 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include "BasePlugin.h"
|
#include "BasePlugin.h"
|
||||||
#include "RouteParameters.h"
|
#include "RouteParameters.h"
|
||||||
|
|
||||||
#include "ObjectForPluginStruct.h"
|
#include "../Server/DataStructures/QueryObjectsStorage.h"
|
||||||
|
|
||||||
#include "../DataStructures/NodeInformationHelpDesk.h"
|
#include "../DataStructures/NodeInformationHelpDesk.h"
|
||||||
#include "../DataStructures/HashTable.h"
|
#include "../DataStructures/HashTable.h"
|
||||||
@ -37,7 +37,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
*/
|
*/
|
||||||
class NearestPlugin : public BasePlugin {
|
class NearestPlugin : public BasePlugin {
|
||||||
public:
|
public:
|
||||||
NearestPlugin(ObjectsForQueryStruct * objects) {
|
NearestPlugin(QueryObjectsStorage * objects) {
|
||||||
nodeHelpDesk = objects->nodeHelpDesk;
|
nodeHelpDesk = objects->nodeHelpDesk;
|
||||||
descriptorTable.Set("", 0); //default descriptor
|
descriptorTable.Set("", 0); //default descriptor
|
||||||
descriptorTable.Set("kml", 0);
|
descriptorTable.Set("kml", 0);
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
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 OBJECTSFORQUERYSTRUCT_H_
|
|
||||||
#define OBJECTSFORQUERYSTRUCT_H_
|
|
||||||
|
|
||||||
#include<vector>
|
|
||||||
#include<string>
|
|
||||||
|
|
||||||
#include "../DataStructures/StaticGraph.h"
|
|
||||||
#include "../Util/GraphLoader.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct ObjectsForQueryStruct {
|
|
||||||
typedef StaticGraph<EdgeData> QueryGraph;
|
|
||||||
typedef QueryGraph::InputEdge InputEdge;
|
|
||||||
|
|
||||||
NodeInformationHelpDesk * nodeHelpDesk;
|
|
||||||
std::vector<std::string> * names;
|
|
||||||
QueryGraph * graph;
|
|
||||||
unsigned checkSum;
|
|
||||||
|
|
||||||
ObjectsForQueryStruct(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd = "route") {
|
|
||||||
INFO("loading graph data");
|
|
||||||
std::ifstream hsgrInStream(hsgrPath.c_str(), ios::binary);
|
|
||||||
//Deserialize road network graph
|
|
||||||
std::vector< QueryGraph::_StrNode> nodeList;
|
|
||||||
std::vector< QueryGraph::_StrEdge> edgeList;
|
|
||||||
const int n = readHSGRFromStream(hsgrInStream, nodeList, edgeList, &checkSum);
|
|
||||||
INFO("Data checksum is " << checkSum);
|
|
||||||
graph = new QueryGraph(nodeList, edgeList);
|
|
||||||
assert(0 == nodeList.size());
|
|
||||||
assert(0 == edgeList.size());
|
|
||||||
INFO("Loading nearest neighbor indices");
|
|
||||||
//Init nearest neighbor data structure
|
|
||||||
std::ifstream nodesInStream(nodesPath.c_str(), ios::binary);
|
|
||||||
nodeHelpDesk = new NodeInformationHelpDesk(ramIndexPath.c_str(), fileIndexPath.c_str(), n, checkSum);
|
|
||||||
nodeHelpDesk->initNNGrid(nodesInStream);
|
|
||||||
|
|
||||||
//deserialize street name list
|
|
||||||
INFO("Loading names index");
|
|
||||||
std::ifstream namesInStream(namesPath.c_str(), ios::binary);
|
|
||||||
unsigned size(0);
|
|
||||||
namesInStream.read((char *)&size, sizeof(unsigned));
|
|
||||||
names = new std::vector<std::string>();
|
|
||||||
|
|
||||||
char buf[1024];
|
|
||||||
for(unsigned i = 0; i < size; ++i) {
|
|
||||||
unsigned sizeOfString = 0;
|
|
||||||
namesInStream.read((char *)&sizeOfString, sizeof(unsigned));
|
|
||||||
memset(buf, 0, 1024*sizeof(char));
|
|
||||||
namesInStream.read(buf, sizeOfString);
|
|
||||||
std::string currentStreetName(buf);
|
|
||||||
names->push_back(currentStreetName);
|
|
||||||
}
|
|
||||||
hsgrInStream.close();
|
|
||||||
namesInStream.close();
|
|
||||||
INFO("All query data structures loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
~ObjectsForQueryStruct() {
|
|
||||||
delete names;
|
|
||||||
delete graph;
|
|
||||||
delete nodeHelpDesk;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* OBJECTSFORQUERYSTRUCT_H_ */
|
|
@ -27,8 +27,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ObjectForPluginStruct.h"
|
|
||||||
|
|
||||||
#include "BasePlugin.h"
|
#include "BasePlugin.h"
|
||||||
#include "RouteParameters.h"
|
#include "RouteParameters.h"
|
||||||
|
|
||||||
@ -44,20 +42,21 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include "../Util/StringUtil.h"
|
#include "../Util/StringUtil.h"
|
||||||
|
|
||||||
|
#include "../Server/DataStructures/QueryObjectsStorage.h"
|
||||||
|
|
||||||
class ViaRoutePlugin : public BasePlugin {
|
class ViaRoutePlugin : public BasePlugin {
|
||||||
private:
|
private:
|
||||||
NodeInformationHelpDesk * nodeHelpDesk;
|
NodeInformationHelpDesk * nodeHelpDesk;
|
||||||
std::vector<std::string> * names;
|
std::vector<std::string> & names;
|
||||||
StaticGraph<EdgeData> * graph;
|
StaticGraph<EdgeData> * graph;
|
||||||
HashTable<std::string, unsigned> descriptorTable;
|
HashTable<std::string, unsigned> descriptorTable;
|
||||||
std::string pluginDescriptorString;
|
std::string pluginDescriptorString;
|
||||||
SearchEngine<EdgeData, StaticGraph<EdgeData> > * searchEngine;
|
SearchEngine<EdgeData, StaticGraph<EdgeData> > * searchEngine;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ViaRoutePlugin(ObjectsForQueryStruct * objects, std::string psd = "viaroute") : pluginDescriptorString(psd) {
|
ViaRoutePlugin(QueryObjectsStorage * objects, std::string psd = "viaroute") : names(objects->names), pluginDescriptorString(psd) {
|
||||||
nodeHelpDesk = objects->nodeHelpDesk;
|
nodeHelpDesk = objects->nodeHelpDesk;
|
||||||
graph = objects->graph;
|
graph = objects->graph;
|
||||||
names = objects->names;
|
|
||||||
|
|
||||||
searchEngine = new SearchEngine<EdgeData, StaticGraph<EdgeData> >(graph, nodeHelpDesk, names);
|
searchEngine = new SearchEngine<EdgeData, StaticGraph<EdgeData> >(graph, nodeHelpDesk, names);
|
||||||
|
|
||||||
|
@ -258,6 +258,6 @@ if sys.platform != 'darwin':
|
|||||||
|
|
||||||
env.Program(target = 'osrm-extract', source = ["extractor.cpp", Glob('DataStructures/pbf-proto/*.pb.cc'), Glob('Util/*.cpp')], depends=['osm1', 'osm2'])
|
env.Program(target = 'osrm-extract', source = ["extractor.cpp", Glob('DataStructures/pbf-proto/*.pb.cc'), Glob('Util/*.cpp')], depends=['osm1', 'osm2'])
|
||||||
env.Program(target = 'osrm-prepare', source = ["createHierarchy.cpp", 'Contractor/EdgeBasedGraphFactory.cpp', Glob('Util/SRTMLookup/*.cpp'), Glob('Algorithms/*.cpp')])
|
env.Program(target = 'osrm-prepare', source = ["createHierarchy.cpp", 'Contractor/EdgeBasedGraphFactory.cpp', Glob('Util/SRTMLookup/*.cpp'), Glob('Algorithms/*.cpp')])
|
||||||
env.Program(target = 'osrm-routed', source = ["routed.cpp", 'Descriptors/DescriptionFactory.cpp', Glob('ThirdParty/*.cc')], CCFLAGS = env['CCFLAGS'] + ['-DROUTED'])
|
env.Program(target = 'osrm-routed', source = ["routed.cpp", 'Descriptors/DescriptionFactory.cpp', Glob('ThirdParty/*.cc'), Glob('Server/DataStructures/*.cpp')], CCFLAGS = env['CCFLAGS'] + ['-DROUTED'])
|
||||||
env = conf.Finish()
|
env = conf.Finish()
|
||||||
|
|
||||||
|
68
Server/DataStructures/QueryObjectsStorage.cpp
Normal file
68
Server/DataStructures/QueryObjectsStorage.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "QueryObjectsStorage.h"
|
||||||
|
#include "../../Util/GraphLoader.h"
|
||||||
|
|
||||||
|
QueryObjectsStorage::QueryObjectsStorage(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd) {
|
||||||
|
INFO("loading graph data");
|
||||||
|
std::ifstream hsgrInStream(hsgrPath.c_str(), ios::binary);
|
||||||
|
//Deserialize road network graph
|
||||||
|
std::vector< QueryGraph::_StrNode> nodeList;
|
||||||
|
std::vector< QueryGraph::_StrEdge> edgeList;
|
||||||
|
const int n = readHSGRFromStream(hsgrInStream, nodeList, edgeList, &checkSum);
|
||||||
|
|
||||||
|
INFO("Data checksum is " << checkSum);
|
||||||
|
graph = new QueryGraph(nodeList, edgeList);
|
||||||
|
assert(0 == nodeList.size());
|
||||||
|
assert(0 == edgeList.size());
|
||||||
|
INFO("Loading nearest neighbor indices");
|
||||||
|
//Init nearest neighbor data structure
|
||||||
|
std::ifstream nodesInStream(nodesPath.c_str(), ios::binary);
|
||||||
|
nodeHelpDesk = new NodeInformationHelpDesk(ramIndexPath.c_str(), fileIndexPath.c_str(), n, checkSum);
|
||||||
|
nodeHelpDesk->initNNGrid(nodesInStream);
|
||||||
|
|
||||||
|
//deserialize street name list
|
||||||
|
INFO("Loading names index");
|
||||||
|
std::ifstream namesInStream(namesPath.c_str(), ios::binary);
|
||||||
|
unsigned size(0);
|
||||||
|
namesInStream.read((char *)&size, sizeof(unsigned));
|
||||||
|
// names = new std::vector<std::string>();
|
||||||
|
|
||||||
|
char buf[1024];
|
||||||
|
for(unsigned i = 0; i < size; ++i) {
|
||||||
|
unsigned sizeOfString = 0;
|
||||||
|
namesInStream.read((char *)&sizeOfString, sizeof(unsigned));
|
||||||
|
buf[sizeOfString] = '\0'; // instead of memset
|
||||||
|
namesInStream.read(buf, sizeOfString);
|
||||||
|
names.push_back(buf);
|
||||||
|
}
|
||||||
|
std::vector<std::string>(names).swap(names);
|
||||||
|
hsgrInStream.close();
|
||||||
|
namesInStream.close();
|
||||||
|
INFO("All query data structures loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryObjectsStorage::~QueryObjectsStorage() {
|
||||||
|
// delete names;
|
||||||
|
delete graph;
|
||||||
|
delete nodeHelpDesk;
|
||||||
|
}
|
44
Server/DataStructures/QueryObjectsStorage.h
Normal file
44
Server/DataStructures/QueryObjectsStorage.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
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 QUERYOBJECTSSTORAGE_H_
|
||||||
|
#define QUERYOBJECTSSTORAGE_H_
|
||||||
|
|
||||||
|
#include<vector>
|
||||||
|
#include<string>
|
||||||
|
|
||||||
|
#include "../../DataStructures/StaticGraph.h"
|
||||||
|
|
||||||
|
struct QueryObjectsStorage {
|
||||||
|
typedef StaticGraph<EdgeData> QueryGraph;
|
||||||
|
typedef QueryGraph::InputEdge InputEdge;
|
||||||
|
|
||||||
|
NodeInformationHelpDesk * nodeHelpDesk;
|
||||||
|
std::vector<std::string> names;
|
||||||
|
QueryGraph * graph;
|
||||||
|
unsigned checkSum;
|
||||||
|
|
||||||
|
QueryObjectsStorage(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd = "route");
|
||||||
|
|
||||||
|
~QueryObjectsStorage();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* QUERYOBJECTSSTORAGE_H_ */
|
@ -23,6 +23,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -30,12 +32,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
#ifdef _GLIBCXX_PARALLEL
|
|
||||||
#include <parallel/algorithm>
|
|
||||||
#else
|
|
||||||
#include <algorithm>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../DataStructures/ImportEdge.h"
|
#include "../DataStructures/ImportEdge.h"
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
@ -60,7 +56,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
|
|||||||
for (NodeID i=0; i<n; ++i) {
|
for (NodeID i=0; i<n; ++i) {
|
||||||
in.read((char*)&node, sizeof(_Node));
|
in.read((char*)&node, sizeof(_Node));
|
||||||
int2ExtNodeMap->push_back(NodeInfo(node.lat, node.lon, node.id));
|
int2ExtNodeMap->push_back(NodeInfo(node.lat, node.lon, node.id));
|
||||||
ext2IntNodeMap.insert(make_pair(node.id, i));
|
ext2IntNodeMap.insert(std::make_pair(node.id, i));
|
||||||
if(node.bollard)
|
if(node.bollard)
|
||||||
bollardNodes.push_back(i);
|
bollardNodes.push_back(i);
|
||||||
if(node.trafficLight)
|
if(node.trafficLight)
|
||||||
@ -166,7 +162,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
template<typename EdgeT>
|
template<typename EdgeT>
|
||||||
NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<NodeInfo> * int2ExtNodeMap) {
|
NodeID readDTMPGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeList, std::vector<NodeInfo> * int2ExtNodeMap) {
|
||||||
NodeID n, source, target, id;
|
NodeID n, source, target, id;
|
||||||
EdgeID m;
|
EdgeID m;
|
||||||
int dir, xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open)
|
int dir, xcoord, ycoord;// direction (0 = open, 1 = forward, 2+ = open)
|
||||||
@ -176,7 +172,7 @@ NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
|
|||||||
for (NodeID i=0; i<n;++i) {
|
for (NodeID i=0; i<n;++i) {
|
||||||
in >> id >> ycoord >> xcoord;
|
in >> id >> ycoord >> xcoord;
|
||||||
int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id));
|
int2ExtNodeMap->push_back(NodeInfo(xcoord, ycoord, id));
|
||||||
ext2IntNodeMap.insert(make_pair(id, i));
|
ext2IntNodeMap.insert(std::make_pair(id, i));
|
||||||
}
|
}
|
||||||
in >> m;
|
in >> m;
|
||||||
DEBUG(" and " << m << " edges");
|
DEBUG(" and " << m << " edges");
|
||||||
@ -273,13 +269,13 @@ NodeID readDTMPGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
|
|||||||
edgeList.push_back(inputEdge);
|
edgeList.push_back(inputEdge);
|
||||||
}
|
}
|
||||||
ext2IntNodeMap.clear();
|
ext2IntNodeMap.clear();
|
||||||
vector<ImportEdge>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
|
std::vector<ImportEdge>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
|
||||||
cout << "ok" << endl;
|
std::cout << "ok" << std::endl;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename EdgeT>
|
template<typename EdgeT>
|
||||||
NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<NodeID> & int2ExtNodeMap) {
|
NodeID readDDSGGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeList, std::vector<NodeID> & int2ExtNodeMap) {
|
||||||
ExternalNodeMap nodeMap;
|
ExternalNodeMap nodeMap;
|
||||||
NodeID n, source, target;
|
NodeID n, source, target;
|
||||||
unsigned numberOfNodes = 0;
|
unsigned numberOfNodes = 0;
|
||||||
@ -323,32 +319,24 @@ NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
|
|||||||
EdgeT inputEdge(source, target, 0, weight, forward, backward, 1 );
|
EdgeT inputEdge(source, target, 0, weight, forward, backward, 1 );
|
||||||
edgeList.push_back(inputEdge);
|
edgeList.push_back(inputEdge);
|
||||||
}
|
}
|
||||||
vector<EdgeT>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
|
std::vector<EdgeT>(edgeList.begin(), edgeList.end()).swap(edgeList); //remove excess candidates.
|
||||||
|
|
||||||
nodeMap.clear();
|
nodeMap.clear();
|
||||||
return numberOfNodes;
|
return numberOfNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NodeT, typename EdgeT>
|
template<typename NodeT, typename EdgeT>
|
||||||
unsigned readHSGRFromStream(istream &in, vector<NodeT>& nodeList, vector<EdgeT> & edgeList, unsigned * checkSum) {
|
unsigned readHSGRFromStream(std::istream &in, std::vector<NodeT>& nodeList, std::vector<EdgeT> & edgeList, unsigned * checkSum) {
|
||||||
unsigned numberOfNodes = 0;
|
unsigned numberOfNodes = 0;
|
||||||
in.read((char*) checkSum, sizeof(unsigned));
|
in.read((char*) checkSum, sizeof(unsigned));
|
||||||
in.read((char*) & numberOfNodes, sizeof(unsigned));
|
in.read((char*) & numberOfNodes, sizeof(unsigned));
|
||||||
nodeList.resize(numberOfNodes + 1);
|
nodeList.resize(numberOfNodes + 1);
|
||||||
NodeT currentNode;
|
in.read((char*) &(nodeList[0]), numberOfNodes*sizeof(NodeT));
|
||||||
for(unsigned nodeCounter = 0; nodeCounter < numberOfNodes; ++nodeCounter ) {
|
|
||||||
in.read((char*) ¤tNode, sizeof(NodeT));
|
|
||||||
nodeList[nodeCounter] = currentNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned numberOfEdges = 0;
|
unsigned numberOfEdges = 0;
|
||||||
in.read((char*) &numberOfEdges, sizeof(unsigned));
|
in.read((char*) &numberOfEdges, sizeof(unsigned));
|
||||||
edgeList.resize(numberOfEdges);
|
edgeList.resize(numberOfEdges);
|
||||||
EdgeT currentEdge;
|
in.read((char*) &(edgeList[0]), numberOfEdges*sizeof(EdgeT));
|
||||||
for(unsigned edgeCounter = 0; edgeCounter < numberOfEdges; ++edgeCounter) {
|
|
||||||
in.read((char*) ¤tEdge, sizeof(EdgeT));
|
|
||||||
edgeList[edgeCounter] = currentEdge;
|
|
||||||
}
|
|
||||||
|
|
||||||
return numberOfNodes;
|
return numberOfNodes;
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,13 @@ std::string NasaGridSquare::make_filename(const char* ext) const {
|
|||||||
char EW =(longitude>=0 ? 'E' : 'W' );
|
char EW =(longitude>=0 ? 'E' : 'W' );
|
||||||
char NS =(latitude >=0 ? 'N' : 'S');
|
char NS =(latitude >=0 ? 'N' : 'S');
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<setfill('0')
|
ss<<std::setfill('0')
|
||||||
<< ROOT_PATH
|
<< ROOT_PATH
|
||||||
<< "/"
|
<< "/"
|
||||||
<<NS
|
<<NS
|
||||||
<<setw(2)<<abs(latitude)<<setw(0)
|
<<std::setw(2)<<std::abs(latitude)<<std::setw(0)
|
||||||
<<EW
|
<<EW
|
||||||
<<setw(3)<<abs(longitude)<<setw(0)
|
<<std::setw(3)<<std::abs(longitude)<<std::setw(0)
|
||||||
<<'.'<<ext;
|
<<'.'<<ext;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ typedef DynamicGraph<EdgeData>::InputEdge InputEdge;
|
|||||||
typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
|
typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
|
||||||
typedef BaseConfiguration ContractorConfiguration;
|
typedef BaseConfiguration ContractorConfiguration;
|
||||||
|
|
||||||
std::vector<NodeInfo> internalToExternaleNodeMapping;
|
std::vector<NodeInfo> internalToExternalNodeMapping;
|
||||||
std::vector<_Restriction> inputRestrictions;
|
std::vector<_Restriction> inputRestrictions;
|
||||||
std::vector<NodeID> bollardNodes;
|
std::vector<NodeID> bollardNodes;
|
||||||
std::vector<NodeID> trafficLightNodes;
|
std::vector<NodeID> trafficLightNodes;
|
||||||
@ -111,7 +111,7 @@ int main (int argc, char *argv[]) {
|
|||||||
char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels");
|
char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels");
|
||||||
|
|
||||||
std::vector<ImportEdge> edgeList;
|
std::vector<ImportEdge> edgeList;
|
||||||
NodeID nodeBasedNodeNumber = readBinaryOSRMGraphFromStream(in, edgeList, bollardNodes, trafficLightNodes, &internalToExternaleNodeMapping, inputRestrictions);
|
NodeID nodeBasedNodeNumber = readBinaryOSRMGraphFromStream(in, edgeList, bollardNodes, trafficLightNodes, &internalToExternalNodeMapping, inputRestrictions);
|
||||||
in.close();
|
in.close();
|
||||||
INFO("Loaded " << inputRestrictions.size() << " restrictions, " << bollardNodes.size() << " bollard nodes, " << trafficLightNodes.size() << " traffic lights");
|
INFO("Loaded " << inputRestrictions.size() << " restrictions, " << bollardNodes.size() << " bollard nodes, " << trafficLightNodes.size() << " traffic lights");
|
||||||
|
|
||||||
@ -120,11 +120,11 @@ int main (int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
boost::property_tree::ptree speedProfile;
|
boost::property_tree::ptree speedProfile;
|
||||||
boost::property_tree::ini_parser::read_ini("speedprofile.ini", speedProfile);
|
boost::property_tree::ini_parser::read_ini("speedprofile.ini", speedProfile);
|
||||||
EdgeBasedGraphFactory * edgeBasedGraphFactory = new EdgeBasedGraphFactory (nodeBasedNodeNumber, edgeList, bollardNodes, trafficLightNodes, inputRestrictions, internalToExternaleNodeMapping, speedProfile, SRTM_ROOT);
|
EdgeBasedGraphFactory * edgeBasedGraphFactory = new EdgeBasedGraphFactory (nodeBasedNodeNumber, edgeList, bollardNodes, trafficLightNodes, inputRestrictions, internalToExternalNodeMapping, speedProfile, SRTM_ROOT);
|
||||||
edgeList.clear();
|
|
||||||
std::vector<ImportEdge>().swap(edgeList);
|
std::vector<ImportEdge>().swap(edgeList);
|
||||||
|
|
||||||
edgeBasedGraphFactory->Run();
|
edgeBasedGraphFactory->Run();
|
||||||
|
std::vector<_Restriction>().swap(inputRestrictions);
|
||||||
NodeID edgeBasedNodeNumber = edgeBasedGraphFactory->GetNumberOfNodes();
|
NodeID edgeBasedNodeNumber = edgeBasedGraphFactory->GetNumberOfNodes();
|
||||||
std::vector<EdgeBasedEdge> edgeBasedEdgeList;
|
std::vector<EdgeBasedEdge> edgeBasedEdgeList;
|
||||||
edgeBasedGraphFactory->GetEdgeBasedEdges(edgeBasedEdgeList);
|
edgeBasedGraphFactory->GetEdgeBasedEdges(edgeBasedEdgeList);
|
||||||
@ -140,23 +140,15 @@ int main (int argc, char *argv[]) {
|
|||||||
delete writeableGrid;
|
delete writeableGrid;
|
||||||
CRC32 crc32;
|
CRC32 crc32;
|
||||||
unsigned crc32OfNodeBasedEdgeList = crc32((char *)&(nodeBasedEdgeList[0]), nodeBasedEdgeList.size()*sizeof(EdgeBasedGraphFactory::EdgeBasedNode));
|
unsigned crc32OfNodeBasedEdgeList = crc32((char *)&(nodeBasedEdgeList[0]), nodeBasedEdgeList.size()*sizeof(EdgeBasedGraphFactory::EdgeBasedNode));
|
||||||
// INFO("CRC32 of data is " << crc32OfNodeBasedEdgeList);
|
|
||||||
|
|
||||||
nodeBasedEdgeList.clear();
|
|
||||||
std::vector<EdgeBasedGraphFactory::EdgeBasedNode>().swap(nodeBasedEdgeList);
|
std::vector<EdgeBasedGraphFactory::EdgeBasedNode>().swap(nodeBasedEdgeList);
|
||||||
|
|
||||||
INFO("writing node map ...");
|
INFO("writing node map ...");
|
||||||
std::ofstream mapOutFile(nodeOut, ios::binary);
|
std::ofstream mapOutFile(nodeOut, ios::binary);
|
||||||
mapOutFile.write((char *)&(internalToExternaleNodeMapping[0]), internalToExternaleNodeMapping.size()*sizeof(NodeInfo));
|
mapOutFile.write((char *)&(internalToExternalNodeMapping[0]), internalToExternalNodeMapping.size()*sizeof(NodeInfo));
|
||||||
mapOutFile.close();
|
mapOutFile.close();
|
||||||
|
|
||||||
|
std::vector<NodeInfo>().swap(internalToExternalNodeMapping);
|
||||||
std::vector<NodeInfo>().swap(internalToExternaleNodeMapping);
|
|
||||||
inputRestrictions.clear();
|
|
||||||
std::vector<_Restriction>().swap(inputRestrictions);
|
|
||||||
|
|
||||||
// unsigned crc32OfNodeBasedEdgeList = crc32((char*)&edgeBasedEdgeList[0], edgeBasedEdgeList.size());
|
|
||||||
// INFO("CRC32 of data is " << crc32OfNodeBasedEdgeList);
|
|
||||||
|
|
||||||
INFO("initializing contractor");
|
INFO("initializing contractor");
|
||||||
Contractor* contractor = new Contractor( edgeBasedNodeNumber, edgeBasedEdgeList );
|
Contractor* contractor = new Contractor( edgeBasedNodeNumber, edgeBasedEdgeList );
|
||||||
@ -168,15 +160,6 @@ int main (int argc, char *argv[]) {
|
|||||||
contractor->GetEdges( contractedEdgeList );
|
contractor->GetEdges( contractedEdgeList );
|
||||||
delete contractor;
|
delete contractor;
|
||||||
|
|
||||||
// ContractionCleanup * cleanup = new ContractionCleanup(edgeBasedNodeNumber, contractedEdges);
|
|
||||||
// contractedEdges.clear();
|
|
||||||
// std::vector<ContractionCleanup::Edge>().swap(contractedEdges);
|
|
||||||
// cleanup->Run();
|
|
||||||
//
|
|
||||||
// std::vector< InputEdge> cleanedEdgeList;
|
|
||||||
// cleanup->GetData(cleanedEdgeList);
|
|
||||||
// delete cleanup;
|
|
||||||
|
|
||||||
INFO("Building Node Array");
|
INFO("Building Node Array");
|
||||||
sort(contractedEdgeList.begin(), contractedEdgeList.end());
|
sort(contractedEdgeList.begin(), contractedEdgeList.end());
|
||||||
unsigned numberOfNodes = 0;
|
unsigned numberOfNodes = 0;
|
||||||
|
@ -24,14 +24,15 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
#include "Server/DataStructures/QueryObjectsStorage.h"
|
||||||
#include "Server/ServerConfiguration.h"
|
#include "Server/ServerConfiguration.h"
|
||||||
#include "Server/ServerFactory.h"
|
#include "Server/ServerFactory.h"
|
||||||
|
|
||||||
#include "Plugins/HelloWorldPlugin.h"
|
#include "Plugins/HelloWorldPlugin.h"
|
||||||
#include "Plugins/LocatePlugin.h"
|
#include "Plugins/LocatePlugin.h"
|
||||||
#include "Plugins/NearestPlugin.h"
|
#include "Plugins/NearestPlugin.h"
|
||||||
#include "Plugins/ObjectForPluginStruct.h"
|
|
||||||
#include "Plugins/ViaRoutePlugin.h"
|
#include "Plugins/ViaRoutePlugin.h"
|
||||||
|
|
||||||
#include "Util/InputFileUtil.h"
|
#include "Util/InputFileUtil.h"
|
||||||
#include "Util/OpenMPReplacement.h"
|
#include "Util/OpenMPReplacement.h"
|
||||||
|
|
||||||
@ -39,8 +40,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include "Util/LinuxStackTrace.h"
|
#include "Util/LinuxStackTrace.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
typedef http::RequestHandler RequestHandler;
|
typedef http::RequestHandler RequestHandler;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -89,7 +88,7 @@ int main (int argc, char *argv[]) {
|
|||||||
Server * s = ServerFactory::CreateServer(serverConfig);
|
Server * s = ServerFactory::CreateServer(serverConfig);
|
||||||
RequestHandler & h = s->GetRequestHandlerPtr();
|
RequestHandler & h = s->GetRequestHandlerPtr();
|
||||||
|
|
||||||
ObjectsForQueryStruct * objects = new ObjectsForQueryStruct(serverConfig.GetParameter("hsgrData"),
|
QueryObjectsStorage * objects = new QueryObjectsStorage(serverConfig.GetParameter("hsgrData"),
|
||||||
serverConfig.GetParameter("ramIndex"),
|
serverConfig.GetParameter("ramIndex"),
|
||||||
serverConfig.GetParameter("fileIndex"),
|
serverConfig.GetParameter("fileIndex"),
|
||||||
serverConfig.GetParameter("nodesData"),
|
serverConfig.GetParameter("nodesData"),
|
||||||
|
Loading…
Reference in New Issue
Block a user