From dd3b8469dd8028551e4e6171028b2bcf594a7126 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 27 Jan 2015 13:17:18 +0100 Subject: [PATCH] renamed: Include/* include/* --- CMakeLists.txt | 4 +- Include/osrm/libosrm_config.hpp | 14 ++--- include/osrm/coordinate.hpp | 71 +++++++++++++++++++++++ include/osrm/json_container.hpp | 94 +++++++++++++++++++++++++++++++ include/osrm/libosrm_config.hpp | 48 ++++++++++++++++ include/osrm/route_parameters.hpp | 92 ++++++++++++++++++++++++++++++ include/osrm/server_paths.hpp | 38 +++++++++++++ 7 files changed, 350 insertions(+), 11 deletions(-) create mode 100644 include/osrm/coordinate.hpp create mode 100644 include/osrm/json_container.hpp create mode 100644 include/osrm/libosrm_config.hpp create mode 100644 include/osrm/route_parameters.hpp create mode 100644 include/osrm/server_paths.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d9a6906d..12324fb05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ endif() OPTION(WITH_TOOLS "Build OSRM tools" OFF) OPTION(BUILD_TOOLS "Build OSRM tools" OFF) -include_directories(${CMAKE_SOURCE_DIR}/Include/) +include_directories(${CMAKE_SOURCE_DIR}/include/) include_directories(${CMAKE_SOURCE_DIR}/third_party/) include_directories(${CMAKE_SOURCE_DIR}/third_party/libosmium/include/) @@ -325,7 +325,7 @@ if(WITH_TOOLS OR BUILD_TOOLS) install(TARGETS osrm-springclean DESTINATION bin) endif() -file(GLOB InstallGlob Include/osrm/*.hpp Library/OSRM.h) +file(GLOB InstallGlob include/osrm/*.hpp Library/OSRM.h) file(GLOB VariantGlob third_party/variant/*.hpp) # Add RPATH info to executables so that when they are run after being installed diff --git a/Include/osrm/libosrm_config.hpp b/Include/osrm/libosrm_config.hpp index 078c28f8f..2f0edaf35 100644 --- a/Include/osrm/libosrm_config.hpp +++ b/Include/osrm/libosrm_config.hpp @@ -32,17 +32,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct libosrm_config { - libosrm_config(const libosrm_config&) = delete; - libosrm_config() - : max_locations_distance_table(100) - , use_shared_memory(false) - {} + libosrm_config(const libosrm_config &) = delete; + libosrm_config() : max_locations_distance_table(100), use_shared_memory(false) {} libosrm_config(const ServerPaths &paths, const bool flag, const int max) - : server_paths(paths) - , max_locations_distance_table(max) - , use_shared_memory(flag) - {} + : server_paths(paths), max_locations_distance_table(max), use_shared_memory(flag) + { + } ServerPaths server_paths; int max_locations_distance_table; diff --git a/include/osrm/coordinate.hpp b/include/osrm/coordinate.hpp new file mode 100644 index 000000000..546515d49 --- /dev/null +++ b/include/osrm/coordinate.hpp @@ -0,0 +1,71 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +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 //for std::ostream +#include +#include + +namespace +{ +constexpr static const float COORDINATE_PRECISION = 1000000.f; +} + +struct FixedPointCoordinate +{ + int lat; + int lon; + + FixedPointCoordinate(); + FixedPointCoordinate(int lat, int lon); + + template + FixedPointCoordinate(const T &coordinate) + : lat(coordinate.lat), lon(coordinate.lon) + { + static_assert(std::is_same::value, + "coordinate types incompatible"); + static_assert(std::is_same::value, + "coordinate types incompatible"); + } + + bool is_valid() const; + bool operator==(const FixedPointCoordinate &other) const; + + float bearing(const FixedPointCoordinate &other) const; + void output(std::ostream &out) const; +}; + +inline std::ostream &operator<<(std::ostream &out_stream, FixedPointCoordinate const &coordinate) +{ + coordinate.output(out_stream); + return out_stream; +} + +#endif /* COORDINATE_HPP_ */ diff --git a/include/osrm/json_container.hpp b/include/osrm/json_container.hpp new file mode 100644 index 000000000..9bbbec433 --- /dev/null +++ b/include/osrm/json_container.hpp @@ -0,0 +1,94 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +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_H +#define JSON_CONTAINER_H + +#include + +#include +#include +#include +#include + +namespace JSON +{ + +struct Object; +struct Array; + +struct String +{ + String() {} + String(const char *value) : value(value) {} + String(const std::string &value) : value(value) {} + std::string value; +}; + +struct Number +{ + Number() {} + Number(double value) : value(static_cast(value)) {} + double value; +}; + +struct True +{ +}; + +struct False +{ +}; + +struct Null +{ +}; + +using Value = mapbox::util::variant, + mapbox::util::recursive_wrapper, + True, + False, + Null>; + +struct Object +{ + std::unordered_map values; +}; + +struct Array +{ + std::vector values; +}; + +} // namespace JSON + +#endif // JSON_CONTAINER_H diff --git a/include/osrm/libosrm_config.hpp b/include/osrm/libosrm_config.hpp new file mode 100644 index 000000000..2f0edaf35 --- /dev/null +++ b/include/osrm/libosrm_config.hpp @@ -0,0 +1,48 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +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 SERVER_CONFIG_HPP +#define SERVER_CONFIG_HPP + +#include + +struct libosrm_config +{ + libosrm_config(const libosrm_config &) = delete; + libosrm_config() : max_locations_distance_table(100), use_shared_memory(false) {} + + libosrm_config(const ServerPaths &paths, const bool flag, const int max) + : server_paths(paths), max_locations_distance_table(max), use_shared_memory(flag) + { + } + + ServerPaths server_paths; + int max_locations_distance_table; + bool use_shared_memory; +}; + +#endif // SERVER_CONFIG_HPP diff --git a/include/osrm/route_parameters.hpp b/include/osrm/route_parameters.hpp new file mode 100644 index 000000000..0a450d571 --- /dev/null +++ b/include/osrm/route_parameters.hpp @@ -0,0 +1,92 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +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_H +#define ROUTE_PARAMETERS_H + +#include + +#include + +#include +#include + +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 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 setLanguage(const std::string &language); + + void setGeometryFlag(const bool flag); + + void setCompressionFlag(const bool flag); + + void addCoordinate(const boost::fusion::vector &coordinates); + + short zoom_level; + bool print_instructions; + bool alternate_route; + bool geometry; + bool compression; + bool deprecatedAPI; + bool uturn_default; + unsigned check_sum; + short num_results; + std::string service; + std::string output_format; + std::string jsonp_parameter; + std::string language; + std::vector hints; + std::vector uturns; + std::vector coordinates; +}; + +#endif // ROUTE_PARAMETERS_H diff --git a/include/osrm/server_paths.hpp b/include/osrm/server_paths.hpp new file mode 100644 index 000000000..52b60c7c4 --- /dev/null +++ b/include/osrm/server_paths.hpp @@ -0,0 +1,38 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +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 SERVER_PATH_H +#define SERVER_PATH_H + +#include + +#include +#include + +typedef std::unordered_map ServerPaths; + +#endif // SERVER_PATH_H