From f268163ea082e75b681de4d5aef4ba2e766bcb6f Mon Sep 17 00:00:00 2001 From: karenzshea Date: Mon, 29 May 2017 12:57:33 +0200 Subject: [PATCH] remove shapefile dependency from build --- CMakeLists.txt | 25 ++++--------------------- include/util/timezones.hpp | 2 -- src/tools/contract.cpp | 17 +++++------------ src/tools/customize.cpp | 19 +++++++------------ src/util/timezones.cpp | 14 +++----------- 5 files changed, 19 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab3309ee7..a2ae97db9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -447,11 +447,6 @@ if(ENABLE_MASON) add_dependency_includes(${MASON_PACKAGE_tbb_INCLUDE_DIRS}) set(TBB_LIBRARIES ${MASON_PACKAGE_tbb_LDFLAGS}) - mason_use(libshp2 VERSION ${MASON_LIBSHP_VERSION}) - target_include_directories(UTIL PRIVATE ${MASON_PACKAGE_libshp2_INCLUDE_DIRS}) - set(MAYBE_SHAPEFILE ${MASON_PACKAGE_libshp2_STATIC_LIBS}) - target_compile_definitions(UTIL PRIVATE COMPILE_DEFINITIONS ENABLE_SHAPEFILE) - if(NOT MASON_PACKAGE_tbb_LIBRARY_DIRS) message(FATAL_ERROR "MASON_PACKAGE_tbb_LIBRARY_DIRS is empty, rpath will not work") endif() @@ -527,15 +522,6 @@ else() ENDIF() ENDIF() - find_package(Shapefile) # optional package libshp-dev - if (Shapefile_FOUND) - set(MAYBE_SHAPEFILE "${LIBSHAPEFILE_LIBRARY}") - target_include_directories(UTIL PRIVATE ${LIBSHAPEFILE_INCLUDE_DIR}) - target_compile_definitions(UTIL PRIVATE COMPILE_DEFINITIONS ENABLE_SHAPEFILE) - else() - set(MAYBE_SHAPEFILE "") - endif() - set(USED_LUA_LIBRARIES ${LUA_LIBRARIES}) add_dependency_includes(${LUA_INCLUDE_DIR}) @@ -615,12 +601,12 @@ set(BOOST_ENGINE_LIBRARIES ${BOOST_BASE_LIBRARIES}) # Binaries -target_link_libraries(osrm-datastore osrm_store ${Boost_PROGRAM_OPTIONS_LIBRARY} ${MAYBE_SHAPEFILE}) +target_link_libraries(osrm-datastore osrm_store ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries(osrm-extract osrm_extract ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries(osrm-partition osrm_partition ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries(osrm-customize osrm_customize ${Boost_PROGRAM_OPTIONS_LIBRARY}) target_link_libraries(osrm-contract osrm_contract ${Boost_PROGRAM_OPTIONS_LIBRARY}) -target_link_libraries(osrm-routed osrm ${Boost_PROGRAM_OPTIONS_LIBRARY} ${MAYBE_SHAPEFILE} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY}) +target_link_libraries(osrm-routed osrm ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY}) set(EXTRACTOR_LIBRARIES ${BZIP2_LIBRARIES} @@ -645,7 +631,6 @@ set(CUSTOMIZER_LIBRARIES ${BOOST_ENGINE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${TBB_LIBRARIES} - ${MAYBE_SHAPEFILE} ${MAYBE_RT_LIBRARY} ${MAYBE_COVERAGE_LIBRARIES}) set(UPDATER_LIBRARIES @@ -653,7 +638,6 @@ set(UPDATER_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${TBB_LIBRARIES} ${MAYBE_RT_LIBRARY} - ${MAYBE_SHAPEFILE} ${MAYBE_COVERAGE_LIBRARIES} ${ZLIB_LIBRARY}) set(CONTRACTOR_LIBRARIES @@ -662,7 +646,6 @@ set(CONTRACTOR_LIBRARIES ${USED_LUA_LIBRARIES} ${STXXL_LIBRARY} ${TBB_LIBRARIES} - ${MAYBE_SHAPEFILE} ${MAYBE_RT_LIBRARY} ${MAYBE_COVERAGE_LIBRARIES}) set(ENGINE_LIBRARIES @@ -683,7 +666,6 @@ set(UTIL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${STXXL_LIBRARY} ${TBB_LIBRARIES} - ${MAYBE_SHAPEFILE} ${MAYBE_COVERAGE_LIBRARIES}) # Libraries @@ -703,10 +685,11 @@ install(TARGETS osrm-components DESTINATION bin) if(BUILD_TOOLS) message(STATUS "Activating OSRM internal tools") add_executable(osrm-io-benchmark src/tools/io-benchmark.cpp $) - target_link_libraries(osrm-io-benchmark ${BOOST_BASE_LIBRARIES} ${MAYBE_SHAPEFILE}) + target_link_libraries(osrm-io-benchmark ${BOOST_BASE_LIBRARIES}) install(TARGETS osrm-io-benchmark DESTINATION bin) + find_package(Shapefile) if(SHAPEFILE_FOUND AND (Boost_VERSION VERSION_GREATER 106000 OR ENABLE_MASON)) add_executable(osrm-extract-conditionals src/tools/extract-conditionals.cpp $) target_include_directories(osrm-extract-conditionals PRIVATE ${LIBSHAPEFILE_INCLUDE_DIR}) diff --git a/include/util/timezones.hpp b/include/util/timezones.hpp index 85ec878e6..ef2111700 100644 --- a/include/util/timezones.hpp +++ b/include/util/timezones.hpp @@ -26,8 +26,6 @@ using rtree_t = boost::geometry::index::rtree, boost::geometry::index::rstar<8>>; using local_time_t = std::pair; -bool SupportsShapefiles(); - class Timezoner { public: diff --git a/src/tools/contract.cpp b/src/tools/contract.cpp index 5654ea160..c1107f279 100644 --- a/src/tools/contract.cpp +++ b/src/tools/contract.cpp @@ -68,18 +68,11 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig ->default_value(0), "Optional for conditional turn restriction parsing, provide a UTC time stamp from " "which " - "to evaluate the validity of conditional turn restrictions"); - - if (updater::SupportsShapefiles()) - { - config_options.add_options()("time-zone-file", - boost::program_options::value( - &contractor_config.updater_config.tz_file_path) - ->default_value(""), - "Required for conditional turn restriction parsing, provide a " - "shp or dbf file containing " - "time zone boundaries"); - } + "to evaluate the validity of conditional turn restrictions")( + "time-zone-file", + boost::program_options::value(&contractor_config.updater_config.tz_file_path), + "Required for conditional turn restriction parsing, provide a geojson file containing " + "time zone boundaries"); // hidden options, will be allowed on command line, but will not be shown to the user boost::program_options::options_description hidden_options("Hidden options"); diff --git a/src/tools/customize.cpp b/src/tools/customize.cpp index 423365f2e..9aaa05d23 100644 --- a/src/tools/customize.cpp +++ b/src/tools/customize.cpp @@ -59,18 +59,13 @@ parseArguments(int argc, char *argv[], customizer::CustomizationConfig &customiz ->default_value(0), "Optional for conditional turn restriction parsing, provide a UTC time stamp from " "which " - "to evaluate the validity of conditional turn restrictions"); - - if (updater::SupportsShapefiles()) - { - config_options.add_options()("time-zone-file", - boost::program_options::value( - &customization_config.updater_config.tz_file_path) - ->default_value(""), - "Required for conditional turn restriction parsing, provide a " - "shp or dbf file containing " - "time zone boundaries"); - } + "to evaluate the validity of conditional turn restrictions")( + "time-zone-file", + boost::program_options::value( + &customization_config.updater_config.tz_file_path) + ->default_value(""), + "Required for conditional turn restriction parsing, provide a geojson file containing " + "time zone boundaries"); // hidden options, will be allowed on command line, but will not be // shown to the user diff --git a/src/util/timezones.cpp b/src/util/timezones.cpp index ad869a84d..d28af538d 100644 --- a/src/util/timezones.cpp +++ b/src/util/timezones.cpp @@ -19,15 +19,6 @@ namespace osrm namespace updater { -bool SupportsShapefiles() -{ -#ifdef ENABLE_SHAPEFILE - return true; -#else - return false; -#endif -} - Timezoner::Timezoner(std::string tz_filename, std::time_t utc_time_now) { util::Log() << "Time zone validation based on UTC time : " << utc_time_now; @@ -89,11 +80,12 @@ void Timezoner::ValidateFeature(const rapidjson::Value &feature, const std::stri void Timezoner::LoadLocalTimesRTree(const std::string &tz_shapes_filename, std::time_t utc_time) { if (tz_shapes_filename.empty()) - return; + throw osrm::util::exception("Missing time zone geojson file"); std::ifstream file(tz_shapes_filename.data()); if (!file.is_open()) throw osrm::util::exception("failed to open " + tz_shapes_filename); + util::Log() << "Parsing " + tz_shapes_filename; rapidjson::IStreamWrapper isw(file); rapidjson::Document geojson; geojson.ParseStream(isw); @@ -137,7 +129,7 @@ void Timezoner::LoadLocalTimesRTree(const std::string &tz_shapes_filename, std:: if (feat_type == "polygon") { polygon_t polygon; - // per geojson spec, the first array of polygon coords is the exterior ring + // per geojson spec, the first array of polygon coords is the exterior ring, we only want to access that auto coords_outer_array = features_array[i] .GetObject()["geometry"] .GetObject()["coordinates"]