performance fixes
This commit is contained in:
parent
a5c94c4630
commit
bcb39b9e69
@ -32,7 +32,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include <google/sparse_hash_map>
|
||||
#include <google/sparsetable>
|
||||
|
||||
template< typename NodeID, typename Key, bool initialize = true >
|
||||
template< typename NodeID, typename Key, bool initialize = false >
|
||||
class ArrayStorage {
|
||||
public:
|
||||
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
}
|
||||
|
||||
unsigned int ComputeRoute(PhantomNodes &phantomNodes, vector<_PathData > & path) {
|
||||
|
||||
bool startEdgeIsReversedInGraph = false;
|
||||
bool targetEdgeIsReversed = false;
|
||||
|
||||
@ -127,10 +128,11 @@ public:
|
||||
}
|
||||
|
||||
_InsertedNodes _insertedNodes;
|
||||
|
||||
_Heap _forwardHeap(nodeHelpDesk->getNumberOfNodes());
|
||||
_Heap _backwardHeap(nodeHelpDesk->getNumberOfNodes());
|
||||
|
||||
NodeID middle = ( NodeID ) 0;
|
||||
NodeID middle = ( NodeID ) UINT_MAX;
|
||||
|
||||
if( phantomNodes.PhantomsAreOnSameEdge() ) {
|
||||
const EdgeData& currentEdgeData = _graph->GetEdgeData(sourceEdgeID);
|
||||
@ -179,7 +181,6 @@ public:
|
||||
_insertedNodes.BackInsert(phantomNodes.targetPhantom.startNode);
|
||||
}
|
||||
|
||||
|
||||
while(_forwardHeap.Size() + _backwardHeap.Size() > 0) {
|
||||
if ( _forwardHeap.Size() > 0 ) {
|
||||
_RoutingStep( _forwardHeap, _backwardHeap, true, &middle, &_upperbound );
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
|
||||
double area = fabs(0.5*( descriptorState.startOfSegmentCoordinate.lon*(descriptorState.nextCoordinate.lat - descriptorState.currentCoordinate.lat) + descriptorState.nextCoordinate.lon*(descriptorState.currentCoordinate.lat - descriptorState.startOfSegmentCoordinate.lat) + descriptorState.currentCoordinate.lon*(descriptorState.startOfSegmentCoordinate.lat - descriptorState.nextCoordinate.lat) ) );
|
||||
//if route is generalization does not skip this point, add it to description
|
||||
if( it==path.end()-1 || config.z == 19 || area >= areaThresholds[config.z] || (false == descriptorState.CurrentAndPreviousNameIDsEqual()) ) {
|
||||
if( config.z == 19 || area >= areaThresholds[config.z] || (false == descriptorState.CurrentAndPreviousNameIDsEqual()) ) {
|
||||
//mark the beginning of the segment thats announced
|
||||
// appendCoordinateToString(descriptorState.currentCoordinate, descriptorState.routeGeometryString);
|
||||
polyline.push_back(descriptorState.currentCoordinate);
|
||||
|
@ -50,22 +50,7 @@ private:
|
||||
HashTable<std::string, unsigned> descriptorTable;
|
||||
std::string pluginDescriptorString;
|
||||
|
||||
struct _ThreadData {
|
||||
SearchEngine<EdgeData, StaticGraph<EdgeData> > * sEngine;
|
||||
std::vector< _PathData > * path;
|
||||
unsigned distanceOfSegment;
|
||||
PhantomNodes phantomNodesOfSegment;
|
||||
_ThreadData(SearchEngine<EdgeData, StaticGraph<EdgeData> > * s) : sEngine(s), distanceOfSegment(0) {
|
||||
path = new std::vector< _PathData >();
|
||||
}
|
||||
~_ThreadData() {
|
||||
DELETE( path );
|
||||
DELETE( sEngine );
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<_ThreadData *> threadData;
|
||||
|
||||
SearchEngine<EdgeData, StaticGraph<EdgeData> > * searchEngine;
|
||||
public:
|
||||
|
||||
ViaRoutePlugin(ObjectsForQueryStruct * objects, std::string psd = "viaroute") : pluginDescriptorString(psd) {
|
||||
@ -73,10 +58,7 @@ public:
|
||||
graph = objects->graph;
|
||||
names = objects->names;
|
||||
|
||||
unsigned maxThreads = omp_get_max_threads();
|
||||
for ( unsigned threadNum = 0; threadNum < maxThreads; ++threadNum ) {
|
||||
threadData.push_back( new _ThreadData( new SearchEngine<EdgeData, StaticGraph<EdgeData> >(graph, nodeHelpDesk, names)) );
|
||||
}
|
||||
searchEngine = new SearchEngine<EdgeData, StaticGraph<EdgeData> >(graph, nodeHelpDesk, names);
|
||||
|
||||
descriptorTable.Set("", 0); //default descriptor
|
||||
descriptorTable.Set("kml", 0);
|
||||
@ -85,9 +67,7 @@ public:
|
||||
}
|
||||
|
||||
virtual ~ViaRoutePlugin() {
|
||||
for ( unsigned threadNum = 0; threadNum < threadData.size(); threadNum++ ) {
|
||||
DELETE( threadData[threadNum] );
|
||||
}
|
||||
DELETE( searchEngine );
|
||||
}
|
||||
|
||||
std::string GetDescriptor() { return pluginDescriptorString; }
|
||||
@ -144,25 +124,22 @@ public:
|
||||
vector<PhantomNode> phantomNodeVector(rawRoute.rawViaNodeCoordinates.size());
|
||||
bool errorOccurredFlag = false;
|
||||
|
||||
#pragma omp parallel for
|
||||
for(unsigned i = 0; i < rawRoute.rawViaNodeCoordinates.size(); i++) {
|
||||
threadData[omp_get_thread_num()]->sEngine->FindPhantomNodeForCoordinate( rawRoute.rawViaNodeCoordinates[i], phantomNodeVector[i]);
|
||||
searchEngine->FindPhantomNodeForCoordinate( rawRoute.rawViaNodeCoordinates[i], phantomNodeVector[i]);
|
||||
if(!rawRoute.rawViaNodeCoordinates[i].isSet()) {
|
||||
errorOccurredFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
rawRoute.Resize();
|
||||
|
||||
unsigned distance = 0;
|
||||
|
||||
//#pragma omp parallel for reduction(+:distance)
|
||||
for(unsigned i = 0; i < phantomNodeVector.size()-1 && !errorOccurredFlag; i++) {
|
||||
PhantomNodes & segmentPhantomNodes = threadData[omp_get_thread_num()]->phantomNodesOfSegment;
|
||||
PhantomNodes segmentPhantomNodes;
|
||||
segmentPhantomNodes.startPhantom = phantomNodeVector[i];
|
||||
segmentPhantomNodes.targetPhantom = phantomNodeVector[i+1];
|
||||
std::vector< _PathData > path;
|
||||
unsigned distanceOfSegment = threadData[omp_get_thread_num()]->sEngine->ComputeRoute(segmentPhantomNodes, path);
|
||||
unsigned distanceOfSegment = searchEngine->ComputeRoute(segmentPhantomNodes, path);
|
||||
|
||||
if(UINT_MAX == distanceOfSegment ) {
|
||||
errorOccurredFlag = true;
|
||||
@ -229,7 +206,9 @@ public:
|
||||
phantomNodes.startPhantom = rawRoute.segmentEndCoordinates[0].startPhantom;
|
||||
phantomNodes.targetPhantom = rawRoute.segmentEndCoordinates[rawRoute.segmentEndCoordinates.size()-1].targetPhantom;
|
||||
desc->SetConfig(descriptorConfig);
|
||||
desc->Run(reply, rawRoute, phantomNodes, *threadData[0]->sEngine, distance);
|
||||
|
||||
desc->Run(reply, rawRoute, phantomNodes, *searchEngine, distance);
|
||||
|
||||
if("" != JSONParameter) {
|
||||
reply.content += ")\n";
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
BasePlugin * tempPointer = _pluginVector[i];
|
||||
DELETE( tempPointer );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void handle_request(const Request& req, Reply& rep){
|
||||
|
Loading…
Reference in New Issue
Block a user