From 63d8abe32fa003abca8940ac85e4f9617c125a3f Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 26 Jun 2013 19:48:22 -0400 Subject: [PATCH] First implementation of moving the algorithmic core into a library --- CMakeLists.txt | 26 ++++++++++++++-------- Contractor/TemporaryStorage.cpp | 2 -- Contractor/TemporaryStorage.h | 1 + DataStructures/BinaryHeap.h | 12 +++++----- DataStructures/NodeCoords.h | 5 +++-- DataStructures/SegmentInformation.h | 5 +++-- DataStructures/StaticGraph.h | 7 +++--- DataStructures/XORFastHashStorage.h | 4 ++-- Descriptors/BaseDescriptor.h | 18 +++++++-------- Descriptors/DescriptionFactory.h | 6 ++--- Descriptors/GPXDescriptor.h | 3 ++- Descriptors/JSONDescriptor.h | 10 ++++----- RoutingAlgorithms/AlternativePathRouting.h | 7 +++--- RoutingAlgorithms/ShortestPathRouting.h | 12 +++++----- 14 files changed, 64 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de4c4f13..d24f7a894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,21 +12,27 @@ file(GLOB PrepareGlob Contractor/*.cpp) set(PrepareSources createHierarchy.cpp ${PrepareGlob}) add_executable(osrm-prepare ${PrepareSources}) -file(GLOB RoutedGlob Server/DataStructures/*.cpp Descriptors/*.cpp DataStructures/SearchEngine*.cpp) -set(RoutedSources routed.cpp ${RoutedGlob}) -add_executable(osrm-routed ${RoutedSources}) +add_executable(osrm-routed routed.cpp) set_target_properties(osrm-routed PROPERTIES COMPILE_FLAGS -DROUTED) +file(GLOB DescriptorGlob Descriptors/*.cpp) +file(GLOB LibOSRMGlob Library/*.cpp) +file(GLOB SearchEngineSource DataStructures/SearchEngine*.cpp) +file(GLOB ServerStructureGlob Server/DataStructures/*.cpp) + +set(OSRMSources ${LibOSRMGlob} ${DescriptorGlob} ${SearchEngineSource} ${ServerStructureGlob}) +add_library(OSRM SHARED ${OSRMSources}) + # Check the release mode if(NOT CMAKE_BUILD_TYPE MATCHES Debug) set(CMAKE_BUILD_TYPE Release) -endif(NOT CMAKE_BUILD_TYPE MATCHES Debug) +endif(NOT CMAKE_BUILD_TYPE MATCHES Debug) if(CMAKE_BUILD_TYPE MATCHES Debug) message(STATUS "Configuring OSRM in debug mode") -endif(CMAKE_BUILD_TYPE MATCHES Debug) +endif(CMAKE_BUILD_TYPE MATCHES Debug) if(CMAKE_BUILD_TYPE MATCHES Release) message(STATUS "Configuring OSRM in release mode") -endif(CMAKE_BUILD_TYPE MATCHES Release) +endif(CMAKE_BUILD_TYPE MATCHES Release) #Configuring compilers if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") @@ -35,7 +41,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") message(STATUS "OpenMP parallelization not available using clang++") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # using GCC - set(CMAKE_CXX_FLAGS "-Wall -fopenmp -pedantic") + set(CMAKE_CXX_FLAGS "-Wall -fopenmp -pedantic") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # using Intel C++ set(CMAKE_CXX_FLAGS "-static-intel -wd10237 -Wall -openmp -ipo") @@ -55,9 +61,11 @@ if (NOT Boost_FOUND) message(FATAL_ERROR "Fatal error: Boost (version >= 1.44.0) required.\n") endif (NOT Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) + +target_link_libraries( OSRM ${Boost_LIBRARIES}) target_link_libraries( osrm-extract ${Boost_LIBRARIES} ) target_link_libraries( osrm-prepare ${Boost_LIBRARIES} ) -target_link_libraries( osrm-routed ${Boost_LIBRARIES} ) +target_link_libraries( osrm-routed ${Boost_LIBRARIES} OSRM) find_package ( BZip2 REQUIRED ) include_directories(${BZIP_INCLUDE_DIRS}) @@ -70,7 +78,7 @@ target_link_libraries (osrm-routed ${ZLIB_LIBRARY}) find_package( Threads REQUIRED ) target_link_libraries (osrm-extract ${Threads_LIBRARY}) -find_package( Lua51 REQUIRED ) +find_package( Lua51 REQUIRED ) include_directories(${LUA_INCLUDE_DIR}) target_link_libraries( osrm-extract ${LUA_LIBRARY} ) target_link_libraries( osrm-prepare ${LUA_LIBRARY} ) diff --git a/Contractor/TemporaryStorage.cpp b/Contractor/TemporaryStorage.cpp index 7c894b05c..dbd86e3e5 100644 --- a/Contractor/TemporaryStorage.cpp +++ b/Contractor/TemporaryStorage.cpp @@ -18,8 +18,6 @@ or see http://www.gnu.org/licenses/agpl.txt. */ -#include - #include "TemporaryStorage.h" TemporaryStorage::TemporaryStorage() { diff --git a/Contractor/TemporaryStorage.h b/Contractor/TemporaryStorage.h index e1899817b..84004c71c 100644 --- a/Contractor/TemporaryStorage.h +++ b/Contractor/TemporaryStorage.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/DataStructures/BinaryHeap.h b/DataStructures/BinaryHeap.h index f8b34704f..5bbcb3b3f 100644 --- a/DataStructures/BinaryHeap.h +++ b/DataStructures/BinaryHeap.h @@ -23,13 +23,15 @@ or see http://www.gnu.org/licenses/agpl.txt. //Not compatible with non contiguous node ids -#include -#include -#include -#include -#include #include +#include + +#include +#include +#include +#include + template< typename NodeID, typename Key > class ArrayStorage { public: diff --git a/DataStructures/NodeCoords.h b/DataStructures/NodeCoords.h index 4893a9de6..80fda42b8 100644 --- a/DataStructures/NodeCoords.h +++ b/DataStructures/NodeCoords.h @@ -21,12 +21,13 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef _NODE_COORDS_H #define _NODE_COORDS_H +#include "../typedefs.h" + #include #include #include -#include -#include "../typedefs.h" +#include template struct NodeCoords { diff --git a/DataStructures/SegmentInformation.h b/DataStructures/SegmentInformation.h index cbe4b81cc..8f65eda72 100644 --- a/DataStructures/SegmentInformation.h +++ b/DataStructures/SegmentInformation.h @@ -21,9 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef SEGMENTINFORMATION_H_ #define SEGMENTINFORMATION_H_ -#include - #include "TurnInstructions.h" +#include "../typedefs.h" + +#include struct SegmentInformation { _Coordinate location; diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index eb41683a5..7504cbaa9 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -21,11 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef STATICGRAPH_H_INCLUDED #define STATICGRAPH_H_INCLUDED -#include -#include - #include "../typedefs.h" -#include "ImportEdge.h" + +#include +#include template< typename EdgeDataT> class StaticGraph { diff --git a/DataStructures/XORFastHashStorage.h b/DataStructures/XORFastHashStorage.h index 91820e118..1998f2832 100644 --- a/DataStructures/XORFastHashStorage.h +++ b/DataStructures/XORFastHashStorage.h @@ -21,12 +21,12 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef XORFASTHASHSTORAGE_H_ #define XORFASTHASHSTORAGE_H_ +#include "XORFastHash.h" + #include #include #include -#include "XORFastHash.h" - template< typename NodeID, typename Key > class XORFastHashStorage { public: diff --git a/Descriptors/BaseDescriptor.h b/Descriptors/BaseDescriptor.h index 2ead8bdae..64d776cb3 100644 --- a/Descriptors/BaseDescriptor.h +++ b/Descriptors/BaseDescriptor.h @@ -21,19 +21,19 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef BASE_DESCRIPTOR_H_ #define BASE_DESCRIPTOR_H_ -#include -#include -#include -#include -#include - -#include "../typedefs.h" #include "../DataStructures/HashTable.h" #include "../DataStructures/PhantomNodes.h" #include "../DataStructures/SearchEngine.h" -#include "../Util/StringUtil.h" - #include "../Plugins/RawRouteData.h" +#include "../Util/StringUtil.h" +#include "../typedefs.h" + +#include +#include +#include + +#include +#include struct _DescriptorConfig { _DescriptorConfig() : instructions(true), geometry(true), encodeGeometry(true), z(18) {} diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index 911aae7de..e54752d16 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -21,15 +21,15 @@ #ifndef DESCRIPTIONFACTORY_H_ #define DESCRIPTIONFACTORY_H_ -#include - -#include "../typedefs.h" #include "../Algorithms/DouglasPeucker.h" #include "../Algorithms/PolylineCompressor.h" #include "../DataStructures/Coordinate.h" #include "../DataStructures/SearchEngine.h" #include "../DataStructures/SegmentInformation.h" #include "../DataStructures/TurnInstructions.h" +#include "../typedefs.h" + +#include /* This class is fed with all way segments in consecutive order * and produces the description plus the encoded polyline */ diff --git a/Descriptors/GPXDescriptor.h b/Descriptors/GPXDescriptor.h index 1d3389ade..f4a8190c5 100644 --- a/Descriptors/GPXDescriptor.h +++ b/Descriptors/GPXDescriptor.h @@ -21,9 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef GPX_DESCRIPTOR_H_ #define GPX_DESCRIPTOR_H_ -#include #include "BaseDescriptor.h" +#include + class GPXDescriptor : public BaseDescriptor{ private: _DescriptorConfig config; diff --git a/Descriptors/JSONDescriptor.h b/Descriptors/JSONDescriptor.h index 1db2c688f..7ef4c8dfd 100644 --- a/Descriptors/JSONDescriptor.h +++ b/Descriptors/JSONDescriptor.h @@ -21,11 +21,6 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef JSON_DESCRIPTOR_H_ #define JSON_DESCRIPTOR_H_ -#include - -#include -#include - #include "BaseDescriptor.h" #include "DescriptionFactory.h" #include "../Algorithms/ObjectToBase64.h" @@ -34,6 +29,11 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Util/Azimuth.h" #include "../Util/StringUtil.h" +#include +#include + +#include + class JSONDescriptor : public BaseDescriptor{ private: _DescriptorConfig config; diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index 4cd256b98..8c3e53ef3 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -21,11 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef ALTERNATIVEROUTES_H_ #define ALTERNATIVEROUTES_H_ -#include -#include -#include - #include "BasicRoutingInterface.h" +#include +#include +#include const double VIAPATH_ALPHA = 0.15; const double VIAPATH_EPSILON = 0.10; //alternative at most 15% longer diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index 472e7ddbe..dc69ed31f 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -73,23 +73,23 @@ public: //insert new starting nodes into forward heap, adjusted by previous distances. if(searchFrom1stStartNode) { forward_heap1.Insert(phantomNodePair.startPhantom.edgeBasedNode, -phantomNodePair.startPhantom.weight1, phantomNodePair.startPhantom.edgeBasedNode); - INFO("fw1: " << phantomNodePair.startPhantom.edgeBasedNode << "´, w: " << -phantomNodePair.startPhantom.weight1); + // INFO("fw1: " << phantomNodePair.startPhantom.edgeBasedNode << "´, w: " << -phantomNodePair.startPhantom.weight1); forward_heap2.Insert(phantomNodePair.startPhantom.edgeBasedNode, -phantomNodePair.startPhantom.weight1, phantomNodePair.startPhantom.edgeBasedNode); - INFO("fw2: " << phantomNodePair.startPhantom.edgeBasedNode << "´, w: " << -phantomNodePair.startPhantom.weight1); + // INFO("fw2: " << phantomNodePair.startPhantom.edgeBasedNode << "´, w: " << -phantomNodePair.startPhantom.weight1); } if(phantomNodePair.startPhantom.isBidirected() && searchFrom2ndStartNode) { forward_heap1.Insert(phantomNodePair.startPhantom.edgeBasedNode+1, -phantomNodePair.startPhantom.weight2, phantomNodePair.startPhantom.edgeBasedNode+1); - INFO("fw1: " << phantomNodePair.startPhantom.edgeBasedNode+1 << "´, w: " << -phantomNodePair.startPhantom.weight2); + // INFO("fw1: " << phantomNodePair.startPhantom.edgeBasedNode+1 << "´, w: " << -phantomNodePair.startPhantom.weight2); forward_heap2.Insert(phantomNodePair.startPhantom.edgeBasedNode+1, -phantomNodePair.startPhantom.weight2, phantomNodePair.startPhantom.edgeBasedNode+1); - INFO("fw2: " << phantomNodePair.startPhantom.edgeBasedNode+1 << "´, w: " << -phantomNodePair.startPhantom.weight2); + // INFO("fw2: " << phantomNodePair.startPhantom.edgeBasedNode+1 << "´, w: " << -phantomNodePair.startPhantom.weight2); } //insert new backward nodes into backward heap, unadjusted. reverse_heap1.Insert(phantomNodePair.targetPhantom.edgeBasedNode, phantomNodePair.targetPhantom.weight1, phantomNodePair.targetPhantom.edgeBasedNode); - INFO("rv1: " << phantomNodePair.targetPhantom.edgeBasedNode << ", w;" << phantomNodePair.targetPhantom.weight1 ); + // INFO("rv1: " << phantomNodePair.targetPhantom.edgeBasedNode << ", w;" << phantomNodePair.targetPhantom.weight1 ); if(phantomNodePair.targetPhantom.isBidirected() ) { reverse_heap2.Insert(phantomNodePair.targetPhantom.edgeBasedNode+1, phantomNodePair.targetPhantom.weight2, phantomNodePair.targetPhantom.edgeBasedNode+1); - INFO("rv2: " << phantomNodePair.targetPhantom.edgeBasedNode+1 << ", w;" << phantomNodePair.targetPhantom.weight2 ); + // INFO("rv2: " << phantomNodePair.targetPhantom.edgeBasedNode+1 << ", w;" << phantomNodePair.targetPhantom.weight2 ); } const int forward_offset = phantomNodePair.startPhantom.weight1 + (phantomNodePair.startPhantom.isBidirected() ? phantomNodePair.startPhantom.weight2 : 0); const int reverse_offset = phantomNodePair.targetPhantom.weight1 + (phantomNodePair.targetPhantom.isBidirected() ? phantomNodePair.targetPhantom.weight2 : 0);