replace old-style typefs with using
This commit is contained in:
parent
5565662d87
commit
8ee82d1e03
@ -107,7 +107,7 @@ struct InputRestrictionContainer
|
|||||||
|
|
||||||
struct CmpRestrictionContainerByFrom
|
struct CmpRestrictionContainerByFrom
|
||||||
{
|
{
|
||||||
typedef InputRestrictionContainer value_type;
|
using value_type = InputRestrictionContainer;
|
||||||
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
|
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
|
||||||
{
|
{
|
||||||
return a.restriction.from.way < b.restriction.from.way;
|
return a.restriction.from.way < b.restriction.from.way;
|
||||||
@ -118,7 +118,7 @@ struct CmpRestrictionContainerByFrom
|
|||||||
|
|
||||||
struct CmpRestrictionContainerByTo
|
struct CmpRestrictionContainerByTo
|
||||||
{
|
{
|
||||||
typedef InputRestrictionContainer value_type;
|
using value_type = InputRestrictionContainer;
|
||||||
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
|
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
|
||||||
{
|
{
|
||||||
return a.restriction.to.way < b.restriction.to.way;
|
return a.restriction.to.way < b.restriction.to.way;
|
||||||
|
@ -33,6 +33,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
typedef std::unordered_map<std::string, boost::filesystem::path> ServerPaths;
|
using ServerPaths = std::unordered_map<std::string, boost::filesystem::path>;
|
||||||
|
|
||||||
#endif // SERVER_PATH_H
|
#endif // SERVER_PATH_H
|
||||||
|
@ -43,13 +43,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
typedef osrm::range<EdgeID> EdgeRange;
|
using EdgeRange = osrm::range<EdgeID>;
|
||||||
|
|
||||||
template <class EdgeDataT> class BaseDataFacade
|
template <class EdgeDataT> class BaseDataFacade
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef EdgeBasedNode RTreeLeaf;
|
using RTreeLeaf = EdgeBasedNode;
|
||||||
typedef EdgeDataT EdgeData;
|
using EdgeData = EdgeDataT;
|
||||||
BaseDataFacade() {}
|
BaseDataFacade() {}
|
||||||
virtual ~BaseDataFacade() {}
|
virtual ~BaseDataFacade() {}
|
||||||
|
|
||||||
@ -104,8 +104,8 @@ template <class EdgeDataT> class BaseDataFacade
|
|||||||
virtual bool
|
virtual bool
|
||||||
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
PhantomNode &resulting_phantom_node) = 0;
|
PhantomNode &resulting_phantom_node) = 0;
|
||||||
virtual bool
|
virtual bool IncrementalFindPhantomNodeForCoordinateWithMaxDistance(
|
||||||
IncrementalFindPhantomNodeForCoordinateWithMaxDistance(const FixedPointCoordinate &input_coordinate,
|
const FixedPointCoordinate &input_coordinate,
|
||||||
std::vector<std::pair<PhantomNode, double>> &resulting_phantom_node_vector,
|
std::vector<std::pair<PhantomNode, double>> &resulting_phantom_node_vector,
|
||||||
const double max_distance,
|
const double max_distance,
|
||||||
const unsigned min_number_of_phantom_nodes,
|
const unsigned min_number_of_phantom_nodes,
|
||||||
|
@ -52,10 +52,10 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BaseDataFacade<EdgeDataT> super;
|
using super = BaseDataFacade<EdgeDataT>;
|
||||||
typedef StaticGraph<typename super::EdgeData> QueryGraph;
|
using QueryGraph = StaticGraph<typename super::EdgeData>;
|
||||||
typedef typename QueryGraph::InputEdge InputEdge;
|
using InputEdge = typename QueryGraph::InputEdge;
|
||||||
typedef typename super::RTreeLeaf RTreeLeaf;
|
using RTreeLeaf = typename super::RTreeLeaf;
|
||||||
|
|
||||||
InternalDataFacade() {}
|
InternalDataFacade() {}
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef EdgeDataT EdgeData;
|
using EdgeData = EdgeDataT;
|
||||||
typedef BaseDataFacade<EdgeData> super;
|
using super = BaseDataFacade<EdgeData>;
|
||||||
typedef StaticGraph<EdgeData, true> QueryGraph;
|
using QueryGraph = StaticGraph<EdgeData, true>;
|
||||||
typedef typename StaticGraph<EdgeData, true>::NodeArrayEntry GraphNode;
|
using GraphNode = typename StaticGraph<EdgeData, true>::NodeArrayEntry;
|
||||||
typedef typename StaticGraph<EdgeData, true>::EdgeArrayEntry GraphEdge;
|
using GraphEdge = typename StaticGraph<EdgeData, true>::EdgeArrayEntry;
|
||||||
typedef typename RangeTable<16, true>::BlockT NameIndexBlock;
|
using NameIndexBlock = typename RangeTable<16, true>::BlockT;
|
||||||
typedef typename QueryGraph::InputEdge InputEdge;
|
using InputEdge = typename QueryGraph::InputEdge;
|
||||||
typedef typename super::RTreeLeaf RTreeLeaf;
|
using RTreeLeaf = typename super::RTreeLeaf;
|
||||||
using SharedRTree = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>;
|
using SharedRTree = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>;
|
||||||
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
||||||
using RTreeNode = typename SharedRTree::TreeNode;
|
using RTreeNode = typename SharedRTree::TreeNode;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2013, Project OSRM contributors
|
Copyright (c) 2015, Project OSRM contributors
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -149,7 +149,7 @@ struct cast
|
|||||||
static int floatfield(T) { return boost::spirit::karma::real_policies<T>::fmtflags::fixed; }
|
static int floatfield(T) { return boost::spirit::karma::real_policies<T>::fmtflags::fixed; }
|
||||||
static unsigned int precision(T) { return 6; }
|
static unsigned int precision(T) { return 6; }
|
||||||
};
|
};
|
||||||
typedef boost::spirit::karma::real_generator<double, scientific_policy<double>> science_type;
|
using science_type = boost::spirit::karma::real_generator<double, scientific_policy<double>>;
|
||||||
|
|
||||||
static std::string double_fixed_to_string(const double value)
|
static std::string double_fixed_to_string(const double value)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,223 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
template <typename EdgeT>
|
||||||
|
NodeID read_undirected_osrm_stream(std::istream &input_stream,
|
||||||
|
std::vector<EdgeT> &edge_list,
|
||||||
|
std::vector<FixedPointCoordinate> &coordinate_list)
|
||||||
|
{
|
||||||
|
const FingerPrint fingerprint_orig;
|
||||||
|
FingerPrint fingerprint_loaded;
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&fingerprint_loaded), sizeof(FingerPrint));
|
||||||
|
|
||||||
|
if (!fingerprint_loaded.TestGraphUtil(fingerprint_orig))
|
||||||
|
{
|
||||||
|
SimpleLogger().Write(logWARNING) << ".osrm was prepared with different build.\n"
|
||||||
|
"Reprocess to get rid of this warning.";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unordered_map<NodeID, NodeID> ext_to_int_id_map;
|
||||||
|
|
||||||
|
NodeID n;
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&n), sizeof(NodeID));
|
||||||
|
SimpleLogger().Write() << "Importing n = " << n << " nodes ";
|
||||||
|
|
||||||
|
ExternalMemoryNode current_node;
|
||||||
|
for (NodeID i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
input_stream.read(reinterpret_cast<char *>(¤t_node), sizeof(ExternalMemoryNode));
|
||||||
|
coordinate_list.emplace_back(current_node.lat, current_node.lon);
|
||||||
|
ext_to_int_id_map.emplace(current_node.node_id, i);
|
||||||
|
// if (current_node.barrier)
|
||||||
|
// {
|
||||||
|
// barrier_node_list.emplace_back(i);
|
||||||
|
// }
|
||||||
|
// if (current_node.traffic_lights)
|
||||||
|
// {
|
||||||
|
// traffic_light_node_list.emplace_back(i);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// tighten vector sizes
|
||||||
|
// barrier_node_list.shrink_to_fit();
|
||||||
|
// traffic_light_node_list.shrink_to_fit();
|
||||||
|
|
||||||
|
// renumber nodes in turn restrictions
|
||||||
|
// for (TurnRestriction ¤t_restriction : restriction_list)
|
||||||
|
// {
|
||||||
|
// auto internal_id_iter = ext_to_int_id_map.find(current_restriction.from.node);
|
||||||
|
// if (internal_id_iter == ext_to_int_id_map.end())
|
||||||
|
// {
|
||||||
|
// SimpleLogger().Write(logDEBUG) << "Unmapped from node " <<
|
||||||
|
// current_restriction.from.node
|
||||||
|
// << " of restriction";
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// current_restriction.from.node = internal_id_iter->second;
|
||||||
|
|
||||||
|
// internal_id_iter = ext_to_int_id_map.find(current_restriction.via.node);
|
||||||
|
// if (internal_id_iter == ext_to_int_id_map.end())
|
||||||
|
// {
|
||||||
|
// SimpleLogger().Write(logDEBUG) << "Unmapped via node " <<
|
||||||
|
// current_restriction.via.node
|
||||||
|
// << " of restriction";
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// current_restriction.via.node = internal_id_iter->second;
|
||||||
|
|
||||||
|
// internal_id_iter = ext_to_int_id_map.find(current_restriction.to.node);
|
||||||
|
// if (internal_id_iter == ext_to_int_id_map.end())
|
||||||
|
// {
|
||||||
|
// SimpleLogger().Write(logDEBUG) << "Unmapped to node " << current_restriction.to.node
|
||||||
|
// << " of restriction";
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// current_restriction.to.node = internal_id_iter->second;
|
||||||
|
// }
|
||||||
|
|
||||||
|
EdgeWeight weight;
|
||||||
|
NodeID source, target;
|
||||||
|
unsigned nameID;
|
||||||
|
int length;
|
||||||
|
short dir; // direction (0 = open, 1 = forward, 2+ = open)
|
||||||
|
bool is_roundabout, ignore_in_grid, is_access_restricted, is_split;
|
||||||
|
TravelMode travel_mode;
|
||||||
|
|
||||||
|
EdgeID m;
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&m), sizeof(unsigned));
|
||||||
|
edge_list.reserve(m);
|
||||||
|
SimpleLogger().Write() << " and " << m << " edges ";
|
||||||
|
|
||||||
|
for (EdgeID i = 0; i < m; ++i)
|
||||||
|
{
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&source), sizeof(unsigned));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&target), sizeof(unsigned));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&length), sizeof(int));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&dir), sizeof(short));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&weight), sizeof(int));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&nameID), sizeof(unsigned));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&is_roundabout), sizeof(bool));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&ignore_in_grid), sizeof(bool));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&is_access_restricted), sizeof(bool));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&travel_mode), sizeof(TravelMode));
|
||||||
|
input_stream.read(reinterpret_cast<char *>(&is_split), sizeof(bool));
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(length > 0, "loaded null length edge");
|
||||||
|
BOOST_ASSERT_MSG(weight > 0, "loaded null weight");
|
||||||
|
BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction");
|
||||||
|
|
||||||
|
// bool forward = true;
|
||||||
|
// bool backward = true;
|
||||||
|
// if (1 == dir)
|
||||||
|
// {
|
||||||
|
// backward = false;
|
||||||
|
// }
|
||||||
|
// if (2 == dir)
|
||||||
|
// {
|
||||||
|
// forward = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// translate the external NodeIDs to internal IDs
|
||||||
|
auto internal_id_iter = ext_to_int_id_map.find(source);
|
||||||
|
if (ext_to_int_id_map.find(source) == ext_to_int_id_map.end())
|
||||||
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
SimpleLogger().Write(logWARNING) << " unresolved source NodeID: " << source;
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
source = internal_id_iter->second;
|
||||||
|
internal_id_iter = ext_to_int_id_map.find(target);
|
||||||
|
if (ext_to_int_id_map.find(target) == ext_to_int_id_map.end())
|
||||||
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
SimpleLogger().Write(logWARNING) << "unresolved target NodeID : " << target;
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
target = internal_id_iter->second;
|
||||||
|
BOOST_ASSERT_MSG(source != SPECIAL_NODEID && target != SPECIAL_NODEID,
|
||||||
|
"nonexisting source or target");
|
||||||
|
|
||||||
|
if (source > target)
|
||||||
|
{
|
||||||
|
std::swap(source, target);
|
||||||
|
// std::swap(forward, backward);
|
||||||
|
}
|
||||||
|
|
||||||
|
edge_list.emplace_back(source, target);
|
||||||
|
}
|
||||||
|
ext_to_int_id_map.clear();
|
||||||
|
|
||||||
|
tbb::parallel_sort(edge_list.begin(), edge_list.end());
|
||||||
|
|
||||||
|
// for (unsigned i = 1; i < edge_list.size(); ++i)
|
||||||
|
// {
|
||||||
|
// if ((edge_list[i - 1].target == edge_list[i].target) &&
|
||||||
|
// (edge_list[i - 1].source == edge_list[i].source))
|
||||||
|
// {
|
||||||
|
// const bool edge_flags_equivalent = (edge_list[i - 1].forward == edge_list[i].forward)
|
||||||
|
// &&
|
||||||
|
// (edge_list[i - 1].backward ==
|
||||||
|
// edge_list[i].backward);
|
||||||
|
// const bool edge_flags_are_superset1 =
|
||||||
|
// (edge_list[i - 1].forward && edge_list[i - 1].backward) &&
|
||||||
|
// (edge_list[i].forward != edge_list[i].backward);
|
||||||
|
// const bool edge_flags_are_superset_2 =
|
||||||
|
// (edge_list[i].forward && edge_list[i].backward) &&
|
||||||
|
// (edge_list[i - 1].forward != edge_list[i - 1].backward);
|
||||||
|
|
||||||
|
// if (edge_flags_equivalent)
|
||||||
|
// {
|
||||||
|
// edge_list[i].weight = std::min(edge_list[i - 1].weight, edge_list[i].weight);
|
||||||
|
// edge_list[i - 1].source = SPECIAL_NODEID;
|
||||||
|
// }
|
||||||
|
// else if (edge_flags_are_superset1)
|
||||||
|
// {
|
||||||
|
// if (edge_list[i - 1].weight <= edge_list[i].weight)
|
||||||
|
// {
|
||||||
|
// // edge i-1 is smaller and goes in both directions. Throw away the other edge
|
||||||
|
// edge_list[i].source = SPECIAL_NODEID;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// // edge i-1 is open in both directions, but edge i is smaller in one
|
||||||
|
// direction.
|
||||||
|
// // Close edge i-1 in this direction
|
||||||
|
// edge_list[i - 1].forward = !edge_list[i].forward;
|
||||||
|
// edge_list[i - 1].backward = !edge_list[i].backward;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (edge_flags_are_superset_2)
|
||||||
|
// {
|
||||||
|
// if (edge_list[i - 1].weight <= edge_list[i].weight)
|
||||||
|
// {
|
||||||
|
// // edge i-1 is smaller for one direction. edge i is open in both. close edge
|
||||||
|
// i
|
||||||
|
// // in the other direction
|
||||||
|
// edge_list[i].forward = !edge_list[i - 1].forward;
|
||||||
|
// edge_list[i].backward = !edge_list[i - 1].backward;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// // edge i is smaller and goes in both direction. Throw away edge i-1
|
||||||
|
// edge_list[i - 1].source = SPECIAL_NODEID;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// const auto new_end_iter =
|
||||||
|
// std::remove_if(edge_list.begin(), edge_list.end(), [](const EdgeT &edge)
|
||||||
|
// {
|
||||||
|
// return edge.source == SPECIAL_NODEID || edge.target == SPECIAL_NODEID;
|
||||||
|
// });
|
||||||
|
// edge_list.erase(new_end_iter, edge_list.end()); // remove excess candidates.
|
||||||
|
// edge_list.shrink_to_fit();
|
||||||
|
SimpleLogger().Write() << "Graph loaded ok and has " << edge_list.size() << " edges";
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename EdgeT>
|
template <typename EdgeT>
|
||||||
NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream,
|
NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream,
|
||||||
std::vector<EdgeT> &edge_list,
|
std::vector<EdgeT> &edge_list,
|
||||||
|
Loading…
Reference in New Issue
Block a user