Merge branch 'master' of
https://DennisOSRM@github.com/DennisOSRM/Project-OSRM.git
This commit is contained in:
commit
a88ad71be6
@ -39,7 +39,7 @@ class DouglasPeucker {
|
||||
private:
|
||||
typedef std::pair<std::size_t, std::size_t> PairOfPoints;
|
||||
//Stack to simulate the recursion
|
||||
SimpleStack<PairOfPoints > recursionStack;
|
||||
std::stack<PairOfPoints > recursionStack;
|
||||
|
||||
double ComputeDistanceOfPointToLine(const _Coordinate& inputPoint, const _Coordinate& source, const _Coordinate& target) {
|
||||
double r;
|
||||
@ -81,7 +81,7 @@ public:
|
||||
std::size_t leftBorderOfRange = 0;
|
||||
std::size_t rightBorderOfRange = 1;
|
||||
//Sweep linerarily over array and identify those ranges that need to be checked
|
||||
recursionStack.hint(inputVector.size());
|
||||
// recursionStack.hint(inputVector.size());
|
||||
do {
|
||||
assert(inputVector[leftBorderOfRange].necessary);
|
||||
assert(inputVector[inputVector.size()-1].necessary);
|
||||
|
@ -98,7 +98,7 @@ private:
|
||||
public:
|
||||
|
||||
template< class InputEdge >
|
||||
Contractor( int nodes, std::vector< InputEdge >& inputEdges, const double eqf = 8.4, const double oqf = 4.1, const double df = 3.)
|
||||
Contractor( int nodes, std::vector< InputEdge >& inputEdges, const double eqf = 2, const double oqf = 2, const double df = 1)
|
||||
: edgeQuotionFactor(eqf), originalQuotientFactor(oqf), depthFactor(df) {
|
||||
std::vector< _ImportEdge > edges;
|
||||
edges.reserve( 2 * inputEdges.size() );
|
||||
@ -213,12 +213,13 @@ public:
|
||||
_ThreadData* data = threadData[omp_get_thread_num()];
|
||||
#pragma omp parallel for schedule ( guided )
|
||||
for ( int x = 0; x < ( int ) numberOfNodes; ++x ) {
|
||||
nodePriority[x] = _Evaluate( data, &nodeData[x], x );
|
||||
nodePriority[x] = _Evaluate( data, &nodeData[x], x, false );
|
||||
}
|
||||
}
|
||||
std::cout << "ok" << std::endl << "preprocessing ..." << std::flush;
|
||||
|
||||
while ( numberOfContractedNodes < numberOfNodes ) {
|
||||
bool topOnePercent = (numberOfNodes - numberOfContractedNodes) > 0.01*numberOfNodes;
|
||||
const int last = ( int ) remainingNodes.size();
|
||||
#pragma omp parallel
|
||||
{
|
||||
@ -240,7 +241,10 @@ public:
|
||||
#pragma omp for schedule ( guided ) nowait
|
||||
for ( int position = firstIndependent ; position < last; ++position ) {
|
||||
NodeID x = remainingNodes[position].first;
|
||||
_Contract< false > ( data, x );
|
||||
if(topOnePercent)
|
||||
_Contract< false, true > ( data, x );
|
||||
else
|
||||
_Contract< false, false > ( data, x );
|
||||
nodePriority[x] = -1;
|
||||
}
|
||||
std::sort( data->insertedEdges.begin(), data->insertedEdges.end() );
|
||||
@ -259,6 +263,19 @@ public:
|
||||
_ThreadData& data = *threadData[threadNum];
|
||||
for ( int i = 0; i < ( int ) data.insertedEdges.size(); ++i ) {
|
||||
const _ImportEdge& edge = data.insertedEdges[i];
|
||||
_DynamicGraph::EdgeIterator currentEdgeID = _graph->FindEdge(edge.source, edge.target);
|
||||
if(currentEdgeID != _graph->EndEdges(edge.source)) {
|
||||
_DynamicGraph::EdgeData & currentEdgeData = _graph->GetEdgeData(currentEdgeID);
|
||||
if(edge.data.forward == currentEdgeData.forward && edge.data.backward == currentEdgeData.backward ) {
|
||||
if(_graph->GetEdgeData(_graph->FindEdge(edge.source, edge.target)).distance <= edge.data.distance) {
|
||||
continue;
|
||||
}
|
||||
if(currentEdgeData.distance > edge.data.distance) {
|
||||
currentEdgeData.distance = edge.data.distance;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
_graph->InsertEdge( edge.source, edge.target, edge.data );
|
||||
}
|
||||
data.insertedEdges.clear();
|
||||
@ -270,7 +287,7 @@ public:
|
||||
#pragma omp for schedule ( guided ) nowait
|
||||
for ( int position = firstIndependent ; position < last; ++position ) {
|
||||
NodeID x = remainingNodes[position].first;
|
||||
_UpdateNeighbours( nodePriority, nodeData, data, x );
|
||||
_UpdateNeighbours( nodePriority, nodeData, data, x, topOnePercent );
|
||||
}
|
||||
}
|
||||
//remove contracted nodes from the pool
|
||||
@ -308,7 +325,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
inline void _Dijkstra( const int maxDistance, const unsigned numTargets, const int maxNodes, const short hopLimit, _ThreadData* const data ){
|
||||
inline void _Dijkstra( const int maxDistance, const unsigned numTargets, const int maxNodes, const int hopLimit, _ThreadData* const data ){
|
||||
|
||||
_Heap& heap = data->heap;
|
||||
|
||||
@ -355,11 +372,14 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
double _Evaluate( _ThreadData* const data, _PriorityData* const nodeData, NodeID node ){
|
||||
double _Evaluate( _ThreadData* const data, _PriorityData* const nodeData, NodeID node, bool topOnePercent ){
|
||||
_ContractionInformation stats;
|
||||
|
||||
//perform simulated contraction
|
||||
_Contract< true > ( data, node, &stats );
|
||||
if(topOnePercent)
|
||||
_Contract< true, true > ( data, node, &stats );
|
||||
else
|
||||
_Contract< true, false > ( data, node, &stats );
|
||||
|
||||
// Result will contain the priority
|
||||
if ( stats.edgesDeleted == 0 || stats.originalEdgesDeleted == 0 )
|
||||
@ -367,7 +387,7 @@ private:
|
||||
return edgeQuotionFactor * ((( double ) stats.edgesAdded ) / stats.edgesDeleted ) + originalQuotientFactor * ((( double ) stats.originalEdgesAdded ) / stats.originalEdgesDeleted ) + depthFactor * nodeData->depth;
|
||||
}
|
||||
|
||||
template< bool Simulate >
|
||||
template< bool Simulate, bool topOnePercent >
|
||||
bool _Contract( _ThreadData* data, NodeID node, _ContractionInformation* stats = NULL ) {
|
||||
_Heap& heap = data->heap;
|
||||
int insertedEdgesSize = data->insertedEdges.size();
|
||||
@ -407,9 +427,9 @@ private:
|
||||
}
|
||||
|
||||
if( Simulate )
|
||||
_Dijkstra( maxDistance, numTargets, 1000, 5, data );
|
||||
_Dijkstra( maxDistance, numTargets, 1000, (true ? INT_MAX : 5), data );
|
||||
else
|
||||
_Dijkstra( maxDistance, numTargets, 2000, 7, data );
|
||||
_Dijkstra( maxDistance, numTargets, 2000, (true ? INT_MAX : 7), data );
|
||||
|
||||
for ( _DynamicGraph::EdgeIterator outEdge = _graph->BeginEdges( node ), endOutEdges = _graph->EndEdges( node ); outEdge != endOutEdges; ++outEdge ) {
|
||||
const _EdgeBasedContractorEdgeData& outData = _graph->GetEdgeData( outEdge );
|
||||
@ -482,7 +502,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
bool _UpdateNeighbours( std::vector< double > & priorities, std::vector< _PriorityData > & nodeData, _ThreadData* const data, NodeID node ) {
|
||||
bool _UpdateNeighbours( std::vector< double > & priorities, std::vector< _PriorityData > & nodeData, _ThreadData* const data, NodeID node, bool topOnePercent ) {
|
||||
std::vector< NodeID >& neighbours = data->neighbours;
|
||||
neighbours.clear();
|
||||
|
||||
@ -501,7 +521,7 @@ private:
|
||||
int neighbourSize = ( int ) neighbours.size();
|
||||
for ( int i = 0, e = neighbourSize; i < e; ++i ) {
|
||||
const NodeID u = neighbours[i];
|
||||
priorities[u] = _Evaluate( data, &( nodeData )[u], u );
|
||||
priorities[u] = _Evaluate( data, &( nodeData )[u], u, topOnePercent );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -312,7 +312,7 @@ short EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const N
|
||||
//If street names stay the same and if we are certain that it is not a roundabout, we skip it.
|
||||
if( (data1.nameID == data2.nameID) && (0 != data1.nameID))
|
||||
return TurnInstructions.NoTurn;
|
||||
if( (data1.nameID == data2.nameID) && (0 == data1.nameID) && (_nodeBasedGraph->GetOutDegree(v) == 1) )
|
||||
if( (data1.nameID == data2.nameID) && (0 == data1.nameID) && (_nodeBasedGraph->GetOutDegree(v) <= 2) )
|
||||
return TurnInstructions.NoTurn;
|
||||
|
||||
double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
|
||||
|
@ -151,19 +151,19 @@ public:
|
||||
//run two-Target Dijkstra routing step.
|
||||
while(_forwardHeap->Size() + _backwardHeap->Size() > 0){
|
||||
if(_forwardHeap->Size() > 0){
|
||||
_RoutingStep(_forwardHeap, _backwardHeap, true, &middle1, &_localUpperbound1, 2*offset);
|
||||
_RoutingStep<true>(_forwardHeap, _backwardHeap, &middle1, &_localUpperbound1, 2*offset);
|
||||
}
|
||||
if(_backwardHeap->Size() > 0){
|
||||
_RoutingStep(_backwardHeap, _forwardHeap, false, &middle1, &_localUpperbound1, 2*offset);
|
||||
_RoutingStep<false>(_backwardHeap, _forwardHeap, &middle1, &_localUpperbound1, 2*offset);
|
||||
}
|
||||
}
|
||||
if(_backwardHeap2->Size() > 0) {
|
||||
while(_forwardHeap2->Size() + _backwardHeap2->Size() > 0){
|
||||
if(_forwardHeap2->Size() > 0){
|
||||
_RoutingStep(_forwardHeap2, _backwardHeap2, true, &middle2, &_localUpperbound2, 2*offset);
|
||||
_RoutingStep<true>(_forwardHeap2, _backwardHeap2, &middle2, &_localUpperbound2, 2*offset);
|
||||
}
|
||||
if(_backwardHeap2->Size() > 0){
|
||||
_RoutingStep(_backwardHeap2, _forwardHeap2, false, &middle2, &_localUpperbound2, 2*offset);
|
||||
_RoutingStep<false>(_backwardHeap2, _forwardHeap2, &middle2, &_localUpperbound2, 2*offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -324,16 +324,14 @@ public:
|
||||
}
|
||||
int offset = (phantomNodes.startPhantom.isBidirected() ? std::max(phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.weight2) : phantomNodes.startPhantom.weight1) ;
|
||||
offset += (phantomNodes.targetPhantom.isBidirected() ? std::max(phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.weight2) : phantomNodes.targetPhantom.weight1) ;
|
||||
|
||||
while(_forwardHeap->Size() + _backwardHeap->Size() > 0){
|
||||
if(_forwardHeap->Size() > 0){
|
||||
_RoutingStep(_forwardHeap, _backwardHeap, true, &middle, &_upperbound, 2*offset);
|
||||
_RoutingStep<true>(_forwardHeap, _backwardHeap, &middle, &_upperbound, 2*offset);
|
||||
}
|
||||
if(_backwardHeap->Size() > 0){
|
||||
_RoutingStep(_backwardHeap, _forwardHeap, false, &middle, &_upperbound, 2*offset);
|
||||
_RoutingStep<false>(_backwardHeap, _forwardHeap, &middle, &_upperbound, 2*offset);
|
||||
}
|
||||
}
|
||||
|
||||
// INFO("dist: " << _upperbound);
|
||||
if ( _upperbound == INT_MAX ) {
|
||||
return _upperbound;
|
||||
@ -341,7 +339,6 @@ public:
|
||||
std::deque<NodeID> packedPath;
|
||||
_RetrievePackedPathFromHeap(_forwardHeap, _backwardHeap, middle, packedPath);
|
||||
|
||||
|
||||
//Setting weights to correspond with that of the actual chosen path
|
||||
if(packedPath[0] == phantomNodes.startPhantom.edgeBasedNode && phantomNodes.startPhantom.isBidirected()) {
|
||||
// INFO("Setting weight1=" << phantomNodes.startPhantom.weight1 << " to that of weight2=" << phantomNodes.startPhantom.weight2);
|
||||
@ -414,8 +411,8 @@ private:
|
||||
// std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
inline void _RoutingStep(HeapPtr & _forwardHeap, HeapPtr & _backwardHeap, const bool & forwardDirection, NodeID *middle, int *_upperbound, const int edgeBasedOffset) const {
|
||||
template<bool forwardDirection>
|
||||
inline void _RoutingStep(HeapPtr & _forwardHeap, HeapPtr & _backwardHeap, NodeID *middle, int *_upperbound, const int edgeBasedOffset) const {
|
||||
const NodeID node = _forwardHeap->DeleteMin();
|
||||
const int distance = _forwardHeap->GetKey(node);
|
||||
// INFO((forwardDirection ? "[forw]" : "[back]") << " settled node " << node << " at distance " << distance);
|
||||
@ -485,7 +482,7 @@ private:
|
||||
|
||||
inline void _UnpackPath(std::deque<NodeID> & packedPath, std::vector<_PathData> & unpackedPath) const {
|
||||
const unsigned sizeOfPackedPath = packedPath.size();
|
||||
SimpleStack<std::pair<NodeID, NodeID> > recursionStack(sizeOfPackedPath);
|
||||
std::stack<std::pair<NodeID, NodeID> > recursionStack;
|
||||
|
||||
//We have to push the path in reverse order onto the stack because it's LIFO.
|
||||
for(unsigned i = sizeOfPackedPath-1; i > 0; --i){
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
}
|
||||
|
||||
descriptionFactory.Run(config.z, durationOfTrip);
|
||||
|
||||
reply.content += "\"route_summary\": {"
|
||||
"\"total_distance\":";
|
||||
reply.content += descriptionFactory.summary.lengthString;
|
||||
@ -107,9 +106,9 @@ public:
|
||||
roundAbout.nameID = segment.nameID;
|
||||
roundAbout.startIndex = prefixSumOfNecessarySegments;
|
||||
} else {
|
||||
if(0 != prefixSumOfNecessarySegments)
|
||||
if(0 != prefixSumOfNecessarySegments){
|
||||
reply.content += ",";
|
||||
|
||||
}
|
||||
reply.content += "[\"";
|
||||
if(TurnInstructions.LeaveRoundAbout == segment.turnInstruction) {
|
||||
reply.content += TurnInstructions.TurnStrings[TurnInstructions.EnterRoundAbout];
|
||||
|
@ -29,7 +29,7 @@
|
||||
//======================
|
||||
// OBJECTS
|
||||
//Map
|
||||
var HOST_ROUTING_URL = 'http://141.3.24.68:5000/viaroute';
|
||||
var HOST_ROUTING_URL = 'http://141.3.24.240:5000/viaroute';
|
||||
//var HOST_ROUTING_URL = 'http://routingdemo.geofabrik.de/route-via/';
|
||||
var HOST_WEBSITE = 'http://map.project-osrm.org/';//location.host
|
||||
|
||||
|
@ -26,7 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include "ObjectForPluginStruct.h"
|
||||
#include "BasePlugin.h"
|
||||
#include "RouteParameters.h"
|
||||
|
||||
#include "../Util/StringUtil.h"
|
||||
#include "../DataStructures/NodeInformationHelpDesk.h"
|
||||
|
||||
/*
|
||||
@ -57,33 +57,47 @@ public:
|
||||
_Coordinate result;
|
||||
nodeHelpDesk->FindNearestNodeCoordForLatLon(_Coordinate(lat, lon), result);
|
||||
|
||||
std::string tmp;
|
||||
std::string JSONParameter;
|
||||
//json
|
||||
|
||||
JSONParameter = routeParameters.options.Find("jsonp");
|
||||
if("" != JSONParameter) {
|
||||
reply.content += JSONParameter;
|
||||
reply.content += "(";
|
||||
}
|
||||
|
||||
//Write to stream
|
||||
reply.status = http::Reply::ok;
|
||||
reply.content.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
reply.content.append("<kml xmlns=\"http://www.opengis.net/kml/2.2\">");
|
||||
reply.content.append("<Placemark>");
|
||||
|
||||
std::stringstream out1;
|
||||
out1 << setprecision(10);
|
||||
out1 << "<name>Nearest Place in map to " << lat/100000. << "," << lon/100000. << "</name>";
|
||||
reply.content.append(out1.str());
|
||||
reply.content.append("<Point>");
|
||||
|
||||
std::stringstream out2;
|
||||
out2 << setprecision(10);
|
||||
out2 << "<coordinates>" << result.lon / 100000. << "," << result.lat / 100000. << "</coordinates>";
|
||||
reply.content.append(out2.str());
|
||||
reply.content.append("</Point>");
|
||||
reply.content.append("</Placemark>");
|
||||
reply.content.append("</kml>");
|
||||
|
||||
reply.content += ("{");
|
||||
reply.content += ("\"version\":0.3,");
|
||||
reply.content += ("\"status\":0,");
|
||||
reply.content += ("\"result\":");
|
||||
convertInternalLatLonToString(result.lat, tmp);
|
||||
reply.content += "[";
|
||||
reply.content += tmp;
|
||||
convertInternalLatLonToString(result.lon, tmp);
|
||||
reply.content += ", ";
|
||||
reply.content += tmp;
|
||||
reply.content += "]";
|
||||
reply.content += ",\"transactionId\": \"OSRM Routing Engine JSON Locate (v0.3)\"";
|
||||
reply.content += ("}");
|
||||
reply.headers.resize(3);
|
||||
reply.headers[0].name = "Content-Length";
|
||||
reply.headers[0].value = boost::lexical_cast<std::string>(reply.content.size());
|
||||
if("" != JSONParameter) {
|
||||
reply.content += ")";
|
||||
reply.headers[1].name = "Content-Type";
|
||||
reply.headers[1].value = "application/vnd.google-earth.kml+xml";
|
||||
reply.headers[1].value = "text/javascript";
|
||||
reply.headers[2].name = "Content-Disposition";
|
||||
reply.headers[2].value = "attachment; filename=\"placemark.kml\"";
|
||||
reply.headers[2].value = "attachment; filename=\"location.js\"";
|
||||
} else {
|
||||
reply.headers[1].name = "Content-Type";
|
||||
reply.headers[1].value = "application/x-javascript";
|
||||
reply.headers[2].name = "Content-Disposition";
|
||||
reply.headers[2].value = "attachment; filename=\"location.json\"";
|
||||
}
|
||||
reply.headers[0].name = "Content-Length";
|
||||
intToString(reply.content.size(), tmp);
|
||||
reply.headers[0].value = tmp;
|
||||
return;
|
||||
}
|
||||
private:
|
||||
|
@ -62,40 +62,34 @@ public:
|
||||
//query to helpdesk
|
||||
_Coordinate result;
|
||||
nodeHelpDesk->FindNearestPointOnEdge(_Coordinate(lat, lon), result);
|
||||
unsigned descriptorType = descriptorTable[routeParameters.options.Find("output")];
|
||||
std::stringstream out1;
|
||||
std::stringstream out2;
|
||||
|
||||
std::string tmp;
|
||||
std::string JSONParameter;
|
||||
switch(descriptorType){
|
||||
case 1:
|
||||
//json
|
||||
|
||||
JSONParameter = routeParameters.options.Find("jsonp");
|
||||
if("" != JSONParameter) {
|
||||
reply.content += JSONParameter;
|
||||
reply.content += "(\n";
|
||||
reply.content += "(";
|
||||
}
|
||||
|
||||
reply.status = http::Reply::ok;
|
||||
reply.content += ("{");
|
||||
reply.content += ("\"version\":0.3,");
|
||||
reply.content += ("\"status\":0,");
|
||||
reply.content += ("\"status_message\":");
|
||||
out1 << setprecision(10);
|
||||
out1 << "\"Nearest Place in map to " << lat/100000. << "," << lon/100000. << "\",";
|
||||
reply.content.append(out1.str());
|
||||
reply.content += ("\"coordinate\": ");
|
||||
out2 << setprecision(10);
|
||||
out2 << "[" << result.lat / 100000. << "," << result.lon / 100000. << "]";
|
||||
reply.content.append(out2.str());
|
||||
|
||||
reply.content += ("\"result\":");
|
||||
convertInternalLatLonToString(result.lat, tmp);
|
||||
reply.content += "[";
|
||||
reply.content += tmp;
|
||||
convertInternalLatLonToString(result.lon, tmp);
|
||||
reply.content += ", ";
|
||||
reply.content += tmp;
|
||||
reply.content += "]";
|
||||
reply.content += ",\"transactionId\": \"OSRM Routing Engine JSON Nearest (v0.3)\"";
|
||||
reply.content += ("}");
|
||||
reply.headers.resize(3);
|
||||
reply.headers[0].name = "Content-Length";
|
||||
intToString(reply.content.size(), tmp);
|
||||
reply.headers[0].value = tmp;if("" != JSONParameter) {
|
||||
reply.content += ")\n";
|
||||
if("" != JSONParameter) {
|
||||
reply.content += ")";
|
||||
reply.headers[1].name = "Content-Type";
|
||||
reply.headers[1].value = "text/javascript";
|
||||
reply.headers[2].name = "Content-Disposition";
|
||||
@ -106,38 +100,9 @@ public:
|
||||
reply.headers[2].name = "Content-Disposition";
|
||||
reply.headers[2].value = "attachment; filename=\"location.json\"";
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
reply.status = http::Reply::ok;
|
||||
|
||||
//Write to stream
|
||||
reply.content.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
reply.content.append("<kml xmlns=\"http://www.opengis.net/kml/2.2\">");
|
||||
reply.content.append("<Placemark>");
|
||||
|
||||
|
||||
out1 << setprecision(10);
|
||||
out1 << "<name>Nearest Place in map to " << lat/100000. << "," << lon/100000. << "</name>";
|
||||
reply.content.append(out1.str());
|
||||
reply.content.append("<Point>");
|
||||
|
||||
out2 << setprecision(10);
|
||||
out2 << "<coordinates>" << result.lon / 100000. << "," << result.lat / 100000. << "</coordinates>";
|
||||
reply.content.append(out2.str());
|
||||
reply.content.append("</Point>");
|
||||
reply.content.append("</Placemark>");
|
||||
reply.content.append("</kml>");
|
||||
|
||||
reply.headers.resize(3);
|
||||
reply.headers[0].name = "Content-Length";
|
||||
reply.headers[0].value = boost::lexical_cast<std::string>(reply.content.size());
|
||||
reply.headers[1].name = "Content-Type";
|
||||
reply.headers[1].value = "application/vnd.google-earth.kml+xml";
|
||||
reply.headers[2].name = "Content-Disposition";
|
||||
reply.headers[2].value = "attachment; filename=\"placemark.kml\"";
|
||||
break;
|
||||
}
|
||||
intToString(reply.content.size(), tmp);
|
||||
reply.headers[0].value = tmp;
|
||||
}
|
||||
private:
|
||||
NodeInformationHelpDesk * nodeHelpDesk;
|
||||
|
@ -119,14 +119,12 @@ public:
|
||||
}
|
||||
rawRoute.rawViaNodeCoordinates.push_back(targetCoord);
|
||||
vector<PhantomNode> phantomNodeVector(rawRoute.rawViaNodeCoordinates.size());
|
||||
|
||||
for(unsigned i = 0; i < rawRoute.rawViaNodeCoordinates.size(); ++i) {
|
||||
searchEngine->FindPhantomNodeForCoordinate( rawRoute.rawViaNodeCoordinates[i], phantomNodeVector[i]);
|
||||
}
|
||||
|
||||
unsigned distance = 0;
|
||||
//single route or via point routing
|
||||
if(0 == routeParameters.viaPoints.size()) {
|
||||
if(2 == rawRoute.rawViaNodeCoordinates.size()) {
|
||||
PhantomNodes segmentPhantomNodes;
|
||||
segmentPhantomNodes.startPhantom = phantomNodeVector[0];
|
||||
segmentPhantomNodes.targetPhantom = phantomNodeVector[1];
|
||||
@ -145,7 +143,6 @@ public:
|
||||
if(INT_MAX == distance ) {
|
||||
DEBUG( "Error occurred, single path not found" );
|
||||
}
|
||||
|
||||
reply.status = http::Reply::ok;
|
||||
|
||||
BaseDescriptor<SearchEngine<EdgeData, StaticGraph<EdgeData> > > * desc;
|
||||
@ -197,7 +194,6 @@ public:
|
||||
desc->SetConfig(descriptorConfig);
|
||||
|
||||
desc->Run(reply, rawRoute, phantomNodes, *searchEngine, distance);
|
||||
|
||||
if("" != JSONParameter) {
|
||||
reply.content += ")\n";
|
||||
}
|
||||
|
@ -201,6 +201,6 @@ env.Program(target = 'osrm-extract', source = ["extractor.cpp", Glob('DataStruct
|
||||
env.Program(target = 'osrm-prepare', source = ["createHierarchy.cpp", 'Contractor/EdgeBasedGraphFactory.cpp', Glob('Util/SRTMLookup/*.cpp'), Glob('Algorithms/*.cpp')])
|
||||
env.Append(CCFLAGS = ['-lboost_regex', '-lboost_iostreams', '-lbz2', '-lz', '-lprotobuf'])
|
||||
env.Append(LINKFLAGS = ['-lboost_system'])
|
||||
env.Program(target = 'osrm-routed', source = ["routed.cpp", 'Descriptors/DescriptionFactory.cpp', Glob('ThirdParty/*.cc')], CCFLAGS = ['-DROUTED'])
|
||||
env.Program(target = 'osrm-routed', source = ["routed.cpp", 'Descriptors/DescriptionFactory.cpp', Glob('ThirdParty/*.cc')], CCFLAGS = env['CCFLAGS'] + ['-DROUTED'])
|
||||
env = conf.Finish()
|
||||
|
||||
|
@ -52,10 +52,11 @@ enum CompressionType {
|
||||
|
||||
struct Request {
|
||||
std::string uri;
|
||||
boost::asio::ip::address endpoint;
|
||||
};
|
||||
|
||||
struct Reply {
|
||||
Reply() : status(ok) { content.reserve(1000000); }
|
||||
Reply() : status(ok) { content.reserve(2 << 20); }
|
||||
enum status_type {
|
||||
ok = 200,
|
||||
badRequest = 400,
|
||||
@ -63,9 +64,9 @@ struct Reply {
|
||||
} status;
|
||||
|
||||
std::vector<Header> headers;
|
||||
std::string content;
|
||||
std::vector<boost::asio::const_buffer> toBuffers();
|
||||
std::vector<boost::asio::const_buffer> HeaderstoBuffers();
|
||||
std::string content;
|
||||
static Reply stockReply(status_type status);
|
||||
void setSize(unsigned size) {
|
||||
for (std::size_t i = 0; i < headers.size(); ++i) {
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
// std::cout << "[debug] using deflate" << std::endl;
|
||||
// if(compressionType == noCompression)
|
||||
// std::cout << "[debug] no compression" << std::endl;
|
||||
|
||||
request.endpoint = TCPsocket.remote_endpoint().address();
|
||||
requestHandler.handle_request(request, reply);
|
||||
|
||||
Header compressionHeader;
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void handle_request(const Request& req, Reply& rep){
|
||||
//parse command
|
||||
std::string request(req.uri);
|
||||
// INFO( "[r] " << request );
|
||||
INFO( req.endpoint.to_string() << " " << request );
|
||||
std::string command;
|
||||
std::size_t firstAmpPosition = request.find_first_of("?");
|
||||
command = request.substr(1,firstAmpPosition-1);
|
||||
|
10
server.ini
10
server.ini
@ -2,8 +2,8 @@ Threads = 8
|
||||
IP = 0.0.0.0
|
||||
Port = 5000
|
||||
|
||||
hsgrData=/opt/osm/germany.osrm.hsgr
|
||||
nodesData=/opt/osm/germany.osrm.nodes
|
||||
ramIndex=/opt/osm/germany.osrm.ramIndex
|
||||
fileIndex=/opt/osm/germany.osrm.fileIndex
|
||||
namesData=/opt/osm/germany.osrm.names
|
||||
hsgrData=/opt/osm/berlin.osrm.hsgr
|
||||
nodesData=/opt/osm/berlin.osrm.nodes
|
||||
ramIndex=/opt/osm/berlin.osrm.ramIndex
|
||||
fileIndex=/opt/osm/berlin.osrm.fileIndex
|
||||
namesData=/opt/osm/berlin.osrm.names
|
||||
|
Loading…
Reference in New Issue
Block a user