Runs scripts/format.sh
This commit is contained in:
committed by
Patrick Niklaus
parent
bb06e044f5
commit
7c30ea32bf
@@ -142,9 +142,9 @@ class GraphContractor
|
||||
|
||||
template <class ContainerT>
|
||||
GraphContractor(int nodes,
|
||||
ContainerT &input_edge_list,
|
||||
std::vector<float> &&node_levels_,
|
||||
std::vector<EdgeWeight> &&node_weights_)
|
||||
ContainerT &input_edge_list,
|
||||
std::vector<float> &&node_levels_,
|
||||
std::vector<EdgeWeight> &&node_weights_)
|
||||
: node_levels(std::move(node_levels_)), node_weights(std::move(node_weights_))
|
||||
{
|
||||
std::vector<ContractorEdge> edges;
|
||||
@@ -239,7 +239,8 @@ class GraphContractor
|
||||
}
|
||||
}
|
||||
}
|
||||
util::SimpleLogger().Write() << "merged " << edges.size() - edge << " edges out of " << edges.size();
|
||||
util::SimpleLogger().Write() << "merged " << edges.size() - edge << " edges out of "
|
||||
<< edges.size();
|
||||
edges.resize(edge);
|
||||
contractor_graph = std::make_shared<ContractorGraph>(nodes, edges);
|
||||
edges.clear();
|
||||
@@ -696,7 +697,7 @@ class GraphContractor
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!heap.WasInserted(to))
|
||||
{
|
||||
heap.Insert(to, to_distance, ContractorHeapData {current_hop, false});
|
||||
heap.Insert(to, to_distance, ContractorHeapData{current_hop, false});
|
||||
}
|
||||
// Found a shorter Path -> Update distance
|
||||
else if (to_distance < heap.GetKey(to))
|
||||
@@ -803,7 +804,7 @@ class GraphContractor
|
||||
}
|
||||
|
||||
heap.Clear();
|
||||
heap.Insert(source, 0, ContractorHeapData {});
|
||||
heap.Insert(source, 0, ContractorHeapData{});
|
||||
int max_distance = 0;
|
||||
unsigned number_of_targets = 0;
|
||||
|
||||
@@ -858,7 +859,7 @@ class GraphContractor
|
||||
max_distance = std::max(max_distance, path_distance);
|
||||
if (!heap.WasInserted(target))
|
||||
{
|
||||
heap.Insert(target, INVALID_EDGE_WEIGHT, ContractorHeapData {0, true});
|
||||
heap.Insert(target, INVALID_EDGE_WEIGHT, ContractorHeapData{0, true});
|
||||
++number_of_targets;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,16 @@ namespace api
|
||||
struct MatchParameters : public RouteParameters
|
||||
{
|
||||
MatchParameters()
|
||||
: RouteParameters(false, false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, {})
|
||||
: RouteParameters(false,
|
||||
false,
|
||||
RouteParameters::GeometriesType::Polyline,
|
||||
RouteParameters::OverviewType::Simplified,
|
||||
{})
|
||||
{
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
MatchParameters(std::vector<unsigned> timestamps_,
|
||||
Args... args_)
|
||||
template <typename... Args>
|
||||
MatchParameters(std::vector<unsigned> timestamps_, Args... args_)
|
||||
: RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)}
|
||||
{
|
||||
}
|
||||
@@ -29,10 +32,10 @@ struct MatchParameters : public RouteParameters
|
||||
std::vector<unsigned> timestamps;
|
||||
bool IsValid() const
|
||||
{
|
||||
return RouteParameters::IsValid() && (timestamps.empty() || timestamps.size() == coordinates.size());
|
||||
return RouteParameters::IsValid() &&
|
||||
(timestamps.empty() || timestamps.size() == coordinates.size());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,20 +26,23 @@ class NearestAPI final : public BaseAPI
|
||||
{
|
||||
}
|
||||
|
||||
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, util::json::Object& response) const
|
||||
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
||||
util::json::Object &response) const
|
||||
{
|
||||
BOOST_ASSERT(phantom_nodes.size() == 1);
|
||||
BOOST_ASSERT(parameters.coordinates.size() == 1);
|
||||
|
||||
util::json::Array waypoints;
|
||||
waypoints.values.resize(phantom_nodes.front().size());
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(), waypoints.values.begin(), [this](const PhantomNodeWithDistance& phantom_with_distance)
|
||||
{
|
||||
auto waypoint = MakeWaypoint(parameters.coordinates.front(), phantom_with_distance.phantom_node);
|
||||
waypoint.values["distance"] = phantom_with_distance.distance;
|
||||
return waypoint;
|
||||
});
|
||||
std::transform(phantom_nodes.front().begin(), phantom_nodes.front().end(),
|
||||
waypoints.values.begin(),
|
||||
[this](const PhantomNodeWithDistance &phantom_with_distance)
|
||||
{
|
||||
auto waypoint = MakeWaypoint(parameters.coordinates.front(),
|
||||
phantom_with_distance.phantom_node);
|
||||
waypoint.values["distance"] = phantom_with_distance.distance;
|
||||
return waypoint;
|
||||
});
|
||||
|
||||
response.values["code"] = "ok";
|
||||
response.values["waypoints"] = std::move(waypoints);
|
||||
|
||||
@@ -28,14 +28,15 @@ struct RouteParameters : public BaseParameters
|
||||
|
||||
RouteParameters() = default;
|
||||
|
||||
template<typename... Args>
|
||||
template <typename... Args>
|
||||
RouteParameters(const bool steps_,
|
||||
const bool alternative_,
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
std::vector<boost::optional<bool>> uturns_, Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternative{alternative_}, geometries{geometries_},
|
||||
overview{overview_}, uturns{std::move(uturns_)}
|
||||
std::vector<boost::optional<bool>> uturns_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternative{alternative_},
|
||||
geometries{geometries_}, overview{overview_}, uturns{std::move(uturns_)}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ class TableAPI final : public BaseAPI
|
||||
util::json::Object &response) const
|
||||
{
|
||||
auto number_of_sources = parameters.sources.size();
|
||||
auto number_of_destinations = parameters.destinations.size();;
|
||||
auto number_of_destinations = parameters.destinations.size();
|
||||
;
|
||||
|
||||
// symmetric case
|
||||
if (parameters.sources.empty())
|
||||
@@ -60,7 +61,8 @@ class TableAPI final : public BaseAPI
|
||||
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
|
||||
}
|
||||
|
||||
response.values["durations"] = MakeTable(durations, number_of_sources, number_of_destinations);
|
||||
response.values["durations"] =
|
||||
MakeTable(durations, number_of_sources, number_of_destinations);
|
||||
response.values["code"] = "ok";
|
||||
}
|
||||
|
||||
@@ -105,14 +107,15 @@ class TableAPI final : public BaseAPI
|
||||
auto row_begin_iterator = values.begin() + (row * number_of_columns);
|
||||
auto row_end_iterator = values.begin() + ((row + 1) * number_of_columns);
|
||||
json_row.values.resize(number_of_columns);
|
||||
std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(), [](const EdgeWeight duration)
|
||||
{
|
||||
if (duration == INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
return util::json::Value(util::json::Null());
|
||||
}
|
||||
return util::json::Value(util::json::Number(duration / 10.));
|
||||
});
|
||||
std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(),
|
||||
[](const EdgeWeight duration)
|
||||
{
|
||||
if (duration == INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
return util::json::Value(util::json::Null());
|
||||
}
|
||||
return util::json::Value(util::json::Number(duration / 10.));
|
||||
});
|
||||
json_table.values.push_back(std::move(json_row));
|
||||
}
|
||||
return json_table;
|
||||
|
||||
@@ -15,12 +15,8 @@ struct TileParameters final
|
||||
unsigned z;
|
||||
|
||||
// FIXME check if x and y work with z
|
||||
bool IsValid()
|
||||
{
|
||||
return z < 20;
|
||||
};
|
||||
bool IsValid() { return z < 20; };
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ namespace api
|
||||
|
||||
struct TripParameters : public RouteParameters
|
||||
{
|
||||
//bool IsValid() const; Falls back to base class
|
||||
// bool IsValid() const; Falls back to base class
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class BaseDataFacade
|
||||
// Gets the weight values for each segment in an uncompressed geometry.
|
||||
// Should always be 1 shorter than GetUncompressedGeometry
|
||||
virtual void GetUncompressedWeights(const EdgeID id,
|
||||
std::vector<EdgeWeight> &result_weights) const = 0;
|
||||
std::vector<EdgeWeight> &result_weights) const = 0;
|
||||
|
||||
virtual extractor::guidance::TurnInstruction
|
||||
GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
||||
|
||||
@@ -208,7 +208,8 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
if (number_of_compressed_geometries > 0)
|
||||
{
|
||||
geometry_stream.read((char *)&(m_geometry_list[0]),
|
||||
number_of_compressed_geometries * sizeof(extractor::CompressedEdgeContainer::CompressedEdge));
|
||||
number_of_compressed_geometries *
|
||||
sizeof(extractor::CompressedEdgeContainer::CompressedEdge));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +218,8 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
|
||||
|
||||
m_static_rtree.reset(new InternalRTree(ram_index_path, file_index_path, m_coordinate_list));
|
||||
m_geospatial_query.reset(new InternalGeospatialQuery(*m_static_rtree, m_coordinate_list, *this));
|
||||
m_geospatial_query.reset(
|
||||
new InternalGeospatialQuery(*m_static_rtree, m_coordinate_list, *this));
|
||||
}
|
||||
|
||||
void LoadStreetNames(const boost::filesystem::path &names_file)
|
||||
@@ -553,19 +555,27 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
|
||||
result_nodes.clear();
|
||||
result_nodes.reserve(end - begin);
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_nodes.emplace_back(edge.node_id); });
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
|
||||
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
|
||||
{
|
||||
result_nodes.emplace_back(edge.node_id);
|
||||
});
|
||||
}
|
||||
|
||||
virtual void GetUncompressedWeights(const EdgeID id,
|
||||
std::vector<EdgeWeight> &result_weights) const override final
|
||||
virtual void
|
||||
GetUncompressedWeights(const EdgeID id,
|
||||
std::vector<EdgeWeight> &result_weights) const override final
|
||||
{
|
||||
const unsigned begin = m_geometry_indices.at(id);
|
||||
const unsigned end = m_geometry_indices.at(id + 1);
|
||||
|
||||
result_weights.clear();
|
||||
result_weights.reserve(end - begin);
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_weights.emplace_back(edge.weight); });
|
||||
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
|
||||
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
|
||||
{
|
||||
result_weights.emplace_back(edge.weight);
|
||||
});
|
||||
}
|
||||
|
||||
std::string GetTimestamp() const override final { return m_timestamp; }
|
||||
|
||||
@@ -218,10 +218,10 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
|
||||
auto geometries_list_ptr =
|
||||
data_layout->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge>(
|
||||
shared_memory, storage::SharedDataLayout::GEOMETRIES_LIST);
|
||||
typename util::ShM<extractor::CompressedEdgeContainer::CompressedEdge, true>::vector geometry_list(
|
||||
geometries_list_ptr,
|
||||
data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_LIST]);
|
||||
shared_memory, storage::SharedDataLayout::GEOMETRIES_LIST);
|
||||
typename util::ShM<extractor::CompressedEdgeContainer::CompressedEdge, true>::vector
|
||||
geometry_list(geometries_list_ptr,
|
||||
data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_LIST]);
|
||||
m_geometry_list = std::move(geometry_list);
|
||||
}
|
||||
|
||||
@@ -239,7 +239,8 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
data_timestamp_ptr = static_cast<storage::SharedDataTimestamp *>(
|
||||
storage::makeSharedMemory(storage::CURRENT_REGIONS,
|
||||
sizeof(storage::SharedDataTimestamp), false, false)->Ptr());
|
||||
sizeof(storage::SharedDataTimestamp), false, false)
|
||||
->Ptr());
|
||||
CURRENT_LAYOUT = storage::LAYOUT_NONE;
|
||||
CURRENT_DATA = storage::DATA_NONE;
|
||||
CURRENT_TIMESTAMP = 0;
|
||||
@@ -310,8 +311,8 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
LoadNames();
|
||||
LoadCoreInformation();
|
||||
|
||||
util::SimpleLogger().Write()
|
||||
<< "number of geometries: " << m_coordinate_list->size();
|
||||
util::SimpleLogger().Write() << "number of geometries: "
|
||||
<< m_coordinate_list->size();
|
||||
for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
|
||||
{
|
||||
if (!GetCoordinateOfNode(i).IsValid())
|
||||
@@ -381,19 +382,27 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
|
||||
result_nodes.clear();
|
||||
result_nodes.reserve(end - begin);
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_nodes.emplace_back(edge.node_id); });
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
|
||||
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
|
||||
{
|
||||
result_nodes.emplace_back(edge.node_id);
|
||||
});
|
||||
}
|
||||
|
||||
virtual void GetUncompressedWeights(const EdgeID id,
|
||||
std::vector<EdgeWeight> &result_weights) const override final
|
||||
virtual void
|
||||
GetUncompressedWeights(const EdgeID id,
|
||||
std::vector<EdgeWeight> &result_weights) const override final
|
||||
{
|
||||
const unsigned begin = m_geometry_indices.at(id);
|
||||
const unsigned end = m_geometry_indices.at(id + 1);
|
||||
|
||||
result_weights.clear();
|
||||
result_weights.reserve(end - begin);
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_weights.emplace_back(edge.weight); });
|
||||
|
||||
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
|
||||
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
|
||||
{
|
||||
result_weights.emplace_back(edge.weight);
|
||||
});
|
||||
}
|
||||
|
||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const override final
|
||||
|
||||
@@ -28,7 +28,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
using CoordinateList = typename RTreeT::CoordinateList;
|
||||
|
||||
public:
|
||||
GeospatialQuery(RTreeT &rtree_, std::shared_ptr<CoordinateList> coordinates_, DataFacadeT &datafacade_)
|
||||
GeospatialQuery(RTreeT &rtree_,
|
||||
std::shared_ptr<CoordinateList> coordinates_,
|
||||
DataFacadeT &datafacade_)
|
||||
: rtree(rtree_), coordinates(std::move(coordinates_)), datafacade(datafacade_)
|
||||
{
|
||||
}
|
||||
@@ -352,10 +354,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
int forward_offset = 0, forward_weight = 0;
|
||||
int reverse_offset = 0, reverse_weight = 0;
|
||||
|
||||
if (data.forward_packed_geometry_id != SPECIAL_EDGEID) {
|
||||
if (data.forward_packed_geometry_id != SPECIAL_EDGEID)
|
||||
{
|
||||
std::vector<EdgeWeight> forward_weight_vector;
|
||||
datafacade.GetUncompressedWeights(data.forward_packed_geometry_id,
|
||||
forward_weight_vector);
|
||||
forward_weight_vector);
|
||||
for (std::size_t i = 0; i < data.fwd_segment_position; i++)
|
||||
{
|
||||
forward_offset += forward_weight_vector[i];
|
||||
@@ -363,32 +366,37 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
forward_weight = forward_weight_vector[data.fwd_segment_position];
|
||||
}
|
||||
|
||||
if (data.reverse_packed_geometry_id != SPECIAL_EDGEID) {
|
||||
if (data.reverse_packed_geometry_id != SPECIAL_EDGEID)
|
||||
{
|
||||
std::vector<EdgeWeight> reverse_weight_vector;
|
||||
datafacade.GetUncompressedWeights(data.reverse_packed_geometry_id,
|
||||
reverse_weight_vector);
|
||||
|
||||
BOOST_ASSERT(data.fwd_segment_position < reverse_weight_vector.size());
|
||||
|
||||
for (std::size_t i = 0; i < reverse_weight_vector.size() - data.fwd_segment_position - 1; i++)
|
||||
for (std::size_t i = 0;
|
||||
i < reverse_weight_vector.size() - data.fwd_segment_position - 1; i++)
|
||||
{
|
||||
reverse_offset += reverse_weight_vector[i];
|
||||
}
|
||||
reverse_weight = reverse_weight_vector[reverse_weight_vector.size() -
|
||||
data.fwd_segment_position - 1];
|
||||
reverse_weight =
|
||||
reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1];
|
||||
}
|
||||
|
||||
ratio = std::min(1.0, std::max(0.0, ratio));
|
||||
if (SPECIAL_NODEID != data.forward_edge_based_node_id) {
|
||||
if (SPECIAL_NODEID != data.forward_edge_based_node_id)
|
||||
{
|
||||
forward_weight *= ratio;
|
||||
}
|
||||
if (SPECIAL_NODEID != data.reverse_edge_based_node_id) {
|
||||
if (SPECIAL_NODEID != data.reverse_edge_based_node_id)
|
||||
{
|
||||
reverse_weight *= 1.0 - ratio;
|
||||
}
|
||||
|
||||
auto transformed = PhantomNodeWithDistance{PhantomNode{data, forward_weight, forward_offset,
|
||||
reverse_weight, reverse_offset, point_on_segment},
|
||||
current_perpendicular_distance};
|
||||
auto transformed =
|
||||
PhantomNodeWithDistance{PhantomNode{data, forward_weight, forward_offset,
|
||||
reverse_weight, reverse_offset, point_on_segment},
|
||||
current_perpendicular_distance};
|
||||
|
||||
return transformed;
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ RouteLeg assembleLeg(const DataFacadeT &facade,
|
||||
// `forward_weight`: duration of (d,t)
|
||||
// `forward_offset`: duration of (c, d)
|
||||
//
|
||||
// TODO discuss, this should not be the case after danpats fixes
|
||||
// The PathData will contain entries of b, c and d. But only c will contain
|
||||
// a duration value since its the only point associated with a turn.
|
||||
// As such we want to slice of the duration for (a,s) and add the duration for
|
||||
|
||||
@@ -13,22 +13,21 @@ namespace engine
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
inline Route assembleRoute(const std::vector<RouteLeg> &route_legs)
|
||||
{
|
||||
auto distance = std::accumulate(route_legs.begin(),
|
||||
route_legs.end(), 0.,
|
||||
[](const double sum, const RouteLeg &leg)
|
||||
{
|
||||
return sum + leg.distance;
|
||||
});
|
||||
auto duration = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
|
||||
[](const double sum, const RouteLeg &leg)
|
||||
{
|
||||
return sum + leg.duration;
|
||||
});
|
||||
inline Route assembleRoute(const std::vector<RouteLeg> &route_legs)
|
||||
{
|
||||
auto distance = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
|
||||
[](const double sum, const RouteLeg &leg)
|
||||
{
|
||||
return sum + leg.distance;
|
||||
});
|
||||
auto duration = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
|
||||
[](const double sum, const RouteLeg &leg)
|
||||
{
|
||||
return sum + leg.duration;
|
||||
});
|
||||
|
||||
return Route{duration, distance};
|
||||
}
|
||||
return Route{duration, distance};
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
|
||||
@@ -104,26 +104,18 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
{
|
||||
const auto name = facade.get_name_for_id(path_point.name_id);
|
||||
const auto distance = leg_geometry.segment_distances[segment_index];
|
||||
steps.push_back(RouteStep{path_point.name_id,
|
||||
name,
|
||||
path_point.duration_until_turn / 10.0,
|
||||
distance,
|
||||
path_point.travel_mode,
|
||||
maneuver,
|
||||
leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
steps.push_back(RouteStep{
|
||||
path_point.name_id, name, path_point.duration_until_turn / 10.0, distance,
|
||||
path_point.travel_mode, maneuver, leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
maneuver = detail::stepManeuverFromGeometry(
|
||||
path_point.turn_instruction, leg_geometry, segment_index, path_point.exit);
|
||||
segment_index++;
|
||||
}
|
||||
}
|
||||
const auto distance = leg_geometry.segment_distances[segment_index];
|
||||
steps.push_back(RouteStep{target_node.name_id,
|
||||
facade.get_name_for_id(target_node.name_id),
|
||||
target_duration,
|
||||
distance,
|
||||
target_mode,
|
||||
maneuver,
|
||||
steps.push_back(RouteStep{target_node.name_id, facade.get_name_for_id(target_node.name_id),
|
||||
target_duration, distance, target_mode, maneuver,
|
||||
leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
}
|
||||
@@ -134,20 +126,15 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
// |-------------t target_duration
|
||||
// x---*---*---*---z compressed edge
|
||||
// |-------| duration
|
||||
StepManeuver maneuver = {source_node.location,
|
||||
0.,
|
||||
0.,
|
||||
StepManeuver maneuver = {source_node.location, 0., 0.,
|
||||
extractor::guidance::TurnInstruction{
|
||||
extractor::guidance::TurnType::Location, initial_modifier},
|
||||
INVALID_EXIT_NR};
|
||||
|
||||
steps.push_back(RouteStep{source_node.name_id,
|
||||
facade.get_name_for_id(source_node.name_id),
|
||||
steps.push_back(RouteStep{source_node.name_id, facade.get_name_for_id(source_node.name_id),
|
||||
target_duration - source_duration,
|
||||
leg_geometry.segment_distances[segment_index],
|
||||
source_mode,
|
||||
std::move(maneuver),
|
||||
leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.segment_distances[segment_index], source_mode,
|
||||
std::move(maneuver), leg_geometry.FrontIndex(segment_index),
|
||||
leg_geometry.BackIndex(segment_index) + 1});
|
||||
}
|
||||
|
||||
@@ -159,20 +146,13 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
target_location.get()))
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
// This step has length zero, the only reason we need it is the target location
|
||||
steps.push_back(
|
||||
RouteStep{target_node.name_id,
|
||||
facade.get_name_for_id(target_node.name_id),
|
||||
0.,
|
||||
0.,
|
||||
target_mode,
|
||||
StepManeuver{target_node.location,
|
||||
0.,
|
||||
0.,
|
||||
extractor::guidance::TurnInstruction{
|
||||
extractor::guidance::TurnType::Location, final_modifier},
|
||||
INVALID_EXIT_NR},
|
||||
leg_geometry.locations.size(),
|
||||
leg_geometry.locations.size()});
|
||||
steps.push_back(RouteStep{
|
||||
target_node.name_id, facade.get_name_for_id(target_node.name_id), 0., 0., target_mode,
|
||||
StepManeuver{target_node.location, 0., 0.,
|
||||
extractor::guidance::TurnInstruction{extractor::guidance::TurnType::Location,
|
||||
final_modifier},
|
||||
INVALID_EXIT_NR},
|
||||
leg_geometry.locations.size(), leg_geometry.locations.size()});
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
#ifndef ROUTE_HPP
|
||||
#define ROUTE_HPP
|
||||
|
||||
namespace osrm {
|
||||
namespace engine {
|
||||
namespace guidance {
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
struct Route
|
||||
{
|
||||
double duration;
|
||||
double distance;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ struct RouteLeg
|
||||
std::string summary;
|
||||
std::vector<RouteStep> steps;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ struct RouteStep
|
||||
std::size_t geometry_begin;
|
||||
std::size_t geometry_end;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace map_matching
|
||||
|
||||
struct MatchingConfidence
|
||||
{
|
||||
private:
|
||||
private:
|
||||
using ClassifierT = BayesClassifier<LaplaceDistribution, LaplaceDistribution, double>;
|
||||
using TraceClassification = ClassifierT::ClassificationT;
|
||||
|
||||
public:
|
||||
public:
|
||||
MatchingConfidence()
|
||||
: // the values were derived from fitting a laplace distribution
|
||||
// to the values of manually classified traces
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
BOOST_ASSERT(label_with_confidence.first == ClassifierT::ClassLabel::NEGATIVE);
|
||||
return 1 - label_with_confidence.second;
|
||||
}
|
||||
private:
|
||||
|
||||
private:
|
||||
ClassifierT classifier;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ struct SubMatching
|
||||
std::vector<unsigned> indices;
|
||||
double confidence;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ class TripPlugin final : public BasePlugin
|
||||
|
||||
Status HandleRequest(const api::TripParameters ¶meters, util::json::Object &json_result);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,10 @@ class ManyToManyRouting final
|
||||
const std::vector<std::size_t> &source_indices,
|
||||
const std::vector<std::size_t> &target_indices) const
|
||||
{
|
||||
const auto number_of_sources = source_indices.empty() ? phantom_nodes.size() : source_indices.size();
|
||||
const auto number_of_targets = target_indices.empty() ? phantom_nodes.size() : target_indices.size();
|
||||
const auto number_of_sources =
|
||||
source_indices.empty() ? phantom_nodes.size() : source_indices.size();
|
||||
const auto number_of_targets =
|
||||
target_indices.empty() ? phantom_nodes.size() : target_indices.size();
|
||||
const auto number_of_entries = number_of_sources * number_of_targets;
|
||||
std::vector<EdgeWeight> result_table(number_of_entries,
|
||||
std::numeric_limits<EdgeWeight>::max());
|
||||
@@ -90,7 +92,7 @@ class ManyToManyRouting final
|
||||
|
||||
// for each source do forward search
|
||||
unsigned row_idx = 0;
|
||||
const auto search_source_phantom = [&](const PhantomNode& phantom)
|
||||
const auto search_source_phantom = [&](const PhantomNode &phantom)
|
||||
{
|
||||
query_heap.Clear();
|
||||
// insert target(s) at distance 0
|
||||
|
||||
@@ -244,7 +244,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
const auto haversine_distance = util::coordinate_calculation::haversineDistance(
|
||||
prev_coordinate, current_coordinate);
|
||||
// assumes minumum of 0.1 m/s
|
||||
const int duration_uppder_bound = ((haversine_distance + max_distance_delta) * 0.25) * 10;
|
||||
const int duration_uppder_bound =
|
||||
((haversine_distance + max_distance_delta) * 0.25) * 10;
|
||||
|
||||
// compute d_t for this timestamp and the next one
|
||||
for (const auto s : util::irange<std::size_t>(0u, prev_viterbi.size()))
|
||||
@@ -274,8 +275,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
network_distance = super::GetNetworkDistanceWithCore(
|
||||
forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
prev_unbroken_timestamps_list[s].phantom_node,
|
||||
current_timestamps_list[s_prime].phantom_node,
|
||||
duration_uppder_bound);
|
||||
current_timestamps_list[s_prime].phantom_node, duration_uppder_bound);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -767,7 +767,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
SearchEngineData::QueryHeap &reverse_core_heap,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
int duration_upper_bound=INVALID_EDGE_WEIGHT) const
|
||||
int duration_upper_bound = INVALID_EDGE_WEIGHT) const
|
||||
{
|
||||
BOOST_ASSERT(forward_heap.Empty());
|
||||
BOOST_ASSERT(reverse_heap.Empty());
|
||||
@@ -821,7 +821,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
SearchEngineData::QueryHeap &reverse_heap,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
int duration_upper_bound=INVALID_EDGE_WEIGHT) const
|
||||
int duration_upper_bound = INVALID_EDGE_WEIGHT) const
|
||||
{
|
||||
BOOST_ASSERT(forward_heap.Empty());
|
||||
BOOST_ASSERT(reverse_heap.Empty());
|
||||
|
||||
@@ -243,7 +243,8 @@ class ShortestPathRouting final
|
||||
const std::vector<boost::optional<bool>> &uturn_indicators,
|
||||
InternalRouteResult &raw_route_data) const
|
||||
{
|
||||
BOOST_ASSERT(uturn_indicators.empty() || uturn_indicators.size() == phantom_nodes_vector.size() + 1);
|
||||
BOOST_ASSERT(uturn_indicators.empty() ||
|
||||
uturn_indicators.size() == phantom_nodes_vector.size() + 1);
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||
super::facade->GetNumberOfNodes());
|
||||
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
|
||||
@@ -285,8 +286,11 @@ class ShortestPathRouting final
|
||||
const auto &source_phantom = phantom_node_pair.source_phantom;
|
||||
const auto &target_phantom = phantom_node_pair.target_phantom;
|
||||
|
||||
const bool use_uturn_default = !use_uturn_indicators || !uturn_indicators[current_leg + 1];
|
||||
const bool allow_u_turn_at_via = (use_uturn_default && UTURN_DEFAULT) || (!use_uturn_default && *uturn_indicators[current_leg + 1]);
|
||||
const bool use_uturn_default =
|
||||
!use_uturn_indicators || !uturn_indicators[current_leg + 1];
|
||||
const bool allow_u_turn_at_via =
|
||||
(use_uturn_default && UTURN_DEFAULT) ||
|
||||
(!use_uturn_default && *uturn_indicators[current_leg + 1]);
|
||||
|
||||
bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
|
||||
bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;
|
||||
|
||||
@@ -11,7 +11,6 @@ enum class Status
|
||||
Ok,
|
||||
Error
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ class CompressedEdgeContainer
|
||||
public:
|
||||
struct CompressedEdge
|
||||
{
|
||||
public:
|
||||
NodeID node_id; // refers to an internal node-based-node
|
||||
EdgeWeight weight; // the weight of the edge leading to this node
|
||||
public:
|
||||
NodeID node_id; // refers to an internal node-based-node
|
||||
EdgeWeight weight; // the weight of the edge leading to this node
|
||||
};
|
||||
using EdgeBucket = std::vector<CompressedEdge>;
|
||||
|
||||
@@ -32,9 +32,8 @@ class CompressedEdgeContainer
|
||||
const EdgeWeight weight1,
|
||||
const EdgeWeight weight2);
|
||||
|
||||
void AddUncompressedEdge(const EdgeID edgei_id,
|
||||
const NodeID target_node,
|
||||
const EdgeWeight weight);
|
||||
void
|
||||
AddUncompressedEdge(const EdgeID edgei_id, const NodeID target_node, const EdgeWeight weight);
|
||||
|
||||
bool HasEntryForID(const EdgeID edge_id) const;
|
||||
void PrintStatistics() const;
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace detail
|
||||
const constexpr double DESIRED_SEGMENT_LENGTH = 10.0;
|
||||
const constexpr bool shiftable_ccw[] = {false, true, true, false, false, true, true, false};
|
||||
const constexpr bool shiftable_cw[] = {false, false, true, true, false, false, true, true};
|
||||
const constexpr uint8_t modifier_bounds[detail::num_direction_modifiers] = {
|
||||
0, 36, 93, 121, 136, 163, 220, 255};
|
||||
const constexpr uint8_t modifier_bounds[detail::num_direction_modifiers] = {0, 36, 93, 121,
|
||||
136, 163, 220, 255};
|
||||
const constexpr double discrete_angle_step_size = 360. / 256.;
|
||||
|
||||
template <typename IteratorType>
|
||||
@@ -294,14 +294,10 @@ inline DirectionModifier getTurnDirection(const double angle)
|
||||
// swaps left <-> right modifier types
|
||||
inline DirectionModifier mirrorDirectionModifier(const DirectionModifier modifier)
|
||||
{
|
||||
const constexpr DirectionModifier results[] = {DirectionModifier::UTurn,
|
||||
DirectionModifier::SharpLeft,
|
||||
DirectionModifier::Left,
|
||||
DirectionModifier::SlightLeft,
|
||||
DirectionModifier::Straight,
|
||||
DirectionModifier::SlightRight,
|
||||
DirectionModifier::Right,
|
||||
DirectionModifier::SharpRight};
|
||||
const constexpr DirectionModifier results[] = {
|
||||
DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left,
|
||||
DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight,
|
||||
DirectionModifier::Right, DirectionModifier::SharpRight};
|
||||
return results[modifier];
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::EngineConfig;
|
||||
using engine::EngineConfig;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
#include "util/json_container.hpp"
|
||||
namespace osrm
|
||||
{
|
||||
namespace json = osrm::util::json;
|
||||
namespace json = osrm::util::json;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::api::MatchParameters;
|
||||
using engine::api::MatchParameters;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::api::NearestParameters;
|
||||
using engine::api::NearestParameters;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::api::RouteParameters;
|
||||
using engine::api::RouteParameters;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::Status;
|
||||
using engine::Status;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::api::TableParameters;
|
||||
using engine::api::TableParameters;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using engine::api::TripParameters;
|
||||
using engine::api::TripParameters;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,22 +33,26 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
|
||||
using Iterator = std::string::iterator;
|
||||
using RadiusesT = std::vector<boost::optional<double>>;
|
||||
|
||||
BaseParametersGrammar(qi::rule<Iterator> &root_rule_,
|
||||
engine::api::BaseParameters ¶meters_)
|
||||
BaseParametersGrammar(qi::rule<Iterator> &root_rule_, engine::api::BaseParameters ¶meters_)
|
||||
: BaseParametersGrammar::base_type(root_rule_), base_parameters(parameters_)
|
||||
{
|
||||
const auto add_bearing = [this](boost::optional<boost::fusion::vector2<short, short>> bearing_range) {
|
||||
const auto add_bearing =
|
||||
[this](boost::optional<boost::fusion::vector2<short, short>> bearing_range)
|
||||
{
|
||||
boost::optional<engine::api::BaseParameters::Bearing> bearing;
|
||||
if (bearing_range)
|
||||
{
|
||||
bearing = engine::api::BaseParameters::Bearing {boost::fusion::at_c<0>(*bearing_range), boost::fusion::at_c<1>(*bearing_range)};
|
||||
bearing = engine::api::BaseParameters::Bearing{
|
||||
boost::fusion::at_c<0>(*bearing_range), boost::fusion::at_c<1>(*bearing_range)};
|
||||
}
|
||||
base_parameters.bearings.push_back(std::move(bearing));
|
||||
};
|
||||
const auto set_radiuses = [this](RadiusesT& radiuses) {
|
||||
const auto set_radiuses = [this](RadiusesT &radiuses)
|
||||
{
|
||||
base_parameters.radiuses = std::move(radiuses);
|
||||
};
|
||||
const auto add_hint = [this](const std::string& hint_string) {
|
||||
const auto add_hint = [this](const std::string &hint_string)
|
||||
{
|
||||
if (hint_string.size() > 0)
|
||||
{
|
||||
base_parameters.hints.push_back(engine::Hint::FromBase64(hint_string));
|
||||
@@ -56,9 +60,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
|
||||
};
|
||||
const auto add_coordinate = [this](const boost::fusion::vector<double, double> &lonLat)
|
||||
{
|
||||
base_parameters.coordinates.emplace_back(
|
||||
util::Coordinate(util::FixedLongitude(boost::fusion::at_c<0>(lonLat) * COORDINATE_PRECISION),
|
||||
util::FixedLatitude(boost::fusion::at_c<1>(lonLat) * COORDINATE_PRECISION)));
|
||||
base_parameters.coordinates.emplace_back(util::Coordinate(
|
||||
util::FixedLongitude(boost::fusion::at_c<0>(lonLat) * COORDINATE_PRECISION),
|
||||
util::FixedLatitude(boost::fusion::at_c<1>(lonLat) * COORDINATE_PRECISION)));
|
||||
};
|
||||
const auto polyline_to_coordinates = [this](const std::string &polyline)
|
||||
{
|
||||
@@ -70,7 +74,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
|
||||
base64_char = qi::char_("a-zA-Z0-9--_");
|
||||
|
||||
radiuses_rule = qi::lit("radiuses=") >> -qi::double_ % ";";
|
||||
hints_rule = qi::lit("hints=") >> qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]][add_hint] % ";";
|
||||
hints_rule =
|
||||
qi::lit("hints=") >>
|
||||
qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]][add_hint] % ";";
|
||||
bearings_rule =
|
||||
qi::lit("bearings=") >> (-(qi::short_ >> ',' >> qi::short_))[add_bearing] % ";";
|
||||
polyline_rule = qi::as_string[qi::lit("polyline(") >> +polyline_chars >>
|
||||
@@ -81,11 +87,11 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
|
||||
base_rule = bearings_rule | radiuses_rule[set_radiuses] | hints_rule;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
qi::rule<Iterator> base_rule;
|
||||
qi::rule<Iterator> query_rule;
|
||||
|
||||
private:
|
||||
private:
|
||||
engine::api::BaseParameters &base_parameters;
|
||||
qi::rule<Iterator> bearings_rule;
|
||||
qi::rule<Iterator> hints_rule;
|
||||
|
||||
@@ -68,9 +68,10 @@ struct MatchParametersGrammar final : public BaseParametersGrammar
|
||||
qi::lit("overview=full")[set_full_type] |
|
||||
qi::lit("overview=false")[set_false_type];
|
||||
timestamps_rule = qi::lit("timestamps=") >> qi::uint_ % ";";
|
||||
match_rule = steps_rule[set_steps] | geometries_rule |
|
||||
overview_rule | timestamps_rule[set_timestamps];
|
||||
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (match_rule | base_rule) % '&');
|
||||
match_rule = steps_rule[set_steps] | geometries_rule | overview_rule |
|
||||
timestamps_rule[set_timestamps];
|
||||
root_rule =
|
||||
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (match_rule | base_rule) % '&');
|
||||
}
|
||||
|
||||
engine::api::MatchParameters parameters;
|
||||
|
||||
@@ -31,7 +31,8 @@ struct NearestParametersGrammar final : public BaseParametersGrammar
|
||||
parameters.number_of_results = number;
|
||||
};
|
||||
nearest_rule = (qi::lit("number=") >> qi::uint_)[set_number];
|
||||
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (nearest_rule | base_rule) % '&');
|
||||
root_rule =
|
||||
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (nearest_rule | base_rule) % '&');
|
||||
}
|
||||
|
||||
engine::api::NearestParameters parameters;
|
||||
|
||||
@@ -76,7 +76,8 @@ struct RouteParametersGrammar : public BaseParametersGrammar
|
||||
route_rule = steps_rule[set_steps] | alternative_rule[set_alternative] | geometries_rule |
|
||||
overview_rule | uturns_rule[set_uturns];
|
||||
|
||||
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (route_rule | base_rule) % '&');
|
||||
root_rule =
|
||||
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (route_rule | base_rule) % '&');
|
||||
}
|
||||
|
||||
engine::api::RouteParameters parameters;
|
||||
|
||||
@@ -36,11 +36,14 @@ struct TableParametersGrammar final : public BaseParametersGrammar
|
||||
{
|
||||
parameters.sources = std::move(sources);
|
||||
};
|
||||
destinations_rule = (qi::lit("destinations=") >> (qi::ulong_ % ";")[set_destiantions]) | qi::lit("destinations=all");
|
||||
sources_rule = (qi::lit("sources=") >> (qi::ulong_ % ";")[set_sources]) | qi::lit("sources=all");
|
||||
destinations_rule = (qi::lit("destinations=") >> (qi::ulong_ % ";")[set_destiantions]) |
|
||||
qi::lit("destinations=all");
|
||||
sources_rule =
|
||||
(qi::lit("sources=") >> (qi::ulong_ % ";")[set_sources]) | qi::lit("sources=all");
|
||||
table_rule = destinations_rule | sources_rule;
|
||||
|
||||
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (table_rule | base_rule) % '&');
|
||||
root_rule =
|
||||
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (table_rule | base_rule) % '&');
|
||||
}
|
||||
|
||||
engine::api::TableParameters parameters;
|
||||
|
||||
@@ -26,20 +26,29 @@ struct TileParametersGrammar final : boost::spirit::qi::grammar<std::string::ite
|
||||
{
|
||||
using Iterator = std::string::iterator;
|
||||
|
||||
TileParametersGrammar()
|
||||
: TileParametersGrammar::base_type(root_rule)
|
||||
TileParametersGrammar() : TileParametersGrammar::base_type(root_rule)
|
||||
{
|
||||
const auto set_x = [this](const unsigned x_) { parameters.x = x_; };
|
||||
const auto set_y = [this](const unsigned y_) { parameters.y = y_; };
|
||||
const auto set_z = [this](const unsigned z_) { parameters.z = z_; };
|
||||
const auto set_x = [this](const unsigned x_)
|
||||
{
|
||||
parameters.x = x_;
|
||||
};
|
||||
const auto set_y = [this](const unsigned y_)
|
||||
{
|
||||
parameters.y = y_;
|
||||
};
|
||||
const auto set_z = [this](const unsigned z_)
|
||||
{
|
||||
parameters.z = z_;
|
||||
};
|
||||
|
||||
query_rule = qi::lit("tile(") >> qi::uint_[set_x] >> qi::lit(",") >> qi::uint_[set_y] >> qi::lit(",") >> qi::uint_[set_z] >> qi::lit(")");
|
||||
query_rule = qi::lit("tile(") >> qi::uint_[set_x] >> qi::lit(",") >> qi::uint_[set_y] >>
|
||||
qi::lit(",") >> qi::uint_[set_z] >> qi::lit(")");
|
||||
|
||||
root_rule = query_rule >> qi::lit(".mvt");
|
||||
}
|
||||
engine::api::TileParameters parameters;
|
||||
|
||||
private:
|
||||
private:
|
||||
qi::rule<Iterator> root_rule;
|
||||
qi::rule<Iterator> query_rule;
|
||||
};
|
||||
|
||||
@@ -64,7 +64,8 @@ struct TripParametersGrammar final : public BaseParametersGrammar
|
||||
qi::lit("overview=false")[set_false_type];
|
||||
trip_rule = steps_rule[set_steps] | geometries_rule | overview_rule;
|
||||
|
||||
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (trip_rule | base_rule) % '&');
|
||||
root_rule =
|
||||
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (trip_rule | base_rule) % '&');
|
||||
}
|
||||
|
||||
engine::api::TripParameters parameters;
|
||||
|
||||
@@ -15,14 +15,13 @@ namespace api
|
||||
{
|
||||
|
||||
// Starts parsing and iter and modifies it until iter == end or parsing failed
|
||||
boost::optional<ParsedURL> parseURL(std::string::iterator& iter, std::string::iterator end);
|
||||
boost::optional<ParsedURL> parseURL(std::string::iterator &iter, std::string::iterator end);
|
||||
// copy on purpose because we need mutability
|
||||
inline boost::optional<ParsedURL> parseURL(std::string url_string)
|
||||
{
|
||||
auto iter = url_string.begin();
|
||||
return parseURL(iter, url_string.end());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@ bool constrainParamSize(const char *msg_template,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ class ServiceHandler
|
||||
engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result);
|
||||
|
||||
private:
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<service::BaseService>> service_map;
|
||||
OSRM routing_machine;
|
||||
};
|
||||
|
||||
@@ -13,10 +13,11 @@ namespace storage
|
||||
using DataPaths = std::unordered_map<std::string, boost::filesystem::path>;
|
||||
class Storage
|
||||
{
|
||||
public:
|
||||
Storage(const DataPaths& data_paths);
|
||||
public:
|
||||
Storage(const DataPaths &data_paths);
|
||||
int Run();
|
||||
private:
|
||||
|
||||
private:
|
||||
DataPaths paths;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -195,11 +195,13 @@ struct RectangleInt2D
|
||||
return lons_contained && lats_contained;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& out, const RectangleInt2D& rect);
|
||||
friend std::ostream &operator<<(std::ostream &out, const RectangleInt2D &rect);
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, const RectangleInt2D& rect)
|
||||
inline std::ostream &operator<<(std::ostream &out, const RectangleInt2D &rect)
|
||||
{
|
||||
out << std::setprecision(12) << "(" << toFloating(rect.min_lon) << "," << toFloating(rect.max_lon) << "," << toFloating(rect.min_lat) << "," << toFloating(rect.max_lat) << ")";
|
||||
out << std::setprecision(12) << "(" << toFloating(rect.min_lon) << ","
|
||||
<< toFloating(rect.max_lon) << "," << toFloating(rect.min_lat) << ","
|
||||
<< toFloating(rect.max_lat) << ")";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user