Create public facing libraries for extractor, contractor and datastore
New libraries libosrm_extract, libosrm_contract, libosrm_store
This commit is contained in:
@@ -1,72 +1,11 @@
|
||||
/*
|
||||
#ifndef GLOBAL_COORDINATE_HPP
|
||||
#define GLOBAL_COORDINATE_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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef COORDINATE_HPP_
|
||||
#define COORDINATE_HPP_
|
||||
|
||||
#include <iosfwd> //for std::ostream
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
using util::FixedPointCoordinate;
|
||||
}
|
||||
|
||||
#endif /* COORDINATE_HPP_ */
|
||||
#endif
|
||||
|
||||
@@ -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 @@
|
||||
/*
|
||||
|
||||
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>
|
||||
|
||||
#ifndef GLOBAL_JSON_CONTAINER_HPP
|
||||
#define GLOBAL_JSON_CONTAINER_HPP
|
||||
#include "util/json_container.hpp"
|
||||
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 json
|
||||
{
|
||||
using namespace osrm::util::json;
|
||||
namespace json = osrm::util::json;
|
||||
}
|
||||
|
||||
} // namespace osrm
|
||||
|
||||
#endif // JSON_CONTAINER_HPP
|
||||
#endif
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
|
||||
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 LIBOSRM_CONFIG_HPP
|
||||
#define LIBOSRM_CONFIG_HPP
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
struct LibOSRMConfig
|
||||
{
|
||||
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
||||
int max_locations_trip = -1;
|
||||
int max_locations_viaroute = -1;
|
||||
int max_locations_distance_table = -1;
|
||||
int max_locations_map_matching = -1;
|
||||
bool use_shared_memory = true;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SERVER_CONFIG_HPP
|
||||
+11
-6
@@ -45,21 +45,26 @@ struct Object;
|
||||
|
||||
namespace engine
|
||||
{
|
||||
class Engine;
|
||||
struct EngineConfig;
|
||||
struct RouteParameters;
|
||||
}
|
||||
|
||||
using engine::EngineConfig;
|
||||
using engine::RouteParameters;
|
||||
namespace json = util::json;
|
||||
|
||||
class OSRM
|
||||
{
|
||||
private:
|
||||
class OSRM_impl;
|
||||
std::unique_ptr<OSRM_impl> OSRM_pimpl_;
|
||||
std::unique_ptr<engine::Engine> engine_;
|
||||
|
||||
public:
|
||||
OSRM(LibOSRMConfig &lib_config);
|
||||
OSRM(EngineConfig &lib_config);
|
||||
~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
|
||||
|
||||
@@ -1,127 +1,11 @@
|
||||
/*
|
||||
#ifndef GLOBAL_ROUTE_PARAMETERS_HPP
|
||||
#define GLOBAL_ROUTE_PARAMETERS_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.
|
||||
|
||||
*/
|
||||
|
||||
#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>
|
||||
#include "engine/route_parameters.hpp"
|
||||
|
||||
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;
|
||||
};
|
||||
using engine::RouteParameters;
|
||||
}
|
||||
|
||||
using engine::RouteParameters;
|
||||
}
|
||||
|
||||
#endif // ROUTE_PARAMETERS_HPP
|
||||
#endif
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#ifndef OSRM_STRONG_TYPEDEF_HPP
|
||||
#define OSRM_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 <functional>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
/* Creates strongly typed wrappers around scalar types.
|
||||
* Useful for stopping accidental assignment of lats to lons,
|
||||
* etc. Also clarifies what this random "int" value is
|
||||
* being used for.
|
||||
*/
|
||||
#define OSRM_STRONG_TYPEDEF(From, To) \
|
||||
class To final \
|
||||
{ \
|
||||
static_assert(std::is_arithmetic<From>(), ""); \
|
||||
From x; \
|
||||
\
|
||||
public: \
|
||||
To() = default; \
|
||||
explicit To(const From x_) : x(x_) {} \
|
||||
explicit operator From &() { return x; } \
|
||||
explicit operator const From &() const { return x; } \
|
||||
bool operator<(const To &z_) const { return x < static_cast<const From>(z_); } \
|
||||
bool operator>(const To &z_) const { return x > static_cast<const From>(z_); } \
|
||||
bool operator<=(const To &z_) const { return x <= static_cast<const From>(z_); } \
|
||||
bool operator>=(const To &z_) const { return x >= static_cast<const From>(z_); } \
|
||||
bool operator==(const To &z_) const { return x == static_cast<const From>(z_); } \
|
||||
bool operator!=(const To &z_) const { return x != static_cast<const From>(z_); } \
|
||||
}; \
|
||||
inline From To##_to_##From(To to) { return static_cast<From>(to); } \
|
||||
namespace std \
|
||||
{ \
|
||||
template <> struct hash<To> \
|
||||
{ \
|
||||
std::size_t operator()(const To &k) const \
|
||||
{ \
|
||||
return std::hash<From>()(static_cast<const From>(k)); \
|
||||
} \
|
||||
}; \
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OSRM_STRONG_TYPEDEF_HPP
|
||||
Reference in New Issue
Block a user