Create public facing libraries for extractor, contractor and datastore
New libraries libosrm_extract, libosrm_contract, libosrm_store
This commit is contained in:
parent
b36145e3c4
commit
439eb9da3d
12
.travis.yml
12
.travis.yml
@ -118,7 +118,7 @@ install:
|
|||||||
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
||||||
|
|
||||||
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||||
brew install cmake boost libzip libstxxl libxml2 lua51 luabind tbb GDAL
|
brew install cmake boost libzip libstxxl libxml2 lua51 luabind tbb GDAL md5sha1sum
|
||||||
fi
|
fi
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
@ -135,8 +135,18 @@ script:
|
|||||||
- make --jobs=2
|
- make --jobs=2
|
||||||
- make tests --jobs=2
|
- make tests --jobs=2
|
||||||
- make benchmarks
|
- make benchmarks
|
||||||
|
- sudo make install
|
||||||
|
- |
|
||||||
|
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||||
|
sudo ldconfig
|
||||||
|
fi
|
||||||
- ./extractor-tests
|
- ./extractor-tests
|
||||||
- ./engine-tests
|
- ./engine-tests
|
||||||
- ./util-tests
|
- ./util-tests
|
||||||
- cd ..
|
- cd ..
|
||||||
- cucumber -p verify
|
- cucumber -p verify
|
||||||
|
- make -C test/data
|
||||||
|
- mkdir example/build && cd example/build
|
||||||
|
- cmake ..
|
||||||
|
- make
|
||||||
|
- ./osrm-example ../../test/data/berlin-latest.osrm
|
||||||
|
197
CMakeLists.txt
197
CMakeLists.txt
@ -44,7 +44,7 @@ add_custom_target(FingerPrintConfigure ALL ${CMAKE_COMMAND}
|
|||||||
COMMENT "Configuring revision fingerprint"
|
COMMENT "Configuring revision fingerprint"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
add_custom_target(tests DEPENDS engine-tests extractor-tests util-tests io-tests)
|
add_custom_target(tests DEPENDS engine-tests extractor-tests util-tests)
|
||||||
add_custom_target(benchmarks DEPENDS rtree-bench)
|
add_custom_target(benchmarks DEPENDS rtree-bench)
|
||||||
|
|
||||||
set(BOOST_COMPONENTS date_time filesystem iostreams program_options regex system thread unit_test_framework)
|
set(BOOST_COMPONENTS date_time filesystem iostreams program_options regex system thread unit_test_framework)
|
||||||
@ -56,6 +56,7 @@ configure_file(
|
|||||||
file(GLOB UtilGlob src/util/*.cpp)
|
file(GLOB UtilGlob src/util/*.cpp)
|
||||||
file(GLOB ExtractorGlob src/extractor/*.cpp)
|
file(GLOB ExtractorGlob src/extractor/*.cpp)
|
||||||
file(GLOB ContractorGlob src/contractor/*.cpp)
|
file(GLOB ContractorGlob src/contractor/*.cpp)
|
||||||
|
file(GLOB StorageGlob src/storage/*.cpp)
|
||||||
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp)
|
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp)
|
||||||
file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
||||||
file(GLOB ExtractorTestsGlob unit_tests/extractor/*.cpp)
|
file(GLOB ExtractorTestsGlob unit_tests/extractor/*.cpp)
|
||||||
@ -66,30 +67,29 @@ file(GLOB IOTestsGlob unit_tests/io/*.cpp)
|
|||||||
add_library(UTIL OBJECT ${UtilGlob})
|
add_library(UTIL OBJECT ${UtilGlob})
|
||||||
add_library(EXTRACTOR OBJECT ${ExtractorGlob})
|
add_library(EXTRACTOR OBJECT ${ExtractorGlob})
|
||||||
add_library(CONTRACTOR OBJECT ${ContractorGlob})
|
add_library(CONTRACTOR OBJECT ${ContractorGlob})
|
||||||
|
add_library(STORAGE OBJECT ${StorageGlob})
|
||||||
add_library(ENGINE OBJECT ${EngineGlob})
|
add_library(ENGINE OBJECT ${EngineGlob})
|
||||||
add_library(SERVER OBJECT ${ServerGlob})
|
add_library(SERVER OBJECT ${ServerGlob})
|
||||||
add_library(GRAPH OBJECT src/extractor/external_memory_node.cpp)
|
|
||||||
add_library(PHANTOM OBJECT src/engine/phantom_node.cpp)
|
|
||||||
|
|
||||||
add_dependencies(UTIL FingerPrintConfigure)
|
add_dependencies(UTIL FingerPrintConfigure)
|
||||||
set_target_properties(UTIL PROPERTIES LINKER_LANGUAGE CXX)
|
set_target_properties(UTIL PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
|
|
||||||
add_executable(osrm-extract src/tools/extract.cpp $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
add_executable(osrm-extract src/tools/extract.cpp)
|
||||||
add_executable(osrm-prepare src/tools/contract.cpp $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_executable(osrm-prepare src/tools/contract.cpp)
|
||||||
add_executable(osrm-routed src/tools/routed.cpp $<TARGET_OBJECTS:SERVER> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_executable(osrm-routed src/tools/routed.cpp $<TARGET_OBJECTS:SERVER> $<TARGET_OBJECTS:UTIL>)
|
||||||
add_executable(osrm-datastore src/tools/datastore.cpp $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_executable(osrm-datastore src/tools/store.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
add_library(OSRM $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_library(osrm src/osrm/osrm.cpp $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL>)
|
||||||
|
add_library(osrm_extract $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
||||||
target_link_libraries(osrm-routed OSRM)
|
add_library(osrm_contract $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
||||||
|
add_library(osrm_store $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:UTIL>)
|
||||||
|
|
||||||
# Unit tests
|
# Unit tests
|
||||||
add_executable(engine-tests EXCLUDE_FROM_ALL unit_tests/engine_tests.cpp ${EngineTestsGlob} $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_executable(engine-tests EXCLUDE_FROM_ALL unit_tests/engine_tests.cpp ${EngineTestsGlob} $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL>)
|
||||||
add_executable(extractor-tests EXCLUDE_FROM_ALL unit_tests/extractor_tests.cpp ${ExtractorTestsGlob} $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
add_executable(extractor-tests EXCLUDE_FROM_ALL unit_tests/extractor_tests.cpp ${ExtractorTestsGlob} $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
||||||
add_executable(util-tests EXCLUDE_FROM_ALL unit_tests/util_tests.cpp ${UtilTestsGlob} $<TARGET_OBJECTS:PHANTOM> $<TARGET_OBJECTS:UTIL>)
|
add_executable(util-tests EXCLUDE_FROM_ALL unit_tests/util_tests.cpp ${UtilTestsGlob} $<TARGET_OBJECTS:UTIL>)
|
||||||
add_executable(io-tests EXCLUDE_FROM_ALL unit_tests/io_tests.cpp ${IOTestsGlob} $<TARGET_OBJECTS:UTIL>)
|
|
||||||
|
|
||||||
# Benchmarks
|
# Benchmarks
|
||||||
add_executable(rtree-bench EXCLUDE_FROM_ALL src/benchmarks/static_rtree.cpp $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:PHANTOM>)
|
add_executable(rtree-bench EXCLUDE_FROM_ALL src/benchmarks/static_rtree.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
|
|
||||||
# Check the release mode
|
# Check the release mode
|
||||||
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
@ -221,10 +221,7 @@ if(APPLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
target_link_libraries(osrm-prepare rt)
|
set(MAYBE_RT_LIBRARY rt)
|
||||||
target_link_libraries(osrm-datastore rt)
|
|
||||||
target_link_libraries(OSRM rt)
|
|
||||||
target_link_libraries(engine-tests rt)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/cmake")
|
||||||
@ -232,8 +229,6 @@ set(OSMIUM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/includ
|
|||||||
find_package(Osmium REQUIRED COMPONENTS io)
|
find_package(Osmium REQUIRED COMPONENTS io)
|
||||||
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
|
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
|
||||||
|
|
||||||
target_link_libraries(osrm-extract ${OSMIUM_LIBRARIES})
|
|
||||||
target_link_libraries(extractor-tests ${OSMIUM_LIBRARIES})
|
|
||||||
|
|
||||||
find_package(Boost 1.49.0 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
|
find_package(Boost 1.49.0 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
|
||||||
if(NOT Boost_FOUND)
|
if(NOT Boost_FOUND)
|
||||||
@ -241,72 +236,29 @@ if(NOT Boost_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
include_directories(SYSTEM ${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} ${OPTIONAL_SOCKET_LIBS} OSRM)
|
|
||||||
target_link_libraries(osrm-datastore ${Boost_LIBRARIES})
|
|
||||||
target_link_libraries(engine-tests ${Boost_LIBRARIES})
|
|
||||||
target_link_libraries(extractor-tests ${Boost_LIBRARIES})
|
|
||||||
target_link_libraries(util-tests ${Boost_LIBRARIES})
|
|
||||||
target_link_libraries(rtree-bench ${Boost_LIBRARIES})
|
|
||||||
target_link_libraries(io-tests ${Boost_LIBRARIES})
|
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(osrm-extract ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(osrm-datastore ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(osrm-prepare ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(OSRM ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(engine-tests ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(extractor-tests ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(util-tests ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
target_link_libraries(rtree-bench ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
|
|
||||||
find_package(TBB REQUIRED)
|
find_package(TBB REQUIRED)
|
||||||
|
include_directories(SYSTEM ${TBB_INCLUDE_DIR})
|
||||||
if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug)
|
if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES})
|
set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(osrm-datastore ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(osrm-extract ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(osrm-prepare ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(osrm-routed ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(engine-tests ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(extractor-tests ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(util-tests ${TBB_LIBRARIES})
|
|
||||||
target_link_libraries(rtree-bench ${TBB_LIBRARIES})
|
|
||||||
include_directories(SYSTEM ${TBB_INCLUDE_DIR})
|
|
||||||
|
|
||||||
find_package( Luabind REQUIRED )
|
find_package( Luabind REQUIRED )
|
||||||
include(check_luabind)
|
include(check_luabind)
|
||||||
|
|
||||||
include_directories(SYSTEM ${LUABIND_INCLUDE_DIR})
|
include_directories(SYSTEM ${LUABIND_INCLUDE_DIR})
|
||||||
target_link_libraries(osrm-extract ${LUABIND_LIBRARY})
|
|
||||||
target_link_libraries(osrm-prepare ${LUABIND_LIBRARY})
|
|
||||||
target_link_libraries(extractor-tests ${LUABIND_LIBRARY})
|
|
||||||
|
|
||||||
|
set(USED_LUA_LIBRARIES ${LUA_LIBRARY})
|
||||||
if(LUAJIT_FOUND)
|
if(LUAJIT_FOUND)
|
||||||
target_link_libraries(osrm-extract ${LUAJIT_LIBRARIES})
|
set(USED_LUA_LIBRARIES, LUAJIT_LIBRARIES)
|
||||||
target_link_libraries(osrm-prepare ${LUAJIT_LIBRARIES})
|
|
||||||
target_link_libraries(extractor-tests ${LUAJIT_LIBRARY})
|
|
||||||
else()
|
|
||||||
target_link_libraries(osrm-extract ${LUA_LIBRARY})
|
|
||||||
target_link_libraries(osrm-prepare ${LUA_LIBRARY})
|
|
||||||
target_link_libraries(extractor-tests ${LUA_LIBRARY})
|
|
||||||
endif()
|
endif()
|
||||||
include_directories(SYSTEM ${LUA_INCLUDE_DIR})
|
include_directories(SYSTEM ${LUA_INCLUDE_DIR})
|
||||||
|
|
||||||
find_package(EXPAT REQUIRED)
|
find_package(EXPAT REQUIRED)
|
||||||
include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
|
include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
|
||||||
target_link_libraries(osrm-extract ${EXPAT_LIBRARIES})
|
|
||||||
target_link_libraries(extractor-tests ${EXPAT_LIBRARY})
|
|
||||||
|
|
||||||
find_package(STXXL REQUIRED)
|
find_package(STXXL REQUIRED)
|
||||||
include_directories(SYSTEM ${STXXL_INCLUDE_DIR})
|
include_directories(SYSTEM ${STXXL_INCLUDE_DIR})
|
||||||
target_link_libraries(OSRM ${STXXL_LIBRARY})
|
|
||||||
target_link_libraries(osrm-extract ${STXXL_LIBRARY})
|
|
||||||
target_link_libraries(osrm-prepare ${STXXL_LIBRARY})
|
|
||||||
target_link_libraries(extractor-tests ${STXXL_LIBRARY})
|
|
||||||
target_link_libraries(util-tests ${STXXL_LIBRARY})
|
|
||||||
|
|
||||||
set(OpenMP_FIND_QUIETLY ON)
|
set(OpenMP_FIND_QUIETLY ON)
|
||||||
find_package(OpenMP)
|
find_package(OpenMP)
|
||||||
@ -317,14 +269,9 @@ endif()
|
|||||||
|
|
||||||
find_package(BZip2 REQUIRED)
|
find_package(BZip2 REQUIRED)
|
||||||
include_directories(SYSTEM ${BZIP_INCLUDE_DIRS})
|
include_directories(SYSTEM ${BZIP_INCLUDE_DIRS})
|
||||||
target_link_libraries(osrm-extract ${BZIP2_LIBRARIES})
|
|
||||||
target_link_libraries(extractor-tests ${BZIP2_LIBRARIES})
|
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
|
include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
|
||||||
target_link_libraries(osrm-extract ${ZLIB_LIBRARY})
|
|
||||||
target_link_libraries(osrm-routed ${ZLIB_LIBRARY})
|
|
||||||
target_link_libraries(extractor-tests ${ZLIB_LIBRARY})
|
|
||||||
|
|
||||||
if (ENABLE_JSON_LOGGING)
|
if (ENABLE_JSON_LOGGING)
|
||||||
message(STATUS "Enabling json logging")
|
message(STATUS "Enabling json logging")
|
||||||
@ -336,21 +283,71 @@ if (DEBUG_GEOMETRY)
|
|||||||
add_definitions(-DDEBUG_GEOMETRY)
|
add_definitions(-DDEBUG_GEOMETRY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
target_link_libraries(osrm-datastore osrm_store ${Boost_LIBRARIES})
|
||||||
|
target_link_libraries(osrm-extract osrm_extract ${Boost_LIBRARIES})
|
||||||
|
target_link_libraries(osrm-prepare osrm_contract ${Boost_LIBRARIES})
|
||||||
|
target_link_libraries(osrm-routed osrm ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY})
|
||||||
|
|
||||||
|
set(EXTRACTOR_LIBRARIES
|
||||||
|
${BZIP2_LIBRARIES}
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${EXPAT_LIBRARIES}
|
||||||
|
${LUABIND_LIBRARY}
|
||||||
|
${USED_LUA_LIBRARIES}
|
||||||
|
${OSMIUM_LIBRARIES}
|
||||||
|
${STXXL_LIBRARY}
|
||||||
|
${TBB_LIBRARIES}
|
||||||
|
${ZLIB_LIBRARY})
|
||||||
|
set(CONTRACTOR_LIBRARIES
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${LUABIND_LIBRARY}
|
||||||
|
${USED_LUA_LIBRARIES}
|
||||||
|
${STXXL_LIBRARY}
|
||||||
|
${TBB_LIBRARIES}
|
||||||
|
${MAYBE_RT_LIBRARY})
|
||||||
|
set(ENGINE_LIBRARIES
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${STXXL_LIBRARY}
|
||||||
|
${TBB_LIBRARIES}
|
||||||
|
${MAYBE_RT_LIBRARY})
|
||||||
|
set(STORAGE_LIBRARIES
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${TBB_LIBRARIES}
|
||||||
|
${MAYBE_RT_LIBRARY})
|
||||||
|
set(UTIL_LIBRARIES
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${STXXL_LIBRARY}
|
||||||
|
${TBB_LIBRARIES})
|
||||||
|
# Libraries
|
||||||
|
target_link_libraries(osrm ${ENGINE_LIBRARIES})
|
||||||
|
target_link_libraries(osrm_contract ${CONTRACTOR_LIBRARIES})
|
||||||
|
target_link_libraries(osrm_extract ${EXTRACTOR_LIBRARIES})
|
||||||
|
target_link_libraries(osrm_store ${STORAGE_LIBRARIES})
|
||||||
|
# Tests
|
||||||
|
target_link_libraries(engine-tests ${ENGINE_LIBRARIES})
|
||||||
|
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES})
|
||||||
|
target_link_libraries(rtree-bench ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${TBB_LIBRARIES})
|
||||||
|
target_link_libraries(util-tests ${UTIL_LIBRARIES})
|
||||||
|
|
||||||
if(BUILD_TOOLS)
|
if(BUILD_TOOLS)
|
||||||
message(STATUS "Activating OSRM internal tools")
|
message(STATUS "Activating OSRM internal tools")
|
||||||
find_package(GDAL)
|
find_package(GDAL)
|
||||||
if(GDAL_FOUND)
|
if(GDAL_FOUND)
|
||||||
add_executable(osrm-components src/tools/components.cpp $<TARGET_OBJECTS:GRAPH> $<TARGET_OBJECTS:UTIL>)
|
add_executable(osrm-components src/tools/components.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
target_link_libraries(osrm-components ${TBB_LIBRARIES})
|
target_link_libraries(osrm-components ${TBB_LIBRARIES})
|
||||||
include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
|
include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
|
||||||
target_link_libraries(osrm-components ${GDAL_LIBRARIES} ${Boost_LIBRARIES})
|
target_link_libraries(osrm-components ${GDAL_LIBRARIES} ${Boost_LIBRARIES})
|
||||||
install(TARGETS osrm-components DESTINATION bin)
|
install(TARGETS osrm-components DESTINATION bin)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "libgdal and/or development headers not found")
|
message(WARNING "libgdal and/or development headers not found")
|
||||||
endif()
|
endif()
|
||||||
add_executable(osrm-cli src/tools/simpleclient.cpp)
|
|
||||||
target_link_libraries(osrm-cli ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM)
|
|
||||||
target_link_libraries(osrm-cli ${TBB_LIBRARIES})
|
|
||||||
add_executable(osrm-io-benchmark src/tools/io-benchmark.cpp $<TARGET_OBJECTS:UTIL>)
|
add_executable(osrm-io-benchmark src/tools/io-benchmark.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
target_link_libraries(osrm-io-benchmark ${Boost_LIBRARIES})
|
target_link_libraries(osrm-io-benchmark ${Boost_LIBRARIES})
|
||||||
add_executable(osrm-unlock-all src/tools/unlock_all_mutexes.cpp $<TARGET_OBJECTS:UTIL>)
|
add_executable(osrm-unlock-all src/tools/unlock_all_mutexes.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
@ -358,21 +355,17 @@ if(BUILD_TOOLS)
|
|||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
target_link_libraries(osrm-unlock-all rt)
|
target_link_libraries(osrm-unlock-all rt)
|
||||||
endif()
|
endif()
|
||||||
add_executable(osrm-check-hsgr src/tools/check-hsgr.cpp $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_executable(osrm-check-hsgr src/tools/check-hsgr.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
target_link_libraries(osrm-check-hsgr ${Boost_LIBRARIES} ${TBB_LIBRARIES})
|
target_link_libraries(osrm-check-hsgr ${Boost_LIBRARIES} ${TBB_LIBRARIES})
|
||||||
add_executable(osrm-springclean src/tools/springclean.cpp $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:GRAPH>)
|
add_executable(osrm-springclean src/tools/springclean.cpp $<TARGET_OBJECTS:UTIL>)
|
||||||
target_link_libraries(osrm-springclean ${Boost_LIBRARIES})
|
target_link_libraries(osrm-springclean ${Boost_LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS osrm-cli DESTINATION bin)
|
|
||||||
install(TARGETS osrm-io-benchmark DESTINATION bin)
|
install(TARGETS osrm-io-benchmark DESTINATION bin)
|
||||||
install(TARGETS osrm-unlock-all DESTINATION bin)
|
install(TARGETS osrm-unlock-all DESTINATION bin)
|
||||||
install(TARGETS osrm-check-hsgr DESTINATION bin)
|
install(TARGETS osrm-check-hsgr DESTINATION bin)
|
||||||
install(TARGETS osrm-springclean DESTINATION bin)
|
install(TARGETS osrm-springclean DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(GLOB InstallGlob include/osrm/*.hpp)
|
|
||||||
file(GLOB VariantGlob third_party/variant/*.hpp)
|
|
||||||
|
|
||||||
# Add RPATH info to executables so that when they are run after being installed
|
# Add RPATH info to executables so that when they are run after being installed
|
||||||
# (i.e., from /usr/local/bin/) the linker can find library dependencies. For
|
# (i.e., from /usr/local/bin/) the linker can find library dependencies. For
|
||||||
# more info see http://www.cmake.org/Wiki/CMake_RPATH_handling
|
# more info see http://www.cmake.org/Wiki/CMake_RPATH_handling
|
||||||
@ -381,29 +374,35 @@ set_property(TARGET osrm-prepare PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|||||||
set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
install(FILES ${InstallGlob} DESTINATION include/osrm)
|
file(GLOB VariantGlob third_party/variant/*.hpp)
|
||||||
|
file(GLOB LibraryGlob include/osrm/*.hpp)
|
||||||
|
set(EngineHeader include/engine/engine.hpp include/engine/engine_config.hpp include/engine/route_parameters.hpp)
|
||||||
|
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp)
|
||||||
|
set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp)
|
||||||
|
set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp)
|
||||||
|
#set(StorageHeader include/storage/storage.hpp include/storage/storage_config.hpp)
|
||||||
|
install(FILES ${EngineHeader} DESTINATION include/osrm/engine)
|
||||||
|
install(FILES ${UtilHeader} DESTINATION include/osrm/util)
|
||||||
|
install(FILES ${ExtractorHeader} DESTINATION include/osrm/extractor)
|
||||||
|
install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor)
|
||||||
|
install(FILES ${LibraryGlob} DESTINATION include/osrm)
|
||||||
install(FILES ${VariantGlob} DESTINATION include/variant)
|
install(FILES ${VariantGlob} DESTINATION include/variant)
|
||||||
install(TARGETS osrm-extract DESTINATION bin)
|
install(TARGETS osrm-extract DESTINATION bin)
|
||||||
install(TARGETS osrm-prepare DESTINATION bin)
|
install(TARGETS osrm-prepare DESTINATION bin)
|
||||||
install(TARGETS osrm-datastore DESTINATION bin)
|
install(TARGETS osrm-datastore DESTINATION bin)
|
||||||
install(TARGETS osrm-routed DESTINATION bin)
|
install(TARGETS osrm-routed DESTINATION bin)
|
||||||
install(TARGETS OSRM DESTINATION lib)
|
install(TARGETS osrm DESTINATION lib)
|
||||||
|
install(TARGETS osrm_extract DESTINATION lib)
|
||||||
|
install(TARGETS osrm_contract DESTINATION lib)
|
||||||
|
install(TARGETS osrm_store DESTINATION lib)
|
||||||
|
|
||||||
list(GET Boost_LIBRARIES 1 BOOST_LIBRARY_FIRST)
|
list(GET ENGINE_LIBRARIES 1 ENGINE_LIBRARY_FIRST)
|
||||||
get_filename_component(BOOST_LIBRARY_LISTING "${BOOST_LIBRARY_FIRST}" PATH)
|
foreach(lib ${ENGINE_LIBRARIES})
|
||||||
set(BOOST_LIBRARY_LISTING "-L${BOOST_LIBRARY_LISTING}")
|
get_filename_component(ENGINE_LIBRARY_PATH "${ENGINE_LIBRARY_FIRST}" PATH)
|
||||||
foreach(lib ${Boost_LIBRARIES})
|
get_filename_component(ENGINE_LIBRARY_NAME "${lib}" NAME_WE)
|
||||||
get_filename_component(BOOST_LIBRARY_NAME "${lib}" NAME_WE)
|
string(REPLACE "lib" "" ENGINE_LIBRARY_NAME ${ENGINE_LIBRARY_NAME})
|
||||||
string(REPLACE "lib" "" BOOST_LIBRARY_NAME ${BOOST_LIBRARY_NAME})
|
string(REPLACE "-l" "" ENGINE_LIBRARY_NAME ${ENGINE_LIBRARY_NAME})
|
||||||
set(BOOST_LIBRARY_LISTING "${BOOST_LIBRARY_LISTING} -l${BOOST_LIBRARY_NAME}")
|
set(ENGINE_LIBRARY_LISTING "${ENGINE_LIBRARY_LISTING} -L${ENGINE_LIBRARY_PATH} -l${ENGINE_LIBRARY_NAME}")
|
||||||
endforeach()
|
|
||||||
list(GET TBB_LIBRARIES 1 TBB_LIBRARY_FIRST)
|
|
||||||
get_filename_component(TBB_LIBRARY_LISTING "${TBB_LIBRARY_FIRST}" PATH)
|
|
||||||
set(TBB_LIBRARY_LISTING "-L${TBB_LIBRARY_LISTING}")
|
|
||||||
foreach(lib ${TBB_LIBRARIES})
|
|
||||||
get_filename_component(TBB_LIBRARY_NAME "${lib}" NAME_WE)
|
|
||||||
string(REPLACE "lib" "" TBB_LIBRARY_NAME ${TBB_LIBRARY_NAME})
|
|
||||||
set(TBB_LIBRARY_LISTING "${TBB_LIBRARY_LISTING} -l${TBB_LIBRARY_NAME}")
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig.in libosrm.pc @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig.in libosrm.pc @ONLY)
|
||||||
|
@ -6,6 +6,6 @@ Name: libOSRM
|
|||||||
Description: Project OSRM library
|
Description: Project OSRM library
|
||||||
Version: v@OSRM_VERSION_MAJOR@.@OSRM_VERSION_MINOR@.@OSRM_VERSION_PATCH@
|
Version: v@OSRM_VERSION_MAJOR@.@OSRM_VERSION_MINOR@.@OSRM_VERSION_PATCH@
|
||||||
Requires:
|
Requires:
|
||||||
Libs: -L${libdir} -lOSRM
|
Libs: -L${libdir} -losrm
|
||||||
Libs.private: @BOOST_LIBRARY_LISTING@ @TBB_LIBRARY_LISTING@
|
Libs.private: @ENGINE_LIBRARY_LISTING@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
33
example/CMakeLists.txt
Normal file
33
example/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
|
|
||||||
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
|
||||||
|
message(FATAL_ERROR "In-source builds are not allowed.
|
||||||
|
Please create a directory and run cmake from there, passing the path to this source directory as the last argument.
|
||||||
|
This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. Please delete them.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(osrm-example C CXX)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
|
||||||
|
|
||||||
|
set(bitness 32)
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(bitness 64)
|
||||||
|
message(STATUS "Building on a 64 bit system")
|
||||||
|
else()
|
||||||
|
message(WARNING "Building on a 32 bit system is unsupported")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32 AND MSVC_VERSION LESS 1800)
|
||||||
|
message(FATAL_ERROR "Building with Microsoft compiler needs Visual Studio 2013 or later (Express version works too)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(osrm-example example.cpp)
|
||||||
|
|
||||||
|
find_package(LibOSRM REQUIRED)
|
||||||
|
find_package(Boost 1.49.0 COMPONENTS filesystem system thread REQUIRED)
|
||||||
|
|
||||||
|
target_link_libraries(osrm-example ${LibOSRM_LIBRARIES} ${Boost_LIBRARIES})
|
||||||
|
include_directories(SYSTEM ${LibOSRM_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
|
||||||
|
|
65
example/cmake/FindLibOSRM.cmake
Normal file
65
example/cmake/FindLibOSRM.cmake
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# - Try to find LibOSRM
|
||||||
|
# Once done this will define
|
||||||
|
# LibOSRM_FOUND - System has LibOSRM
|
||||||
|
# LibOSRM_INCLUDE_DIRS - The LibOSRM include directories
|
||||||
|
# LibOSRM_LIBRARIES - The libraries needed to use LibOSRM
|
||||||
|
# LibOSRM_DEFINITIONS - Compiler switches required for using LibOSRM
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LibOSRM QUIET libosrm)
|
||||||
|
set(LibOSRM_DEFINITIONS ${PC_LibOSRM_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(LibOSRM_INCLUDE_DIR osrm/osrm.hpp
|
||||||
|
PATH_SUFFIXES osrm include/osrm include
|
||||||
|
HINTS ${PC_LibOSRM_INCLUDEDIR} ${PC_LibOSRM_INCLUDE_DIRS}
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt/local
|
||||||
|
/opt)
|
||||||
|
|
||||||
|
set(LibOSRM_INCLUDE_DIRS ${LibOSRM_INCLUDE_DIR})
|
||||||
|
|
||||||
|
find_library(TEST_LibOSRM_STATIC_LIBRARY Names osrm.lib libosrm.a
|
||||||
|
PATH_SUFFIXES osrm lib/osrm lib
|
||||||
|
HINTS ${PC_LibOSRM_LIBDIR} ${PC_LibOSRM_LIBRARY_DIRS}
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt/local
|
||||||
|
/opt)
|
||||||
|
find_library(TEST_LibOSRM_DYNAMIC_LIBRARY Names osrm.dynlib libosrm.so
|
||||||
|
PATH_SUFFIXES osrm lib/osrm lib
|
||||||
|
HINTS ${PC_LibOSRM_LIBDIR} ${PC_LibOSRM_LIBRARY_DIRS}
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt/local
|
||||||
|
/opt)
|
||||||
|
|
||||||
|
if (NOT ("${TEST_LibOSRM_STATIC_LIBRARY}" STREQUAL "TEST_LibOSRM_STATIC_LIBRARY-NOTFOUND"))
|
||||||
|
if ("${PC_LibOSRM_STATIC_LIBRARIES}" STREQUAL "")
|
||||||
|
set(LibOSRM_STATIC_LIBRARIES ${TEST_LibOSRM_STATIC_LIBRARY})
|
||||||
|
else()
|
||||||
|
set(LibOSRM_STATIC_LIBRARIES ${PC_LibOSRM_STATIC_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
set(LibOSRM_LIBRARIES ${LibOSRM_STATIC_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT ("${TEST_LibOSRM_DYNAMIC_LIBRARY}" STREQUAL "TEST_LibOSRM_DYNAMIC_LIBRARY-NOTFOUND"))
|
||||||
|
if ("${PC_LibOSRM_LIBRARIES}" STREQUAL "")
|
||||||
|
set(LibOSRM_DYNAMIC_LIBRARIES ${TEST_LibOSRM_DYNAMIC_LIBRARY})
|
||||||
|
else()
|
||||||
|
set(LibOSRM_DYNAMIC_LIBRARIES ${PC_LibOSRM_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
set(LibOSRM_LIBRARIES ${LibOSRM_DYNAMIC_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LIBOSRM_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(LibOSRM DEFAULT_MSG
|
||||||
|
LibOSRM_LIBRARIES LibOSRM_INCLUDE_DIR)
|
283
example/cmake/FindTBB.cmake
Normal file
283
example/cmake/FindTBB.cmake
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
# Locate Intel Threading Building Blocks include paths and libraries
|
||||||
|
# FindTBB.cmake can be found at https://code.google.com/p/findtbb/
|
||||||
|
# Written by Hannes Hofmann <hannes.hofmann _at_ informatik.uni-erlangen.de>
|
||||||
|
# Improvements by Gino van den Bergen <gino _at_ dtecta.com>,
|
||||||
|
# Florian Uhlig <F.Uhlig _at_ gsi.de>,
|
||||||
|
# Jiri Marsik <jiri.marsik89 _at_ gmail.com>
|
||||||
|
|
||||||
|
# The MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011 Hannes Hofmann
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
# GvdB: This module uses the environment variable TBB_ARCH_PLATFORM which defines architecture and compiler.
|
||||||
|
# e.g. "ia32/vc8" or "em64t/cc4.1.0_libc2.4_kernel2.6.16.21"
|
||||||
|
# TBB_ARCH_PLATFORM is set by the build script tbbvars[.bat|.sh|.csh], which can be found
|
||||||
|
# in the TBB installation directory (TBB_INSTALL_DIR).
|
||||||
|
#
|
||||||
|
# GvdB: Mac OS X distribution places libraries directly in lib directory.
|
||||||
|
#
|
||||||
|
# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER.
|
||||||
|
# TBB_ARCHITECTURE [ ia32 | em64t | itanium ]
|
||||||
|
# which architecture to use
|
||||||
|
# TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9
|
||||||
|
# which compiler to use (detected automatically on Windows)
|
||||||
|
|
||||||
|
# This module respects
|
||||||
|
# TBB_INSTALL_DIR or $ENV{TBB21_INSTALL_DIR} or $ENV{TBB_INSTALL_DIR}
|
||||||
|
|
||||||
|
# This module defines
|
||||||
|
# TBB_INCLUDE_DIRS, where to find task_scheduler_init.h, etc.
|
||||||
|
# TBB_LIBRARY_DIRS, where to find libtbb, libtbbmalloc
|
||||||
|
# TBB_DEBUG_LIBRARY_DIRS, where to find libtbb_debug, libtbbmalloc_debug
|
||||||
|
# TBB_INSTALL_DIR, the base TBB install directory
|
||||||
|
# TBB_LIBRARIES, the libraries to link against to use TBB.
|
||||||
|
# TBB_DEBUG_LIBRARIES, the libraries to link against to use TBB with debug symbols.
|
||||||
|
# TBB_FOUND, If false, don't try to use TBB.
|
||||||
|
# TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h
|
||||||
|
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
# has em64t/vc8 em64t/vc9
|
||||||
|
# has ia32/vc7.1 ia32/vc8 ia32/vc9
|
||||||
|
set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
|
||||||
|
set(_TBB_LIB_NAME "tbb")
|
||||||
|
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||||
|
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||||
|
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||||
|
if (MSVC71)
|
||||||
|
set (_TBB_COMPILER "vc7.1")
|
||||||
|
endif(MSVC71)
|
||||||
|
if (MSVC80)
|
||||||
|
set(_TBB_COMPILER "vc8")
|
||||||
|
endif(MSVC80)
|
||||||
|
if (MSVC90)
|
||||||
|
set(_TBB_COMPILER "vc9")
|
||||||
|
endif(MSVC90)
|
||||||
|
if(MSVC10)
|
||||||
|
set(_TBB_COMPILER "vc10")
|
||||||
|
endif(MSVC10)
|
||||||
|
# Todo: add other Windows compilers such as ICL.
|
||||||
|
set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
|
||||||
|
endif (WIN32)
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
|
if (APPLE)
|
||||||
|
# MAC
|
||||||
|
set(_TBB_DEFAULT_INSTALL_DIR "/Library/Frameworks/Intel_TBB.framework/Versions")
|
||||||
|
# libs: libtbb.dylib, libtbbmalloc.dylib, *_debug
|
||||||
|
set(_TBB_LIB_NAME "tbb")
|
||||||
|
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||||
|
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||||
|
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||||
|
# default flavor on apple: ia32/cc4.0.1_os10.4.9
|
||||||
|
# Jiri: There is no reason to presume there is only one flavor and
|
||||||
|
# that user's setting of variables should be ignored.
|
||||||
|
if(NOT TBB_COMPILER)
|
||||||
|
set(_TBB_COMPILER "cc4.0.1_os10.4.9")
|
||||||
|
elseif (NOT TBB_COMPILER)
|
||||||
|
set(_TBB_COMPILER ${TBB_COMPILER})
|
||||||
|
endif(NOT TBB_COMPILER)
|
||||||
|
if(NOT TBB_ARCHITECTURE)
|
||||||
|
set(_TBB_ARCHITECTURE "ia32")
|
||||||
|
elseif(NOT TBB_ARCHITECTURE)
|
||||||
|
set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
|
||||||
|
endif(NOT TBB_ARCHITECTURE)
|
||||||
|
else (APPLE)
|
||||||
|
# LINUX
|
||||||
|
set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include")
|
||||||
|
set(_TBB_LIB_NAME "tbb")
|
||||||
|
set(_TBB_LIB_MALLOC_NAME "${_TBB_LIB_NAME}malloc")
|
||||||
|
set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_NAME}_debug")
|
||||||
|
set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_NAME}_debug")
|
||||||
|
# has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21
|
||||||
|
# has ia32/*
|
||||||
|
# has itanium/*
|
||||||
|
set(_TBB_COMPILER ${TBB_COMPILER})
|
||||||
|
set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
|
||||||
|
endif (APPLE)
|
||||||
|
endif (UNIX)
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||||
|
# SUN
|
||||||
|
# not yet supported
|
||||||
|
# has em64t/cc3.4.3_kernel5.10
|
||||||
|
# has ia32/*
|
||||||
|
endif (CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||||
|
|
||||||
|
|
||||||
|
#-- Clear the public variables
|
||||||
|
set (TBB_FOUND "NO")
|
||||||
|
|
||||||
|
|
||||||
|
#-- Find TBB install dir and set ${_TBB_INSTALL_DIR} and cached ${TBB_INSTALL_DIR}
|
||||||
|
# first: use CMake variable TBB_INSTALL_DIR
|
||||||
|
if (TBB_INSTALL_DIR)
|
||||||
|
set (_TBB_INSTALL_DIR ${TBB_INSTALL_DIR})
|
||||||
|
endif (TBB_INSTALL_DIR)
|
||||||
|
# second: use environment variable
|
||||||
|
if (NOT _TBB_INSTALL_DIR)
|
||||||
|
if (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
|
||||||
|
set (_TBB_INSTALL_DIR $ENV{TBB_INSTALL_DIR})
|
||||||
|
endif (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
|
||||||
|
# Intel recommends setting TBB21_INSTALL_DIR
|
||||||
|
if (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
|
||||||
|
set (_TBB_INSTALL_DIR $ENV{TBB21_INSTALL_DIR})
|
||||||
|
endif (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
|
||||||
|
if (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
|
||||||
|
set (_TBB_INSTALL_DIR $ENV{TBB22_INSTALL_DIR})
|
||||||
|
endif (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
|
||||||
|
if (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
|
||||||
|
set (_TBB_INSTALL_DIR $ENV{TBB30_INSTALL_DIR})
|
||||||
|
endif (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
|
||||||
|
endif (NOT _TBB_INSTALL_DIR)
|
||||||
|
# third: try to find path automatically
|
||||||
|
if (NOT _TBB_INSTALL_DIR)
|
||||||
|
if (_TBB_DEFAULT_INSTALL_DIR)
|
||||||
|
set (_TBB_INSTALL_DIR ${_TBB_DEFAULT_INSTALL_DIR})
|
||||||
|
endif (_TBB_DEFAULT_INSTALL_DIR)
|
||||||
|
endif (NOT _TBB_INSTALL_DIR)
|
||||||
|
# sanity check
|
||||||
|
if (NOT _TBB_INSTALL_DIR)
|
||||||
|
message ("ERROR: Unable to find Intel TBB install directory. ${_TBB_INSTALL_DIR}")
|
||||||
|
else (NOT _TBB_INSTALL_DIR)
|
||||||
|
# finally: set the cached CMake variable TBB_INSTALL_DIR
|
||||||
|
if (NOT TBB_INSTALL_DIR)
|
||||||
|
set (TBB_INSTALL_DIR ${_TBB_INSTALL_DIR} CACHE PATH "Intel TBB install directory")
|
||||||
|
mark_as_advanced(TBB_INSTALL_DIR)
|
||||||
|
endif (NOT TBB_INSTALL_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
#-- A macro to rewrite the paths of the library. This is necessary, because
|
||||||
|
# find_library() always found the em64t/vc9 version of the TBB libs
|
||||||
|
macro(TBB_CORRECT_LIB_DIR var_name)
|
||||||
|
# if (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
|
||||||
|
string(REPLACE em64t "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
|
||||||
|
# endif (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
|
||||||
|
string(REPLACE ia32 "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
|
||||||
|
string(REPLACE vc7.1 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||||
|
string(REPLACE vc8 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||||
|
string(REPLACE vc9 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||||
|
string(REPLACE vc10 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
|
||||||
|
endmacro(TBB_CORRECT_LIB_DIR var_content)
|
||||||
|
|
||||||
|
|
||||||
|
#-- Look for include directory and set ${TBB_INCLUDE_DIR}
|
||||||
|
set (TBB_INC_SEARCH_DIR ${_TBB_INSTALL_DIR}/include)
|
||||||
|
# Jiri: tbbvars now sets the CPATH environment variable to the directory
|
||||||
|
# containing the headers.
|
||||||
|
find_path(TBB_INCLUDE_DIR
|
||||||
|
tbb/task_scheduler_init.h
|
||||||
|
PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
|
||||||
|
)
|
||||||
|
mark_as_advanced(TBB_INCLUDE_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
#-- Look for libraries
|
||||||
|
# GvdB: $ENV{TBB_ARCH_PLATFORM} is set by the build script tbbvars[.bat|.sh|.csh]
|
||||||
|
if (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
|
||||||
|
set (_TBB_LIBRARY_DIR
|
||||||
|
${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM}
|
||||||
|
${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib
|
||||||
|
)
|
||||||
|
endif (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
|
||||||
|
# Jiri: This block isn't mutually exclusive with the previous one
|
||||||
|
# (hence no else), instead I test if the user really specified
|
||||||
|
# the variables in question.
|
||||||
|
if ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
|
||||||
|
# HH: deprecated
|
||||||
|
message(STATUS "[Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set \$ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).")
|
||||||
|
# Jiri: It doesn't hurt to look in more places, so I store the hints from
|
||||||
|
# ENV{TBB_ARCH_PLATFORM} and the TBB_ARCHITECTURE and TBB_COMPILER
|
||||||
|
# variables and search them both.
|
||||||
|
set (_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}/lib" ${_TBB_LIBRARY_DIR})
|
||||||
|
endif ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
|
||||||
|
|
||||||
|
# GvdB: Mac OS X distribution places libraries directly in lib directory.
|
||||||
|
list(APPEND _TBB_LIBRARY_DIR ${_TBB_INSTALL_DIR}/lib)
|
||||||
|
|
||||||
|
# Jiri: No reason not to check the default paths. From recent versions,
|
||||||
|
# tbbvars has started exporting the LIBRARY_PATH and LD_LIBRARY_PATH
|
||||||
|
# variables, which now point to the directories of the lib files.
|
||||||
|
# It all makes more sense to use the ${_TBB_LIBRARY_DIR} as a HINTS
|
||||||
|
# argument instead of the implicit PATHS as it isn't hard-coded
|
||||||
|
# but computed by system introspection. Searching the LIBRARY_PATH
|
||||||
|
# and LD_LIBRARY_PATH environment variables is now even more important
|
||||||
|
# that tbbvars doesn't export TBB_ARCH_PLATFORM and it facilitates
|
||||||
|
# the use of TBB built from sources.
|
||||||
|
find_library(TBB_LIBRARY ${_TBB_LIB_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||||
|
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||||
|
find_library(TBB_MALLOC_LIBRARY ${_TBB_LIB_MALLOC_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||||
|
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||||
|
|
||||||
|
#Extract path from TBB_LIBRARY name
|
||||||
|
get_filename_component(TBB_LIBRARY_DIR ${TBB_LIBRARY} PATH)
|
||||||
|
|
||||||
|
#TBB_CORRECT_LIB_DIR(TBB_LIBRARY)
|
||||||
|
#TBB_CORRECT_LIB_DIR(TBB_MALLOC_LIBRARY)
|
||||||
|
mark_as_advanced(TBB_LIBRARY TBB_MALLOC_LIBRARY)
|
||||||
|
|
||||||
|
#-- Look for debug libraries
|
||||||
|
# Jiri: Changed the same way as for the release libraries.
|
||||||
|
find_library(TBB_LIBRARY_DEBUG ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||||
|
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||||
|
find_library(TBB_MALLOC_LIBRARY_DEBUG ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
|
||||||
|
PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
|
||||||
|
|
||||||
|
# Jiri: Self-built TBB stores the debug libraries in a separate directory.
|
||||||
|
# Extract path from TBB_LIBRARY_DEBUG name
|
||||||
|
get_filename_component(TBB_LIBRARY_DEBUG_DIR ${TBB_LIBRARY_DEBUG} PATH)
|
||||||
|
|
||||||
|
#TBB_CORRECT_LIB_DIR(TBB_LIBRARY_DEBUG)
|
||||||
|
#TBB_CORRECT_LIB_DIR(TBB_MALLOC_LIBRARY_DEBUG)
|
||||||
|
mark_as_advanced(TBB_LIBRARY_DEBUG TBB_MALLOC_LIBRARY_DEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
if (TBB_INCLUDE_DIR)
|
||||||
|
if (TBB_LIBRARY)
|
||||||
|
set (TBB_FOUND "YES")
|
||||||
|
set (TBB_LIBRARIES ${TBB_LIBRARY} ${TBB_MALLOC_LIBRARY} ${TBB_LIBRARIES})
|
||||||
|
set (TBB_DEBUG_LIBRARIES ${TBB_LIBRARY_DEBUG} ${TBB_MALLOC_LIBRARY_DEBUG} ${TBB_DEBUG_LIBRARIES})
|
||||||
|
set (TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE)
|
||||||
|
set (TBB_LIBRARY_DIRS ${TBB_LIBRARY_DIR} CACHE PATH "TBB library directory" FORCE)
|
||||||
|
# Jiri: Self-built TBB stores the debug libraries in a separate directory.
|
||||||
|
set (TBB_DEBUG_LIBRARY_DIRS ${TBB_LIBRARY_DEBUG_DIR} CACHE PATH "TBB debug library directory" FORCE)
|
||||||
|
mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARY_DIRS TBB_DEBUG_LIBRARY_DIRS TBB_LIBRARIES TBB_DEBUG_LIBRARIES)
|
||||||
|
message(STATUS "Found Intel TBB")
|
||||||
|
endif (TBB_LIBRARY)
|
||||||
|
endif (TBB_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if (NOT TBB_FOUND)
|
||||||
|
message("ERROR: Intel TBB NOT found!")
|
||||||
|
message(STATUS "Looked for Threading Building Blocks in ${_TBB_INSTALL_DIR}")
|
||||||
|
# do only throw fatal, if this pkg is REQUIRED
|
||||||
|
if (TBB_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could NOT find TBB library.")
|
||||||
|
endif (TBB_FIND_REQUIRED)
|
||||||
|
endif (NOT TBB_FOUND)
|
||||||
|
|
||||||
|
endif (NOT _TBB_INSTALL_DIR)
|
||||||
|
|
||||||
|
if (TBB_FOUND)
|
||||||
|
set(TBB_INTERFACE_VERSION 0)
|
||||||
|
FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS)
|
||||||
|
STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}")
|
||||||
|
set(TBB_INTERFACE_VERSION "${TBB_INTERFACE_VERSION}")
|
||||||
|
endif (TBB_FOUND)
|
63
example/example.cpp
Normal file
63
example/example.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include "osrm/json_container.hpp"
|
||||||
|
#include "osrm/engine_config.hpp"
|
||||||
|
#include "osrm/route_parameters.hpp"
|
||||||
|
#include "osrm/osrm.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <iostream>
|
||||||
|
#include <exception>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) try
|
||||||
|
{
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
std::cerr << "Error: Not enough arguments." << std::endl
|
||||||
|
<< "Run " << argv[0] << " data.osrm" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
osrm::EngineConfig engine_config;
|
||||||
|
std::string base_path(argv[1]);
|
||||||
|
engine_config.server_paths["ramindex"] = base_path + ".ramIndex";
|
||||||
|
engine_config.server_paths["fileindex"] = base_path + ".fileIndex";
|
||||||
|
engine_config.server_paths["hsgrdata"] = base_path + ".hsgr";
|
||||||
|
engine_config.server_paths["nodesdata"] = base_path + ".nodes";
|
||||||
|
engine_config.server_paths["edgesdata"] = base_path + ".edges";
|
||||||
|
engine_config.server_paths["coredata"] = base_path + ".core";
|
||||||
|
engine_config.server_paths["geometries"] = base_path + ".geometry";
|
||||||
|
engine_config.server_paths["timestamp"] = base_path + ".timestamp";
|
||||||
|
engine_config.server_paths["namesdata"] = base_path + ".names";
|
||||||
|
engine_config.use_shared_memory = false;
|
||||||
|
|
||||||
|
osrm::OSRM routing_machine(engine_config);
|
||||||
|
|
||||||
|
osrm::RouteParameters route_parameters;
|
||||||
|
// route is in Berlin
|
||||||
|
auto start = std::make_pair(52.519930, 13.438640);
|
||||||
|
auto target = std::make_pair(52.513191, 13.415852);
|
||||||
|
route_parameters.service = "viaroute";
|
||||||
|
route_parameters.AddCoordinate({start.first, start.second});
|
||||||
|
route_parameters.AddCoordinate({target.first, target.second});
|
||||||
|
|
||||||
|
osrm::json::Object json_result;
|
||||||
|
const int result_code = routing_machine.RunQuery(route_parameters, json_result);
|
||||||
|
std::cout << "result code: " << result_code << std::endl;
|
||||||
|
// 2xx code
|
||||||
|
if (result_code / 100 == 2)
|
||||||
|
{
|
||||||
|
// Extract data out of JSON structure
|
||||||
|
auto& summary = json_result.values["route_summary"].get<osrm::json::Object>();
|
||||||
|
auto duration = summary.values["total_time"].get<osrm::json::Number>().value;
|
||||||
|
auto distance = summary.values["total_distance"].get<osrm::json::Number>().value;
|
||||||
|
std::cout << "duration: " << duration << std::endl;
|
||||||
|
std::cout << "distance: " << distance << std::endl;
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
catch (const std::exception ¤t_exception)
|
||||||
|
{
|
||||||
|
std::cout << "exception: " << current_exception.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -10,17 +10,21 @@ namespace osrm
|
|||||||
namespace contractor
|
namespace contractor
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class return_code : unsigned
|
|
||||||
{
|
|
||||||
ok,
|
|
||||||
fail,
|
|
||||||
exit
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ContractorConfig
|
struct ContractorConfig
|
||||||
{
|
{
|
||||||
ContractorConfig() : requested_num_threads(0) {}
|
ContractorConfig() : requested_num_threads(0) {}
|
||||||
|
|
||||||
|
// Infer the output names from the path of the .osrm file
|
||||||
|
void UseDefaultOutputNames()
|
||||||
|
{
|
||||||
|
level_output_path = osrm_input_path.string() + ".level";
|
||||||
|
core_output_path = osrm_input_path.string() + ".core";
|
||||||
|
graph_output_path = osrm_input_path.string() + ".hsgr";
|
||||||
|
edge_based_graph_path = osrm_input_path.string() + ".ebg";
|
||||||
|
edge_segment_lookup_path = osrm_input_path.string() + ".edge_segment_lookup";
|
||||||
|
edge_penalty_path = osrm_input_path.string() + ".edge_penalties";
|
||||||
|
}
|
||||||
|
|
||||||
boost::filesystem::path config_file_path;
|
boost::filesystem::path config_file_path;
|
||||||
boost::filesystem::path osrm_input_path;
|
boost::filesystem::path osrm_input_path;
|
||||||
boost::filesystem::path profile_path;
|
boost::filesystem::path profile_path;
|
||||||
@ -48,13 +52,6 @@ struct ContractorConfig
|
|||||||
std::string debug_geometry_path;
|
std::string debug_geometry_path;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ContractorOptions
|
|
||||||
{
|
|
||||||
static return_code ParseArguments(int argc, char *argv[], ContractorConfig &extractor_config);
|
|
||||||
|
|
||||||
static void GenerateOutputFilesNames(ContractorConfig &extractor_config);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1104
include/contractor/graph_contractor.hpp
Normal file
1104
include/contractor/graph_contractor.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,73 +0,0 @@
|
|||||||
#ifndef PROCESSING_CHAIN_HPP
|
|
||||||
#define PROCESSING_CHAIN_HPP
|
|
||||||
|
|
||||||
#include "contractor/contractor.hpp"
|
|
||||||
#include "contractor/contractor_options.hpp"
|
|
||||||
#include "contractor/query_edge.hpp"
|
|
||||||
#include "extractor/edge_based_edge.hpp"
|
|
||||||
#include "util/static_graph.hpp"
|
|
||||||
#include "util/deallocating_vector.hpp"
|
|
||||||
#include "util/node_based_graph.hpp"
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct lua_State;
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace extractor
|
|
||||||
{
|
|
||||||
struct SpeedProfileProperties;
|
|
||||||
struct EdgeBasedNode;
|
|
||||||
}
|
|
||||||
namespace contractor
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief class of 'prepare' utility.
|
|
||||||
*/
|
|
||||||
class Prepare
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using EdgeData = QueryEdge::EdgeData;
|
|
||||||
|
|
||||||
explicit Prepare(ContractorConfig contractor_config) : config(std::move(contractor_config)) {}
|
|
||||||
Prepare(const Prepare &) = delete;
|
|
||||||
~Prepare();
|
|
||||||
|
|
||||||
int Run();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void ContractGraph(const unsigned max_edge_id,
|
|
||||||
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
|
||||||
util::DeallocatingVector<QueryEdge> &contracted_edge_list,
|
|
||||||
std::vector<EdgeWeight> &&node_weights,
|
|
||||||
std::vector<bool> &is_core_node,
|
|
||||||
std::vector<float> &node_levels) const;
|
|
||||||
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
|
|
||||||
void WriteNodeLevels(std::vector<float> &&node_levels) const;
|
|
||||||
void ReadNodeLevels(std::vector<float> &contraction_order) const;
|
|
||||||
std::size_t
|
|
||||||
WriteContractedGraph(unsigned number_of_edge_based_nodes,
|
|
||||||
const util::DeallocatingVector<QueryEdge> &contracted_edge_list);
|
|
||||||
void FindComponents(unsigned max_edge_id,
|
|
||||||
const util::DeallocatingVector<extractor::EdgeBasedEdge> &edges,
|
|
||||||
std::vector<extractor::EdgeBasedNode> &nodes) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ContractorConfig config;
|
|
||||||
std::size_t
|
|
||||||
LoadEdgeExpandedGraph(const std::string &edge_based_graph_path,
|
|
||||||
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
|
||||||
const std::string &edge_segment_lookup_path,
|
|
||||||
const std::string &edge_penalty_path,
|
|
||||||
const std::string &segment_speed_path);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // PROCESSING_CHAIN_HPP
|
|
@ -4,7 +4,8 @@
|
|||||||
// implements all data storage when shared memory _IS_ used
|
// implements all data storage when shared memory _IS_ used
|
||||||
|
|
||||||
#include "engine/datafacade/datafacade_base.hpp"
|
#include "engine/datafacade/datafacade_base.hpp"
|
||||||
#include "engine/datafacade/shared_datatype.hpp"
|
#include "storage/shared_datatype.hpp"
|
||||||
|
#include "storage/shared_memory.hpp"
|
||||||
|
|
||||||
#include "engine/geospatial_query.hpp"
|
#include "engine/geospatial_query.hpp"
|
||||||
#include "util/range_table.hpp"
|
#include "util/range_table.hpp"
|
||||||
@ -44,18 +45,18 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
||||||
using RTreeNode = typename SharedRTree::TreeNode;
|
using RTreeNode = typename SharedRTree::TreeNode;
|
||||||
|
|
||||||
SharedDataLayout *data_layout;
|
storage::SharedDataLayout *data_layout;
|
||||||
char *shared_memory;
|
char *shared_memory;
|
||||||
SharedDataTimestamp *data_timestamp_ptr;
|
storage::SharedDataTimestamp *data_timestamp_ptr;
|
||||||
|
|
||||||
SharedDataType CURRENT_LAYOUT;
|
storage::SharedDataType CURRENT_LAYOUT;
|
||||||
SharedDataType CURRENT_DATA;
|
storage::SharedDataType CURRENT_DATA;
|
||||||
unsigned CURRENT_TIMESTAMP;
|
unsigned CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
unsigned m_check_sum;
|
unsigned m_check_sum;
|
||||||
std::unique_ptr<QueryGraph> m_query_graph;
|
std::unique_ptr<QueryGraph> m_query_graph;
|
||||||
std::unique_ptr<datastore::SharedMemory> m_layout_memory;
|
std::unique_ptr<storage::SharedMemory> m_layout_memory;
|
||||||
std::unique_ptr<datastore::SharedMemory> m_large_memory;
|
std::unique_ptr<storage::SharedMemory> m_large_memory;
|
||||||
std::string m_timestamp;
|
std::string m_timestamp;
|
||||||
|
|
||||||
std::shared_ptr<util::ShM<util::FixedPointCoordinate, true>::vector> m_coordinate_list;
|
std::shared_ptr<util::ShM<util::FixedPointCoordinate, true>::vector> m_coordinate_list;
|
||||||
@ -79,17 +80,17 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
void LoadChecksum()
|
void LoadChecksum()
|
||||||
{
|
{
|
||||||
m_check_sum =
|
m_check_sum =
|
||||||
*data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::HSGR_CHECKSUM);
|
*data_layout->GetBlockPtr<unsigned>(shared_memory, storage::SharedDataLayout::HSGR_CHECKSUM);
|
||||||
util::SimpleLogger().Write() << "set checksum: " << m_check_sum;
|
util::SimpleLogger().Write() << "set checksum: " << m_check_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadTimestamp()
|
void LoadTimestamp()
|
||||||
{
|
{
|
||||||
char *timestamp_ptr =
|
char *timestamp_ptr =
|
||||||
data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::TIMESTAMP);
|
data_layout->GetBlockPtr<char>(shared_memory, storage::SharedDataLayout::TIMESTAMP);
|
||||||
m_timestamp.resize(data_layout->GetBlockSize(SharedDataLayout::TIMESTAMP));
|
m_timestamp.resize(data_layout->GetBlockSize(storage::SharedDataLayout::TIMESTAMP));
|
||||||
std::copy(timestamp_ptr,
|
std::copy(timestamp_ptr,
|
||||||
timestamp_ptr + data_layout->GetBlockSize(SharedDataLayout::TIMESTAMP),
|
timestamp_ptr + data_layout->GetBlockSize(storage::SharedDataLayout::TIMESTAMP),
|
||||||
m_timestamp.begin());
|
m_timestamp.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +99,11 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
|
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
|
||||||
|
|
||||||
RTreeNode *tree_ptr =
|
RTreeNode *tree_ptr =
|
||||||
data_layout->GetBlockPtr<RTreeNode>(shared_memory, SharedDataLayout::R_SEARCH_TREE);
|
data_layout->GetBlockPtr<RTreeNode>(shared_memory, storage::SharedDataLayout::R_SEARCH_TREE);
|
||||||
m_static_rtree.reset(new TimeStampedRTreePair(
|
m_static_rtree.reset(new TimeStampedRTreePair(
|
||||||
CURRENT_TIMESTAMP,
|
CURRENT_TIMESTAMP,
|
||||||
util::make_unique<SharedRTree>(
|
util::make_unique<SharedRTree>(
|
||||||
tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE],
|
tree_ptr, data_layout->num_entries[storage::SharedDataLayout::R_SEARCH_TREE],
|
||||||
file_index_path, m_coordinate_list)));
|
file_index_path, m_coordinate_list)));
|
||||||
m_geospatial_query.reset(
|
m_geospatial_query.reset(
|
||||||
new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list));
|
new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list));
|
||||||
@ -111,15 +112,15 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
void LoadGraph()
|
void LoadGraph()
|
||||||
{
|
{
|
||||||
GraphNode *graph_nodes_ptr =
|
GraphNode *graph_nodes_ptr =
|
||||||
data_layout->GetBlockPtr<GraphNode>(shared_memory, SharedDataLayout::GRAPH_NODE_LIST);
|
data_layout->GetBlockPtr<GraphNode>(shared_memory, storage::SharedDataLayout::GRAPH_NODE_LIST);
|
||||||
|
|
||||||
GraphEdge *graph_edges_ptr =
|
GraphEdge *graph_edges_ptr =
|
||||||
data_layout->GetBlockPtr<GraphEdge>(shared_memory, SharedDataLayout::GRAPH_EDGE_LIST);
|
data_layout->GetBlockPtr<GraphEdge>(shared_memory, storage::SharedDataLayout::GRAPH_EDGE_LIST);
|
||||||
|
|
||||||
typename util::ShM<GraphNode, true>::vector node_list(
|
typename util::ShM<GraphNode, true>::vector node_list(
|
||||||
graph_nodes_ptr, data_layout->num_entries[SharedDataLayout::GRAPH_NODE_LIST]);
|
graph_nodes_ptr, data_layout->num_entries[storage::SharedDataLayout::GRAPH_NODE_LIST]);
|
||||||
typename util::ShM<GraphEdge, true>::vector edge_list(
|
typename util::ShM<GraphEdge, true>::vector edge_list(
|
||||||
graph_edges_ptr, data_layout->num_entries[SharedDataLayout::GRAPH_EDGE_LIST]);
|
graph_edges_ptr, data_layout->num_entries[storage::SharedDataLayout::GRAPH_EDGE_LIST]);
|
||||||
m_query_graph.reset(new QueryGraph(node_list, edge_list));
|
m_query_graph.reset(new QueryGraph(node_list, edge_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,56 +129,56 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
util::FixedPointCoordinate *coordinate_list_ptr =
|
util::FixedPointCoordinate *coordinate_list_ptr =
|
||||||
data_layout->GetBlockPtr<util::FixedPointCoordinate>(shared_memory,
|
data_layout->GetBlockPtr<util::FixedPointCoordinate>(shared_memory,
|
||||||
SharedDataLayout::COORDINATE_LIST);
|
storage::SharedDataLayout::COORDINATE_LIST);
|
||||||
m_coordinate_list = util::make_unique<util::ShM<util::FixedPointCoordinate, true>::vector>(
|
m_coordinate_list = util::make_unique<util::ShM<util::FixedPointCoordinate, true>::vector>(
|
||||||
coordinate_list_ptr, data_layout->num_entries[SharedDataLayout::COORDINATE_LIST]);
|
coordinate_list_ptr, data_layout->num_entries[storage::SharedDataLayout::COORDINATE_LIST]);
|
||||||
|
|
||||||
extractor::TravelMode *travel_mode_list_ptr =
|
extractor::TravelMode *travel_mode_list_ptr =
|
||||||
data_layout->GetBlockPtr<extractor::TravelMode>(shared_memory,
|
data_layout->GetBlockPtr<extractor::TravelMode>(shared_memory,
|
||||||
SharedDataLayout::TRAVEL_MODE);
|
storage::SharedDataLayout::TRAVEL_MODE);
|
||||||
typename util::ShM<extractor::TravelMode, true>::vector travel_mode_list(
|
typename util::ShM<extractor::TravelMode, true>::vector travel_mode_list(
|
||||||
travel_mode_list_ptr, data_layout->num_entries[SharedDataLayout::TRAVEL_MODE]);
|
travel_mode_list_ptr, data_layout->num_entries[storage::SharedDataLayout::TRAVEL_MODE]);
|
||||||
m_travel_mode_list.swap(travel_mode_list);
|
m_travel_mode_list.swap(travel_mode_list);
|
||||||
|
|
||||||
extractor::TurnInstruction *turn_instruction_list_ptr =
|
extractor::TurnInstruction *turn_instruction_list_ptr =
|
||||||
data_layout->GetBlockPtr<extractor::TurnInstruction>(
|
data_layout->GetBlockPtr<extractor::TurnInstruction>(
|
||||||
shared_memory, SharedDataLayout::TURN_INSTRUCTION);
|
shared_memory, storage::SharedDataLayout::TURN_INSTRUCTION);
|
||||||
typename util::ShM<extractor::TurnInstruction, true>::vector turn_instruction_list(
|
typename util::ShM<extractor::TurnInstruction, true>::vector turn_instruction_list(
|
||||||
turn_instruction_list_ptr,
|
turn_instruction_list_ptr,
|
||||||
data_layout->num_entries[SharedDataLayout::TURN_INSTRUCTION]);
|
data_layout->num_entries[storage::SharedDataLayout::TURN_INSTRUCTION]);
|
||||||
m_turn_instruction_list.swap(turn_instruction_list);
|
m_turn_instruction_list.swap(turn_instruction_list);
|
||||||
|
|
||||||
unsigned *name_id_list_ptr =
|
unsigned *name_id_list_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_ID_LIST);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, storage::SharedDataLayout::NAME_ID_LIST);
|
||||||
typename util::ShM<unsigned, true>::vector name_id_list(
|
typename util::ShM<unsigned, true>::vector name_id_list(
|
||||||
name_id_list_ptr, data_layout->num_entries[SharedDataLayout::NAME_ID_LIST]);
|
name_id_list_ptr, data_layout->num_entries[storage::SharedDataLayout::NAME_ID_LIST]);
|
||||||
m_name_ID_list.swap(name_id_list);
|
m_name_ID_list.swap(name_id_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadViaNodeList()
|
void LoadViaNodeList()
|
||||||
{
|
{
|
||||||
NodeID *via_node_list_ptr =
|
NodeID *via_node_list_ptr =
|
||||||
data_layout->GetBlockPtr<NodeID>(shared_memory, SharedDataLayout::VIA_NODE_LIST);
|
data_layout->GetBlockPtr<NodeID>(shared_memory, storage::SharedDataLayout::VIA_NODE_LIST);
|
||||||
typename util::ShM<NodeID, true>::vector via_node_list(
|
typename util::ShM<NodeID, true>::vector via_node_list(
|
||||||
via_node_list_ptr, data_layout->num_entries[SharedDataLayout::VIA_NODE_LIST]);
|
via_node_list_ptr, data_layout->num_entries[storage::SharedDataLayout::VIA_NODE_LIST]);
|
||||||
m_via_node_list.swap(via_node_list);
|
m_via_node_list.swap(via_node_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadNames()
|
void LoadNames()
|
||||||
{
|
{
|
||||||
unsigned *offsets_ptr =
|
unsigned *offsets_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_OFFSETS);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, storage::SharedDataLayout::NAME_OFFSETS);
|
||||||
NameIndexBlock *blocks_ptr =
|
NameIndexBlock *blocks_ptr =
|
||||||
data_layout->GetBlockPtr<NameIndexBlock>(shared_memory, SharedDataLayout::NAME_BLOCKS);
|
data_layout->GetBlockPtr<NameIndexBlock>(shared_memory, storage::SharedDataLayout::NAME_BLOCKS);
|
||||||
typename util::ShM<unsigned, true>::vector name_offsets(
|
typename util::ShM<unsigned, true>::vector name_offsets(
|
||||||
offsets_ptr, data_layout->num_entries[SharedDataLayout::NAME_OFFSETS]);
|
offsets_ptr, data_layout->num_entries[storage::SharedDataLayout::NAME_OFFSETS]);
|
||||||
typename util::ShM<NameIndexBlock, true>::vector name_blocks(
|
typename util::ShM<NameIndexBlock, true>::vector name_blocks(
|
||||||
blocks_ptr, data_layout->num_entries[SharedDataLayout::NAME_BLOCKS]);
|
blocks_ptr, data_layout->num_entries[storage::SharedDataLayout::NAME_BLOCKS]);
|
||||||
|
|
||||||
char *names_list_ptr =
|
char *names_list_ptr =
|
||||||
data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::NAME_CHAR_LIST);
|
data_layout->GetBlockPtr<char>(shared_memory, storage::SharedDataLayout::NAME_CHAR_LIST);
|
||||||
typename util::ShM<char, true>::vector names_char_list(
|
typename util::ShM<char, true>::vector names_char_list(
|
||||||
names_list_ptr, data_layout->num_entries[SharedDataLayout::NAME_CHAR_LIST]);
|
names_list_ptr, data_layout->num_entries[storage::SharedDataLayout::NAME_CHAR_LIST]);
|
||||||
m_name_table = util::make_unique<util::RangeTable<16, true>>(
|
m_name_table = util::make_unique<util::RangeTable<16, true>>(
|
||||||
name_offsets, name_blocks, static_cast<unsigned>(names_char_list.size()));
|
name_offsets, name_blocks, static_cast<unsigned>(names_char_list.size()));
|
||||||
|
|
||||||
@ -186,37 +187,37 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
void LoadCoreInformation()
|
void LoadCoreInformation()
|
||||||
{
|
{
|
||||||
if (data_layout->num_entries[SharedDataLayout::CORE_MARKER] <= 0)
|
if (data_layout->num_entries[storage::SharedDataLayout::CORE_MARKER] <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned *core_marker_ptr =
|
unsigned *core_marker_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::CORE_MARKER);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, storage::SharedDataLayout::CORE_MARKER);
|
||||||
typename util::ShM<bool, true>::vector is_core_node(
|
typename util::ShM<bool, true>::vector is_core_node(
|
||||||
core_marker_ptr, data_layout->num_entries[SharedDataLayout::CORE_MARKER]);
|
core_marker_ptr, data_layout->num_entries[storage::SharedDataLayout::CORE_MARKER]);
|
||||||
m_is_core_node.swap(is_core_node);
|
m_is_core_node.swap(is_core_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGeometries()
|
void LoadGeometries()
|
||||||
{
|
{
|
||||||
unsigned *geometries_compressed_ptr = data_layout->GetBlockPtr<unsigned>(
|
unsigned *geometries_compressed_ptr = data_layout->GetBlockPtr<unsigned>(
|
||||||
shared_memory, SharedDataLayout::GEOMETRIES_INDICATORS);
|
shared_memory, storage::SharedDataLayout::GEOMETRIES_INDICATORS);
|
||||||
typename util::ShM<bool, true>::vector edge_is_compressed(
|
typename util::ShM<bool, true>::vector edge_is_compressed(
|
||||||
geometries_compressed_ptr,
|
geometries_compressed_ptr,
|
||||||
data_layout->num_entries[SharedDataLayout::GEOMETRIES_INDICATORS]);
|
data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_INDICATORS]);
|
||||||
m_edge_is_compressed.swap(edge_is_compressed);
|
m_edge_is_compressed.swap(edge_is_compressed);
|
||||||
|
|
||||||
unsigned *geometries_index_ptr =
|
unsigned *geometries_index_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::GEOMETRIES_INDEX);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, storage::SharedDataLayout::GEOMETRIES_INDEX);
|
||||||
typename util::ShM<unsigned, true>::vector geometry_begin_indices(
|
typename util::ShM<unsigned, true>::vector geometry_begin_indices(
|
||||||
geometries_index_ptr, data_layout->num_entries[SharedDataLayout::GEOMETRIES_INDEX]);
|
geometries_index_ptr, data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_INDEX]);
|
||||||
m_geometry_indices.swap(geometry_begin_indices);
|
m_geometry_indices.swap(geometry_begin_indices);
|
||||||
|
|
||||||
unsigned *geometries_list_ptr =
|
unsigned *geometries_list_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::GEOMETRIES_LIST);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, storage::SharedDataLayout::GEOMETRIES_LIST);
|
||||||
typename util::ShM<unsigned, true>::vector geometry_list(
|
typename util::ShM<unsigned, true>::vector geometry_list(
|
||||||
geometries_list_ptr, data_layout->num_entries[SharedDataLayout::GEOMETRIES_LIST]);
|
geometries_list_ptr, data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_LIST]);
|
||||||
m_geometry_list.swap(geometry_list);
|
m_geometry_list.swap(geometry_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,15 +228,16 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
SharedDataFacade()
|
SharedDataFacade()
|
||||||
{
|
{
|
||||||
if (!datastore::SharedMemory::RegionExists(CURRENT_REGIONS))
|
if (!storage::SharedMemory::RegionExists(storage::CURRENT_REGIONS))
|
||||||
{
|
{
|
||||||
throw util::exception("No shared memory blocks found, have you forgotten to run osrm-datastore?");
|
throw util::exception("No shared memory blocks found, have you forgotten to run osrm-datastore?");
|
||||||
}
|
}
|
||||||
data_timestamp_ptr = (SharedDataTimestamp *)datastore::SharedMemoryFactory::Get(
|
data_timestamp_ptr = static_cast<storage::SharedDataTimestamp *>(
|
||||||
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)
|
storage::makeSharedMemory(storage::CURRENT_REGIONS,
|
||||||
->Ptr();
|
sizeof(storage::SharedDataTimestamp), false, false)
|
||||||
CURRENT_LAYOUT = LAYOUT_NONE;
|
->Ptr());
|
||||||
CURRENT_DATA = DATA_NONE;
|
CURRENT_LAYOUT = storage::LAYOUT_NONE;
|
||||||
|
CURRENT_DATA = storage::DATA_NONE;
|
||||||
CURRENT_TIMESTAMP = 0;
|
CURRENT_TIMESTAMP = 0;
|
||||||
|
|
||||||
// load data
|
// load data
|
||||||
@ -248,7 +250,6 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
CURRENT_DATA != data_timestamp_ptr->data ||
|
CURRENT_DATA != data_timestamp_ptr->data ||
|
||||||
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
|
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get exclusive lock
|
// Get exclusive lock
|
||||||
util::SimpleLogger().Write(logDEBUG) << "Updates available, getting exclusive lock";
|
util::SimpleLogger().Write(logDEBUG) << "Updates available, getting exclusive lock";
|
||||||
boost::unique_lock<boost::shared_mutex> lock(data_mutex);
|
boost::unique_lock<boost::shared_mutex> lock(data_mutex);
|
||||||
@ -257,8 +258,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
CURRENT_DATA != data_timestamp_ptr->data)
|
CURRENT_DATA != data_timestamp_ptr->data)
|
||||||
{
|
{
|
||||||
// release the previous shared memory segments
|
// release the previous shared memory segments
|
||||||
datastore::SharedMemory::Remove(CURRENT_LAYOUT);
|
storage::SharedMemory::Remove(CURRENT_LAYOUT);
|
||||||
datastore::SharedMemory::Remove(CURRENT_DATA);
|
storage::SharedMemory::Remove(CURRENT_DATA);
|
||||||
|
|
||||||
CURRENT_LAYOUT = data_timestamp_ptr->layout;
|
CURRENT_LAYOUT = data_timestamp_ptr->layout;
|
||||||
CURRENT_DATA = data_timestamp_ptr->data;
|
CURRENT_DATA = data_timestamp_ptr->data;
|
||||||
@ -277,15 +278,15 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;
|
CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;
|
||||||
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "Performing data reload";
|
util::SimpleLogger().Write(logDEBUG) << "Performing data reload";
|
||||||
m_layout_memory.reset(datastore::SharedMemoryFactory::Get(CURRENT_LAYOUT));
|
m_layout_memory.reset(storage::makeSharedMemory(CURRENT_LAYOUT));
|
||||||
|
|
||||||
data_layout = (SharedDataLayout *) (m_layout_memory->Ptr());
|
data_layout = (storage::SharedDataLayout *) (m_layout_memory->Ptr());
|
||||||
|
|
||||||
m_large_memory.reset(datastore::SharedMemoryFactory::Get(CURRENT_DATA));
|
m_large_memory.reset(storage::makeSharedMemory(CURRENT_DATA));
|
||||||
shared_memory = (char *) (m_large_memory->Ptr());
|
shared_memory = (char *) (m_large_memory->Ptr());
|
||||||
|
|
||||||
const char *file_index_ptr =
|
const char *file_index_ptr =
|
||||||
data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::FILE_INDEX_PATH);
|
data_layout->GetBlockPtr<char>(shared_memory, storage::SharedDataLayout::FILE_INDEX_PATH);
|
||||||
file_index_path = boost::filesystem::path(file_index_ptr);
|
file_index_path = boost::filesystem::path(file_index_ptr);
|
||||||
if (!boost::filesystem::exists(file_index_path)) {
|
if (!boost::filesystem::exists(file_index_path)) {
|
||||||
util::SimpleLogger().Write(logDEBUG) << "Leaf file name "
|
util::SimpleLogger().Write(logDEBUG) << "Leaf file name "
|
||||||
@ -303,8 +304,6 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
LoadNames();
|
LoadNames();
|
||||||
LoadCoreInformation();
|
LoadCoreInformation();
|
||||||
|
|
||||||
data_layout->PrintInformation();
|
|
||||||
|
|
||||||
util::SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
|
util::SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
|
||||||
for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
|
for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#ifndef OSRM_IMPL_HPP
|
#ifndef ENGINE_HPP
|
||||||
#define OSRM_IMPL_HPP
|
#define ENGINE_HPP
|
||||||
|
|
||||||
#include "contractor/query_edge.hpp"
|
#include "contractor/query_edge.hpp"
|
||||||
|
|
||||||
#include "osrm/json_container.hpp"
|
#include "osrm/json_container.hpp"
|
||||||
#include "osrm/libosrm_config.hpp"
|
|
||||||
#include "osrm/osrm.hpp"
|
#include "osrm/osrm.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -14,6 +13,11 @@
|
|||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace storage
|
||||||
|
{
|
||||||
|
struct SharedBarriers;
|
||||||
|
}
|
||||||
|
|
||||||
namespace util
|
namespace util
|
||||||
{
|
{
|
||||||
namespace json
|
namespace json
|
||||||
@ -24,33 +28,32 @@ struct Object;
|
|||||||
|
|
||||||
namespace engine
|
namespace engine
|
||||||
{
|
{
|
||||||
|
struct EngineConfig;
|
||||||
struct RouteParameters;
|
struct RouteParameters;
|
||||||
namespace plugins
|
namespace plugins
|
||||||
{
|
{
|
||||||
class BasePlugin;
|
class BasePlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace datafacade
|
namespace datafacade
|
||||||
{
|
{
|
||||||
struct SharedBarriers;
|
|
||||||
template <class EdgeDataT> class BaseDataFacade;
|
template <class EdgeDataT> class BaseDataFacade;
|
||||||
}
|
}
|
||||||
|
|
||||||
class OSRM::OSRM_impl final
|
class Engine final
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using PluginMap = std::unordered_map<std::string, std::unique_ptr<plugins::BasePlugin>>;
|
using PluginMap = std::unordered_map<std::string, std::unique_ptr<plugins::BasePlugin>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSRM_impl(LibOSRMConfig &lib_config);
|
Engine(EngineConfig &config_);
|
||||||
OSRM_impl(const OSRM_impl &) = delete;
|
Engine(const Engine &) = delete;
|
||||||
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RegisterPlugin(plugins::BasePlugin *plugin);
|
void RegisterPlugin(plugins::BasePlugin *plugin);
|
||||||
PluginMap plugin_map;
|
PluginMap plugin_map;
|
||||||
// will only be initialized if shared memory is used
|
// will only be initialized if shared memory is used
|
||||||
std::unique_ptr<datafacade::SharedBarriers> barrier;
|
std::unique_ptr<storage::SharedBarriers> barrier;
|
||||||
// base class pointer to the objects
|
// base class pointer to the objects
|
||||||
datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData> *query_data_facade;
|
datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData> *query_data_facade;
|
||||||
|
|
@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBOSRM_CONFIG_HPP
|
#ifndef ENGINE_CONFIG_HPP
|
||||||
#define LIBOSRM_CONFIG_HPP
|
#define ENGINE_CONFIG_HPP
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
@ -36,7 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
|
||||||
struct LibOSRMConfig
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
|
struct EngineConfig
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
||||||
int max_locations_trip = -1;
|
int max_locations_trip = -1;
|
||||||
@ -45,6 +48,8 @@ struct LibOSRMConfig
|
|||||||
int max_locations_map_matching = -1;
|
int max_locations_map_matching = -1;
|
||||||
bool use_shared_memory = true;
|
bool use_shared_memory = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SERVER_CONFIG_HPP
|
#endif // SERVER_CONFIG_HPP
|
@ -30,9 +30,63 @@ struct PhantomNode
|
|||||||
util::FixedPointCoordinate &location,
|
util::FixedPointCoordinate &location,
|
||||||
unsigned short fwd_segment_position,
|
unsigned short fwd_segment_position,
|
||||||
extractor::TravelMode forward_travel_mode,
|
extractor::TravelMode forward_travel_mode,
|
||||||
extractor::TravelMode backward_travel_mode);
|
extractor::TravelMode backward_travel_mode)
|
||||||
|
: forward_node_id(forward_node_id), reverse_node_id(reverse_node_id), name_id(name_id),
|
||||||
|
forward_weight(forward_weight), reverse_weight(reverse_weight),
|
||||||
|
forward_offset(forward_offset), reverse_offset(reverse_offset),
|
||||||
|
packed_geometry_id(packed_geometry_id), component{component_id, is_tiny_component},
|
||||||
|
location(location), fwd_segment_position(fwd_segment_position),
|
||||||
|
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PhantomNode();
|
PhantomNode()
|
||||||
|
: forward_node_id(SPECIAL_NODEID), reverse_node_id(SPECIAL_NODEID),
|
||||||
|
name_id(std::numeric_limits<unsigned>::max()), forward_weight(INVALID_EDGE_WEIGHT),
|
||||||
|
reverse_weight(INVALID_EDGE_WEIGHT), forward_offset(0), reverse_offset(0),
|
||||||
|
packed_geometry_id(SPECIAL_EDGEID), component{INVALID_COMPONENTID, false},
|
||||||
|
fwd_segment_position(0), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||||
|
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetForwardWeightPlusOffset() const
|
||||||
|
{
|
||||||
|
if (SPECIAL_NODEID == forward_node_id)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return forward_offset + forward_weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetReverseWeightPlusOffset() const
|
||||||
|
{
|
||||||
|
if (SPECIAL_NODEID == reverse_node_id)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return reverse_offset + reverse_weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsBidirected() const
|
||||||
|
{
|
||||||
|
return (forward_node_id != SPECIAL_NODEID) && (reverse_node_id != SPECIAL_NODEID);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsCompressed() const { return (forward_offset != 0) || (reverse_offset != 0); }
|
||||||
|
|
||||||
|
bool IsValid(const unsigned number_of_nodes) const
|
||||||
|
{
|
||||||
|
return location.IsValid() &&
|
||||||
|
((forward_node_id < number_of_nodes) || (reverse_node_id < number_of_nodes)) &&
|
||||||
|
((forward_weight != INVALID_EDGE_WEIGHT) ||
|
||||||
|
(reverse_weight != INVALID_EDGE_WEIGHT)) &&
|
||||||
|
(component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValid() const { return location.IsValid() && (name_id != INVALID_NAMEID); }
|
||||||
|
|
||||||
|
bool operator==(const PhantomNode &other) const { return location == other.location; }
|
||||||
|
|
||||||
template <class OtherT>
|
template <class OtherT>
|
||||||
PhantomNode(const OtherT &other, const util::FixedPointCoordinate &foot_point)
|
PhantomNode(const OtherT &other, const util::FixedPointCoordinate &foot_point)
|
||||||
@ -82,20 +136,6 @@ struct PhantomNode
|
|||||||
// but the saved byte would be padding anyway
|
// but the saved byte would be padding anyway
|
||||||
extractor::TravelMode forward_travel_mode;
|
extractor::TravelMode forward_travel_mode;
|
||||||
extractor::TravelMode backward_travel_mode;
|
extractor::TravelMode backward_travel_mode;
|
||||||
|
|
||||||
int GetForwardWeightPlusOffset() const;
|
|
||||||
|
|
||||||
int GetReverseWeightPlusOffset() const;
|
|
||||||
|
|
||||||
bool IsBidirected() const;
|
|
||||||
|
|
||||||
bool IsCompressed() const;
|
|
||||||
|
|
||||||
bool is_valid(const unsigned numberOfNodes) const;
|
|
||||||
|
|
||||||
bool IsValid() const;
|
|
||||||
|
|
||||||
bool operator==(const PhantomNode &other) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
@ -96,7 +96,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
{
|
{
|
||||||
PhantomNode current_phantom_node;
|
PhantomNode current_phantom_node;
|
||||||
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], current_phantom_node);
|
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], current_phantom_node);
|
||||||
if (current_phantom_node.is_valid(facade->GetNumberOfNodes()))
|
if (current_phantom_node.IsValid(facade->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
if (route_parameters.is_source[i])
|
if (route_parameters.is_source[i])
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||||
route_parameters.coordinates[i], bearing, range);
|
route_parameters.coordinates[i], bearing, range);
|
||||||
// we didn't found a fitting node, return error
|
// we didn't found a fitting node, return error
|
||||||
if (!phantom_node_source_out_iter->first.is_valid(facade->GetNumberOfNodes()))
|
if (!phantom_node_source_out_iter->first.IsValid(facade->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
json_result.values["status_message"] =
|
||||||
std::string("Could not find a matching segment for coordinate ") +
|
std::string("Could not find a matching segment for coordinate ") +
|
||||||
@ -153,7 +153,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||||
route_parameters.coordinates[i], bearing, range);
|
route_parameters.coordinates[i], bearing, range);
|
||||||
// we didn't found a fitting node, return error
|
// we didn't found a fitting node, return error
|
||||||
if (!phantom_node_target_out_iter->first.is_valid(facade->GetNumberOfNodes()))
|
if (!phantom_node_target_out_iter->first.IsValid(facade->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
json_result.values["status_message"] =
|
||||||
std::string("Could not find a matching segment for coordinate ") +
|
std::string("Could not find a matching segment for coordinate ") +
|
||||||
|
@ -66,7 +66,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
{
|
{
|
||||||
PhantomNode current_phantom_node;
|
PhantomNode current_phantom_node;
|
||||||
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], current_phantom_node);
|
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], current_phantom_node);
|
||||||
if (current_phantom_node.is_valid(facade->GetNumberOfNodes()))
|
if (current_phantom_node.IsValid(facade->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
phantom_node_list.push_back(std::move(current_phantom_node));
|
phantom_node_list.push_back(std::move(current_phantom_node));
|
||||||
continue;
|
continue;
|
||||||
@ -83,7 +83,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
phantom_node_list.push_back(std::move(results.front().phantom_node));
|
phantom_node_list.push_back(std::move(results.front().phantom_node));
|
||||||
BOOST_ASSERT(phantom_node_list.back().is_valid(facade->GetNumberOfNodes()));
|
BOOST_ASSERT(phantom_node_list.back().IsValid(facade->GetNumberOfNodes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return phantom_node_list;
|
return phantom_node_list;
|
||||||
|
@ -85,7 +85,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
{
|
{
|
||||||
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i],
|
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i],
|
||||||
phantom_node_pair_list[i].first);
|
phantom_node_pair_list[i].first);
|
||||||
if (phantom_node_pair_list[i].first.is_valid(facade->GetNumberOfNodes()))
|
if (phantom_node_pair_list[i].first.IsValid(facade->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -97,15 +97,15 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
phantom_node_pair_list[i] = facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
phantom_node_pair_list[i] = facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||||
route_parameters.coordinates[i], bearing, range);
|
route_parameters.coordinates[i], bearing, range);
|
||||||
// we didn't found a fitting node, return error
|
// we didn't found a fitting node, return error
|
||||||
if (!phantom_node_pair_list[i].first.is_valid(facade->GetNumberOfNodes()))
|
if (!phantom_node_pair_list[i].first.IsValid(facade->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
json_result.values["status_message"] =
|
||||||
std::string("Could not find a matching segment for coordinate ") +
|
std::string("Could not find a matching segment for coordinate ") +
|
||||||
std::to_string(i);
|
std::to_string(i);
|
||||||
return Status::NoSegment;
|
return Status::NoSegment;
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(phantom_node_pair_list[i].first.is_valid(facade->GetNumberOfNodes()));
|
BOOST_ASSERT(phantom_node_pair_list[i].first.IsValid(facade->GetNumberOfNodes()));
|
||||||
BOOST_ASSERT(phantom_node_pair_list[i].second.is_valid(facade->GetNumberOfNodes()));
|
BOOST_ASSERT(phantom_node_pair_list[i].second.IsValid(facade->GetNumberOfNodes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto snapped_phantoms = snapPhantomNodes(phantom_node_pair_list);
|
auto snapped_phantoms = snapPhantomNodes(phantom_node_pair_list);
|
||||||
|
125
include/engine/route_parameters.hpp
Normal file
125
include/engine/route_parameters.hpp
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2016, Project OSRM contributors
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ROUTE_PARAMETERS_HPP
|
||||||
|
#define ROUTE_PARAMETERS_HPP
|
||||||
|
|
||||||
|
#include "osrm/coordinate.hpp"
|
||||||
|
|
||||||
|
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||||
|
#include <boost/spirit/include/qi.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
|
struct RouteParameters
|
||||||
|
{
|
||||||
|
RouteParameters();
|
||||||
|
|
||||||
|
void SetZoomLevel(const short level);
|
||||||
|
|
||||||
|
void SetNumberOfResults(const short number);
|
||||||
|
|
||||||
|
void SetAlternateRouteFlag(const bool flag);
|
||||||
|
|
||||||
|
void SetUTurn(const bool flag);
|
||||||
|
|
||||||
|
void SetAllUTurns(const bool flag);
|
||||||
|
|
||||||
|
void SetClassify(const bool classify);
|
||||||
|
|
||||||
|
void SetMatchingBeta(const double beta);
|
||||||
|
|
||||||
|
void SetGPSPrecision(const double precision);
|
||||||
|
|
||||||
|
void SetDeprecatedAPIFlag(const std::string &);
|
||||||
|
|
||||||
|
void SetChecksum(const unsigned check_sum);
|
||||||
|
|
||||||
|
void SetInstructionFlag(const bool flag);
|
||||||
|
|
||||||
|
void SetService(const std::string &service);
|
||||||
|
|
||||||
|
void SetOutputFormat(const std::string &format);
|
||||||
|
|
||||||
|
void SetJSONpParameter(const std::string ¶meter);
|
||||||
|
|
||||||
|
void AddHint(const std::string &hint);
|
||||||
|
|
||||||
|
void AddTimestamp(const unsigned timestamp);
|
||||||
|
|
||||||
|
void AddBearing(const boost::fusion::vector<int, boost::optional<int>> &received_bearing,
|
||||||
|
boost::spirit::qi::unused_type unused,
|
||||||
|
bool &pass);
|
||||||
|
|
||||||
|
void SetLanguage(const std::string &language);
|
||||||
|
|
||||||
|
void SetGeometryFlag(const bool flag);
|
||||||
|
|
||||||
|
void SetCompressionFlag(const bool flag);
|
||||||
|
|
||||||
|
void AddCoordinate(const boost::fusion::vector<double, double> &received_coordinates);
|
||||||
|
|
||||||
|
void AddDestination(const boost::fusion::vector<double, double> &received_coordinates);
|
||||||
|
|
||||||
|
void AddSource(const boost::fusion::vector<double, double> &received_coordinates);
|
||||||
|
|
||||||
|
void SetCoordinatesFromGeometry(const std::string &geometry_string);
|
||||||
|
|
||||||
|
short zoom_level;
|
||||||
|
bool print_instructions;
|
||||||
|
bool alternate_route;
|
||||||
|
bool geometry;
|
||||||
|
bool compression;
|
||||||
|
bool deprecatedAPI;
|
||||||
|
bool uturn_default;
|
||||||
|
bool classify;
|
||||||
|
double matching_beta;
|
||||||
|
double gps_precision;
|
||||||
|
unsigned check_sum;
|
||||||
|
short num_results;
|
||||||
|
std::string service;
|
||||||
|
std::string output_format;
|
||||||
|
std::string jsonp_parameter;
|
||||||
|
std::string language;
|
||||||
|
std::vector<std::string> hints;
|
||||||
|
std::vector<unsigned> timestamps;
|
||||||
|
std::vector<std::pair<const int, const boost::optional<int>>> bearings;
|
||||||
|
std::vector<bool> uturns;
|
||||||
|
std::vector<FixedPointCoordinate> coordinates;
|
||||||
|
std::vector<bool> is_destination;
|
||||||
|
std::vector<bool> is_source;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ROUTE_PARAMETERS_HPP
|
@ -12,13 +12,23 @@ namespace extractor
|
|||||||
|
|
||||||
struct ExternalMemoryNode : QueryNode
|
struct ExternalMemoryNode : QueryNode
|
||||||
{
|
{
|
||||||
ExternalMemoryNode(int lat, int lon, OSMNodeID id, bool barrier, bool traffic_light);
|
ExternalMemoryNode(int lat, int lon, OSMNodeID node_id, bool barrier, bool traffic_lights)
|
||||||
|
: QueryNode(lat, lon, node_id), barrier(barrier), traffic_lights(traffic_lights)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ExternalMemoryNode();
|
ExternalMemoryNode() : barrier(false), traffic_lights(false) {}
|
||||||
|
|
||||||
static ExternalMemoryNode min_value();
|
static ExternalMemoryNode min_value()
|
||||||
|
{
|
||||||
|
return ExternalMemoryNode(0, 0, MIN_OSM_NODEID, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
static ExternalMemoryNode max_value();
|
static ExternalMemoryNode max_value()
|
||||||
|
{
|
||||||
|
return ExternalMemoryNode(std::numeric_limits<int>::max(), std::numeric_limits<int>::max(),
|
||||||
|
MAX_OSM_NODEID, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
bool barrier;
|
bool barrier;
|
||||||
bool traffic_lights;
|
bool traffic_lights;
|
||||||
@ -27,9 +37,12 @@ struct ExternalMemoryNode : QueryNode
|
|||||||
struct ExternalMemoryNodeSTXXLCompare
|
struct ExternalMemoryNodeSTXXLCompare
|
||||||
{
|
{
|
||||||
using value_type = ExternalMemoryNode;
|
using value_type = ExternalMemoryNode;
|
||||||
bool operator()(const ExternalMemoryNode &left, const ExternalMemoryNode &right) const;
|
value_type max_value() { return value_type::max_value(); }
|
||||||
value_type max_value();
|
value_type min_value() { return value_type::min_value(); }
|
||||||
value_type min_value();
|
bool operator()(const value_type &left, const value_type &right) const
|
||||||
|
{
|
||||||
|
return left.node_id < right.node_id;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define EXTRACTOR_HPP
|
#define EXTRACTOR_HPP
|
||||||
|
|
||||||
#include "extractor/edge_based_edge.hpp"
|
#include "extractor/edge_based_edge.hpp"
|
||||||
#include "extractor/extractor_options.hpp"
|
#include "extractor/extractor_config.hpp"
|
||||||
#include "extractor/edge_based_graph_factory.hpp"
|
#include "extractor/edge_based_graph_factory.hpp"
|
||||||
#include "extractor/graph_compressor.hpp"
|
#include "extractor/graph_compressor.hpp"
|
||||||
|
|
||||||
|
78
include/extractor/extractor_config.hpp
Normal file
78
include/extractor/extractor_config.hpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#ifndef EXTRACTOR_CONFIG_HPP
|
||||||
|
#define EXTRACTOR_CONFIG_HPP
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ExtractorConfig
|
||||||
|
{
|
||||||
|
ExtractorConfig() noexcept : requested_num_threads(0) {}
|
||||||
|
void UseDefaultOutputNames()
|
||||||
|
{
|
||||||
|
std::string basepath = input_path.string();
|
||||||
|
|
||||||
|
auto pos = std::string::npos;
|
||||||
|
std::array<std::string, 5> known_extensions{
|
||||||
|
{".osm.bz2", ".osm.pbf", ".osm.xml", ".pbf", ".osm"}};
|
||||||
|
for (auto ext : known_extensions)
|
||||||
|
{
|
||||||
|
pos = basepath.find(ext);
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
basepath.replace(pos, ext.size(), "");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output_file_name = basepath + ".osrm";
|
||||||
|
restriction_file_name = basepath + ".osrm.restrictions";
|
||||||
|
names_file_name = basepath + ".osrm.names";
|
||||||
|
timestamp_file_name = basepath + ".osrm.timestamp";
|
||||||
|
geometry_output_path = basepath + ".osrm.geometry";
|
||||||
|
node_output_path = basepath + ".osrm.nodes";
|
||||||
|
edge_output_path = basepath + ".osrm.edges";
|
||||||
|
edge_graph_output_path = basepath + ".osrm.ebg";
|
||||||
|
rtree_nodes_output_path = basepath + ".osrm.ramIndex";
|
||||||
|
rtree_leafs_output_path = basepath + ".osrm.fileIndex";
|
||||||
|
edge_segment_lookup_path = basepath + ".osrm.edge_segment_lookup";
|
||||||
|
edge_penalty_path = basepath + ".osrm.edge_penalties";
|
||||||
|
edge_based_node_weights_output_path = basepath + ".osrm.enw";
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path config_file_path;
|
||||||
|
boost::filesystem::path input_path;
|
||||||
|
boost::filesystem::path profile_path;
|
||||||
|
|
||||||
|
std::string output_file_name;
|
||||||
|
std::string restriction_file_name;
|
||||||
|
std::string names_file_name;
|
||||||
|
std::string timestamp_file_name;
|
||||||
|
std::string geometry_output_path;
|
||||||
|
std::string edge_output_path;
|
||||||
|
std::string edge_graph_output_path;
|
||||||
|
std::string edge_based_node_weights_output_path;
|
||||||
|
std::string node_output_path;
|
||||||
|
std::string rtree_nodes_output_path;
|
||||||
|
std::string rtree_leafs_output_path;
|
||||||
|
|
||||||
|
unsigned requested_num_threads;
|
||||||
|
unsigned small_component_size;
|
||||||
|
|
||||||
|
bool generate_edge_lookup;
|
||||||
|
std::string edge_penalty_path;
|
||||||
|
std::string edge_segment_lookup_path;
|
||||||
|
#ifdef DEBUG_GEOMETRY
|
||||||
|
std::string debug_turns_path;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EXTRACTOR_CONFIG_HPP
|
@ -1,63 +0,0 @@
|
|||||||
#ifndef EXTRACTOR_OPTIONS_HPP
|
|
||||||
#define EXTRACTOR_OPTIONS_HPP
|
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace extractor
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class return_code : unsigned
|
|
||||||
{
|
|
||||||
ok,
|
|
||||||
fail,
|
|
||||||
exit
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExtractorConfig
|
|
||||||
{
|
|
||||||
ExtractorConfig() : requested_num_threads(0) {}
|
|
||||||
boost::filesystem::path config_file_path;
|
|
||||||
boost::filesystem::path input_path;
|
|
||||||
boost::filesystem::path profile_path;
|
|
||||||
|
|
||||||
std::string output_file_name;
|
|
||||||
std::string restriction_file_name;
|
|
||||||
std::string names_file_name;
|
|
||||||
std::string timestamp_file_name;
|
|
||||||
std::string geometry_output_path;
|
|
||||||
std::string edge_output_path;
|
|
||||||
std::string edge_graph_output_path;
|
|
||||||
std::string node_output_path;
|
|
||||||
std::string rtree_nodes_output_path;
|
|
||||||
std::string rtree_leafs_output_path;
|
|
||||||
|
|
||||||
// every edge based node represents a segment in the original graph. During contraciton we need
|
|
||||||
// to know about this segment length, as we might have to add self-loops in cases of shorter
|
|
||||||
// parts than the segment represents itself
|
|
||||||
std::string edge_based_node_weights_output_path;
|
|
||||||
|
|
||||||
unsigned requested_num_threads;
|
|
||||||
unsigned small_component_size;
|
|
||||||
|
|
||||||
bool generate_edge_lookup;
|
|
||||||
std::string edge_penalty_path;
|
|
||||||
std::string edge_segment_lookup_path;
|
|
||||||
#ifdef DEBUG_GEOMETRY
|
|
||||||
std::string debug_turns_path;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExtractorOptions
|
|
||||||
{
|
|
||||||
static return_code ParseArguments(int argc, char *argv[], ExtractorConfig &extractor_config);
|
|
||||||
|
|
||||||
static void GenerateOutputFilesNames(ExtractorConfig &extractor_config);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // EXTRACTOR_OPTIONS_HPP
|
|
@ -1,72 +1,11 @@
|
|||||||
/*
|
#ifndef GLOBAL_COORDINATE_HPP
|
||||||
|
#define GLOBAL_COORDINATE_HPP
|
||||||
|
|
||||||
Copyright (c) 2016, Project OSRM contributors
|
#include "util/coordinate.hpp"
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COORDINATE_HPP_
|
|
||||||
#define COORDINATE_HPP_
|
|
||||||
|
|
||||||
#include <iosfwd> //for std::ostream
|
|
||||||
#include <string>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
using util::FixedPointCoordinate;
|
||||||
constexpr static const double COORDINATE_PRECISION = 1000000.0;
|
|
||||||
|
|
||||||
namespace util
|
|
||||||
{
|
|
||||||
|
|
||||||
struct FixedPointCoordinate
|
|
||||||
{
|
|
||||||
int lat;
|
|
||||||
int lon;
|
|
||||||
|
|
||||||
FixedPointCoordinate();
|
|
||||||
FixedPointCoordinate(int lat, int lon);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
FixedPointCoordinate(const T &coordinate)
|
|
||||||
: lat(coordinate.lat), lon(coordinate.lon)
|
|
||||||
{
|
|
||||||
static_assert(std::is_same<decltype(lat), decltype(coordinate.lat)>::value,
|
|
||||||
"coordinate types incompatible");
|
|
||||||
static_assert(std::is_same<decltype(lon), decltype(coordinate.lon)>::value,
|
|
||||||
"coordinate types incompatible");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsValid() const;
|
|
||||||
bool operator==(const FixedPointCoordinate &other) const;
|
|
||||||
friend std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
|
|
||||||
};
|
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using util::FixedPointCoordinate;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* COORDINATE_HPP_ */
|
|
||||||
|
12
include/osrm/engine_config.hpp
Normal file
12
include/osrm/engine_config.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef GLOBAL_ENGINE_CONFIG_HPP
|
||||||
|
#define GLOBAL_ENGINE_CONFIG_HPP
|
||||||
|
|
||||||
|
#include "engine/engine_config.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
using engine::EngineConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,108 +1,8 @@
|
|||||||
/*
|
#ifndef GLOBAL_JSON_CONTAINER_HPP
|
||||||
|
#define GLOBAL_JSON_CONTAINER_HPP
|
||||||
Copyright (c) 2016, Project OSRM contributors
|
#include "util/json_container.hpp"
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// based on
|
|
||||||
// https://svn.apache.org/repos/asf/mesos/tags/release-0.9.0-incubating-RC0/src/common/json.hpp
|
|
||||||
|
|
||||||
#ifndef JSON_CONTAINER_HPP
|
|
||||||
#define JSON_CONTAINER_HPP
|
|
||||||
|
|
||||||
#include <variant/variant.hpp>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace json = osrm::util::json;
|
||||||
namespace util
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace json
|
|
||||||
{
|
|
||||||
|
|
||||||
struct Object;
|
|
||||||
struct Array;
|
|
||||||
|
|
||||||
struct String
|
|
||||||
{
|
|
||||||
String() {}
|
|
||||||
String(const char *value) : value(value) {}
|
|
||||||
String(std::string value) : value(std::move(value)) {}
|
|
||||||
std::string value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Number
|
|
||||||
{
|
|
||||||
Number() {}
|
|
||||||
Number(double value) : value(static_cast<double>(value)) {}
|
|
||||||
double value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct True
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
struct False
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Null
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
using Value = mapbox::util::variant<String,
|
|
||||||
Number,
|
|
||||||
mapbox::util::recursive_wrapper<Object>,
|
|
||||||
mapbox::util::recursive_wrapper<Array>,
|
|
||||||
True,
|
|
||||||
False,
|
|
||||||
Null>;
|
|
||||||
|
|
||||||
struct Object
|
|
||||||
{
|
|
||||||
std::unordered_map<std::string, Value> values;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Array
|
|
||||||
{
|
|
||||||
std::vector<Value> values;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace JSON
|
|
||||||
} // namespace util
|
|
||||||
|
|
||||||
namespace json
|
|
||||||
{
|
|
||||||
using namespace osrm::util::json;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} // namespace osrm
|
|
||||||
|
|
||||||
#endif // JSON_CONTAINER_HPP
|
|
||||||
|
@ -45,21 +45,26 @@ struct Object;
|
|||||||
|
|
||||||
namespace engine
|
namespace engine
|
||||||
{
|
{
|
||||||
|
class Engine;
|
||||||
|
struct EngineConfig;
|
||||||
struct RouteParameters;
|
struct RouteParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
using engine::EngineConfig;
|
||||||
|
using engine::RouteParameters;
|
||||||
|
namespace json = util::json;
|
||||||
|
|
||||||
class OSRM
|
class OSRM
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
class OSRM_impl;
|
std::unique_ptr<engine::Engine> engine_;
|
||||||
std::unique_ptr<OSRM_impl> OSRM_pimpl_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSRM(LibOSRMConfig &lib_config);
|
OSRM(EngineConfig &lib_config);
|
||||||
~OSRM(); // needed because we need to define it with the implementation of OSRM_impl
|
~OSRM(); // needed because we need to define it with the implementation of OSRM_impl
|
||||||
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
int RunQuery(const RouteParameters &route_parameters, json::Object &json_result);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
using engine::OSRM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OSRM_HPP
|
#endif // OSRM_HPP
|
||||||
|
@ -1,127 +1,11 @@
|
|||||||
/*
|
#ifndef GLOBAL_ROUTE_PARAMETERS_HPP
|
||||||
|
#define GLOBAL_ROUTE_PARAMETERS_HPP
|
||||||
|
|
||||||
Copyright (c) 2016, Project OSRM contributors
|
#include "engine/route_parameters.hpp"
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ROUTE_PARAMETERS_HPP
|
|
||||||
#define ROUTE_PARAMETERS_HPP
|
|
||||||
|
|
||||||
#include "coordinate.hpp"
|
|
||||||
|
|
||||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
|
||||||
#include <boost/spirit/include/qi.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace engine
|
using engine::RouteParameters;
|
||||||
{
|
|
||||||
|
|
||||||
struct RouteParameters
|
|
||||||
{
|
|
||||||
RouteParameters();
|
|
||||||
|
|
||||||
void SetZoomLevel(const short level);
|
|
||||||
|
|
||||||
void SetNumberOfResults(const short number);
|
|
||||||
|
|
||||||
void SetAlternateRouteFlag(const bool flag);
|
|
||||||
|
|
||||||
void SetUTurn(const bool flag);
|
|
||||||
|
|
||||||
void SetAllUTurns(const bool flag);
|
|
||||||
|
|
||||||
void SetClassify(const bool classify);
|
|
||||||
|
|
||||||
void SetMatchingBeta(const double beta);
|
|
||||||
|
|
||||||
void SetGPSPrecision(const double precision);
|
|
||||||
|
|
||||||
void SetDeprecatedAPIFlag(const std::string &);
|
|
||||||
|
|
||||||
void SetChecksum(const unsigned check_sum);
|
|
||||||
|
|
||||||
void SetInstructionFlag(const bool flag);
|
|
||||||
|
|
||||||
void SetService(const std::string &service);
|
|
||||||
|
|
||||||
void SetOutputFormat(const std::string &format);
|
|
||||||
|
|
||||||
void SetJSONpParameter(const std::string ¶meter);
|
|
||||||
|
|
||||||
void AddHint(const std::string &hint);
|
|
||||||
|
|
||||||
void AddTimestamp(const unsigned timestamp);
|
|
||||||
|
|
||||||
void AddBearing(const boost::fusion::vector<int, boost::optional<int>> &received_bearing,
|
|
||||||
boost::spirit::qi::unused_type unused,
|
|
||||||
bool &pass);
|
|
||||||
|
|
||||||
void SetLanguage(const std::string &language);
|
|
||||||
|
|
||||||
void SetGeometryFlag(const bool flag);
|
|
||||||
|
|
||||||
void SetCompressionFlag(const bool flag);
|
|
||||||
|
|
||||||
void AddCoordinate(const boost::fusion::vector<double, double> &received_coordinates);
|
|
||||||
|
|
||||||
void AddDestination(const boost::fusion::vector<double, double> &received_coordinates);
|
|
||||||
|
|
||||||
void AddSource(const boost::fusion::vector<double, double> &received_coordinates);
|
|
||||||
|
|
||||||
void SetCoordinatesFromGeometry(const std::string &geometry_string);
|
|
||||||
|
|
||||||
short zoom_level;
|
|
||||||
bool print_instructions;
|
|
||||||
bool alternate_route;
|
|
||||||
bool geometry;
|
|
||||||
bool compression;
|
|
||||||
bool deprecatedAPI;
|
|
||||||
bool uturn_default;
|
|
||||||
bool classify;
|
|
||||||
double matching_beta;
|
|
||||||
double gps_precision;
|
|
||||||
unsigned check_sum;
|
|
||||||
short num_results;
|
|
||||||
std::string service;
|
|
||||||
std::string output_format;
|
|
||||||
std::string jsonp_parameter;
|
|
||||||
std::string language;
|
|
||||||
std::vector<std::string> hints;
|
|
||||||
std::vector<unsigned> timestamps;
|
|
||||||
std::vector<std::pair<const int, const boost::optional<int>>> bearings;
|
|
||||||
std::vector<bool> uturns;
|
|
||||||
std::vector<FixedPointCoordinate> coordinates;
|
|
||||||
std::vector<bool> is_destination;
|
|
||||||
std::vector<bool> is_source;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using engine::RouteParameters;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ROUTE_PARAMETERS_HPP
|
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
class OSRM;
|
||||||
namespace engine
|
namespace engine
|
||||||
{
|
{
|
||||||
class OSRM;
|
|
||||||
struct RouteParameters;
|
struct RouteParameters;
|
||||||
}
|
}
|
||||||
namespace server
|
namespace server
|
||||||
@ -30,10 +30,10 @@ class RequestHandler
|
|||||||
RequestHandler(const RequestHandler &) = delete;
|
RequestHandler(const RequestHandler &) = delete;
|
||||||
|
|
||||||
void handle_request(const http::request ¤t_request, http::reply ¤t_reply);
|
void handle_request(const http::request ¤t_request, http::reply ¤t_reply);
|
||||||
void RegisterRoutingMachine(engine::OSRM *osrm);
|
void RegisterRoutingMachine(OSRM *osrm);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
engine::OSRM *routing_machine;
|
OSRM *routing_machine;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,8 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace engine
|
namespace storage
|
||||||
{
|
{
|
||||||
namespace datafacade
|
|
||||||
{
|
|
||||||
|
|
||||||
struct SharedBarriers
|
struct SharedBarriers
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,6 +35,5 @@ struct SharedBarriers
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SHARED_BARRIERS_HPP
|
#endif // SHARED_BARRIERS_HPP
|
@ -10,9 +10,7 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace engine
|
namespace storage
|
||||||
{
|
|
||||||
namespace datafacade
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// Added at the start and end of each block as sanity check
|
// Added at the start and end of each block as sanity check
|
||||||
@ -48,46 +46,6 @@ struct SharedDataLayout
|
|||||||
|
|
||||||
SharedDataLayout() : num_entries(), entry_size() {}
|
SharedDataLayout() : num_entries(), entry_size() {}
|
||||||
|
|
||||||
void PrintInformation() const
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "NAME_OFFSETS "
|
|
||||||
<< ": " << GetBlockSize(NAME_OFFSETS);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "NAME_BLOCKS "
|
|
||||||
<< ": " << GetBlockSize(NAME_BLOCKS);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "NAME_CHAR_LIST "
|
|
||||||
<< ": " << GetBlockSize(NAME_CHAR_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "NAME_ID_LIST "
|
|
||||||
<< ": " << GetBlockSize(NAME_ID_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "VIA_NODE_LIST "
|
|
||||||
<< ": " << GetBlockSize(VIA_NODE_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "GRAPH_NODE_LIST "
|
|
||||||
<< ": " << GetBlockSize(GRAPH_NODE_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "GRAPH_EDGE_LIST "
|
|
||||||
<< ": " << GetBlockSize(GRAPH_EDGE_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "COORDINATE_LIST "
|
|
||||||
<< ": " << GetBlockSize(COORDINATE_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "TURN_INSTRUCTION "
|
|
||||||
<< ": " << GetBlockSize(TURN_INSTRUCTION);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "TRAVEL_MODE "
|
|
||||||
<< ": " << GetBlockSize(TRAVEL_MODE);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "R_SEARCH_TREE "
|
|
||||||
<< ": " << GetBlockSize(R_SEARCH_TREE);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDEX "
|
|
||||||
<< ": " << GetBlockSize(GEOMETRIES_INDEX);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "GEOMETRIES_LIST "
|
|
||||||
<< ": " << GetBlockSize(GEOMETRIES_LIST);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDICATORS"
|
|
||||||
<< ": " << GetBlockSize(GEOMETRIES_INDICATORS);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "HSGR_CHECKSUM "
|
|
||||||
<< ": " << GetBlockSize(HSGR_CHECKSUM);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "TIMESTAMP "
|
|
||||||
<< ": " << GetBlockSize(TIMESTAMP);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "FILE_INDEX_PATH "
|
|
||||||
<< ": " << GetBlockSize(FILE_INDEX_PATH);
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "CORE_MARKER "
|
|
||||||
<< ": " << GetBlockSize(CORE_MARKER);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> inline void SetBlockSize(BlockID bid, uint64_t entries)
|
template <typename T> inline void SetBlockSize(BlockID bid, uint64_t entries)
|
||||||
{
|
{
|
||||||
num_entries[bid] = entries;
|
num_entries[bid] = entries;
|
||||||
@ -170,6 +128,5 @@ struct SharedDataTimestamp
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SHARED_DATA_TYPE_HPP */
|
#endif /* SHARED_DATA_TYPE_HPP */
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef SHARED_MEMORY_FACTORY_HPP
|
#ifndef SHARED_MEMORY_HPP
|
||||||
#define SHARED_MEMORY_FACTORY_HPP
|
#define SHARED_MEMORY_HPP
|
||||||
|
|
||||||
#include "util/osrm_exception.hpp"
|
#include "util/osrm_exception.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace datastore
|
namespace storage
|
||||||
{
|
{
|
||||||
|
|
||||||
struct OSRMLockFile
|
struct OSRMLockFile
|
||||||
@ -322,47 +322,37 @@ class SharedMemory
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class LockFileT = OSRMLockFile> class SharedMemoryFactory_tmpl
|
template <typename IdentifierT, typename LockFileT = OSRMLockFile>
|
||||||
|
SharedMemory *makeSharedMemory(const IdentifierT &id,
|
||||||
|
const uint64_t size = 0,
|
||||||
|
bool read_write = false,
|
||||||
|
bool remove_prev = true)
|
||||||
{
|
{
|
||||||
public:
|
try
|
||||||
template <typename IdentifierT>
|
{
|
||||||
static SharedMemory *Get(const IdentifierT &id,
|
LockFileT lock_file;
|
||||||
const uint64_t size = 0,
|
if (!boost::filesystem::exists(lock_file()))
|
||||||
bool read_write = false,
|
|
||||||
bool remove_prev = true)
|
|
||||||
{
|
{
|
||||||
try
|
if (0 == size)
|
||||||
{
|
{
|
||||||
LockFileT lock_file;
|
throw util::exception("lock file does not exist, exiting");
|
||||||
if (!boost::filesystem::exists(lock_file()))
|
}
|
||||||
{
|
else
|
||||||
if (0 == size)
|
{
|
||||||
{
|
boost::filesystem::ofstream ofs(lock_file());
|
||||||
throw util::exception("lock file does not exist, exiting");
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
boost::filesystem::ofstream ofs(lock_file());
|
|
||||||
ofs.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new SharedMemory(lock_file(), id, size, read_write, remove_prev);
|
|
||||||
}
|
|
||||||
catch (const boost::interprocess::interprocess_exception &e)
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what() << ", code "
|
|
||||||
<< e.get_error_code();
|
|
||||||
throw util::exception(e.what());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return new SharedMemory(lock_file(), id, size, read_write, remove_prev);
|
||||||
|
}
|
||||||
|
catch (const boost::interprocess::interprocess_exception &e)
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what() << ", code "
|
||||||
|
<< e.get_error_code();
|
||||||
|
throw util::exception(e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SharedMemoryFactory_tmpl() = delete;
|
|
||||||
SharedMemoryFactory_tmpl(const SharedMemoryFactory_tmpl &) = delete;
|
|
||||||
SharedMemoryFactory_tmpl &operator=(const SharedMemoryFactory_tmpl &) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
using SharedMemoryFactory = SharedMemoryFactory_tmpl<>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SHARED_MEMORY_FACTORY_HPP
|
#endif // SHARED_MEMORY_HPP
|
25
include/storage/storage.hpp
Normal file
25
include/storage/storage.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef STORAGE_HPP
|
||||||
|
#define STORAGE_HPP
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace storage
|
||||||
|
{
|
||||||
|
using DataPaths = std::unordered_map<std::string, boost::filesystem::path>;
|
||||||
|
class Storage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Storage(const DataPaths& data_paths);
|
||||||
|
int Run();
|
||||||
|
private:
|
||||||
|
DataPaths paths;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
71
include/util/coordinate.hpp
Normal file
71
include/util/coordinate.hpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2016, Project OSRM contributors
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COORDINATE_HPP_
|
||||||
|
#define COORDINATE_HPP_
|
||||||
|
|
||||||
|
#include <iosfwd> //for std::ostream
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
|
||||||
|
constexpr const double COORDINATE_PRECISION = 1000000.0;
|
||||||
|
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
|
struct FixedPointCoordinate
|
||||||
|
{
|
||||||
|
int lat;
|
||||||
|
int lon;
|
||||||
|
|
||||||
|
FixedPointCoordinate();
|
||||||
|
FixedPointCoordinate(int lat, int lon);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
FixedPointCoordinate(const T &coordinate)
|
||||||
|
: lat(coordinate.lat), lon(coordinate.lon)
|
||||||
|
{
|
||||||
|
static_assert(std::is_same<decltype(lat), decltype(coordinate.lat)>::value,
|
||||||
|
"coordinate types incompatible");
|
||||||
|
static_assert(std::is_same<decltype(lon), decltype(coordinate.lon)>::value,
|
||||||
|
"coordinate types incompatible");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
bool operator==(const FixedPointCoordinate &other) const;
|
||||||
|
friend std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
|
||||||
|
};
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* COORDINATE_HPP_ */
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DEBUG_GEOMETRY_H
|
#ifndef DEBUG_GEOMETRY_H
|
||||||
#define DEBUG_GEOMETRY_H
|
#define DEBUG_GEOMETRY_H
|
||||||
|
|
||||||
#include "contractor/contractor_options.hpp"
|
#include "contractor/contractor_config.hpp"
|
||||||
#include "extractor/query_node.hpp"
|
#include "extractor/query_node.hpp"
|
||||||
|
|
||||||
#ifndef DEBUG_GEOMETRY
|
#ifndef DEBUG_GEOMETRY
|
||||||
|
@ -17,7 +17,7 @@ class FingerPrint
|
|||||||
const boost::uuids::uuid &GetFingerPrint() const;
|
const boost::uuids::uuid &GetFingerPrint() const;
|
||||||
bool IsMagicNumberOK(const FingerPrint &other) const;
|
bool IsMagicNumberOK(const FingerPrint &other) const;
|
||||||
bool TestGraphUtil(const FingerPrint &other) const;
|
bool TestGraphUtil(const FingerPrint &other) const;
|
||||||
bool TestPrepare(const FingerPrint &other) const;
|
bool TestContractor(const FingerPrint &other) const;
|
||||||
bool TestRTree(const FingerPrint &other) const;
|
bool TestRTree(const FingerPrint &other) const;
|
||||||
bool TestQueryObjects(const FingerPrint &other) const;
|
bool TestQueryObjects(const FingerPrint &other) const;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ bool FingerPrint::TestGraphUtil(const FingerPrint &other) const
|
|||||||
return std::equal(md5_graph, md5_graph + 32, other.md5_graph);
|
return std::equal(md5_graph, md5_graph + 32, other.md5_graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FingerPrint::TestPrepare(const FingerPrint &other) const
|
bool FingerPrint::TestContractor(const FingerPrint &other) const
|
||||||
{
|
{
|
||||||
if (!IsMagicNumberOK(other))
|
if (!IsMagicNumberOK(other))
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ unsigned loadRestrictionsFromFile(std::istream &input_stream,
|
|||||||
FingerPrint fingerprint_loaded;
|
FingerPrint fingerprint_loaded;
|
||||||
unsigned number_of_usable_restrictions = 0;
|
unsigned number_of_usable_restrictions = 0;
|
||||||
input_stream.read((char *)&fingerprint_loaded, sizeof(FingerPrint));
|
input_stream.read((char *)&fingerprint_loaded, sizeof(FingerPrint));
|
||||||
if (!fingerprint_loaded.TestPrepare(fingerprint_valid))
|
if (!fingerprint_loaded.TestContractor(fingerprint_valid))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << ".restrictions was prepared with different build.\n"
|
SimpleLogger().Write(logWARNING) << ".restrictions was prepared with different build.\n"
|
||||||
"Reprocess to get rid of this warning.";
|
"Reprocess to get rid of this warning.";
|
||||||
@ -71,7 +71,7 @@ NodeID loadNodesFromFile(std::istream &input_stream,
|
|||||||
FingerPrint fingerprint_loaded;
|
FingerPrint fingerprint_loaded;
|
||||||
input_stream.read(reinterpret_cast<char *>(&fingerprint_loaded), sizeof(FingerPrint));
|
input_stream.read(reinterpret_cast<char *>(&fingerprint_loaded), sizeof(FingerPrint));
|
||||||
|
|
||||||
if (!fingerprint_loaded.TestPrepare(fingerprint_valid))
|
if (!fingerprint_loaded.TestContractor(fingerprint_valid))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << ".osrm was prepared with different build.\n"
|
SimpleLogger().Write(logWARNING) << ".osrm was prepared with different build.\n"
|
||||||
"Reprocess to get rid of this warning.";
|
"Reprocess to get rid of this warning.";
|
||||||
|
@ -33,7 +33,7 @@ inline bool readAndCheckFingerprint(std::istream &stream)
|
|||||||
stream.read(reinterpret_cast<char *>(&fingerprint), sizeof(fingerprint));
|
stream.read(reinterpret_cast<char *>(&fingerprint), sizeof(fingerprint));
|
||||||
// compare the compilation state stored in the fingerprint
|
// compare the compilation state stored in the fingerprint
|
||||||
return static_cast<bool>(stream) && valid.IsMagicNumberOK(fingerprint) &&
|
return static_cast<bool>(stream) && valid.IsMagicNumberOK(fingerprint) &&
|
||||||
valid.TestPrepare(fingerprint) && valid.TestGraphUtil(fingerprint) &&
|
valid.TestContractor(fingerprint) && valid.TestGraphUtil(fingerprint) &&
|
||||||
valid.TestRTree(fingerprint) && valid.TestQueryObjects(fingerprint);
|
valid.TestRTree(fingerprint) && valid.TestQueryObjects(fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
102
include/util/json_container.hpp
Normal file
102
include/util/json_container.hpp
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2016, Project OSRM contributors
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// based on
|
||||||
|
// https://svn.apache.org/repos/asf/mesos/tags/release-0.9.0-incubating-RC0/src/common/json.hpp
|
||||||
|
|
||||||
|
#ifndef JSON_CONTAINER_HPP
|
||||||
|
#define JSON_CONTAINER_HPP
|
||||||
|
|
||||||
|
#include <variant/variant.hpp>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace json
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Object;
|
||||||
|
struct Array;
|
||||||
|
|
||||||
|
struct String
|
||||||
|
{
|
||||||
|
String() {}
|
||||||
|
String(const char *value) : value(value) {}
|
||||||
|
String(std::string value) : value(std::move(value)) {}
|
||||||
|
std::string value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Number
|
||||||
|
{
|
||||||
|
Number() {}
|
||||||
|
Number(double value) : value(static_cast<double>(value)) {}
|
||||||
|
double value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct True
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct False
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Null
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
using Value = mapbox::util::variant<String,
|
||||||
|
Number,
|
||||||
|
mapbox::util::recursive_wrapper<Object>,
|
||||||
|
mapbox::util::recursive_wrapper<Array>,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
Null>;
|
||||||
|
|
||||||
|
struct Object
|
||||||
|
{
|
||||||
|
std::unordered_map<std::string, Value> values;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Array
|
||||||
|
{
|
||||||
|
std::vector<Value> values;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace JSON
|
||||||
|
} // namespace util
|
||||||
|
} // namespace osrm
|
||||||
|
|
||||||
|
#endif // JSON_CONTAINER_HPP
|
@ -2,7 +2,6 @@
|
|||||||
#define RANGE_TABLE_HPP
|
#define RANGE_TABLE_HPP
|
||||||
|
|
||||||
#include "util/integer_range.hpp"
|
#include "util/integer_range.hpp"
|
||||||
#include "datastore/shared_memory_factory.hpp"
|
|
||||||
#include "util/shared_memory_vector_wrapper.hpp"
|
#include "util/shared_memory_vector_wrapper.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "util/deallocating_vector.hpp"
|
#include "util/deallocating_vector.hpp"
|
||||||
#include "util/hilbert_value.hpp"
|
#include "util/hilbert_value.hpp"
|
||||||
#include "util/rectangle.hpp"
|
#include "util/rectangle.hpp"
|
||||||
#include "datastore/shared_memory_factory.hpp"
|
|
||||||
#include "util/shared_memory_vector_wrapper.hpp"
|
#include "util/shared_memory_vector_wrapper.hpp"
|
||||||
|
|
||||||
#include "util/bearing.hpp"
|
#include "util/bearing.hpp"
|
||||||
|
@ -1,32 +1,5 @@
|
|||||||
#ifndef OSRM_STRONG_TYPEDEF_HPP
|
#ifndef STRONG_TYPEDEF_HPP
|
||||||
#define OSRM_STRONG_TYPEDEF_HPP
|
#define STRONG_TYPEDEF_HPP
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) 2016, Project OSRM contributors
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <functional>
|
#include <functional>
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef TYPEDEFS_H
|
#ifndef TYPEDEFS_H
|
||||||
#define TYPEDEFS_H
|
#define TYPEDEFS_H
|
||||||
|
|
||||||
#include "osrm/strong_typedef.hpp"
|
#include "util/strong_typedef.hpp"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "contractor/processing_chain.hpp"
|
|
||||||
#include "contractor/contractor.hpp"
|
#include "contractor/contractor.hpp"
|
||||||
|
#include "contractor/graph_contractor.hpp"
|
||||||
|
|
||||||
#include "extractor/edge_based_edge.hpp"
|
#include "extractor/edge_based_edge.hpp"
|
||||||
|
|
||||||
@ -51,9 +51,7 @@ namespace osrm
|
|||||||
namespace contractor
|
namespace contractor
|
||||||
{
|
{
|
||||||
|
|
||||||
Prepare::~Prepare() {}
|
int Contractor::Run()
|
||||||
|
|
||||||
int Prepare::Run()
|
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma message("Memory consumption on Windows can be higher due to different bit packing")
|
#pragma message("Memory consumption on Windows can be higher due to different bit packing")
|
||||||
@ -125,7 +123,7 @@ int Prepare::Run()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t Prepare::LoadEdgeExpandedGraph(
|
std::size_t Contractor::LoadEdgeExpandedGraph(
|
||||||
std::string const &edge_based_graph_filename,
|
std::string const &edge_based_graph_filename,
|
||||||
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||||
const std::string &edge_segment_lookup_filename,
|
const std::string &edge_segment_lookup_filename,
|
||||||
@ -154,7 +152,7 @@ std::size_t Prepare::LoadEdgeExpandedGraph(
|
|||||||
const util::FingerPrint fingerprint_valid = util::FingerPrint::GetValid();
|
const util::FingerPrint fingerprint_valid = util::FingerPrint::GetValid();
|
||||||
util::FingerPrint fingerprint_loaded;
|
util::FingerPrint fingerprint_loaded;
|
||||||
input_stream.read((char *)&fingerprint_loaded, sizeof(util::FingerPrint));
|
input_stream.read((char *)&fingerprint_loaded, sizeof(util::FingerPrint));
|
||||||
fingerprint_loaded.TestPrepare(fingerprint_valid);
|
fingerprint_loaded.TestContractor(fingerprint_valid);
|
||||||
|
|
||||||
// TODO std::size_t can vary on systems. Our files are not transferable, but we might want to
|
// TODO std::size_t can vary on systems. Our files are not transferable, but we might want to
|
||||||
// consider using a fixed size type for I/O
|
// consider using a fixed size type for I/O
|
||||||
@ -260,7 +258,7 @@ std::size_t Prepare::LoadEdgeExpandedGraph(
|
|||||||
return max_edge_id;
|
return max_edge_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prepare::ReadNodeLevels(std::vector<float> &node_levels) const
|
void Contractor::ReadNodeLevels(std::vector<float> &node_levels) const
|
||||||
{
|
{
|
||||||
boost::filesystem::ifstream order_input_stream(config.level_output_path, std::ios::binary);
|
boost::filesystem::ifstream order_input_stream(config.level_output_path, std::ios::binary);
|
||||||
|
|
||||||
@ -270,7 +268,7 @@ void Prepare::ReadNodeLevels(std::vector<float> &node_levels) const
|
|||||||
order_input_stream.read((char *)node_levels.data(), sizeof(float) * node_levels.size());
|
order_input_stream.read((char *)node_levels.data(), sizeof(float) * node_levels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prepare::WriteNodeLevels(std::vector<float> &&in_node_levels) const
|
void Contractor::WriteNodeLevels(std::vector<float> &&in_node_levels) const
|
||||||
{
|
{
|
||||||
std::vector<float> node_levels(std::move(in_node_levels));
|
std::vector<float> node_levels(std::move(in_node_levels));
|
||||||
|
|
||||||
@ -281,7 +279,7 @@ void Prepare::WriteNodeLevels(std::vector<float> &&in_node_levels) const
|
|||||||
order_output_stream.write((char *)node_levels.data(), sizeof(float) * node_levels.size());
|
order_output_stream.write((char *)node_levels.data(), sizeof(float) * node_levels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prepare::WriteCoreNodeMarker(std::vector<bool> &&in_is_core_node) const
|
void Contractor::WriteCoreNodeMarker(std::vector<bool> &&in_is_core_node) const
|
||||||
{
|
{
|
||||||
std::vector<bool> is_core_node(std::move(in_is_core_node));
|
std::vector<bool> is_core_node(std::move(in_is_core_node));
|
||||||
std::vector<char> unpacked_bool_flags(std::move(is_core_node.size()));
|
std::vector<char> unpacked_bool_flags(std::move(is_core_node.size()));
|
||||||
@ -299,7 +297,7 @@ void Prepare::WriteCoreNodeMarker(std::vector<bool> &&in_is_core_node) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
Prepare::WriteContractedGraph(unsigned max_node_id,
|
Contractor::WriteContractedGraph(unsigned max_node_id,
|
||||||
const util::DeallocatingVector<QueryEdge> &contracted_edge_list)
|
const util::DeallocatingVector<QueryEdge> &contracted_edge_list)
|
||||||
{
|
{
|
||||||
// Sorting contracted edges in a way that the static query graph can read some in in-place.
|
// Sorting contracted edges in a way that the static query graph can read some in in-place.
|
||||||
@ -420,7 +418,7 @@ Prepare::WriteContractedGraph(unsigned max_node_id,
|
|||||||
/**
|
/**
|
||||||
\brief Build contracted graph.
|
\brief Build contracted graph.
|
||||||
*/
|
*/
|
||||||
void Prepare::ContractGraph(
|
void Contractor::ContractGraph(
|
||||||
const unsigned max_edge_id,
|
const unsigned max_edge_id,
|
||||||
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||||
util::DeallocatingVector<QueryEdge> &contracted_edge_list,
|
util::DeallocatingVector<QueryEdge> &contracted_edge_list,
|
||||||
@ -431,15 +429,12 @@ void Prepare::ContractGraph(
|
|||||||
std::vector<float> node_levels;
|
std::vector<float> node_levels;
|
||||||
node_levels.swap(inout_node_levels);
|
node_levels.swap(inout_node_levels);
|
||||||
|
|
||||||
Contractor contractor(max_edge_id + 1, edge_based_edge_list, std::move(node_levels),
|
GraphContractor graph_contractor(max_edge_id + 1, edge_based_edge_list, std::move(node_levels),
|
||||||
std::move(node_weights));
|
std::move(node_weights));
|
||||||
contractor.Run(config.core_factor);
|
graph_contractor.Run(config.core_factor);
|
||||||
contractor.GetEdges(contracted_edge_list);
|
graph_contractor.GetEdges(contracted_edge_list);
|
||||||
contractor.GetCoreMarker(is_core_node);
|
graph_contractor.GetCoreMarker(is_core_node);
|
||||||
contractor.GetNodeLevels(inout_node_levels);
|
graph_contractor.GetNodeLevels(inout_node_levels);
|
||||||
|
|
||||||
std::cout << "Levels: " << inout_node_levels.size() << " Core: " << is_core_node.size()
|
|
||||||
<< " MEID: " << max_edge_id << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,128 +0,0 @@
|
|||||||
#include "contractor/contractor_options.hpp"
|
|
||||||
|
|
||||||
#include "util/simple_logger.hpp"
|
|
||||||
#include "util/version.hpp"
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/program_options.hpp>
|
|
||||||
|
|
||||||
#include <tbb/task_scheduler_init.h>
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace contractor
|
|
||||||
{
|
|
||||||
|
|
||||||
return_code
|
|
||||||
ContractorOptions::ParseArguments(int argc, char *argv[], ContractorConfig &contractor_config)
|
|
||||||
{
|
|
||||||
// declare a group of options that will be allowed only on command line
|
|
||||||
boost::program_options::options_description generic_options("Options");
|
|
||||||
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
|
||||||
"config,c",
|
|
||||||
boost::program_options::value<boost::filesystem::path>(&contractor_config.config_file_path)
|
|
||||||
->default_value("contractor.ini"),
|
|
||||||
"Path to a configuration file.");
|
|
||||||
|
|
||||||
// declare a group of options that will be allowed both on command line and in config file
|
|
||||||
boost::program_options::options_description config_options("Configuration");
|
|
||||||
config_options.add_options()(
|
|
||||||
"profile,p",
|
|
||||||
boost::program_options::value<boost::filesystem::path>(&contractor_config.profile_path)
|
|
||||||
->default_value("profile.lua"),
|
|
||||||
"Path to LUA routing profile")(
|
|
||||||
"threads,t",
|
|
||||||
boost::program_options::value<unsigned int>(&contractor_config.requested_num_threads)
|
|
||||||
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
|
||||||
"Number of threads to use")(
|
|
||||||
"core,k",
|
|
||||||
boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0),
|
|
||||||
"Percentage of the graph (in vertices) to contract [0..1]")(
|
|
||||||
"segment-speed-file",
|
|
||||||
boost::program_options::value<std::string>(&contractor_config.segment_speed_lookup_path),
|
|
||||||
"Lookup file containing nodeA,nodeB,speed data to adjust edge weights")(
|
|
||||||
"level-cache,o", boost::program_options::value<bool>(&contractor_config.use_cached_priority)
|
|
||||||
->default_value(false),
|
|
||||||
"Use .level file to retain the contaction level for each node from the last run.");
|
|
||||||
|
|
||||||
#ifdef DEBUG_GEOMETRY
|
|
||||||
config_options.add_options()(
|
|
||||||
"debug-geometry",
|
|
||||||
boost::program_options::value<std::string>(&contractor_config.debug_geometry_path),
|
|
||||||
"Write out edge-weight debugging geometry data in GeoJSON format to this file");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// hidden options, will be allowed both on command line and in config file, but will not be
|
|
||||||
// shown to the user
|
|
||||||
boost::program_options::options_description hidden_options("Hidden options");
|
|
||||||
hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>(
|
|
||||||
&contractor_config.osrm_input_path),
|
|
||||||
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
|
||||||
|
|
||||||
// positional option
|
|
||||||
boost::program_options::positional_options_description positional_options;
|
|
||||||
positional_options.add("input", 1);
|
|
||||||
|
|
||||||
// combine above options for parsing
|
|
||||||
boost::program_options::options_description cmdline_options;
|
|
||||||
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
|
||||||
|
|
||||||
boost::program_options::options_description config_file_options;
|
|
||||||
config_file_options.add(config_options).add(hidden_options);
|
|
||||||
|
|
||||||
boost::program_options::options_description visible_options(
|
|
||||||
"Usage: " + boost::filesystem::basename(argv[0]) + " <input.osrm> [options]");
|
|
||||||
visible_options.add(generic_options).add(config_options);
|
|
||||||
|
|
||||||
// parse command line options
|
|
||||||
boost::program_options::variables_map option_variables;
|
|
||||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
|
|
||||||
.options(cmdline_options)
|
|
||||||
.positional(positional_options)
|
|
||||||
.run(),
|
|
||||||
option_variables);
|
|
||||||
|
|
||||||
const auto &temp_config_path = option_variables["config"].as<boost::filesystem::path>();
|
|
||||||
if (boost::filesystem::is_regular_file(temp_config_path))
|
|
||||||
{
|
|
||||||
boost::program_options::store(boost::program_options::parse_config_file<char>(
|
|
||||||
temp_config_path.string().c_str(), cmdline_options, true),
|
|
||||||
option_variables);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option_variables.count("version"))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << OSRM_VERSION;
|
|
||||||
return return_code::exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option_variables.count("help"))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << "\n" << visible_options;
|
|
||||||
return return_code::exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::program_options::notify(option_variables);
|
|
||||||
|
|
||||||
if (!option_variables.count("input"))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << "\n" << visible_options;
|
|
||||||
return return_code::fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
return return_code::ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContractorOptions::GenerateOutputFilesNames(ContractorConfig &contractor_config)
|
|
||||||
{
|
|
||||||
contractor_config.level_output_path = contractor_config.osrm_input_path.string() + ".level";
|
|
||||||
contractor_config.core_output_path = contractor_config.osrm_input_path.string() + ".core";
|
|
||||||
contractor_config.graph_output_path = contractor_config.osrm_input_path.string() + ".hsgr";
|
|
||||||
contractor_config.edge_based_graph_path = contractor_config.osrm_input_path.string() + ".ebg";
|
|
||||||
contractor_config.edge_segment_lookup_path =
|
|
||||||
contractor_config.osrm_input_path.string() + ".edge_segment_lookup";
|
|
||||||
contractor_config.edge_penalty_path =
|
|
||||||
contractor_config.osrm_input_path.string() + ".edge_penalties";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,6 @@
|
|||||||
#include "engine/osrm_impl.hpp"
|
#include "engine/engine.hpp"
|
||||||
|
#include "engine/engine_config.hpp"
|
||||||
|
#include "engine/route_parameters.hpp"
|
||||||
|
|
||||||
#include "engine/plugins/distance_table.hpp"
|
#include "engine/plugins/distance_table.hpp"
|
||||||
#include "engine/plugins/hello_world.hpp"
|
#include "engine/plugins/hello_world.hpp"
|
||||||
@ -7,10 +9,12 @@
|
|||||||
#include "engine/plugins/trip.hpp"
|
#include "engine/plugins/trip.hpp"
|
||||||
#include "engine/plugins/viaroute.hpp"
|
#include "engine/plugins/viaroute.hpp"
|
||||||
#include "engine/plugins/match.hpp"
|
#include "engine/plugins/match.hpp"
|
||||||
|
|
||||||
#include "engine/datafacade/datafacade_base.hpp"
|
#include "engine/datafacade/datafacade_base.hpp"
|
||||||
#include "engine/datafacade/internal_datafacade.hpp"
|
#include "engine/datafacade/internal_datafacade.hpp"
|
||||||
#include "engine/datafacade/shared_barriers.hpp"
|
|
||||||
#include "engine/datafacade/shared_datafacade.hpp"
|
#include "engine/datafacade/shared_datafacade.hpp"
|
||||||
|
|
||||||
|
#include "storage/shared_barriers.hpp"
|
||||||
#include "util/make_unique.hpp"
|
#include "util/make_unique.hpp"
|
||||||
#include "util/routed_options.hpp"
|
#include "util/routed_options.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
@ -19,10 +23,6 @@
|
|||||||
#include <boost/interprocess/sync/named_condition.hpp>
|
#include <boost/interprocess/sync/named_condition.hpp>
|
||||||
#include <boost/interprocess/sync/scoped_lock.hpp>
|
#include <boost/interprocess/sync/scoped_lock.hpp>
|
||||||
|
|
||||||
#include "osrm/libosrm_config.hpp"
|
|
||||||
#include "osrm/osrm.hpp"
|
|
||||||
#include "osrm/route_parameters.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -33,45 +33,45 @@ namespace osrm
|
|||||||
namespace engine
|
namespace engine
|
||||||
{
|
{
|
||||||
|
|
||||||
OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig &lib_config)
|
Engine::Engine(EngineConfig &config)
|
||||||
{
|
{
|
||||||
if (lib_config.use_shared_memory)
|
if (config.use_shared_memory)
|
||||||
{
|
{
|
||||||
barrier = util::make_unique<datafacade::SharedBarriers>();
|
barrier = util::make_unique<storage::SharedBarriers>();
|
||||||
query_data_facade = new datafacade::SharedDataFacade<contractor::QueryEdge::EdgeData>();
|
query_data_facade = new datafacade::SharedDataFacade<contractor::QueryEdge::EdgeData>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// populate base path
|
// populate base path
|
||||||
util::populate_base_path(lib_config.server_paths);
|
util::populate_base_path(config.server_paths);
|
||||||
query_data_facade = new datafacade::InternalDataFacade<contractor::QueryEdge::EdgeData>(
|
query_data_facade = new datafacade::InternalDataFacade<contractor::QueryEdge::EdgeData>(
|
||||||
lib_config.server_paths);
|
config.server_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
using DataFacade = datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData>;
|
using DataFacade = datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData>;
|
||||||
|
|
||||||
// The following plugins handle all requests.
|
// The following plugins handle all requests.
|
||||||
RegisterPlugin(new plugins::DistanceTablePlugin<DataFacade>(
|
RegisterPlugin(new plugins::DistanceTablePlugin<DataFacade>(
|
||||||
query_data_facade, lib_config.max_locations_distance_table));
|
query_data_facade, config.max_locations_distance_table));
|
||||||
RegisterPlugin(new plugins::HelloWorldPlugin());
|
RegisterPlugin(new plugins::HelloWorldPlugin());
|
||||||
RegisterPlugin(new plugins::NearestPlugin<DataFacade>(query_data_facade));
|
RegisterPlugin(new plugins::NearestPlugin<DataFacade>(query_data_facade));
|
||||||
RegisterPlugin(new plugins::MapMatchingPlugin<DataFacade>(
|
RegisterPlugin(new plugins::MapMatchingPlugin<DataFacade>(
|
||||||
query_data_facade, lib_config.max_locations_map_matching));
|
query_data_facade, config.max_locations_map_matching));
|
||||||
RegisterPlugin(new plugins::TimestampPlugin<DataFacade>(query_data_facade));
|
RegisterPlugin(new plugins::TimestampPlugin<DataFacade>(query_data_facade));
|
||||||
RegisterPlugin(new plugins::ViaRoutePlugin<DataFacade>(query_data_facade,
|
RegisterPlugin(new plugins::ViaRoutePlugin<DataFacade>(query_data_facade,
|
||||||
lib_config.max_locations_viaroute));
|
config.max_locations_viaroute));
|
||||||
RegisterPlugin(
|
RegisterPlugin(
|
||||||
new plugins::RoundTripPlugin<DataFacade>(query_data_facade, lib_config.max_locations_trip));
|
new plugins::RoundTripPlugin<DataFacade>(query_data_facade, config.max_locations_trip));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSRM::OSRM_impl::RegisterPlugin(plugins::BasePlugin *raw_plugin_ptr)
|
void Engine::RegisterPlugin(plugins::BasePlugin *raw_plugin_ptr)
|
||||||
{
|
{
|
||||||
std::unique_ptr<plugins::BasePlugin> plugin_ptr(raw_plugin_ptr);
|
std::unique_ptr<plugins::BasePlugin> plugin_ptr(raw_plugin_ptr);
|
||||||
util::SimpleLogger().Write() << "loaded plugin: " << plugin_ptr->GetDescriptor();
|
util::SimpleLogger().Write() << "loaded plugin: " << plugin_ptr->GetDescriptor();
|
||||||
plugin_map[plugin_ptr->GetDescriptor()] = std::move(plugin_ptr);
|
plugin_map[plugin_ptr->GetDescriptor()] = std::move(plugin_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OSRM::OSRM_impl::RunQuery(const RouteParameters &route_parameters,
|
int Engine::RunQuery(const RouteParameters &route_parameters,
|
||||||
util::json::Object &json_result)
|
util::json::Object &json_result)
|
||||||
{
|
{
|
||||||
const auto &plugin_iterator = plugin_map.find(route_parameters.service);
|
const auto &plugin_iterator = plugin_map.find(route_parameters.service);
|
||||||
@ -99,7 +99,7 @@ int OSRM::OSRM_impl::RunQuery(const RouteParameters &route_parameters,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// decrease number of concurrent queries
|
// decrease number of concurrent queries
|
||||||
void OSRM::OSRM_impl::decrease_concurrent_query_count()
|
void Engine::decrease_concurrent_query_count()
|
||||||
{
|
{
|
||||||
if (!barrier)
|
if (!barrier)
|
||||||
{
|
{
|
||||||
@ -121,7 +121,7 @@ void OSRM::OSRM_impl::decrease_concurrent_query_count()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// increase number of concurrent queries
|
// increase number of concurrent queries
|
||||||
void OSRM::OSRM_impl::increase_concurrent_query_count()
|
void Engine::increase_concurrent_query_count()
|
||||||
{
|
{
|
||||||
if (!barrier)
|
if (!barrier)
|
||||||
{
|
{
|
||||||
@ -147,15 +147,5 @@ void OSRM::OSRM_impl::increase_concurrent_query_count()
|
|||||||
->CheckAndReloadFacade();
|
->CheckAndReloadFacade();
|
||||||
}
|
}
|
||||||
|
|
||||||
// proxy code for compilation firewall
|
|
||||||
OSRM::OSRM(LibOSRMConfig &lib_config) : OSRM_pimpl_(util::make_unique<OSRM_impl>(lib_config)) {}
|
|
||||||
|
|
||||||
// needed because unique_ptr needs the size of OSRM_impl for delete
|
|
||||||
OSRM::~OSRM() {}
|
|
||||||
|
|
||||||
int OSRM::RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result)
|
|
||||||
{
|
|
||||||
return OSRM_pimpl_->RunQuery(route_parameters, json_result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,83 +0,0 @@
|
|||||||
#include "engine/phantom_node.hpp"
|
|
||||||
#include "extractor/travel_mode.hpp"
|
|
||||||
#include "util/typedefs.hpp"
|
|
||||||
#include "osrm/coordinate.hpp"
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace engine
|
|
||||||
{
|
|
||||||
|
|
||||||
PhantomNode::PhantomNode(NodeID forward_node_id,
|
|
||||||
NodeID reverse_node_id,
|
|
||||||
unsigned name_id,
|
|
||||||
int forward_weight,
|
|
||||||
int reverse_weight,
|
|
||||||
int forward_offset,
|
|
||||||
int reverse_offset,
|
|
||||||
unsigned packed_geometry_id,
|
|
||||||
bool is_tiny_component,
|
|
||||||
unsigned component_id,
|
|
||||||
util::FixedPointCoordinate &location,
|
|
||||||
unsigned short fwd_segment_position,
|
|
||||||
extractor::TravelMode forward_travel_mode,
|
|
||||||
extractor::TravelMode backward_travel_mode)
|
|
||||||
: forward_node_id(forward_node_id), reverse_node_id(reverse_node_id), name_id(name_id),
|
|
||||||
forward_weight(forward_weight), reverse_weight(reverse_weight),
|
|
||||||
forward_offset(forward_offset), reverse_offset(reverse_offset),
|
|
||||||
packed_geometry_id(packed_geometry_id), component{component_id, is_tiny_component},
|
|
||||||
location(location), fwd_segment_position(fwd_segment_position),
|
|
||||||
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PhantomNode::PhantomNode()
|
|
||||||
: forward_node_id(SPECIAL_NODEID), reverse_node_id(SPECIAL_NODEID),
|
|
||||||
name_id(std::numeric_limits<unsigned>::max()), forward_weight(INVALID_EDGE_WEIGHT),
|
|
||||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_offset(0), reverse_offset(0),
|
|
||||||
packed_geometry_id(SPECIAL_EDGEID), component{INVALID_COMPONENTID, false},
|
|
||||||
fwd_segment_position(0), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
|
||||||
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int PhantomNode::GetForwardWeightPlusOffset() const
|
|
||||||
{
|
|
||||||
if (SPECIAL_NODEID == forward_node_id)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return forward_offset + forward_weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PhantomNode::GetReverseWeightPlusOffset() const
|
|
||||||
{
|
|
||||||
if (SPECIAL_NODEID == reverse_node_id)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return reverse_offset + reverse_weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PhantomNode::IsBidirected() const
|
|
||||||
{
|
|
||||||
return (forward_node_id != SPECIAL_NODEID) && (reverse_node_id != SPECIAL_NODEID);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PhantomNode::IsCompressed() const { return (forward_offset != 0) || (reverse_offset != 0); }
|
|
||||||
|
|
||||||
bool PhantomNode::is_valid(const unsigned number_of_nodes) const
|
|
||||||
{
|
|
||||||
return location.IsValid() &&
|
|
||||||
((forward_node_id < number_of_nodes) || (reverse_node_id < number_of_nodes)) &&
|
|
||||||
((forward_weight != INVALID_EDGE_WEIGHT) || (reverse_weight != INVALID_EDGE_WEIGHT)) &&
|
|
||||||
(component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PhantomNode::IsValid() const { return location.IsValid() && (name_id != INVALID_NAMEID); }
|
|
||||||
|
|
||||||
bool PhantomNode::operator==(const PhantomNode &other) const { return location == other.location; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,8 @@
|
|||||||
#include <boost/fusion/include/at_c.hpp>
|
#include <boost/fusion/include/at_c.hpp>
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
|
|
||||||
#include "osrm/route_parameters.hpp"
|
#include "engine/route_parameters.hpp"
|
||||||
|
#include "util/coordinate.hpp"
|
||||||
|
|
||||||
#include "engine/polyline_compressor.hpp"
|
#include "engine/polyline_compressor.hpp"
|
||||||
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
#include "extractor/external_memory_node.hpp"
|
|
||||||
#include "extractor/query_node.hpp"
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace extractor
|
|
||||||
{
|
|
||||||
|
|
||||||
ExternalMemoryNode::ExternalMemoryNode(
|
|
||||||
int lat, int lon, OSMNodeID node_id, bool barrier, bool traffic_lights)
|
|
||||||
: QueryNode(lat, lon, node_id), barrier(barrier), traffic_lights(traffic_lights)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalMemoryNode::ExternalMemoryNode() : barrier(false), traffic_lights(false) {}
|
|
||||||
|
|
||||||
ExternalMemoryNode ExternalMemoryNode::min_value()
|
|
||||||
{
|
|
||||||
return ExternalMemoryNode(0, 0, MIN_OSM_NODEID, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalMemoryNode ExternalMemoryNode::max_value()
|
|
||||||
{
|
|
||||||
return ExternalMemoryNode(std::numeric_limits<int>::max(), std::numeric_limits<int>::max(),
|
|
||||||
MAX_OSM_NODEID, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExternalMemoryNodeSTXXLCompare::operator()(const ExternalMemoryNode &left,
|
|
||||||
const ExternalMemoryNode &right) const
|
|
||||||
{
|
|
||||||
return left.node_id < right.node_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalMemoryNodeSTXXLCompare::value_type ExternalMemoryNodeSTXXLCompare::max_value()
|
|
||||||
{
|
|
||||||
return ExternalMemoryNode::max_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalMemoryNodeSTXXLCompare::value_type ExternalMemoryNodeSTXXLCompare::min_value()
|
|
||||||
{
|
|
||||||
return ExternalMemoryNode::min_value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,218 +0,0 @@
|
|||||||
#include "extractor/extractor_options.hpp"
|
|
||||||
|
|
||||||
#include "util/ini_file.hpp"
|
|
||||||
#include "util/version.hpp"
|
|
||||||
#include "util/simple_logger.hpp"
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/program_options.hpp>
|
|
||||||
|
|
||||||
#include <tbb/task_scheduler_init.h>
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace extractor
|
|
||||||
{
|
|
||||||
|
|
||||||
return_code
|
|
||||||
ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extractor_config)
|
|
||||||
{
|
|
||||||
// declare a group of options that will be allowed only on command line
|
|
||||||
boost::program_options::options_description generic_options("Options");
|
|
||||||
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
|
||||||
/*
|
|
||||||
* TODO: re-enable this
|
|
||||||
"restrictions,r",
|
|
||||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.restrictions_path),
|
|
||||||
"Restrictions file in .osrm.restrictions format")(
|
|
||||||
*/
|
|
||||||
"config,c",
|
|
||||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.config_file_path)
|
|
||||||
->default_value("extractor.ini"),
|
|
||||||
"Path to a configuration file.");
|
|
||||||
|
|
||||||
// declare a group of options that will be allowed both on command line and in config file
|
|
||||||
boost::program_options::options_description config_options("Configuration");
|
|
||||||
config_options.add_options()(
|
|
||||||
"profile,p",
|
|
||||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
|
|
||||||
->default_value("profile.lua"),
|
|
||||||
"Path to LUA routing profile")(
|
|
||||||
"threads,t",
|
|
||||||
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
|
|
||||||
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
|
||||||
"Number of threads to use")(
|
|
||||||
"generate-edge-lookup",
|
|
||||||
boost::program_options::value<bool>(&extractor_config.generate_edge_lookup)
|
|
||||||
->implicit_value(true)
|
|
||||||
->default_value(false),
|
|
||||||
"Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")(
|
|
||||||
"small-component-size",
|
|
||||||
boost::program_options::value<unsigned int>(&extractor_config.small_component_size)
|
|
||||||
->default_value(1000),
|
|
||||||
"Number of nodes required before a strongly-connected-componennt is considered big "
|
|
||||||
"(affects nearest neighbor snapping)");
|
|
||||||
|
|
||||||
#ifdef DEBUG_GEOMETRY
|
|
||||||
config_options.add_options()("debug-turns", boost::program_options::value<std::string>(
|
|
||||||
&extractor_config.debug_turns_path),
|
|
||||||
"Write out GeoJSON with turn penalty data");
|
|
||||||
#endif // DEBUG_GEOMETRY
|
|
||||||
|
|
||||||
// hidden options, will be allowed both on command line and in config file, but will not be
|
|
||||||
// shown to the user
|
|
||||||
boost::program_options::options_description hidden_options("Hidden options");
|
|
||||||
hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>(
|
|
||||||
&extractor_config.input_path),
|
|
||||||
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
|
||||||
|
|
||||||
// positional option
|
|
||||||
boost::program_options::positional_options_description positional_options;
|
|
||||||
positional_options.add("input", 1);
|
|
||||||
|
|
||||||
// combine above options for parsing
|
|
||||||
boost::program_options::options_description cmdline_options;
|
|
||||||
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
|
||||||
|
|
||||||
boost::program_options::options_description config_file_options;
|
|
||||||
config_file_options.add(config_options).add(hidden_options);
|
|
||||||
|
|
||||||
boost::program_options::options_description visible_options(
|
|
||||||
boost::filesystem::basename(argv[0]) + " <input.osm/.osm.bz2/.osm.pbf> [options]");
|
|
||||||
visible_options.add(generic_options).add(config_options);
|
|
||||||
|
|
||||||
// parse command line options
|
|
||||||
try
|
|
||||||
{
|
|
||||||
boost::program_options::variables_map option_variables;
|
|
||||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
|
|
||||||
.options(cmdline_options)
|
|
||||||
.positional(positional_options)
|
|
||||||
.run(),
|
|
||||||
option_variables);
|
|
||||||
if (option_variables.count("version"))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << OSRM_VERSION;
|
|
||||||
return return_code::exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option_variables.count("help"))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << visible_options;
|
|
||||||
return return_code::exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::program_options::notify(option_variables);
|
|
||||||
|
|
||||||
// parse config file
|
|
||||||
if (boost::filesystem::is_regular_file(extractor_config.config_file_path))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << "Reading options from: "
|
|
||||||
<< extractor_config.config_file_path.string();
|
|
||||||
std::string ini_file_contents =
|
|
||||||
util::read_file_lower_content(extractor_config.config_file_path);
|
|
||||||
std::stringstream config_stream(ini_file_contents);
|
|
||||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
|
||||||
option_variables);
|
|
||||||
boost::program_options::notify(option_variables);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!option_variables.count("input"))
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write() << visible_options;
|
|
||||||
return return_code::exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (std::exception &e)
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write(logWARNING) << e.what();
|
|
||||||
return return_code::fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
return return_code::ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtractorOptions::GenerateOutputFilesNames(ExtractorConfig &extractor_config)
|
|
||||||
{
|
|
||||||
boost::filesystem::path &input_path = extractor_config.input_path;
|
|
||||||
extractor_config.output_file_name = input_path.string();
|
|
||||||
extractor_config.restriction_file_name = input_path.string();
|
|
||||||
extractor_config.names_file_name = input_path.string();
|
|
||||||
extractor_config.timestamp_file_name = input_path.string();
|
|
||||||
extractor_config.geometry_output_path = input_path.string();
|
|
||||||
extractor_config.edge_output_path = input_path.string();
|
|
||||||
extractor_config.edge_graph_output_path = input_path.string();
|
|
||||||
extractor_config.edge_based_node_weights_output_path = input_path.string();
|
|
||||||
extractor_config.node_output_path = input_path.string();
|
|
||||||
extractor_config.rtree_nodes_output_path = input_path.string();
|
|
||||||
extractor_config.rtree_leafs_output_path = input_path.string();
|
|
||||||
extractor_config.edge_segment_lookup_path = input_path.string();
|
|
||||||
extractor_config.edge_penalty_path = input_path.string();
|
|
||||||
std::string::size_type pos = extractor_config.output_file_name.find(".osm.bz2");
|
|
||||||
if (pos == std::string::npos)
|
|
||||||
{
|
|
||||||
pos = extractor_config.output_file_name.find(".osm.pbf");
|
|
||||||
if (pos == std::string::npos)
|
|
||||||
{
|
|
||||||
pos = extractor_config.output_file_name.find(".osm.xml");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pos == std::string::npos)
|
|
||||||
{
|
|
||||||
pos = extractor_config.output_file_name.find(".pbf");
|
|
||||||
}
|
|
||||||
if (pos == std::string::npos)
|
|
||||||
{
|
|
||||||
pos = extractor_config.output_file_name.find(".osm");
|
|
||||||
if (pos == std::string::npos)
|
|
||||||
{
|
|
||||||
extractor_config.output_file_name.append(".osrm");
|
|
||||||
extractor_config.restriction_file_name.append(".osrm.restrictions");
|
|
||||||
extractor_config.names_file_name.append(".osrm.names");
|
|
||||||
extractor_config.timestamp_file_name.append(".osrm.timestamp");
|
|
||||||
extractor_config.geometry_output_path.append(".osrm.geometry");
|
|
||||||
extractor_config.node_output_path.append(".osrm.nodes");
|
|
||||||
extractor_config.edge_output_path.append(".osrm.edges");
|
|
||||||
extractor_config.edge_graph_output_path.append(".osrm.ebg");
|
|
||||||
extractor_config.edge_based_node_weights_output_path.append(".osrm.enw");
|
|
||||||
extractor_config.rtree_nodes_output_path.append(".osrm.ramIndex");
|
|
||||||
extractor_config.rtree_leafs_output_path.append(".osrm.fileIndex");
|
|
||||||
extractor_config.edge_segment_lookup_path.append(".osrm.edge_segment_lookup");
|
|
||||||
extractor_config.edge_penalty_path.append(".osrm.edge_penalties");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
extractor_config.output_file_name.replace(pos, 5, ".osrm");
|
|
||||||
extractor_config.restriction_file_name.replace(pos, 5, ".osrm.restrictions");
|
|
||||||
extractor_config.names_file_name.replace(pos, 5, ".osrm.names");
|
|
||||||
extractor_config.timestamp_file_name.replace(pos, 5, ".osrm.timestamp");
|
|
||||||
extractor_config.geometry_output_path.replace(pos, 5, ".osrm.geometry");
|
|
||||||
extractor_config.node_output_path.replace(pos, 5, ".osrm.nodes");
|
|
||||||
extractor_config.edge_output_path.replace(pos, 5, ".osrm.edges");
|
|
||||||
extractor_config.edge_graph_output_path.replace(pos, 5, ".osrm.ebg");
|
|
||||||
extractor_config.edge_based_node_weights_output_path.replace(pos, 5, ".osrm.enw");
|
|
||||||
extractor_config.rtree_nodes_output_path.replace(pos, 5, ".osrm.ramIndex");
|
|
||||||
extractor_config.rtree_leafs_output_path.replace(pos, 5, ".osrm.fileIndex");
|
|
||||||
extractor_config.edge_segment_lookup_path.replace(pos, 5, ".osrm.edge_segment_lookup");
|
|
||||||
extractor_config.edge_penalty_path.replace(pos, 5, ".osrm.edge_penalties");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
extractor_config.output_file_name.replace(pos, 8, ".osrm");
|
|
||||||
extractor_config.restriction_file_name.replace(pos, 8, ".osrm.restrictions");
|
|
||||||
extractor_config.names_file_name.replace(pos, 8, ".osrm.names");
|
|
||||||
extractor_config.timestamp_file_name.replace(pos, 8, ".osrm.timestamp");
|
|
||||||
extractor_config.geometry_output_path.replace(pos, 8, ".osrm.geometry");
|
|
||||||
extractor_config.node_output_path.replace(pos, 8, ".osrm.nodes");
|
|
||||||
extractor_config.edge_output_path.replace(pos, 8, ".osrm.edges");
|
|
||||||
extractor_config.edge_graph_output_path.replace(pos, 8, ".osrm.ebg");
|
|
||||||
extractor_config.edge_based_node_weights_output_path.replace(pos, 8, ".osrm.enw");
|
|
||||||
extractor_config.rtree_nodes_output_path.replace(pos, 8, ".osrm.ramIndex");
|
|
||||||
extractor_config.rtree_leafs_output_path.replace(pos, 8, ".osrm.fileIndex");
|
|
||||||
extractor_config.edge_segment_lookup_path.replace(pos, 8, ".osrm.edge_segment_lookup");
|
|
||||||
extractor_config.edge_penalty_path.replace(pos, 8, ".osrm.edge_penalties");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
22
src/osrm/osrm.cpp
Normal file
22
src/osrm/osrm.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "osrm/osrm.hpp"
|
||||||
|
#include "engine/engine.hpp"
|
||||||
|
#include "engine/engine_config.hpp"
|
||||||
|
#include "engine/plugins/plugin_base.hpp"
|
||||||
|
#include "storage/shared_barriers.hpp"
|
||||||
|
#include "util/make_unique.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
|
||||||
|
// proxy code for compilation firewall
|
||||||
|
OSRM::OSRM(engine::EngineConfig &config_) : engine_(util::make_unique<engine::Engine>(config_)) {}
|
||||||
|
|
||||||
|
// needed because unique_ptr needs the size of OSRM_impl for delete
|
||||||
|
OSRM::~OSRM() {}
|
||||||
|
|
||||||
|
int OSRM::RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result)
|
||||||
|
{
|
||||||
|
return engine_->RunQuery(route_parameters, json_result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,8 +10,8 @@
|
|||||||
#include "util/xml_renderer.hpp"
|
#include "util/xml_renderer.hpp"
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include "osrm/route_parameters.hpp"
|
#include "engine/route_parameters.hpp"
|
||||||
#include "osrm/json_container.hpp"
|
#include "util/json_container.hpp"
|
||||||
#include "osrm/osrm.hpp"
|
#include "osrm/osrm.hpp"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
#include "util/range_table.hpp"
|
#include "util/range_table.hpp"
|
||||||
#include "contractor/query_edge.hpp"
|
#include "contractor/query_edge.hpp"
|
||||||
#include "extractor/query_node.hpp"
|
#include "extractor/query_node.hpp"
|
||||||
#include "datastore/shared_memory_factory.hpp"
|
|
||||||
#include "util/shared_memory_vector_wrapper.hpp"
|
#include "util/shared_memory_vector_wrapper.hpp"
|
||||||
#include "util/static_graph.hpp"
|
#include "util/static_graph.hpp"
|
||||||
#include "util/static_rtree.hpp"
|
#include "util/static_rtree.hpp"
|
||||||
#include "engine/datafacade/datafacade_base.hpp"
|
#include "engine/datafacade/datafacade_base.hpp"
|
||||||
#include "extractor/travel_mode.hpp"
|
#include "extractor/travel_mode.hpp"
|
||||||
#include "extractor/turn_instructions.hpp"
|
#include "extractor/turn_instructions.hpp"
|
||||||
#include "engine/datafacade/shared_datatype.hpp"
|
#include "storage/storage.hpp"
|
||||||
#include "engine/datafacade/shared_barriers.hpp"
|
#include "storage/shared_datatype.hpp"
|
||||||
#include "util/datastore_options.hpp"
|
#include "storage/shared_barriers.hpp"
|
||||||
|
#include "storage/shared_memory.hpp"
|
||||||
#include "util/fingerprint.hpp"
|
#include "util/fingerprint.hpp"
|
||||||
#include "util/osrm_exception.hpp"
|
#include "util/osrm_exception.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
@ -32,10 +32,10 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// FIXME remove after move to datastore
|
namespace osrm
|
||||||
using namespace osrm::engine::datafacade;
|
{
|
||||||
using namespace osrm::datastore;
|
namespace storage
|
||||||
using namespace osrm;
|
{
|
||||||
|
|
||||||
using RTreeLeaf =
|
using RTreeLeaf =
|
||||||
typename engine::datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData>::RTreeLeaf;
|
typename engine::datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData>::RTreeLeaf;
|
||||||
@ -44,11 +44,6 @@ using RTreeNode = util::StaticRTree<RTreeLeaf,
|
|||||||
true>::TreeNode;
|
true>::TreeNode;
|
||||||
using QueryGraph = util::StaticGraph<contractor::QueryEdge::EdgeData>;
|
using QueryGraph = util::StaticGraph<contractor::QueryEdge::EdgeData>;
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace tools
|
|
||||||
{
|
|
||||||
|
|
||||||
// delete a shared memory region. report warning if it could not be deleted
|
// delete a shared memory region. report warning if it could not be deleted
|
||||||
void deleteRegion(const SharedDataType region)
|
void deleteRegion(const SharedDataType region)
|
||||||
{
|
{
|
||||||
@ -78,10 +73,10 @@ void deleteRegion(const SharedDataType region)
|
|||||||
util::SimpleLogger().Write(logWARNING) << "could not delete shared memory region " << name;
|
util::SimpleLogger().Write(logWARNING) << "could not delete shared memory region " << name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(const int argc, const char *argv[]) try
|
Storage::Storage(const DataPaths &paths_) : paths(paths_) {}
|
||||||
|
|
||||||
|
int Storage::Run()
|
||||||
{
|
{
|
||||||
util::LogPolicy::GetInstance().Unmute();
|
util::LogPolicy::GetInstance().Unmute();
|
||||||
SharedBarriers barrier;
|
SharedBarriers barrier;
|
||||||
@ -91,8 +86,7 @@ int main(const int argc, const char *argv[]) try
|
|||||||
const bool lock_flags = MCL_CURRENT | MCL_FUTURE;
|
const bool lock_flags = MCL_CURRENT | MCL_FUTURE;
|
||||||
if (-1 == mlockall(lock_flags))
|
if (-1 == mlockall(lock_flags))
|
||||||
{
|
{
|
||||||
util::SimpleLogger().Write(logWARNING) << "Process " << argv[0]
|
util::SimpleLogger().Write(logWARNING) << "Could not request RAM lock";
|
||||||
<< " could not request RAM lock";
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -107,107 +101,99 @@ int main(const int argc, const char *argv[]) try
|
|||||||
barrier.pending_update_mutex.unlock();
|
barrier.pending_update_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
util::SimpleLogger().Write(logDEBUG) << "Checking input parameters";
|
if (paths.find("hsgrdata") == paths.end())
|
||||||
|
|
||||||
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
|
||||||
if (!util::GenerateDataStoreOptions(argc, argv, server_paths))
|
|
||||||
{
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server_paths.find("hsgrdata") == server_paths.end())
|
|
||||||
{
|
{
|
||||||
throw util::exception("no hsgr file found");
|
throw util::exception("no hsgr file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("ramindex") == server_paths.end())
|
if (paths.find("ramindex") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no ram index file found");
|
throw util::exception("no ram index file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("fileindex") == server_paths.end())
|
if (paths.find("fileindex") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no leaf index file found");
|
throw util::exception("no leaf index file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("nodesdata") == server_paths.end())
|
if (paths.find("nodesdata") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no nodes file found");
|
throw util::exception("no nodes file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("edgesdata") == server_paths.end())
|
if (paths.find("edgesdata") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no edges file found");
|
throw util::exception("no edges file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("namesdata") == server_paths.end())
|
if (paths.find("namesdata") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no names file found");
|
throw util::exception("no names file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("geometry") == server_paths.end())
|
if (paths.find("geometry") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no geometry file found");
|
throw util::exception("no geometry file found");
|
||||||
}
|
}
|
||||||
if (server_paths.find("core") == server_paths.end())
|
if (paths.find("core") == paths.end())
|
||||||
{
|
{
|
||||||
throw util::exception("no core file found");
|
throw util::exception("no core file found");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto paths_iterator = server_paths.find("hsgrdata");
|
auto paths_iterator = paths.find("hsgrdata");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &hsgr_path = paths_iterator->second;
|
const boost::filesystem::path &hsgr_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("timestamp");
|
paths_iterator = paths.find("timestamp");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path ×tamp_path = paths_iterator->second;
|
const boost::filesystem::path ×tamp_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("ramindex");
|
paths_iterator = paths.find("ramindex");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &ram_index_path = paths_iterator->second;
|
const boost::filesystem::path &ram_index_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("fileindex");
|
paths_iterator = paths.find("fileindex");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path index_file_path_absolute =
|
const boost::filesystem::path index_file_path_absolute =
|
||||||
boost::filesystem::canonical(paths_iterator->second);
|
boost::filesystem::canonical(paths_iterator->second);
|
||||||
const std::string &file_index_path = index_file_path_absolute.string();
|
const std::string &file_index_path = index_file_path_absolute.string();
|
||||||
paths_iterator = server_paths.find("nodesdata");
|
paths_iterator = paths.find("nodesdata");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &nodes_data_path = paths_iterator->second;
|
const boost::filesystem::path &nodes_data_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("edgesdata");
|
paths_iterator = paths.find("edgesdata");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &edges_data_path = paths_iterator->second;
|
const boost::filesystem::path &edges_data_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("namesdata");
|
paths_iterator = paths.find("namesdata");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &names_data_path = paths_iterator->second;
|
const boost::filesystem::path &names_data_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("geometry");
|
paths_iterator = paths.find("geometry");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &geometries_data_path = paths_iterator->second;
|
const boost::filesystem::path &geometries_data_path = paths_iterator->second;
|
||||||
paths_iterator = server_paths.find("core");
|
paths_iterator = paths.find("core");
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
BOOST_ASSERT(paths.end() != paths_iterator);
|
||||||
BOOST_ASSERT(!paths_iterator->second.empty());
|
BOOST_ASSERT(!paths_iterator->second.empty());
|
||||||
const boost::filesystem::path &core_marker_path = paths_iterator->second;
|
const boost::filesystem::path &core_marker_path = paths_iterator->second;
|
||||||
|
|
||||||
// determine segment to use
|
// determine segment to use
|
||||||
bool segment2_in_use = SharedMemory::RegionExists(LAYOUT_2);
|
bool segment2_in_use = SharedMemory::RegionExists(LAYOUT_2);
|
||||||
const engine::datafacade::SharedDataType layout_region = [&]
|
const storage::SharedDataType layout_region = [&]
|
||||||
{
|
{
|
||||||
return segment2_in_use ? LAYOUT_1 : LAYOUT_2;
|
return segment2_in_use ? LAYOUT_1 : LAYOUT_2;
|
||||||
}();
|
}();
|
||||||
const engine::datafacade::SharedDataType data_region = [&]
|
const storage::SharedDataType data_region = [&]
|
||||||
{
|
{
|
||||||
return segment2_in_use ? DATA_1 : DATA_2;
|
return segment2_in_use ? DATA_1 : DATA_2;
|
||||||
}();
|
}();
|
||||||
const engine::datafacade::SharedDataType previous_layout_region = [&]
|
const storage::SharedDataType previous_layout_region = [&]
|
||||||
{
|
{
|
||||||
return segment2_in_use ? LAYOUT_2 : LAYOUT_1;
|
return segment2_in_use ? LAYOUT_2 : LAYOUT_1;
|
||||||
}();
|
}();
|
||||||
const engine::datafacade::SharedDataType previous_data_region = [&]
|
const storage::SharedDataType previous_data_region = [&]
|
||||||
{
|
{
|
||||||
return segment2_in_use ? DATA_2 : DATA_1;
|
return segment2_in_use ? DATA_2 : DATA_1;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
// Allocate a memory layout in shared memory, deallocate previous
|
// Allocate a memory layout in shared memory, deallocate previous
|
||||||
auto *layout_memory = SharedMemoryFactory::Get(layout_region, sizeof(SharedDataLayout));
|
auto *layout_memory = makeSharedMemory(layout_region, sizeof(SharedDataLayout));
|
||||||
auto shared_layout_ptr = new (layout_memory->Ptr()) SharedDataLayout();
|
auto shared_layout_ptr = new (layout_memory->Ptr()) SharedDataLayout();
|
||||||
|
|
||||||
shared_layout_ptr->SetBlockSize<char>(SharedDataLayout::FILE_INDEX_PATH,
|
shared_layout_ptr->SetBlockSize<char>(SharedDataLayout::FILE_INDEX_PATH,
|
||||||
@ -345,8 +331,7 @@ int main(const int argc, const char *argv[]) try
|
|||||||
// allocate shared memory block
|
// allocate shared memory block
|
||||||
util::SimpleLogger().Write() << "allocating shared memory of "
|
util::SimpleLogger().Write() << "allocating shared memory of "
|
||||||
<< shared_layout_ptr->GetSizeOfLayout() << " bytes";
|
<< shared_layout_ptr->GetSizeOfLayout() << " bytes";
|
||||||
SharedMemory *shared_memory =
|
auto *shared_memory = makeSharedMemory(data_region, shared_layout_ptr->GetSizeOfLayout());
|
||||||
SharedMemoryFactory::Get(data_region, shared_layout_ptr->GetSizeOfLayout());
|
|
||||||
char *shared_memory_ptr = static_cast<char *>(shared_memory->Ptr());
|
char *shared_memory_ptr = static_cast<char *>(shared_memory->Ptr());
|
||||||
|
|
||||||
// read actual data into shared memory object //
|
// read actual data into shared memory object //
|
||||||
@ -555,7 +540,7 @@ int main(const int argc, const char *argv[]) try
|
|||||||
|
|
||||||
// acquire lock
|
// acquire lock
|
||||||
SharedMemory *data_type_memory =
|
SharedMemory *data_type_memory =
|
||||||
SharedMemoryFactory::Get(CURRENT_REGIONS, sizeof(SharedDataTimestamp), true, false);
|
makeSharedMemory(CURRENT_REGIONS, sizeof(SharedDataTimestamp), true, false);
|
||||||
SharedDataTimestamp *data_timestamp_ptr =
|
SharedDataTimestamp *data_timestamp_ptr =
|
||||||
static_cast<SharedDataTimestamp *>(data_type_memory->Ptr());
|
static_cast<SharedDataTimestamp *>(data_type_memory->Ptr());
|
||||||
|
|
||||||
@ -571,22 +556,11 @@ int main(const int argc, const char *argv[]) try
|
|||||||
data_timestamp_ptr->layout = layout_region;
|
data_timestamp_ptr->layout = layout_region;
|
||||||
data_timestamp_ptr->data = data_region;
|
data_timestamp_ptr->data = data_region;
|
||||||
data_timestamp_ptr->timestamp += 1;
|
data_timestamp_ptr->timestamp += 1;
|
||||||
tools::deleteRegion(previous_data_region);
|
deleteRegion(previous_data_region);
|
||||||
tools::deleteRegion(previous_layout_region);
|
deleteRegion(previous_layout_region);
|
||||||
util::SimpleLogger().Write() << "all data loaded";
|
util::SimpleLogger().Write() << "all data loaded";
|
||||||
|
|
||||||
shared_layout_ptr->PrintInformation();
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc &e)
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
|
||||||
util::SimpleLogger().Write(logWARNING)
|
|
||||||
<< "Please provide more memory or disable locking the virtual "
|
|
||||||
"address space (note: this makes OSRM swap, i.e. slow)";
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what();
|
|
||||||
}
|
}
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
@ -22,72 +23,71 @@ using QueryGraph = util::StaticGraph<EdgeData>;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) try
|
||||||
{
|
{
|
||||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
osrm::util::LogPolicy::GetInstance().Unmute();
|
||||||
try
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " <file.hsgr>";
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path hsgr_path(argv[1]);
|
||||||
|
|
||||||
|
std::vector<osrm::tools::QueryGraph::NodeArrayEntry> node_list;
|
||||||
|
std::vector<osrm::tools::QueryGraph::EdgeArrayEntry> edge_list;
|
||||||
|
osrm::util::SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
||||||
|
|
||||||
|
unsigned m_check_sum = 0;
|
||||||
|
unsigned m_number_of_nodes =
|
||||||
|
readHSGRFromStream(hsgr_path, node_list, edge_list, &m_check_sum);
|
||||||
|
osrm::util::SimpleLogger().Write() << "expecting " << m_number_of_nodes
|
||||||
|
<< " nodes, checksum: " << m_check_sum;
|
||||||
|
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
||||||
|
osrm::util::SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and "
|
||||||
|
<< edge_list.size() << " edges";
|
||||||
|
auto m_query_graph = std::make_shared<osrm::tools::QueryGraph>(node_list, edge_list);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
||||||
|
BOOST_ASSERT_MSG(0 == edge_list.size(), "edge list not flushed");
|
||||||
|
|
||||||
|
osrm::util::Percent progress(m_query_graph->GetNumberOfNodes());
|
||||||
|
for (const auto node_u : osrm::util::irange(0u, m_query_graph->GetNumberOfNodes()))
|
||||||
|
{
|
||||||
|
for (const auto eid : m_query_graph->GetAdjacentEdgeRange(node_u))
|
||||||
{
|
{
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " <file.hsgr>";
|
const osrm::tools::EdgeData &data = m_query_graph->GetEdgeData(eid);
|
||||||
return 1;
|
if (!data.shortcut)
|
||||||
}
|
|
||||||
|
|
||||||
boost::filesystem::path hsgr_path(argv[1]);
|
|
||||||
|
|
||||||
std::vector<osrm::tools::QueryGraph::NodeArrayEntry> node_list;
|
|
||||||
std::vector<osrm::tools::QueryGraph::EdgeArrayEntry> edge_list;
|
|
||||||
osrm::util::SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
|
||||||
|
|
||||||
unsigned m_check_sum = 0;
|
|
||||||
unsigned m_number_of_nodes =
|
|
||||||
readHSGRFromStream(hsgr_path, node_list, edge_list, &m_check_sum);
|
|
||||||
osrm::util::SimpleLogger().Write() << "expecting " << m_number_of_nodes
|
|
||||||
<< " nodes, checksum: " << m_check_sum;
|
|
||||||
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
|
||||||
osrm::util::SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and "
|
|
||||||
<< edge_list.size() << " edges";
|
|
||||||
auto m_query_graph = std::make_shared<osrm::tools::QueryGraph>(node_list, edge_list);
|
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
|
||||||
BOOST_ASSERT_MSG(0 == edge_list.size(), "edge list not flushed");
|
|
||||||
|
|
||||||
osrm::util::Percent progress(m_query_graph->GetNumberOfNodes());
|
|
||||||
for (const auto node_u : osrm::util::irange(0u, m_query_graph->GetNumberOfNodes()))
|
|
||||||
{
|
|
||||||
for (const auto eid : m_query_graph->GetAdjacentEdgeRange(node_u))
|
|
||||||
{
|
{
|
||||||
const osrm::tools::EdgeData &data = m_query_graph->GetEdgeData(eid);
|
continue;
|
||||||
if (!data.shortcut)
|
}
|
||||||
{
|
const unsigned node_v = m_query_graph->GetTarget(eid);
|
||||||
continue;
|
const EdgeID edge_id_1 = m_query_graph->FindEdgeInEitherDirection(node_u, data.id);
|
||||||
}
|
if (SPECIAL_EDGEID == edge_id_1)
|
||||||
const unsigned node_v = m_query_graph->GetTarget(eid);
|
{
|
||||||
const EdgeID edge_id_1 = m_query_graph->FindEdgeInEitherDirection(node_u, data.id);
|
throw osrm::util::exception(
|
||||||
if (SPECIAL_EDGEID == edge_id_1)
|
"cannot find first segment of edge (" + std::to_string(node_u) + "," +
|
||||||
{
|
std::to_string(data.id) + "," + std::to_string(node_v) + "), eid: " +
|
||||||
throw osrm::util::exception(
|
std::to_string(eid));
|
||||||
"cannot find first segment of edge (" + std::to_string(node_u) + "," +
|
}
|
||||||
std::to_string(data.id) + "," + std::to_string(node_v) + "), eid: " +
|
const EdgeID edge_id_2 = m_query_graph->FindEdgeInEitherDirection(data.id, node_v);
|
||||||
std::to_string(eid));
|
if (SPECIAL_EDGEID == edge_id_2)
|
||||||
}
|
{
|
||||||
const EdgeID edge_id_2 = m_query_graph->FindEdgeInEitherDirection(data.id, node_v);
|
throw osrm::util::exception(
|
||||||
if (SPECIAL_EDGEID == edge_id_2)
|
"cannot find second segment of edge (" + std::to_string(node_u) + "," +
|
||||||
{
|
std::to_string(data.id) + "," + std::to_string(node_v) + "), eid: " +
|
||||||
throw osrm::util::exception(
|
std::to_string(eid));
|
||||||
"cannot find second segment of edge (" + std::to_string(node_u) + "," +
|
|
||||||
std::to_string(data.id) + "," + std::to_string(node_v) + "), eid: " +
|
|
||||||
std::to_string(eid));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
progress.printStatus(node_u);
|
|
||||||
}
|
}
|
||||||
m_query_graph.reset();
|
progress.printStatus(node_u);
|
||||||
osrm::util::SimpleLogger().Write() << "Data file " << argv[0] << " appears to be OK";
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
m_query_graph.reset();
|
||||||
{
|
osrm::util::SimpleLogger().Write() << "Data file " << argv[0] << " appears to be OK";
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
|
||||||
}
|
return EXIT_SUCCESS;
|
||||||
return 0;
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -98,141 +98,139 @@ std::size_t loadGraph(const char *path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) try
|
||||||
{
|
{
|
||||||
std::vector<osrm::extractor::QueryNode> coordinate_list;
|
std::vector<osrm::extractor::QueryNode> coordinate_list;
|
||||||
|
|
||||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
osrm::util::LogPolicy::GetInstance().Unmute();
|
||||||
try
|
|
||||||
|
// enable logging
|
||||||
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
// enable logging
|
osrm::util::SimpleLogger().Write(logWARNING) << "usage:\n" << argv[0] << " <osrm>";
|
||||||
if (argc < 2)
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<osrm::tools::TarjanEdge> graph_edge_list;
|
||||||
|
auto number_of_nodes = osrm::tools::loadGraph(argv[1], coordinate_list, graph_edge_list);
|
||||||
|
|
||||||
|
tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
|
||||||
|
const auto graph =
|
||||||
|
std::make_shared<osrm::tools::TarjanGraph>(number_of_nodes, graph_edge_list);
|
||||||
|
graph_edge_list.clear();
|
||||||
|
graph_edge_list.shrink_to_fit();
|
||||||
|
|
||||||
|
osrm::util::SimpleLogger().Write() << "Starting SCC graph traversal";
|
||||||
|
|
||||||
|
auto tarjan =
|
||||||
|
osrm::util::make_unique<osrm::extractor::TarjanSCC<osrm::tools::TarjanGraph>>(graph);
|
||||||
|
tarjan->run();
|
||||||
|
osrm::util::SimpleLogger().Write() << "identified: " << tarjan->get_number_of_components()
|
||||||
|
<< " many components";
|
||||||
|
osrm::util::SimpleLogger().Write() << "identified " << tarjan->get_size_one_count()
|
||||||
|
<< " size 1 SCCs";
|
||||||
|
|
||||||
|
// output
|
||||||
|
TIMER_START(SCC_RUN_SETUP);
|
||||||
|
|
||||||
|
// remove files from previous run if exist
|
||||||
|
osrm::tools::deleteFileIfExists("component.dbf");
|
||||||
|
osrm::tools::deleteFileIfExists("component.shx");
|
||||||
|
osrm::tools::deleteFileIfExists("component.shp");
|
||||||
|
|
||||||
|
osrm::util::Percent percentage(graph->GetNumberOfNodes());
|
||||||
|
|
||||||
|
OGRRegisterAll();
|
||||||
|
|
||||||
|
const char *psz_driver_name = "ESRI Shapefile";
|
||||||
|
auto *po_driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(psz_driver_name);
|
||||||
|
if (nullptr == po_driver)
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("ESRI Shapefile driver not available");
|
||||||
|
}
|
||||||
|
auto *po_datasource = po_driver->CreateDataSource("component.shp", nullptr);
|
||||||
|
|
||||||
|
if (nullptr == po_datasource)
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("Creation of output file failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *po_srs = new OGRSpatialReference();
|
||||||
|
po_srs->importFromEPSG(4326);
|
||||||
|
|
||||||
|
auto *po_layer = po_datasource->CreateLayer("component", po_srs, wkbLineString, nullptr);
|
||||||
|
|
||||||
|
if (nullptr == po_layer)
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("Layer creation failed.");
|
||||||
|
}
|
||||||
|
TIMER_STOP(SCC_RUN_SETUP);
|
||||||
|
osrm::util::SimpleLogger().Write() << "shapefile setup took "
|
||||||
|
<< TIMER_MSEC(SCC_RUN_SETUP) / 1000. << "s";
|
||||||
|
|
||||||
|
uint64_t total_network_length = 0;
|
||||||
|
percentage.reinit(graph->GetNumberOfNodes());
|
||||||
|
TIMER_START(SCC_OUTPUT);
|
||||||
|
for (const NodeID source : osrm::util::irange(0u, graph->GetNumberOfNodes()))
|
||||||
|
{
|
||||||
|
percentage.printIncrement();
|
||||||
|
for (const auto current_edge : graph->GetAdjacentEdgeRange(source))
|
||||||
{
|
{
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "usage:\n" << argv[0] << " <osrm>";
|
const auto target = graph->GetTarget(current_edge);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<osrm::tools::TarjanEdge> graph_edge_list;
|
if (source < target || SPECIAL_EDGEID == graph->FindEdge(target, source))
|
||||||
auto number_of_nodes = osrm::tools::loadGraph(argv[1], coordinate_list, graph_edge_list);
|
|
||||||
|
|
||||||
tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
|
|
||||||
const auto graph =
|
|
||||||
std::make_shared<osrm::tools::TarjanGraph>(number_of_nodes, graph_edge_list);
|
|
||||||
graph_edge_list.clear();
|
|
||||||
graph_edge_list.shrink_to_fit();
|
|
||||||
|
|
||||||
osrm::util::SimpleLogger().Write() << "Starting SCC graph traversal";
|
|
||||||
|
|
||||||
auto tarjan =
|
|
||||||
osrm::util::make_unique<osrm::extractor::TarjanSCC<osrm::tools::TarjanGraph>>(graph);
|
|
||||||
tarjan->run();
|
|
||||||
osrm::util::SimpleLogger().Write() << "identified: " << tarjan->get_number_of_components()
|
|
||||||
<< " many components";
|
|
||||||
osrm::util::SimpleLogger().Write() << "identified " << tarjan->get_size_one_count()
|
|
||||||
<< " size 1 SCCs";
|
|
||||||
|
|
||||||
// output
|
|
||||||
TIMER_START(SCC_RUN_SETUP);
|
|
||||||
|
|
||||||
// remove files from previous run if exist
|
|
||||||
osrm::tools::deleteFileIfExists("component.dbf");
|
|
||||||
osrm::tools::deleteFileIfExists("component.shx");
|
|
||||||
osrm::tools::deleteFileIfExists("component.shp");
|
|
||||||
|
|
||||||
osrm::util::Percent percentage(graph->GetNumberOfNodes());
|
|
||||||
|
|
||||||
OGRRegisterAll();
|
|
||||||
|
|
||||||
const char *psz_driver_name = "ESRI Shapefile";
|
|
||||||
auto *po_driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(psz_driver_name);
|
|
||||||
if (nullptr == po_driver)
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("ESRI Shapefile driver not available");
|
|
||||||
}
|
|
||||||
auto *po_datasource = po_driver->CreateDataSource("component.shp", nullptr);
|
|
||||||
|
|
||||||
if (nullptr == po_datasource)
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("Creation of output file failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto *po_srs = new OGRSpatialReference();
|
|
||||||
po_srs->importFromEPSG(4326);
|
|
||||||
|
|
||||||
auto *po_layer = po_datasource->CreateLayer("component", po_srs, wkbLineString, nullptr);
|
|
||||||
|
|
||||||
if (nullptr == po_layer)
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("Layer creation failed.");
|
|
||||||
}
|
|
||||||
TIMER_STOP(SCC_RUN_SETUP);
|
|
||||||
osrm::util::SimpleLogger().Write() << "shapefile setup took "
|
|
||||||
<< TIMER_MSEC(SCC_RUN_SETUP) / 1000. << "s";
|
|
||||||
|
|
||||||
uint64_t total_network_length = 0;
|
|
||||||
percentage.reinit(graph->GetNumberOfNodes());
|
|
||||||
TIMER_START(SCC_OUTPUT);
|
|
||||||
for (const NodeID source : osrm::util::irange(0u, graph->GetNumberOfNodes()))
|
|
||||||
{
|
|
||||||
percentage.printIncrement();
|
|
||||||
for (const auto current_edge : graph->GetAdjacentEdgeRange(source))
|
|
||||||
{
|
{
|
||||||
const auto target = graph->GetTarget(current_edge);
|
total_network_length +=
|
||||||
|
100 * osrm::util::coordinate_calculation::greatCircleDistance(
|
||||||
|
coordinate_list[source].lat, coordinate_list[source].lon,
|
||||||
|
coordinate_list[target].lat, coordinate_list[target].lon);
|
||||||
|
|
||||||
if (source < target || SPECIAL_EDGEID == graph->FindEdge(target, source))
|
BOOST_ASSERT(current_edge != SPECIAL_EDGEID);
|
||||||
|
BOOST_ASSERT(source != SPECIAL_NODEID);
|
||||||
|
BOOST_ASSERT(target != SPECIAL_NODEID);
|
||||||
|
|
||||||
|
const unsigned size_of_containing_component =
|
||||||
|
std::min(tarjan->get_component_size(tarjan->get_component_id(source)),
|
||||||
|
tarjan->get_component_size(tarjan->get_component_id(target)));
|
||||||
|
|
||||||
|
// edges that end on bollard nodes may actually be in two distinct components
|
||||||
|
if (size_of_containing_component < 1000)
|
||||||
{
|
{
|
||||||
total_network_length +=
|
OGRLineString line_string;
|
||||||
100 * osrm::util::coordinate_calculation::greatCircleDistance(
|
line_string.addPoint(
|
||||||
coordinate_list[source].lat, coordinate_list[source].lon,
|
coordinate_list[source].lon / osrm::COORDINATE_PRECISION,
|
||||||
coordinate_list[target].lat, coordinate_list[target].lon);
|
coordinate_list[source].lat / osrm::COORDINATE_PRECISION);
|
||||||
|
line_string.addPoint(
|
||||||
|
coordinate_list[target].lon / osrm::COORDINATE_PRECISION,
|
||||||
|
coordinate_list[target].lat / osrm::COORDINATE_PRECISION);
|
||||||
|
|
||||||
BOOST_ASSERT(current_edge != SPECIAL_EDGEID);
|
OGRFeature *po_feature =
|
||||||
BOOST_ASSERT(source != SPECIAL_NODEID);
|
OGRFeature::CreateFeature(po_layer->GetLayerDefn());
|
||||||
BOOST_ASSERT(target != SPECIAL_NODEID);
|
|
||||||
|
|
||||||
const unsigned size_of_containing_component =
|
po_feature->SetGeometry(&line_string);
|
||||||
std::min(tarjan->get_component_size(tarjan->get_component_id(source)),
|
if (OGRERR_NONE != po_layer->CreateFeature(po_feature))
|
||||||
tarjan->get_component_size(tarjan->get_component_id(target)));
|
|
||||||
|
|
||||||
// edges that end on bollard nodes may actually be in two distinct components
|
|
||||||
if (size_of_containing_component < 1000)
|
|
||||||
{
|
{
|
||||||
OGRLineString line_string;
|
throw osrm::util::exception("Failed to create feature in shapefile.");
|
||||||
line_string.addPoint(
|
|
||||||
coordinate_list[source].lon / osrm::COORDINATE_PRECISION,
|
|
||||||
coordinate_list[source].lat / osrm::COORDINATE_PRECISION);
|
|
||||||
line_string.addPoint(
|
|
||||||
coordinate_list[target].lon / osrm::COORDINATE_PRECISION,
|
|
||||||
coordinate_list[target].lat / osrm::COORDINATE_PRECISION);
|
|
||||||
|
|
||||||
OGRFeature *po_feature =
|
|
||||||
OGRFeature::CreateFeature(po_layer->GetLayerDefn());
|
|
||||||
|
|
||||||
po_feature->SetGeometry(&line_string);
|
|
||||||
if (OGRERR_NONE != po_layer->CreateFeature(po_feature))
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("Failed to create feature in shapefile.");
|
|
||||||
}
|
|
||||||
OGRFeature::DestroyFeature(po_feature);
|
|
||||||
}
|
}
|
||||||
|
OGRFeature::DestroyFeature(po_feature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OGRSpatialReference::DestroySpatialReference(po_srs);
|
|
||||||
OGRDataSource::DestroyDataSource(po_datasource);
|
|
||||||
TIMER_STOP(SCC_OUTPUT);
|
|
||||||
osrm::util::SimpleLogger().Write()
|
|
||||||
<< "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000. << "s";
|
|
||||||
|
|
||||||
osrm::util::SimpleLogger().Write()
|
|
||||||
<< "total network distance: "
|
|
||||||
<< static_cast<uint64_t>(total_network_length / 100 / 1000.) << " km";
|
|
||||||
|
|
||||||
osrm::util::SimpleLogger().Write() << "finished component analysis";
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
OGRSpatialReference::DestroySpatialReference(po_srs);
|
||||||
{
|
OGRDataSource::DestroyDataSource(po_datasource);
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
TIMER_STOP(SCC_OUTPUT);
|
||||||
}
|
osrm::util::SimpleLogger().Write()
|
||||||
return 0;
|
<< "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000. << "s";
|
||||||
|
|
||||||
|
osrm::util::SimpleLogger().Write()
|
||||||
|
<< "total network distance: "
|
||||||
|
<< static_cast<uint64_t>(total_network_length / 100 / 1000.) << " km";
|
||||||
|
|
||||||
|
osrm::util::SimpleLogger().Write() << "finished component analysis";
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include "contractor/processing_chain.hpp"
|
#include "contractor/contractor.hpp"
|
||||||
#include "contractor/contractor_options.hpp"
|
#include "contractor/contractor_config.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
|
#include "util/version.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/program_options/errors.hpp>
|
#include <boost/program_options/errors.hpp>
|
||||||
|
|
||||||
#include <tbb/task_scheduler_init.h>
|
#include <tbb/task_scheduler_init.h>
|
||||||
@ -13,25 +16,131 @@
|
|||||||
|
|
||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
|
enum class return_code : unsigned
|
||||||
|
{
|
||||||
|
ok,
|
||||||
|
fail,
|
||||||
|
exit
|
||||||
|
};
|
||||||
|
|
||||||
|
return_code
|
||||||
|
parseArguments(int argc, char *argv[], contractor::ContractorConfig &contractor_config)
|
||||||
|
{
|
||||||
|
// declare a group of options that will be allowed only on command line
|
||||||
|
boost::program_options::options_description generic_options("Options");
|
||||||
|
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
||||||
|
"config,c",
|
||||||
|
boost::program_options::value<boost::filesystem::path>(&contractor_config.config_file_path)
|
||||||
|
->default_value("contractor.ini"),
|
||||||
|
"Path to a configuration file.");
|
||||||
|
|
||||||
|
// declare a group of options that will be allowed both on command line and in config file
|
||||||
|
boost::program_options::options_description config_options("Configuration");
|
||||||
|
config_options.add_options()(
|
||||||
|
"profile,p",
|
||||||
|
boost::program_options::value<boost::filesystem::path>(&contractor_config.profile_path)
|
||||||
|
->default_value("profile.lua"),
|
||||||
|
"Path to LUA routing profile")(
|
||||||
|
"threads,t",
|
||||||
|
boost::program_options::value<unsigned int>(&contractor_config.requested_num_threads)
|
||||||
|
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||||
|
"Number of threads to use")(
|
||||||
|
"core,k",
|
||||||
|
boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0),
|
||||||
|
"Percentage of the graph (in vertices) to contract [0..1]")(
|
||||||
|
"segment-speed-file",
|
||||||
|
boost::program_options::value<std::string>(&contractor_config.segment_speed_lookup_path),
|
||||||
|
"Lookup file containing nodeA,nodeB,speed data to adjust edge weights")(
|
||||||
|
"level-cache,o", boost::program_options::value<bool>(&contractor_config.use_cached_priority)
|
||||||
|
->default_value(false),
|
||||||
|
"Use .level file to retain the contaction level for each node from the last run.");
|
||||||
|
|
||||||
|
#ifdef DEBUG_GEOMETRY
|
||||||
|
config_options.add_options()(
|
||||||
|
"debug-geometry",
|
||||||
|
boost::program_options::value<std::string>(&contractor_config.debug_geometry_path),
|
||||||
|
"Write out edge-weight debugging geometry data in GeoJSON format to this file");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// hidden options, will be allowed both on command line and in config file, but will not be
|
||||||
|
// shown to the user
|
||||||
|
boost::program_options::options_description hidden_options("Hidden options");
|
||||||
|
hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>(
|
||||||
|
&contractor_config.osrm_input_path),
|
||||||
|
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
||||||
|
|
||||||
|
// positional option
|
||||||
|
boost::program_options::positional_options_description positional_options;
|
||||||
|
positional_options.add("input", 1);
|
||||||
|
|
||||||
|
// combine above options for parsing
|
||||||
|
boost::program_options::options_description cmdline_options;
|
||||||
|
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
||||||
|
|
||||||
|
boost::program_options::options_description config_file_options;
|
||||||
|
config_file_options.add(config_options).add(hidden_options);
|
||||||
|
|
||||||
|
boost::program_options::options_description visible_options(
|
||||||
|
"Usage: " + boost::filesystem::basename(argv[0]) + " <input.osrm> [options]");
|
||||||
|
visible_options.add(generic_options).add(config_options);
|
||||||
|
|
||||||
|
// parse command line options
|
||||||
|
boost::program_options::variables_map option_variables;
|
||||||
|
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
|
||||||
|
.options(cmdline_options)
|
||||||
|
.positional(positional_options)
|
||||||
|
.run(),
|
||||||
|
option_variables);
|
||||||
|
|
||||||
|
const auto &temp_config_path = option_variables["config"].as<boost::filesystem::path>();
|
||||||
|
if (boost::filesystem::is_regular_file(temp_config_path))
|
||||||
|
{
|
||||||
|
boost::program_options::store(boost::program_options::parse_config_file<char>(
|
||||||
|
temp_config_path.string().c_str(), cmdline_options, true),
|
||||||
|
option_variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option_variables.count("version"))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << OSRM_VERSION;
|
||||||
|
return return_code::exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option_variables.count("help"))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << "\n" << visible_options;
|
||||||
|
return return_code::exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::program_options::notify(option_variables);
|
||||||
|
|
||||||
|
if (!option_variables.count("input"))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << "\n" << visible_options;
|
||||||
|
return return_code::fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_code::ok;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) try
|
int main(int argc, char *argv[]) try
|
||||||
{
|
{
|
||||||
util::LogPolicy::GetInstance().Unmute();
|
util::LogPolicy::GetInstance().Unmute();
|
||||||
contractor::ContractorConfig contractor_config;
|
contractor::ContractorConfig contractor_config;
|
||||||
|
|
||||||
const contractor::return_code result =
|
const return_code result = parseArguments(argc, argv, contractor_config);
|
||||||
contractor::ContractorOptions::ParseArguments(argc, argv, contractor_config);
|
|
||||||
|
|
||||||
if (contractor::return_code::fail == result)
|
if (return_code::fail == result)
|
||||||
{
|
{
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contractor::return_code::exit == result)
|
if (return_code::exit == result)
|
||||||
{
|
{
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
contractor::ContractorOptions::GenerateOutputFilesNames(contractor_config);
|
contractor_config.UseDefaultOutputNames();
|
||||||
|
|
||||||
if (1 > contractor_config.requested_num_threads)
|
if (1 > contractor_config.requested_num_threads)
|
||||||
{
|
{
|
||||||
@ -70,7 +179,7 @@ int main(int argc, char *argv[]) try
|
|||||||
|
|
||||||
tbb::task_scheduler_init init(contractor_config.requested_num_threads);
|
tbb::task_scheduler_init init(contractor_config.requested_num_threads);
|
||||||
|
|
||||||
return contractor::Prepare(contractor_config).Run();
|
return contractor::Contractor(contractor_config).Run();
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc &e)
|
catch (const std::bad_alloc &e)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
#include "extractor/extractor.hpp"
|
#include "extractor/extractor.hpp"
|
||||||
#include "extractor/extractor_options.hpp"
|
#include "extractor/extractor_config.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
|
#include "util/ini_file.hpp"
|
||||||
|
#include "util/version.hpp"
|
||||||
|
|
||||||
|
#include <tbb/task_scheduler_init.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
@ -10,25 +15,150 @@
|
|||||||
|
|
||||||
using namespace osrm;
|
using namespace osrm;
|
||||||
|
|
||||||
|
enum class return_code : unsigned
|
||||||
|
{
|
||||||
|
ok,
|
||||||
|
fail,
|
||||||
|
exit
|
||||||
|
};
|
||||||
|
|
||||||
|
return_code
|
||||||
|
parseArguments(int argc, char *argv[], extractor::ExtractorConfig &extractor_config)
|
||||||
|
{
|
||||||
|
// declare a group of options that will be allowed only on command line
|
||||||
|
boost::program_options::options_description generic_options("Options");
|
||||||
|
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
|
||||||
|
/*
|
||||||
|
* TODO: re-enable this
|
||||||
|
"restrictions,r",
|
||||||
|
boost::program_options::value<boost::filesystem::path>(&extractor_config.restrictions_path),
|
||||||
|
"Restrictions file in .osrm.restrictions format")(
|
||||||
|
*/
|
||||||
|
"config,c",
|
||||||
|
boost::program_options::value<boost::filesystem::path>(&extractor_config.config_file_path)
|
||||||
|
->default_value("extractor.ini"),
|
||||||
|
"Path to a configuration file.");
|
||||||
|
|
||||||
|
// declare a group of options that will be allowed both on command line and in config file
|
||||||
|
boost::program_options::options_description config_options("Configuration");
|
||||||
|
config_options.add_options()(
|
||||||
|
"profile,p",
|
||||||
|
boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
|
||||||
|
->default_value("profile.lua"),
|
||||||
|
"Path to LUA routing profile")(
|
||||||
|
"threads,t",
|
||||||
|
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
|
||||||
|
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||||
|
"Number of threads to use")(
|
||||||
|
"generate-edge-lookup",
|
||||||
|
boost::program_options::value<bool>(&extractor_config.generate_edge_lookup)
|
||||||
|
->implicit_value(true)
|
||||||
|
->default_value(false),
|
||||||
|
"Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")(
|
||||||
|
"small-component-size",
|
||||||
|
boost::program_options::value<unsigned int>(&extractor_config.small_component_size)
|
||||||
|
->default_value(1000),
|
||||||
|
"Number of nodes required before a strongly-connected-componennt is considered big "
|
||||||
|
"(affects nearest neighbor snapping)");
|
||||||
|
|
||||||
|
#ifdef DEBUG_GEOMETRY
|
||||||
|
config_options.add_options()("debug-turns", boost::program_options::value<std::string>(
|
||||||
|
&extractor_config.debug_turns_path),
|
||||||
|
"Write out GeoJSON with turn penalty data");
|
||||||
|
#endif // DEBUG_GEOMETRY
|
||||||
|
|
||||||
|
// hidden options, will be allowed both on command line and in config file, but will not be
|
||||||
|
// shown to the user
|
||||||
|
boost::program_options::options_description hidden_options("Hidden options");
|
||||||
|
hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>(
|
||||||
|
&extractor_config.input_path),
|
||||||
|
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
||||||
|
|
||||||
|
// positional option
|
||||||
|
boost::program_options::positional_options_description positional_options;
|
||||||
|
positional_options.add("input", 1);
|
||||||
|
|
||||||
|
// combine above options for parsing
|
||||||
|
boost::program_options::options_description cmdline_options;
|
||||||
|
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
||||||
|
|
||||||
|
boost::program_options::options_description config_file_options;
|
||||||
|
config_file_options.add(config_options).add(hidden_options);
|
||||||
|
|
||||||
|
boost::program_options::options_description visible_options(
|
||||||
|
boost::filesystem::basename(argv[0]) + " <input.osm/.osm.bz2/.osm.pbf> [options]");
|
||||||
|
visible_options.add(generic_options).add(config_options);
|
||||||
|
|
||||||
|
// parse command line options
|
||||||
|
try
|
||||||
|
{
|
||||||
|
boost::program_options::variables_map option_variables;
|
||||||
|
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
|
||||||
|
.options(cmdline_options)
|
||||||
|
.positional(positional_options)
|
||||||
|
.run(),
|
||||||
|
option_variables);
|
||||||
|
if (option_variables.count("version"))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << OSRM_VERSION;
|
||||||
|
return return_code::exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option_variables.count("help"))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << visible_options;
|
||||||
|
return return_code::exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::program_options::notify(option_variables);
|
||||||
|
|
||||||
|
// parse config file
|
||||||
|
if (boost::filesystem::is_regular_file(extractor_config.config_file_path))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << "Reading options from: "
|
||||||
|
<< extractor_config.config_file_path.string();
|
||||||
|
std::string ini_file_contents =
|
||||||
|
util::read_file_lower_content(extractor_config.config_file_path);
|
||||||
|
std::stringstream config_stream(ini_file_contents);
|
||||||
|
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||||
|
option_variables);
|
||||||
|
boost::program_options::notify(option_variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!option_variables.count("input"))
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << visible_options;
|
||||||
|
return return_code::exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write(logWARNING) << e.what();
|
||||||
|
return return_code::fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_code::ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) try
|
int main(int argc, char *argv[]) try
|
||||||
{
|
{
|
||||||
util::LogPolicy::GetInstance().Unmute();
|
util::LogPolicy::GetInstance().Unmute();
|
||||||
extractor::ExtractorConfig extractor_config;
|
extractor::ExtractorConfig extractor_config;
|
||||||
|
|
||||||
const extractor::return_code result =
|
const auto result = parseArguments(argc, argv, extractor_config);
|
||||||
extractor::ExtractorOptions::ParseArguments(argc, argv, extractor_config);
|
|
||||||
|
|
||||||
if (extractor::return_code::fail == result)
|
if (return_code::fail == result)
|
||||||
{
|
{
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extractor::return_code::exit == result)
|
if (return_code::exit == result)
|
||||||
{
|
{
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
extractor::ExtractorOptions::GenerateOutputFilesNames(extractor_config);
|
extractor_config.UseDefaultOutputNames();
|
||||||
|
|
||||||
if (1 > extractor_config.requested_num_threads)
|
if (1 > extractor_config.requested_num_threads)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,9 @@ void runStatistics(std::vector<double> &timings_vector, Statistics &stats)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
boost::filesystem::path test_path;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) try
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
@ -60,279 +62,275 @@ int main(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
osrm::util::LogPolicy::GetInstance().Unmute();
|
||||||
boost::filesystem::path test_path;
|
if (1 == argc)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (1 == argc)
|
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0]
|
||||||
|
<< " /path/on/device";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
test_path = boost::filesystem::path(argv[1]);
|
||||||
|
test_path /= "osrm.tst";
|
||||||
|
osrm::util::SimpleLogger().Write(logDEBUG) << "temporary file: " << test_path.string();
|
||||||
|
|
||||||
|
// create files for testing
|
||||||
|
if (2 == argc)
|
||||||
|
{
|
||||||
|
// create file to test
|
||||||
|
if (boost::filesystem::exists(test_path))
|
||||||
{
|
{
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0]
|
throw osrm::util::exception("Data file already exists");
|
||||||
<< " /path/on/device";
|
}
|
||||||
|
|
||||||
|
int *random_array = new int[osrm::tools::NUMBER_OF_ELEMENTS];
|
||||||
|
std::generate(random_array, random_array + osrm::tools::NUMBER_OF_ELEMENTS, std::rand);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
FILE *fd = fopen(test_path.string().c_str(), "w");
|
||||||
|
fcntl(fileno(fd), F_NOCACHE, 1);
|
||||||
|
fcntl(fileno(fd), F_RDAHEAD, 0);
|
||||||
|
TIMER_START(write_1gb);
|
||||||
|
write(fileno(fd), (char *)random_array,
|
||||||
|
osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||||
|
TIMER_STOP(write_1gb);
|
||||||
|
fclose(fd);
|
||||||
|
#endif
|
||||||
|
#ifdef __linux__
|
||||||
|
int file_desc =
|
||||||
|
open(test_path.string().c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_SYNC, S_IRWXU);
|
||||||
|
if (-1 == file_desc)
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("Could not open random data file");
|
||||||
|
}
|
||||||
|
TIMER_START(write_1gb);
|
||||||
|
int ret =
|
||||||
|
write(file_desc, random_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||||
|
if (0 > ret)
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("could not write random data file");
|
||||||
|
}
|
||||||
|
TIMER_STOP(write_1gb);
|
||||||
|
close(file_desc);
|
||||||
|
#endif
|
||||||
|
delete[] random_array;
|
||||||
|
osrm::util::SimpleLogger().Write(logDEBUG) << "writing raw 1GB took "
|
||||||
|
<< TIMER_SEC(write_1gb) << "s";
|
||||||
|
osrm::util::SimpleLogger().Write() << "raw write performance: " << std::setprecision(5)
|
||||||
|
<< std::fixed << 1024 * 1024 / TIMER_SEC(write_1gb)
|
||||||
|
<< "MB/sec";
|
||||||
|
|
||||||
|
osrm::util::SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "finished creation of random data. Flush disk cache now!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Run Non-Cached I/O benchmarks
|
||||||
|
if (!boost::filesystem::exists(test_path))
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("data file does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
// volatiles do not get optimized
|
||||||
|
osrm::tools::Statistics stats;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
volatile unsigned single_block[1024];
|
||||||
|
char *raw_array = new char[osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned)];
|
||||||
|
FILE *fd = fopen(test_path.string().c_str(), "r");
|
||||||
|
fcntl(fileno(fd), F_NOCACHE, 1);
|
||||||
|
fcntl(fileno(fd), F_RDAHEAD, 0);
|
||||||
|
#endif
|
||||||
|
#ifdef __linux__
|
||||||
|
char *single_block = (char *)memalign(512, 1024 * sizeof(unsigned));
|
||||||
|
|
||||||
|
int file_desc = open(test_path.string().c_str(), O_RDONLY | O_DIRECT | O_SYNC);
|
||||||
|
if (-1 == file_desc)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
char *raw_array =
|
||||||
test_path = boost::filesystem::path(argv[1]);
|
(char *)memalign(512, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||||
test_path /= "osrm.tst";
|
#endif
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "temporary file: " << test_path.string();
|
TIMER_START(read_1gb);
|
||||||
|
|
||||||
// create files for testing
|
|
||||||
if (2 == argc)
|
|
||||||
{
|
|
||||||
// create file to test
|
|
||||||
if (boost::filesystem::exists(test_path))
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("Data file already exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
int *random_array = new int[osrm::tools::NUMBER_OF_ELEMENTS];
|
|
||||||
std::generate(random_array, random_array + osrm::tools::NUMBER_OF_ELEMENTS, std::rand);
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
FILE *fd = fopen(test_path.string().c_str(), "w");
|
read(fileno(fd), raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||||
fcntl(fileno(fd), F_NOCACHE, 1);
|
close(fileno(fd));
|
||||||
fcntl(fileno(fd), F_RDAHEAD, 0);
|
fd = fopen(test_path.string().c_str(), "r");
|
||||||
TIMER_START(write_1gb);
|
|
||||||
write(fileno(fd), (char *)random_array,
|
|
||||||
osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
|
||||||
TIMER_STOP(write_1gb);
|
|
||||||
fclose(fd);
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int file_desc =
|
int ret =
|
||||||
open(test_path.string().c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_SYNC, S_IRWXU);
|
read(file_desc, raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||||
if (-1 == file_desc)
|
osrm::util::SimpleLogger().Write(logDEBUG) << "read " << ret
|
||||||
{
|
<< " bytes, error: " << strerror(errno);
|
||||||
throw osrm::util::exception("Could not open random data file");
|
close(file_desc);
|
||||||
}
|
file_desc = open(test_path.string().c_str(), O_RDONLY | O_DIRECT | O_SYNC);
|
||||||
TIMER_START(write_1gb);
|
osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno);
|
||||||
int ret =
|
|
||||||
write(file_desc, random_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
|
||||||
if (0 > ret)
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("could not write random data file");
|
|
||||||
}
|
|
||||||
TIMER_STOP(write_1gb);
|
|
||||||
close(file_desc);
|
|
||||||
#endif
|
#endif
|
||||||
delete[] random_array;
|
TIMER_STOP(read_1gb);
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "writing raw 1GB took "
|
|
||||||
<< TIMER_SEC(write_1gb) << "s";
|
|
||||||
osrm::util::SimpleLogger().Write() << "raw write performance: " << std::setprecision(5)
|
|
||||||
<< std::fixed << 1024 * 1024 / TIMER_SEC(write_1gb)
|
|
||||||
<< "MB/sec";
|
|
||||||
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG)
|
osrm::util::SimpleLogger().Write(logDEBUG) << "reading raw 1GB took "
|
||||||
<< "finished creation of random data. Flush disk cache now!";
|
<< TIMER_SEC(read_1gb) << "s";
|
||||||
|
osrm::util::SimpleLogger().Write() << "raw read performance: " << std::setprecision(5)
|
||||||
|
<< std::fixed << 1024 * 1024 / TIMER_SEC(read_1gb)
|
||||||
|
<< "MB/sec";
|
||||||
|
|
||||||
|
std::vector<double> timing_results_raw_random;
|
||||||
|
osrm::util::SimpleLogger().Write(logDEBUG) << "running 1000 random I/Os of 4KB";
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
fseek(fd, 0, SEEK_SET);
|
||||||
|
#endif
|
||||||
|
#ifdef __linux__
|
||||||
|
lseek(file_desc, 0, SEEK_SET);
|
||||||
|
#endif
|
||||||
|
// make 1000 random access, time each I/O seperately
|
||||||
|
unsigned number_of_blocks =
|
||||||
|
(osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned) - 1) / 4096;
|
||||||
|
std::random_device rd;
|
||||||
|
std::default_random_engine e1(rd());
|
||||||
|
std::uniform_int_distribution<unsigned> uniform_dist(0, number_of_blocks - 1);
|
||||||
|
for (unsigned i = 0; i < 1000; ++i)
|
||||||
|
{
|
||||||
|
unsigned block_to_read = uniform_dist(e1);
|
||||||
|
off_t current_offset = block_to_read * 4096;
|
||||||
|
TIMER_START(random_access);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
int ret1 = fseek(fd, current_offset, SEEK_SET);
|
||||||
|
int ret2 = read(fileno(fd), (char *)&single_block[0], 4096);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
int ret1 = 0;
|
||||||
|
int ret2 = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
int ret1 = lseek(file_desc, current_offset, SEEK_SET);
|
||||||
|
int ret2 = read(file_desc, (char *)single_block, 4096);
|
||||||
|
#endif
|
||||||
|
TIMER_STOP(random_access);
|
||||||
|
if (((off_t)-1) == ret1)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "seek error "
|
||||||
|
<< strerror(errno);
|
||||||
|
throw osrm::util::exception("seek error");
|
||||||
|
}
|
||||||
|
if (-1 == ret2)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "read error "
|
||||||
|
<< strerror(errno);
|
||||||
|
throw osrm::util::exception("read error");
|
||||||
|
}
|
||||||
|
timing_results_raw_random.push_back(TIMER_SEC(random_access));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Do statistics
|
||||||
|
osrm::util::SimpleLogger().Write(logDEBUG) << "running raw random I/O statistics";
|
||||||
|
std::ofstream random_csv("random.csv", std::ios::trunc);
|
||||||
|
for (unsigned i = 0; i < timing_results_raw_random.size(); ++i)
|
||||||
{
|
{
|
||||||
// Run Non-Cached I/O benchmarks
|
random_csv << i << ", " << timing_results_raw_random[i] << std::endl;
|
||||||
if (!boost::filesystem::exists(test_path))
|
}
|
||||||
{
|
random_csv.close();
|
||||||
throw osrm::util::exception("data file does not exist");
|
osrm::tools::runStatistics(timing_results_raw_random, stats);
|
||||||
}
|
|
||||||
|
|
||||||
// volatiles do not get optimized
|
osrm::util::SimpleLogger().Write() << "raw random I/O: " << std::setprecision(5)
|
||||||
osrm::tools::Statistics stats;
|
<< std::fixed << "min: " << stats.min << "ms, "
|
||||||
|
<< "mean: " << stats.mean << "ms, "
|
||||||
|
<< "med: " << stats.med << "ms, "
|
||||||
|
<< "max: " << stats.max << "ms, "
|
||||||
|
<< "dev: " << stats.dev << "ms";
|
||||||
|
|
||||||
|
std::vector<double> timing_results_raw_seq;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
volatile unsigned single_block[1024];
|
fseek(fd, 0, SEEK_SET);
|
||||||
char *raw_array = new char[osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned)];
|
|
||||||
FILE *fd = fopen(test_path.string().c_str(), "r");
|
|
||||||
fcntl(fileno(fd), F_NOCACHE, 1);
|
|
||||||
fcntl(fileno(fd), F_RDAHEAD, 0);
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
char *single_block = (char *)memalign(512, 1024 * sizeof(unsigned));
|
lseek(file_desc, 0, SEEK_SET);
|
||||||
|
|
||||||
int file_desc = open(test_path.string().c_str(), O_RDONLY | O_DIRECT | O_SYNC);
|
|
||||||
if (-1 == file_desc)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
char *raw_array =
|
|
||||||
(char *)memalign(512, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
|
||||||
#endif
|
#endif
|
||||||
TIMER_START(read_1gb);
|
|
||||||
|
// read every 100th block
|
||||||
|
for (unsigned i = 0; i < 1000; ++i)
|
||||||
|
{
|
||||||
|
off_t current_offset = i * 4096;
|
||||||
|
TIMER_START(read_every_100);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
read(fileno(fd), raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
int ret1 = fseek(fd, current_offset, SEEK_SET);
|
||||||
close(fileno(fd));
|
int ret2 = read(fileno(fd), (char *)&single_block, 4096);
|
||||||
fd = fopen(test_path.string().c_str(), "r");
|
|
||||||
#endif
|
|
||||||
#ifdef __linux__
|
|
||||||
int ret =
|
|
||||||
read(file_desc, raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "read " << ret
|
|
||||||
<< " bytes, error: " << strerror(errno);
|
|
||||||
close(file_desc);
|
|
||||||
file_desc = open(test_path.string().c_str(), O_RDONLY | O_DIRECT | O_SYNC);
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno);
|
|
||||||
#endif
|
|
||||||
TIMER_STOP(read_1gb);
|
|
||||||
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "reading raw 1GB took "
|
|
||||||
<< TIMER_SEC(read_1gb) << "s";
|
|
||||||
osrm::util::SimpleLogger().Write() << "raw read performance: " << std::setprecision(5)
|
|
||||||
<< std::fixed << 1024 * 1024 / TIMER_SEC(read_1gb)
|
|
||||||
<< "MB/sec";
|
|
||||||
|
|
||||||
std::vector<double> timing_results_raw_random;
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "running 1000 random I/Os of 4KB";
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
fseek(fd, 0, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
#ifdef __linux__
|
|
||||||
lseek(file_desc, 0, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
// make 1000 random access, time each I/O seperately
|
|
||||||
unsigned number_of_blocks =
|
|
||||||
(osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned) - 1) / 4096;
|
|
||||||
std::random_device rd;
|
|
||||||
std::default_random_engine e1(rd());
|
|
||||||
std::uniform_int_distribution<unsigned> uniform_dist(0, number_of_blocks - 1);
|
|
||||||
for (unsigned i = 0; i < 1000; ++i)
|
|
||||||
{
|
|
||||||
unsigned block_to_read = uniform_dist(e1);
|
|
||||||
off_t current_offset = block_to_read * 4096;
|
|
||||||
TIMER_START(random_access);
|
|
||||||
#ifdef __APPLE__
|
|
||||||
int ret1 = fseek(fd, current_offset, SEEK_SET);
|
|
||||||
int ret2 = read(fileno(fd), (char *)&single_block[0], 4096);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
int ret1 = 0;
|
int ret1 = 0;
|
||||||
int ret2 = 0;
|
int ret2 = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int ret1 = lseek(file_desc, current_offset, SEEK_SET);
|
int ret1 = lseek(file_desc, current_offset, SEEK_SET);
|
||||||
int ret2 = read(file_desc, (char *)single_block, 4096);
|
|
||||||
#endif
|
|
||||||
TIMER_STOP(random_access);
|
|
||||||
if (((off_t)-1) == ret1)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "seek error "
|
|
||||||
<< strerror(errno);
|
|
||||||
throw osrm::util::exception("seek error");
|
|
||||||
}
|
|
||||||
if (-1 == ret2)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "read error "
|
|
||||||
<< strerror(errno);
|
|
||||||
throw osrm::util::exception("read error");
|
|
||||||
}
|
|
||||||
timing_results_raw_random.push_back(TIMER_SEC(random_access));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do statistics
|
int ret2 = read(file_desc, (char *)single_block, 4096);
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "running raw random I/O statistics";
|
#endif
|
||||||
std::ofstream random_csv("random.csv", std::ios::trunc);
|
TIMER_STOP(read_every_100);
|
||||||
for (unsigned i = 0; i < timing_results_raw_random.size(); ++i)
|
if (((off_t)-1) == ret1)
|
||||||
{
|
{
|
||||||
random_csv << i << ", " << timing_results_raw_random[i] << std::endl;
|
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "seek error "
|
||||||
|
<< strerror(errno);
|
||||||
|
throw osrm::util::exception("seek error");
|
||||||
}
|
}
|
||||||
random_csv.close();
|
if (-1 == ret2)
|
||||||
osrm::tools::runStatistics(timing_results_raw_random, stats);
|
|
||||||
|
|
||||||
osrm::util::SimpleLogger().Write() << "raw random I/O: " << std::setprecision(5)
|
|
||||||
<< std::fixed << "min: " << stats.min << "ms, "
|
|
||||||
<< "mean: " << stats.mean << "ms, "
|
|
||||||
<< "med: " << stats.med << "ms, "
|
|
||||||
<< "max: " << stats.max << "ms, "
|
|
||||||
<< "dev: " << stats.dev << "ms";
|
|
||||||
|
|
||||||
std::vector<double> timing_results_raw_seq;
|
|
||||||
#ifdef __APPLE__
|
|
||||||
fseek(fd, 0, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
#ifdef __linux__
|
|
||||||
lseek(file_desc, 0, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// read every 100th block
|
|
||||||
for (unsigned i = 0; i < 1000; ++i)
|
|
||||||
{
|
{
|
||||||
off_t current_offset = i * 4096;
|
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||||
TIMER_START(read_every_100);
|
osrm::util::SimpleLogger().Write(logWARNING) << "read error "
|
||||||
#ifdef __APPLE__
|
<< strerror(errno);
|
||||||
int ret1 = fseek(fd, current_offset, SEEK_SET);
|
throw osrm::util::exception("read error");
|
||||||
int ret2 = read(fileno(fd), (char *)&single_block, 4096);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
int ret1 = 0;
|
|
||||||
int ret2 = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
int ret1 = lseek(file_desc, current_offset, SEEK_SET);
|
|
||||||
|
|
||||||
int ret2 = read(file_desc, (char *)single_block, 4096);
|
|
||||||
#endif
|
|
||||||
TIMER_STOP(read_every_100);
|
|
||||||
if (((off_t)-1) == ret1)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "seek error "
|
|
||||||
<< strerror(errno);
|
|
||||||
throw osrm::util::exception("seek error");
|
|
||||||
}
|
|
||||||
if (-1 == ret2)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "read error "
|
|
||||||
<< strerror(errno);
|
|
||||||
throw osrm::util::exception("read error");
|
|
||||||
}
|
|
||||||
timing_results_raw_seq.push_back(TIMER_SEC(read_every_100));
|
|
||||||
}
|
}
|
||||||
|
timing_results_raw_seq.push_back(TIMER_SEC(read_every_100));
|
||||||
|
}
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
// free(single_element);
|
// free(single_element);
|
||||||
free(raw_array);
|
free(raw_array);
|
||||||
// free(single_block);
|
// free(single_block);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
close(file_desc);
|
close(file_desc);
|
||||||
#endif
|
#endif
|
||||||
// Do statistics
|
// Do statistics
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "running sequential I/O statistics";
|
osrm::util::SimpleLogger().Write(logDEBUG) << "running sequential I/O statistics";
|
||||||
// print simple statistics: min, max, median, variance
|
// print simple statistics: min, max, median, variance
|
||||||
std::ofstream seq_csv("sequential.csv", std::ios::trunc);
|
std::ofstream seq_csv("sequential.csv", std::ios::trunc);
|
||||||
for (unsigned i = 0; i < timing_results_raw_seq.size(); ++i)
|
for (unsigned i = 0; i < timing_results_raw_seq.size(); ++i)
|
||||||
{
|
{
|
||||||
seq_csv << i << ", " << timing_results_raw_seq[i] << std::endl;
|
seq_csv << i << ", " << timing_results_raw_seq[i] << std::endl;
|
||||||
}
|
|
||||||
seq_csv.close();
|
|
||||||
osrm::tools::runStatistics(timing_results_raw_seq, stats);
|
|
||||||
osrm::util::SimpleLogger().Write() << "raw sequential I/O: " << std::setprecision(5)
|
|
||||||
<< std::fixed << "min: " << stats.min << "ms, "
|
|
||||||
<< "mean: " << stats.mean << "ms, "
|
|
||||||
<< "med: " << stats.med << "ms, "
|
|
||||||
<< "max: " << stats.max << "ms, "
|
|
||||||
<< "dev: " << stats.dev << "ms";
|
|
||||||
|
|
||||||
if (boost::filesystem::exists(test_path))
|
|
||||||
{
|
|
||||||
boost::filesystem::remove(test_path);
|
|
||||||
osrm::util::SimpleLogger().Write(logDEBUG) << "removing temporary files";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
seq_csv.close();
|
||||||
catch (const std::exception &e)
|
osrm::tools::runStatistics(timing_results_raw_seq, stats);
|
||||||
{
|
osrm::util::SimpleLogger().Write() << "raw sequential I/O: " << std::setprecision(5)
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what();
|
<< std::fixed << "min: " << stats.min << "ms, "
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "cleaning up, and exiting";
|
<< "mean: " << stats.mean << "ms, "
|
||||||
|
<< "med: " << stats.med << "ms, "
|
||||||
|
<< "max: " << stats.max << "ms, "
|
||||||
|
<< "dev: " << stats.dev << "ms";
|
||||||
|
|
||||||
if (boost::filesystem::exists(test_path))
|
if (boost::filesystem::exists(test_path))
|
||||||
{
|
{
|
||||||
boost::filesystem::remove(test_path);
|
boost::filesystem::remove(test_path);
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "removing temporary files";
|
osrm::util::SimpleLogger().Write(logDEBUG) << "removing temporary files";
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what();
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "cleaning up, and exiting";
|
||||||
|
if (boost::filesystem::exists(test_path))
|
||||||
|
{
|
||||||
|
boost::filesystem::remove(test_path);
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "removing temporary files";
|
||||||
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
|
|
||||||
#include "osrm/osrm.hpp"
|
#include "osrm/osrm.hpp"
|
||||||
#include "osrm/libosrm_config.hpp"
|
#include "osrm/engine_config.hpp"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -49,12 +49,12 @@ int main(int argc, const char *argv[]) try
|
|||||||
std::string ip_address;
|
std::string ip_address;
|
||||||
int ip_port, requested_thread_num;
|
int ip_port, requested_thread_num;
|
||||||
|
|
||||||
LibOSRMConfig lib_config;
|
EngineConfig config;
|
||||||
const unsigned init_result = util::GenerateServerProgramOptions(
|
const unsigned init_result = util::GenerateServerProgramOptions(
|
||||||
argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num,
|
argc, argv, config.server_paths, ip_address, ip_port, requested_thread_num,
|
||||||
lib_config.use_shared_memory, trial_run, lib_config.max_locations_trip,
|
config.use_shared_memory, trial_run, config.max_locations_trip,
|
||||||
lib_config.max_locations_viaroute, lib_config.max_locations_distance_table,
|
config.max_locations_viaroute, config.max_locations_distance_table,
|
||||||
lib_config.max_locations_map_matching);
|
config.max_locations_map_matching);
|
||||||
if (init_result == util::INIT_OK_DO_NOT_START_ENGINE)
|
if (init_result == util::INIT_OK_DO_NOT_START_ENGINE)
|
||||||
{
|
{
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
@ -81,11 +81,11 @@ int main(int argc, const char *argv[]) try
|
|||||||
(void)munlockall();
|
(void)munlockall();
|
||||||
}
|
}
|
||||||
bool should_lock = false, could_lock = true;
|
bool should_lock = false, could_lock = true;
|
||||||
} memory_locker(lib_config.use_shared_memory);
|
} memory_locker(config.use_shared_memory);
|
||||||
#endif
|
#endif
|
||||||
util::SimpleLogger().Write() << "starting up engines, " << OSRM_VERSION;
|
util::SimpleLogger().Write() << "starting up engines, " << OSRM_VERSION;
|
||||||
|
|
||||||
if (lib_config.use_shared_memory)
|
if (config.use_shared_memory)
|
||||||
{
|
{
|
||||||
util::SimpleLogger().Write(logDEBUG) << "Loading from shared memory";
|
util::SimpleLogger().Write(logDEBUG) << "Loading from shared memory";
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ int main(int argc, const char *argv[]) try
|
|||||||
pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask);
|
pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OSRM osrm_lib(lib_config);
|
OSRM osrm_lib(config);
|
||||||
auto routing_server = server::Server::CreateServer(ip_address, ip_port, requested_thread_num);
|
auto routing_server = server::Server::CreateServer(ip_address, ip_port, requested_thread_num);
|
||||||
|
|
||||||
routing_server->GetRequestHandlerPtr().RegisterRoutingMachine(&osrm_lib);
|
routing_server->GetRequestHandlerPtr().RegisterRoutingMachine(&osrm_lib);
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
#include "util/json_renderer.hpp"
|
|
||||||
#include "util/routed_options.hpp"
|
|
||||||
#include "util/simple_logger.hpp"
|
|
||||||
|
|
||||||
#include "osrm/json_container.hpp"
|
|
||||||
#include "osrm/libosrm_config.hpp"
|
|
||||||
#include "osrm/route_parameters.hpp"
|
|
||||||
#include "osrm/osrm.hpp"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
|
||||||
{
|
|
||||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string ip_address;
|
|
||||||
int ip_port, requested_thread_num;
|
|
||||||
bool trial_run = false;
|
|
||||||
osrm::LibOSRMConfig lib_config;
|
|
||||||
const unsigned init_result = osrm::util::GenerateServerProgramOptions(
|
|
||||||
argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num,
|
|
||||||
lib_config.use_shared_memory, trial_run, lib_config.max_locations_trip,
|
|
||||||
lib_config.max_locations_viaroute, lib_config.max_locations_distance_table,
|
|
||||||
lib_config.max_locations_map_matching);
|
|
||||||
|
|
||||||
if (init_result == osrm::util::INIT_OK_DO_NOT_START_ENGINE)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (init_result == osrm::util::INIT_FAILED)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
osrm::OSRM routing_machine(lib_config);
|
|
||||||
|
|
||||||
osrm::RouteParameters route_parameters;
|
|
||||||
route_parameters.zoom_level = 18; // no generalization
|
|
||||||
route_parameters.print_instructions = true; // turn by turn instructions
|
|
||||||
route_parameters.alternate_route = true; // get an alternate route, too
|
|
||||||
route_parameters.geometry = true; // retrieve geometry of route
|
|
||||||
route_parameters.compression = true; // polyline encoding
|
|
||||||
route_parameters.check_sum = -1; // see wiki
|
|
||||||
route_parameters.service = "viaroute"; // that's routing
|
|
||||||
route_parameters.output_format = "json";
|
|
||||||
route_parameters.jsonp_parameter = ""; // set for jsonp wrapping
|
|
||||||
route_parameters.language = ""; // unused atm
|
|
||||||
// route_parameters.hints.push_back(); // see wiki, saves I/O if done properly
|
|
||||||
|
|
||||||
// start_coordinate
|
|
||||||
route_parameters.coordinates.emplace_back(52.519930 * osrm::COORDINATE_PRECISION,
|
|
||||||
13.438640 * osrm::COORDINATE_PRECISION);
|
|
||||||
// target_coordinate
|
|
||||||
route_parameters.coordinates.emplace_back(52.513191 * osrm::COORDINATE_PRECISION,
|
|
||||||
13.415852 * osrm::COORDINATE_PRECISION);
|
|
||||||
osrm::json::Object json_result;
|
|
||||||
const int result_code = routing_machine.RunQuery(route_parameters, json_result);
|
|
||||||
osrm::util::SimpleLogger().Write() << "http code: " << result_code;
|
|
||||||
osrm::json::render(osrm::util::SimpleLogger().Write(), json_result);
|
|
||||||
}
|
|
||||||
catch (std::exception ¤t_exception)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "caught exception: "
|
|
||||||
<< current_exception.what();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "datastore/shared_memory_factory.hpp"
|
#include "storage/shared_memory.hpp"
|
||||||
#include "engine/datafacade/shared_datatype.hpp"
|
#include "storage/shared_datatype.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
@ -10,8 +10,7 @@ namespace tools
|
|||||||
{
|
{
|
||||||
|
|
||||||
// FIXME remove after folding back into datastore
|
// FIXME remove after folding back into datastore
|
||||||
using namespace datastore;
|
using namespace storage;
|
||||||
using namespace engine::datafacade;
|
|
||||||
|
|
||||||
void deleteRegion(const SharedDataType region)
|
void deleteRegion(const SharedDataType region)
|
||||||
{
|
{
|
||||||
@ -55,33 +54,31 @@ void springclean()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main() try
|
||||||
{
|
{
|
||||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
osrm::util::LogPolicy::GetInstance().Unmute();
|
||||||
try
|
osrm::util::SimpleLogger().Write() << "Releasing all locks";
|
||||||
{
|
osrm::util::SimpleLogger().Write() << "ATTENTION! BE CAREFUL!";
|
||||||
osrm::util::SimpleLogger().Write() << "Releasing all locks";
|
osrm::util::SimpleLogger().Write() << "----------------------";
|
||||||
osrm::util::SimpleLogger().Write() << "ATTENTION! BE CAREFUL!";
|
osrm::util::SimpleLogger().Write()
|
||||||
osrm::util::SimpleLogger().Write() << "----------------------";
|
<< "This tool may put osrm-routed into an undefined state!";
|
||||||
osrm::util::SimpleLogger().Write()
|
osrm::util::SimpleLogger().Write()
|
||||||
<< "This tool may put osrm-routed into an undefined state!";
|
<< "Type 'Y' to acknowledge that you know what your are doing.";
|
||||||
osrm::util::SimpleLogger().Write()
|
osrm::util::SimpleLogger().Write()
|
||||||
<< "Type 'Y' to acknowledge that you know what your are doing.";
|
<< "\n\nDo you want to purge all shared memory allocated "
|
||||||
osrm::util::SimpleLogger().Write()
|
<< "by osrm-datastore? [type 'Y' to confirm]";
|
||||||
<< "\n\nDo you want to purge all shared memory allocated "
|
|
||||||
<< "by osrm-datastore? [type 'Y' to confirm]";
|
|
||||||
|
|
||||||
const auto letter = getchar();
|
const auto letter = getchar();
|
||||||
if (letter != 'Y')
|
if (letter != 'Y')
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write() << "aborted.";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
osrm::tools::springclean();
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
{
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "[excpetion] " << e.what();
|
osrm::util::SimpleLogger().Write() << "aborted.";
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
return 0;
|
osrm::tools::springclean();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "[excpetion] " << e.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,19 @@
|
|||||||
#ifndef DATASTORE_OPTIONS_HPP
|
#include "storage/storage.hpp"
|
||||||
#define DATASTORE_OPTIONS_HPP
|
|
||||||
|
|
||||||
#include "util/version.hpp"
|
|
||||||
#include "util/ini_file.hpp"
|
|
||||||
#include "util/osrm_exception.hpp"
|
#include "util/osrm_exception.hpp"
|
||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
|
#include "util/typedefs.hpp"
|
||||||
|
#include "util/ini_file.hpp"
|
||||||
|
#include "util/version.hpp"
|
||||||
|
|
||||||
#include <boost/any.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <string>
|
using namespace osrm;
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace osrm
|
|
||||||
{
|
|
||||||
namespace util
|
|
||||||
{
|
|
||||||
|
|
||||||
// generate boost::program_options object for the routing part
|
// generate boost::program_options object for the routing part
|
||||||
bool GenerateDataStoreOptions(const int argc,
|
bool generateDataStoreOptions(const int argc,
|
||||||
const char *argv[],
|
const char *argv[],
|
||||||
std::unordered_map<std::string, boost::filesystem::path> &paths)
|
storage::DataPaths &paths)
|
||||||
{
|
{
|
||||||
// declare a group of options that will be allowed only on command line
|
// declare a group of options that will be allowed only on command line
|
||||||
boost::program_options::options_description generic_options("Options");
|
boost::program_options::options_description generic_options("Options");
|
||||||
@ -76,6 +68,13 @@ bool GenerateDataStoreOptions(const int argc,
|
|||||||
boost::filesystem::basename(argv[0]) + " [<options>] <configuration>");
|
boost::filesystem::basename(argv[0]) + " [<options>] <configuration>");
|
||||||
visible_options.add(generic_options).add(config_options);
|
visible_options.add(generic_options).add(config_options);
|
||||||
|
|
||||||
|
// print help options if no infile is specified
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write() << visible_options;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// parse command line options
|
// parse command line options
|
||||||
boost::program_options::variables_map option_variables;
|
boost::program_options::variables_map option_variables;
|
||||||
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
|
boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
|
||||||
@ -86,13 +85,13 @@ bool GenerateDataStoreOptions(const int argc,
|
|||||||
|
|
||||||
if (option_variables.count("version"))
|
if (option_variables.count("version"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << OSRM_VERSION;
|
util::SimpleLogger().Write() << OSRM_VERSION;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option_variables.count("help"))
|
if (option_variables.count("help"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << visible_options;
|
util::SimpleLogger().Write() << visible_options;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,8 +120,8 @@ bool GenerateDataStoreOptions(const int argc,
|
|||||||
boost::filesystem::is_regular_file(paths.find("config")->second)) ||
|
boost::filesystem::is_regular_file(paths.find("config")->second)) ||
|
||||||
option_variables.count("base"))
|
option_variables.count("base"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << "conflicting parameters";
|
util::SimpleLogger().Write(logWARNING) << "conflicting parameters";
|
||||||
SimpleLogger().Write() << visible_options;
|
util::SimpleLogger().Write() << visible_options;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,8 +131,8 @@ bool GenerateDataStoreOptions(const int argc,
|
|||||||
if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) &&
|
if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) &&
|
||||||
!option_variables.count("base"))
|
!option_variables.count("base"))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
util::SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
||||||
std::string ini_file_contents = read_file_lower_content(path_iterator->second);
|
std::string ini_file_contents = util::read_file_lower_content(path_iterator->second);
|
||||||
std::stringstream config_stream(ini_file_contents);
|
std::stringstream config_stream(ini_file_contents);
|
||||||
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
boost::program_options::store(parse_config_file(config_stream, config_file_options),
|
||||||
option_variables);
|
option_variables);
|
||||||
@ -204,61 +203,84 @@ bool GenerateDataStoreOptions(const int argc,
|
|||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .hsgr file must be specified");
|
throw util::exception("valid .hsgr file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("nodesdata");
|
path_iterator = paths.find("nodesdata");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .nodes file must be specified");
|
throw util::exception("valid .nodes file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("edgesdata");
|
path_iterator = paths.find("edgesdata");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .edges file must be specified");
|
throw util::exception("valid .edges file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("geometry");
|
path_iterator = paths.find("geometry");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .geometry file must be specified");
|
throw util::exception("valid .geometry file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("ramindex");
|
path_iterator = paths.find("ramindex");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .ramindex file must be specified");
|
throw util::exception("valid .ramindex file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("fileindex");
|
path_iterator = paths.find("fileindex");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .fileindex file must be specified");
|
throw util::exception("valid .fileindex file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("namesdata");
|
path_iterator = paths.find("namesdata");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .names file must be specified");
|
throw util::exception("valid .names file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
path_iterator = paths.find("timestamp");
|
path_iterator = paths.find("timestamp");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||||
{
|
{
|
||||||
throw exception("valid .timestamp file must be specified");
|
throw util::exception("valid .timestamp file must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* DATASTORE_OPTIONS_HPP */
|
int main(const int argc, const char *argv[]) try
|
||||||
|
{
|
||||||
|
util::LogPolicy::GetInstance().Unmute();
|
||||||
|
|
||||||
|
storage::DataPaths paths;
|
||||||
|
if (!generateDataStoreOptions(argc, argv, paths))
|
||||||
|
{
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
storage::Storage storage(paths);
|
||||||
|
return storage.Run();
|
||||||
|
}
|
||||||
|
catch (const std::bad_alloc &e)
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
||||||
|
util::SimpleLogger().Write(logWARNING)
|
||||||
|
<< "Please provide more memory or disable locking the virtual "
|
||||||
|
"address space (note: this makes OSRM swap, i.e. slow)";
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
@ -1,22 +1,20 @@
|
|||||||
#include "util/simple_logger.hpp"
|
#include "util/simple_logger.hpp"
|
||||||
#include "engine/datafacade/shared_barriers.hpp"
|
#include "storage/shared_barriers.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int main() try
|
||||||
{
|
{
|
||||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
osrm::util::LogPolicy::GetInstance().Unmute();
|
||||||
try
|
osrm::util::SimpleLogger().Write() << "Releasing all locks";
|
||||||
{
|
osrm::storage::SharedBarriers barrier;
|
||||||
osrm::util::SimpleLogger().Write() << "Releasing all locks";
|
barrier.pending_update_mutex.unlock();
|
||||||
osrm::engine::datafacade::SharedBarriers barrier;
|
barrier.query_mutex.unlock();
|
||||||
barrier.pending_update_mutex.unlock();
|
barrier.update_mutex.unlock();
|
||||||
barrier.query_mutex.unlock();
|
|
||||||
barrier.update_mutex.unlock();
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
osrm::util::SimpleLogger().Write(logWARNING) << "[excpetion] " << e.what();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
osrm::util::SimpleLogger().Write(logWARNING) << "[excpetion] " << e.what();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
29
test/data/Makefile
Executable file
29
test/data/Makefile
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
BERLIN_URL:=https://s3.amazonaws.com/mapbox/node-osrm/testing/berlin-latest.osm.pbf
|
||||||
|
TOOL_ROOT:=../../build
|
||||||
|
PROFILE_ROOT:=../../profiles
|
||||||
|
OSRM_EXTRACT:=$(TOOL_ROOT)/osrm-extract
|
||||||
|
OSRM_PREPARE:=$(TOOL_ROOT)/osrm-prepare
|
||||||
|
PROFILE:=$(PROFILE_ROOT)/car.lua
|
||||||
|
|
||||||
|
all: berlin-latest.osrm.hsgr
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm berlin-latest.*
|
||||||
|
|
||||||
|
berlin-latest.osm.pbf:
|
||||||
|
wget $(BERLIN_URL) -O berlin-latest.osm.pbf
|
||||||
|
|
||||||
|
berlin-latest.osrm: berlin-latest.osm.pbf $(PROFILE) $(OSRM_EXTRACT)
|
||||||
|
@echo "Verifiyng data file integrity..."
|
||||||
|
md5sum -c data.md5sum
|
||||||
|
@echo "Running osrm-extract..."
|
||||||
|
$(OSRM_EXTRACT) berlin-latest.osm.pbf -p $(PROFILE)
|
||||||
|
|
||||||
|
berlin-latest.osrm.hsgr: berlin-latest.osrm $(PROFILE) $(OSRM_PREPARE)
|
||||||
|
@echo "Running osrm-prepare..."
|
||||||
|
$(OSRM_PREPARE) berlin-latest.osrm -p $(PROFILE)
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
md5sum berlin-latest.osm.pbf > data.md5sum
|
||||||
|
|
||||||
|
.PHONY: clean checksum
|
1
test/data/data.md5sum
Normal file
1
test/data/data.md5sum
Normal file
@ -0,0 +1 @@
|
|||||||
|
045af81d07eb9f22e5718db13cf337e4 berlin-latest.osm.pbf
|
@ -1,7 +0,0 @@
|
|||||||
#define BOOST_TEST_MODULE io tests
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file will contain an automatically generated main function.
|
|
||||||
*/
|
|
Loading…
Reference in New Issue
Block a user