Create public facing libraries for extractor, contractor and datastore
New libraries libosrm_extract, libosrm_contract, libosrm_store
This commit is contained in:
+50
-1134
File diff suppressed because it is too large
Load Diff
+11
-14
@@ -10,17 +10,21 @@ namespace osrm
|
||||
namespace contractor
|
||||
{
|
||||
|
||||
enum class return_code : unsigned
|
||||
{
|
||||
ok,
|
||||
fail,
|
||||
exit
|
||||
};
|
||||
|
||||
struct ContractorConfig
|
||||
{
|
||||
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 osrm_input_path;
|
||||
boost::filesystem::path profile_path;
|
||||
@@ -48,13 +52,6 @@ struct ContractorConfig
|
||||
std::string debug_geometry_path;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ContractorOptions
|
||||
{
|
||||
static return_code ParseArguments(int argc, char *argv[], ContractorConfig &extractor_config);
|
||||
|
||||
static void GenerateOutputFilesNames(ContractorConfig &extractor_config);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#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 "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 RTreeNode = typename SharedRTree::TreeNode;
|
||||
|
||||
SharedDataLayout *data_layout;
|
||||
storage::SharedDataLayout *data_layout;
|
||||
char *shared_memory;
|
||||
SharedDataTimestamp *data_timestamp_ptr;
|
||||
storage::SharedDataTimestamp *data_timestamp_ptr;
|
||||
|
||||
SharedDataType CURRENT_LAYOUT;
|
||||
SharedDataType CURRENT_DATA;
|
||||
storage::SharedDataType CURRENT_LAYOUT;
|
||||
storage::SharedDataType CURRENT_DATA;
|
||||
unsigned CURRENT_TIMESTAMP;
|
||||
|
||||
unsigned m_check_sum;
|
||||
std::unique_ptr<QueryGraph> m_query_graph;
|
||||
std::unique_ptr<datastore::SharedMemory> m_layout_memory;
|
||||
std::unique_ptr<datastore::SharedMemory> m_large_memory;
|
||||
std::unique_ptr<storage::SharedMemory> m_layout_memory;
|
||||
std::unique_ptr<storage::SharedMemory> m_large_memory;
|
||||
std::string m_timestamp;
|
||||
|
||||
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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
void LoadTimestamp()
|
||||
{
|
||||
char *timestamp_ptr =
|
||||
data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::TIMESTAMP);
|
||||
m_timestamp.resize(data_layout->GetBlockSize(SharedDataLayout::TIMESTAMP));
|
||||
data_layout->GetBlockPtr<char>(shared_memory, storage::SharedDataLayout::TIMESTAMP);
|
||||
m_timestamp.resize(data_layout->GetBlockSize(storage::SharedDataLayout::TIMESTAMP));
|
||||
std::copy(timestamp_ptr,
|
||||
timestamp_ptr + data_layout->GetBlockSize(SharedDataLayout::TIMESTAMP),
|
||||
timestamp_ptr + data_layout->GetBlockSize(storage::SharedDataLayout::TIMESTAMP),
|
||||
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");
|
||||
|
||||
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(
|
||||
CURRENT_TIMESTAMP,
|
||||
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)));
|
||||
m_geospatial_query.reset(
|
||||
new SharedGeospatialQuery(*m_static_rtree->second, m_coordinate_list));
|
||||
@@ -111,15 +112,15 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
void LoadGraph()
|
||||
{
|
||||
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 =
|
||||
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(
|
||||
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(
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -128,56 +129,56 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
|
||||
util::FixedPointCoordinate *coordinate_list_ptr =
|
||||
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>(
|
||||
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 =
|
||||
data_layout->GetBlockPtr<extractor::TravelMode>(shared_memory,
|
||||
SharedDataLayout::TRAVEL_MODE);
|
||||
storage::SharedDataLayout::TRAVEL_MODE);
|
||||
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);
|
||||
|
||||
extractor::TurnInstruction *turn_instruction_list_ptr =
|
||||
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(
|
||||
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);
|
||||
|
||||
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(
|
||||
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);
|
||||
}
|
||||
|
||||
void LoadViaNodeList()
|
||||
{
|
||||
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(
|
||||
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);
|
||||
}
|
||||
|
||||
void LoadNames()
|
||||
{
|
||||
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 =
|
||||
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(
|
||||
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(
|
||||
blocks_ptr, data_layout->num_entries[SharedDataLayout::NAME_BLOCKS]);
|
||||
blocks_ptr, data_layout->num_entries[storage::SharedDataLayout::NAME_BLOCKS]);
|
||||
|
||||
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(
|
||||
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>>(
|
||||
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()
|
||||
{
|
||||
if (data_layout->num_entries[SharedDataLayout::CORE_MARKER] <= 0)
|
||||
if (data_layout->num_entries[storage::SharedDataLayout::CORE_MARKER] <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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(
|
||||
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);
|
||||
}
|
||||
|
||||
void LoadGeometries()
|
||||
{
|
||||
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(
|
||||
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);
|
||||
|
||||
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(
|
||||
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);
|
||||
|
||||
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(
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -227,15 +228,16 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
|
||||
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?");
|
||||
}
|
||||
data_timestamp_ptr = (SharedDataTimestamp *)datastore::SharedMemoryFactory::Get(
|
||||
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)
|
||||
->Ptr();
|
||||
CURRENT_LAYOUT = LAYOUT_NONE;
|
||||
CURRENT_DATA = DATA_NONE;
|
||||
data_timestamp_ptr = static_cast<storage::SharedDataTimestamp *>(
|
||||
storage::makeSharedMemory(storage::CURRENT_REGIONS,
|
||||
sizeof(storage::SharedDataTimestamp), false, false)
|
||||
->Ptr());
|
||||
CURRENT_LAYOUT = storage::LAYOUT_NONE;
|
||||
CURRENT_DATA = storage::DATA_NONE;
|
||||
CURRENT_TIMESTAMP = 0;
|
||||
|
||||
// load data
|
||||
@@ -248,7 +250,6 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
CURRENT_DATA != data_timestamp_ptr->data ||
|
||||
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
|
||||
{
|
||||
|
||||
// Get exclusive lock
|
||||
util::SimpleLogger().Write(logDEBUG) << "Updates available, getting exclusive lock";
|
||||
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)
|
||||
{
|
||||
// release the previous shared memory segments
|
||||
datastore::SharedMemory::Remove(CURRENT_LAYOUT);
|
||||
datastore::SharedMemory::Remove(CURRENT_DATA);
|
||||
storage::SharedMemory::Remove(CURRENT_LAYOUT);
|
||||
storage::SharedMemory::Remove(CURRENT_DATA);
|
||||
|
||||
CURRENT_LAYOUT = data_timestamp_ptr->layout;
|
||||
CURRENT_DATA = data_timestamp_ptr->data;
|
||||
@@ -277,15 +278,15 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;
|
||||
|
||||
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());
|
||||
|
||||
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);
|
||||
if (!boost::filesystem::exists(file_index_path)) {
|
||||
util::SimpleLogger().Write(logDEBUG) << "Leaf file name "
|
||||
@@ -303,8 +304,6 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
||||
LoadNames();
|
||||
LoadCoreInformation();
|
||||
|
||||
data_layout->PrintInformation();
|
||||
|
||||
util::SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
|
||||
for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#ifndef OSRM_IMPL_HPP
|
||||
#define OSRM_IMPL_HPP
|
||||
#ifndef ENGINE_HPP
|
||||
#define ENGINE_HPP
|
||||
|
||||
#include "contractor/query_edge.hpp"
|
||||
|
||||
#include "osrm/json_container.hpp"
|
||||
#include "osrm/libosrm_config.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
#include <memory>
|
||||
@@ -14,6 +13,11 @@
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
namespace storage
|
||||
{
|
||||
struct SharedBarriers;
|
||||
}
|
||||
|
||||
namespace util
|
||||
{
|
||||
namespace json
|
||||
@@ -24,33 +28,32 @@ struct Object;
|
||||
|
||||
namespace engine
|
||||
{
|
||||
struct EngineConfig;
|
||||
struct RouteParameters;
|
||||
namespace plugins
|
||||
{
|
||||
class BasePlugin;
|
||||
}
|
||||
|
||||
namespace datafacade
|
||||
{
|
||||
struct SharedBarriers;
|
||||
template <class EdgeDataT> class BaseDataFacade;
|
||||
}
|
||||
|
||||
class OSRM::OSRM_impl final
|
||||
class Engine final
|
||||
{
|
||||
private:
|
||||
using PluginMap = std::unordered_map<std::string, std::unique_ptr<plugins::BasePlugin>>;
|
||||
|
||||
public:
|
||||
OSRM_impl(LibOSRMConfig &lib_config);
|
||||
OSRM_impl(const OSRM_impl &) = delete;
|
||||
Engine(EngineConfig &config_);
|
||||
Engine(const Engine &) = delete;
|
||||
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
||||
|
||||
private:
|
||||
void RegisterPlugin(plugins::BasePlugin *plugin);
|
||||
PluginMap plugin_map;
|
||||
// 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
|
||||
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
|
||||
#define LIBOSRM_CONFIG_HPP
|
||||
#ifndef ENGINE_CONFIG_HPP
|
||||
#define ENGINE_CONFIG_HPP
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
@@ -36,7 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
struct LibOSRMConfig
|
||||
namespace engine
|
||||
{
|
||||
|
||||
struct EngineConfig
|
||||
{
|
||||
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
||||
int max_locations_trip = -1;
|
||||
@@ -45,6 +48,8 @@ struct LibOSRMConfig
|
||||
int max_locations_map_matching = -1;
|
||||
bool use_shared_memory = true;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SERVER_CONFIG_HPP
|
||||
@@ -30,9 +30,63 @@ struct PhantomNode
|
||||
util::FixedPointCoordinate &location,
|
||||
unsigned short fwd_segment_position,
|
||||
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>
|
||||
PhantomNode(const OtherT &other, const util::FixedPointCoordinate &foot_point)
|
||||
@@ -82,20 +136,6 @@ struct PhantomNode
|
||||
// but the saved byte would be padding anyway
|
||||
extractor::TravelMode forward_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
|
||||
|
||||
@@ -96,7 +96,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
{
|
||||
PhantomNode 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])
|
||||
{
|
||||
@@ -130,7 +130,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
route_parameters.coordinates[i], bearing, range);
|
||||
// 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"] =
|
||||
std::string("Could not find a matching segment for coordinate ") +
|
||||
@@ -153,7 +153,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||
facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
route_parameters.coordinates[i], bearing, range);
|
||||
// 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"] =
|
||||
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;
|
||||
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));
|
||||
continue;
|
||||
@@ -83,7 +83,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
break;
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -85,7 +85,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
{
|
||||
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i],
|
||||
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;
|
||||
}
|
||||
@@ -97,15 +97,15 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
phantom_node_pair_list[i] = facade->NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
route_parameters.coordinates[i], bearing, range);
|
||||
// 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"] =
|
||||
std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(i);
|
||||
return Status::NoSegment;
|
||||
}
|
||||
BOOST_ASSERT(phantom_node_pair_list[i].first.is_valid(facade->GetNumberOfNodes()));
|
||||
BOOST_ASSERT(phantom_node_pair_list[i].second.is_valid(facade->GetNumberOfNodes()));
|
||||
BOOST_ASSERT(phantom_node_pair_list[i].first.IsValid(facade->GetNumberOfNodes()));
|
||||
BOOST_ASSERT(phantom_node_pair_list[i].second.IsValid(facade->GetNumberOfNodes()));
|
||||
}
|
||||
|
||||
auto snapped_phantoms = snapPhantomNodes(phantom_node_pair_list);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
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 traffic_lights;
|
||||
@@ -27,9 +37,12 @@ struct ExternalMemoryNode : QueryNode
|
||||
struct ExternalMemoryNodeSTXXLCompare
|
||||
{
|
||||
using value_type = ExternalMemoryNode;
|
||||
bool operator()(const ExternalMemoryNode &left, const ExternalMemoryNode &right) const;
|
||||
value_type max_value();
|
||||
value_type min_value();
|
||||
value_type max_value() { return value_type::max_value(); }
|
||||
value_type min_value() { return 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
|
||||
|
||||
#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/graph_compressor.hpp"
|
||||
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
+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
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
class OSRM;
|
||||
namespace engine
|
||||
{
|
||||
class OSRM;
|
||||
struct RouteParameters;
|
||||
}
|
||||
namespace server
|
||||
@@ -30,10 +30,10 @@ class RequestHandler
|
||||
RequestHandler(const RequestHandler &) = delete;
|
||||
|
||||
void handle_request(const http::request ¤t_request, http::reply ¤t_reply);
|
||||
void RegisterRoutingMachine(engine::OSRM *osrm);
|
||||
void RegisterRoutingMachine(OSRM *osrm);
|
||||
|
||||
private:
|
||||
engine::OSRM *routing_machine;
|
||||
OSRM *routing_machine;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
namespace storage
|
||||
{
|
||||
namespace datafacade
|
||||
{
|
||||
|
||||
struct SharedBarriers
|
||||
{
|
||||
|
||||
@@ -38,6 +35,5 @@ struct SharedBarriers
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SHARED_BARRIERS_HPP
|
||||
+1
-44
@@ -10,9 +10,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace datafacade
|
||||
namespace storage
|
||||
{
|
||||
|
||||
// Added at the start and end of each block as sanity check
|
||||
@@ -48,46 +46,6 @@ struct SharedDataLayout
|
||||
|
||||
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)
|
||||
{
|
||||
num_entries[bid] = entries;
|
||||
@@ -170,6 +128,5 @@ struct SharedDataTimestamp
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SHARED_DATA_TYPE_HPP */
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef SHARED_MEMORY_FACTORY_HPP
|
||||
#define SHARED_MEMORY_FACTORY_HPP
|
||||
#ifndef SHARED_MEMORY_HPP
|
||||
#define SHARED_MEMORY_HPP
|
||||
|
||||
#include "util/osrm_exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace datastore
|
||||
namespace storage
|
||||
{
|
||||
|
||||
struct OSRMLockFile
|
||||
@@ -322,47 +322,37 @@ class SharedMemory
|
||||
};
|
||||
#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:
|
||||
template <typename IdentifierT>
|
||||
static SharedMemory *Get(const IdentifierT &id,
|
||||
const uint64_t size = 0,
|
||||
bool read_write = false,
|
||||
bool remove_prev = true)
|
||||
try
|
||||
{
|
||||
LockFileT lock_file;
|
||||
if (!boost::filesystem::exists(lock_file()))
|
||||
{
|
||||
try
|
||||
{
|
||||
LockFileT lock_file;
|
||||
if (!boost::filesystem::exists(lock_file()))
|
||||
{
|
||||
if (0 == size)
|
||||
{
|
||||
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());
|
||||
}
|
||||
if (0 == size)
|
||||
{
|
||||
throw util::exception("lock file does not exist, exiting");
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::filesystem::ofstream ofs(lock_file());
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -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
|
||||
@@ -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,264 +0,0 @@
|
||||
#ifndef DATASTORE_OPTIONS_HPP
|
||||
#define DATASTORE_OPTIONS_HPP
|
||||
|
||||
#include "util/version.hpp"
|
||||
#include "util/ini_file.hpp"
|
||||
#include "util/osrm_exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// generate boost::program_options object for the routing part
|
||||
bool GenerateDataStoreOptions(const int argc,
|
||||
const char *argv[],
|
||||
std::unordered_map<std::string, boost::filesystem::path> &paths)
|
||||
{
|
||||
// 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")(
|
||||
"springclean,s", "Remove all regions in shared memory")(
|
||||
"config,c", boost::program_options::value<boost::filesystem::path>(&paths["config"])
|
||||
->default_value("server.ini"),
|
||||
"Path to a configuration file");
|
||||
|
||||
// declare a group of options that will be allowed both on command line
|
||||
// as well as in a config file
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
config_options.add_options()(
|
||||
"hsgrdata", boost::program_options::value<boost::filesystem::path>(&paths["hsgrdata"]),
|
||||
".hsgr file")("nodesdata",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["nodesdata"]),
|
||||
".nodes file")(
|
||||
"edgesdata", boost::program_options::value<boost::filesystem::path>(&paths["edgesdata"]),
|
||||
".edges file")("geometry",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["geometry"]),
|
||||
".geometry file")(
|
||||
"ramindex", boost::program_options::value<boost::filesystem::path>(&paths["ramindex"]),
|
||||
".ramIndex file")(
|
||||
"fileindex", boost::program_options::value<boost::filesystem::path>(&paths["fileindex"]),
|
||||
".fileIndex file")("core",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["core"]),
|
||||
".core file")(
|
||||
"namesdata", boost::program_options::value<boost::filesystem::path>(&paths["namesdata"]),
|
||||
".names file")("timestamp",
|
||||
boost::program_options::value<boost::filesystem::path>(&paths["timestamp"]),
|
||||
".timestamp file");
|
||||
|
||||
// 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()(
|
||||
"base,b", boost::program_options::value<boost::filesystem::path>(&paths["base"]),
|
||||
"base path to .osrm file");
|
||||
|
||||
// positional option
|
||||
boost::program_options::positional_options_description positional_options;
|
||||
positional_options.add("base", 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]) + " [<options>] <configuration>");
|
||||
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);
|
||||
|
||||
if (option_variables.count("version"))
|
||||
{
|
||||
SimpleLogger().Write() << OSRM_VERSION;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (option_variables.count("help"))
|
||||
{
|
||||
SimpleLogger().Write() << visible_options;
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::program_options::notify(option_variables);
|
||||
|
||||
const bool parameter_present =
|
||||
(paths.find("hsgrdata") != paths.end() &&
|
||||
!paths.find("hsgrdata")->second.string().empty()) ||
|
||||
(paths.find("nodesdata") != paths.end() &&
|
||||
!paths.find("nodesdata")->second.string().empty()) ||
|
||||
(paths.find("edgesdata") != paths.end() &&
|
||||
!paths.find("edgesdata")->second.string().empty()) ||
|
||||
(paths.find("geometry") != paths.end() &&
|
||||
!paths.find("geometry")->second.string().empty()) ||
|
||||
(paths.find("ramindex") != paths.end() &&
|
||||
!paths.find("ramindex")->second.string().empty()) ||
|
||||
(paths.find("fileindex") != paths.end() &&
|
||||
!paths.find("fileindex")->second.string().empty()) ||
|
||||
(paths.find("core") != paths.end() && !paths.find("core")->second.string().empty()) ||
|
||||
(paths.find("timestamp") != paths.end() &&
|
||||
!paths.find("timestamp")->second.string().empty());
|
||||
|
||||
if (parameter_present)
|
||||
{
|
||||
if ((paths.find("config") != paths.end() &&
|
||||
boost::filesystem::is_regular_file(paths.find("config")->second)) ||
|
||||
option_variables.count("base"))
|
||||
{
|
||||
SimpleLogger().Write(logWARNING) << "conflicting parameters";
|
||||
SimpleLogger().Write() << visible_options;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// parse config file
|
||||
auto path_iterator = paths.find("config");
|
||||
if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) &&
|
||||
!option_variables.count("base"))
|
||||
{
|
||||
SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string();
|
||||
std::string ini_file_contents = read_file_lower_content(path_iterator->second);
|
||||
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);
|
||||
}
|
||||
else if (option_variables.count("base"))
|
||||
{
|
||||
path_iterator = paths.find("base");
|
||||
BOOST_ASSERT(paths.end() != path_iterator);
|
||||
std::string base_string = path_iterator->second.string();
|
||||
|
||||
path_iterator = paths.find("hsgrdata");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".hsgr";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("nodesdata");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".nodes";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("edgesdata");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".edges";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("geometry");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".geometry";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("ramindex");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".ramIndex";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("fileindex");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".fileIndex";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("core");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".core";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("namesdata");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".names";
|
||||
}
|
||||
|
||||
path_iterator = paths.find("timestamp");
|
||||
if (path_iterator != paths.end())
|
||||
{
|
||||
path_iterator->second = base_string + ".timestamp";
|
||||
}
|
||||
}
|
||||
|
||||
path_iterator = paths.find("hsgrdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .hsgr file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("nodesdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .nodes file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("edgesdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .edges file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("geometry");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .geometry file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("ramindex");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .ramindex file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("fileindex");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .fileindex file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("namesdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .names file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("timestamp");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw exception("valid .timestamp file must be specified");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DATASTORE_OPTIONS_HPP */
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef DEBUG_GEOMETRY_H
|
||||
#define DEBUG_GEOMETRY_H
|
||||
|
||||
#include "contractor/contractor_options.hpp"
|
||||
#include "contractor/contractor_config.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#ifndef DEBUG_GEOMETRY
|
||||
|
||||
@@ -17,7 +17,7 @@ class FingerPrint
|
||||
const boost::uuids::uuid &GetFingerPrint() const;
|
||||
bool IsMagicNumberOK(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 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);
|
||||
}
|
||||
|
||||
bool FingerPrint::TestPrepare(const FingerPrint &other) const
|
||||
bool FingerPrint::TestContractor(const FingerPrint &other) const
|
||||
{
|
||||
if (!IsMagicNumberOK(other))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ unsigned loadRestrictionsFromFile(std::istream &input_stream,
|
||||
FingerPrint fingerprint_loaded;
|
||||
unsigned number_of_usable_restrictions = 0;
|
||||
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"
|
||||
"Reprocess to get rid of this warning.";
|
||||
@@ -71,7 +71,7 @@ NodeID loadNodesFromFile(std::istream &input_stream,
|
||||
FingerPrint fingerprint_loaded;
|
||||
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"
|
||||
"Reprocess to get rid of this warning.";
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ inline bool readAndCheckFingerprint(std::istream &stream)
|
||||
stream.read(reinterpret_cast<char *>(&fingerprint), sizeof(fingerprint));
|
||||
// compare the compilation state stored in the 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
#include "util/integer_range.hpp"
|
||||
#include "datastore/shared_memory_factory.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/hilbert_value.hpp"
|
||||
#include "util/rectangle.hpp"
|
||||
#include "datastore/shared_memory_factory.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
|
||||
#include "util/bearing.hpp"
|
||||
|
||||
@@ -1,32 +1,5 @@
|
||||
#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.
|
||||
|
||||
*/
|
||||
#ifndef STRONG_TYPEDEF_HPP
|
||||
#define STRONG_TYPEDEF_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TYPEDEFS_H
|
||||
#define TYPEDEFS_H
|
||||
|
||||
#include "osrm/strong_typedef.hpp"
|
||||
#include "util/strong_typedef.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <cstddef>
|
||||
|
||||
Reference in New Issue
Block a user