Runs scripts/format.sh
This commit is contained in:
parent
bb06e044f5
commit
7c30ea32bf
@ -38,7 +38,7 @@ int main(int argc, const char *argv[]) try
|
||||
// The following shows how to use the Route service; configure this service
|
||||
RouteParameters params;
|
||||
|
||||
// Rout in monaco
|
||||
// Route in monaco
|
||||
params.coordinates.push_back({util::FloatLongitude(7.419758), util::FloatLatitude(43.731142)});
|
||||
params.coordinates.push_back({util::FloatLongitude(7.419505), util::FloatLatitude(43.736825)});
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -28,14 +28,8 @@ namespace json
|
||||
namespace detail
|
||||
{
|
||||
|
||||
const constexpr char *modifier_names[] = {"uturn",
|
||||
"sharp right",
|
||||
"right",
|
||||
"slight right",
|
||||
"straight",
|
||||
"slight left",
|
||||
"left",
|
||||
"sharp left"};
|
||||
const constexpr char *modifier_names[] = {"uturn", "sharp right", "right", "slight right",
|
||||
"straight", "slight left", "left", "sharp left"};
|
||||
|
||||
// translations of TurnTypes. Not all types are exposed to the outside world.
|
||||
// invalid types should never be returned as part of the API
|
||||
|
@ -59,8 +59,8 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs);
|
||||
|
||||
InternalRouteResult raw_route;
|
||||
auto build_phantom_pairs =
|
||||
[&raw_route](const PhantomNode &first_node, const PhantomNode &second_node)
|
||||
auto build_phantom_pairs = [&raw_route](const PhantomNode &first_node,
|
||||
const PhantomNode &second_node)
|
||||
{
|
||||
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
|
||||
};
|
||||
|
@ -70,10 +70,15 @@ std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter
|
||||
delta_numbers.reserve((size - 1) * 2);
|
||||
int current_lat = 0;
|
||||
int current_lon = 0;
|
||||
std::for_each(begin, end, [&delta_numbers, ¤t_lat, ¤t_lon](const util::Coordinate loc)
|
||||
std::for_each(begin, end,
|
||||
[&delta_numbers, ¤t_lat, ¤t_lon](const util::Coordinate loc)
|
||||
{
|
||||
const int lat_diff = std::round(static_cast<int>(loc.lat) * detail::COORDINATE_TO_POLYLINE) - current_lat;
|
||||
const int lon_diff = std::round(static_cast<int>(loc.lon) * detail::COORDINATE_TO_POLYLINE) - current_lon;
|
||||
const int lat_diff =
|
||||
std::round(static_cast<int>(loc.lat) * detail::COORDINATE_TO_POLYLINE) -
|
||||
current_lat;
|
||||
const int lon_diff =
|
||||
std::round(static_cast<int>(loc.lon) * detail::COORDINATE_TO_POLYLINE) -
|
||||
current_lon;
|
||||
delta_numbers.emplace_back(lat_diff);
|
||||
delta_numbers.emplace_back(lon_diff);
|
||||
current_lat += lat_diff;
|
||||
|
@ -78,7 +78,7 @@ void CompressedEdgeContainer::SerializeInternalVector(const std::string &path) c
|
||||
const unsigned unpacked_size = current_vector.size();
|
||||
control_sum += unpacked_size;
|
||||
BOOST_ASSERT(std::numeric_limits<unsigned>::max() != unpacked_size);
|
||||
for (const auto & current_node : current_vector)
|
||||
for (const auto ¤t_node : current_vector)
|
||||
{
|
||||
geometry_out_stream.write((char *)&(current_node), sizeof(CompressedEdge));
|
||||
}
|
||||
@ -143,7 +143,7 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
|
||||
// weight1 is the distance to the (currently) last coordinate in the bucket
|
||||
if (edge_bucket_list1.empty())
|
||||
{
|
||||
edge_bucket_list1.emplace_back(CompressedEdge { via_node_id, weight1 });
|
||||
edge_bucket_list1.emplace_back(CompressedEdge{via_node_id, weight1});
|
||||
}
|
||||
|
||||
BOOST_ASSERT(0 < edge_bucket_list1.size());
|
||||
@ -174,11 +174,11 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
|
||||
else
|
||||
{
|
||||
// we are certain that the second edge is atomic.
|
||||
edge_bucket_list1.emplace_back( CompressedEdge { target_node_id, weight2 });
|
||||
edge_bucket_list1.emplace_back(CompressedEdge{target_node_id, weight2});
|
||||
}
|
||||
}
|
||||
|
||||
void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
|
||||
void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
|
||||
const NodeID target_node_id,
|
||||
const EdgeWeight weight)
|
||||
{
|
||||
@ -215,12 +215,10 @@ void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
|
||||
// Don't re-add this if it's already in there.
|
||||
if (edge_bucket_list.empty())
|
||||
{
|
||||
edge_bucket_list.emplace_back(CompressedEdge { target_node_id, weight });
|
||||
edge_bucket_list.emplace_back(CompressedEdge{target_node_id, weight});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CompressedEdgeContainer::PrintStatistics() const
|
||||
{
|
||||
const uint64_t compressed_edges = m_compressed_geometries.size();
|
||||
|
@ -278,8 +278,7 @@ int Extractor::run()
|
||||
|
||||
util::SimpleLogger().Write() << "Saving edge-based node weights to file.";
|
||||
TIMER_START(timer_write_node_weights);
|
||||
util::serializeVector(config.edge_based_node_weights_output_path,
|
||||
edge_based_node_weights);
|
||||
util::serializeVector(config.edge_based_node_weights_output_path, edge_based_node_weights);
|
||||
TIMER_STOP(timer_write_node_weights);
|
||||
util::SimpleLogger().Write() << "Done writing. (" << TIMER_SEC(timer_write_node_weights)
|
||||
<< ")";
|
||||
|
@ -41,9 +41,7 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
|
||||
external_memory.all_nodes_list.push_back(
|
||||
{util::toFixed(util::FloatLongitude(input_node.location().lon())),
|
||||
util::toFixed(util::FloatLatitude(input_node.location().lat())),
|
||||
OSMNodeID(input_node.id()),
|
||||
result_node.barrier,
|
||||
result_node.traffic_lights});
|
||||
OSMNodeID(input_node.id()), result_node.barrier, result_node.traffic_lights});
|
||||
}
|
||||
|
||||
void ExtractorCallbacks::ProcessRestriction(
|
||||
@ -125,8 +123,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
if (forward_weight_data.type == InternalExtractorEdge::WeightType::INVALID &&
|
||||
backward_weight_data.type == InternalExtractorEdge::WeightType::INVALID)
|
||||
{
|
||||
util::SimpleLogger().Write(logDEBUG)
|
||||
<< "found way with bogus speed, id: " << input_way.id();
|
||||
util::SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: "
|
||||
<< input_way.id();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -187,11 +185,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
});
|
||||
|
||||
external_memory.way_start_end_id_list.push_back(
|
||||
{OSMWayID(input_way.id()),
|
||||
OSMNodeID(input_way.nodes().back().ref()),
|
||||
{OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()),
|
||||
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
|
||||
OSMNodeID(input_way.nodes()[1].ref()),
|
||||
OSMNodeID(input_way.nodes()[0].ref())});
|
||||
OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -223,11 +219,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
}
|
||||
|
||||
external_memory.way_start_end_id_list.push_back(
|
||||
{OSMWayID(input_way.id()),
|
||||
OSMNodeID(input_way.nodes().back().ref()),
|
||||
{OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()),
|
||||
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
|
||||
OSMNodeID(input_way.nodes()[1].ref()),
|
||||
OSMNodeID(input_way.nodes()[0].ref())});
|
||||
OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,12 +156,10 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph);
|
||||
|
||||
// store compressed geometry in container
|
||||
geometry_compressor.CompressEdge(
|
||||
forward_e1, forward_e2, node_v, node_w,
|
||||
forward_weight1, forward_weight2);
|
||||
geometry_compressor.CompressEdge(
|
||||
reverse_e1, reverse_e2, node_v, node_u,
|
||||
reverse_weight1, reverse_weight2);
|
||||
geometry_compressor.CompressEdge(forward_e1, forward_e2, node_v, node_w,
|
||||
forward_weight1, forward_weight2);
|
||||
geometry_compressor.CompressEdge(reverse_e1, reverse_e2, node_v, node_u,
|
||||
reverse_weight1, reverse_weight2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +177,6 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
geometry_compressor.AddUncompressedEdge(edge_id, target, data.distance);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes,
|
||||
|
@ -29,14 +29,12 @@ namespace osrm
|
||||
namespace server
|
||||
{
|
||||
|
||||
|
||||
void RequestHandler::RegisterServiceHandler(std::unique_ptr<ServiceHandler> service_handler_)
|
||||
{
|
||||
service_handler = std::move(service_handler_);
|
||||
}
|
||||
|
||||
void RequestHandler::HandleRequest(const http::request ¤t_request,
|
||||
http::reply ¤t_reply)
|
||||
void RequestHandler::HandleRequest(const http::request ¤t_request, http::reply ¤t_reply)
|
||||
{
|
||||
if (!service_handler)
|
||||
{
|
||||
@ -78,15 +76,16 @@ void RequestHandler::HandleRequest(const http::request ¤t_request,
|
||||
<< request_string;
|
||||
|
||||
auto api_iterator = request_string.begin();
|
||||
auto maybe_parsed_url = api::parseURL(api_iterator, request_string.end());;
|
||||
auto maybe_parsed_url = api::parseURL(api_iterator, request_string.end());
|
||||
;
|
||||
ServiceHandler::ResultT result;
|
||||
|
||||
|
||||
// check if the was an error with the request
|
||||
if (maybe_parsed_url && api_iterator == request_string.end())
|
||||
{
|
||||
|
||||
const engine::Status status = service_handler->RunQuery(std::move(*maybe_parsed_url), result);
|
||||
const engine::Status status =
|
||||
service_handler->RunQuery(std::move(*maybe_parsed_url), result);
|
||||
if (status != engine::Status::Ok)
|
||||
{
|
||||
// 4xx bad request return code
|
||||
@ -101,18 +100,18 @@ void RequestHandler::HandleRequest(const http::request ¤t_request,
|
||||
{
|
||||
const auto position = std::distance(request_string.begin(), api_iterator);
|
||||
const auto context_begin = request_string.begin() + std::max(position - 3UL, 0UL);
|
||||
const auto context_end = request_string.begin() + std::min(position + 3UL, request_string.size());
|
||||
const auto context_end =
|
||||
request_string.begin() + std::min(position + 3UL, request_string.size());
|
||||
std::string context(context_begin, context_end);
|
||||
|
||||
current_reply.status = http::reply::bad_request;
|
||||
result = util::json::Object();
|
||||
auto& json_result = result.get<util::json::Object>();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
json_result.values["code"] = "invalid-url";
|
||||
json_result.values["message"] =
|
||||
"URL string malformed close to position " + std::to_string(position) + ": \"" + context + "\"";
|
||||
json_result.values["message"] = "URL string malformed close to position " +
|
||||
std::to_string(position) + ": \"" + context + "\"";
|
||||
}
|
||||
|
||||
|
||||
current_reply.headers.emplace_back("Access-Control-Allow-Origin", "*");
|
||||
current_reply.headers.emplace_back("Access-Control-Allow-Methods", "GET");
|
||||
current_reply.headers.emplace_back("Access-Control-Allow-Headers",
|
||||
@ -121,14 +120,15 @@ void RequestHandler::HandleRequest(const http::request ¤t_request,
|
||||
{
|
||||
current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8");
|
||||
current_reply.headers.emplace_back("Content-Disposition",
|
||||
"inline; filename=\"response.json\"");
|
||||
"inline; filename=\"response.json\"");
|
||||
|
||||
util::json::render(current_reply.content, result.get<util::json::Object>());
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(result.is<std::string>());
|
||||
std::copy(result.get<std::string>().cbegin(), result.get<std::string>().cend(), std::back_inserter(current_reply.content));
|
||||
std::copy(result.get<std::string>().cbegin(), result.get<std::string>().cend(),
|
||||
std::back_inserter(current_reply.content));
|
||||
|
||||
current_reply.headers.emplace_back("Content-Type", "application/x-protobuf");
|
||||
}
|
||||
@ -144,6 +144,5 @@ void RequestHandler::HandleRequest(const http::request ¤t_request,
|
||||
<< ", uri: " << current_request.uri;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ RequestParser::parse(http::request ¤t_request, char *begin, char *end)
|
||||
return std::make_tuple(result, selected_compression);
|
||||
}
|
||||
|
||||
RequestParser::RequestStatus RequestParser::consume(http::request ¤t_request, const char input)
|
||||
RequestParser::RequestStatus RequestParser::consume(http::request ¤t_request,
|
||||
const char input)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters)
|
||||
engine::Status MatchService::RunQuery(std::string &query, ResultT &result)
|
||||
{
|
||||
result = util::json::Object();
|
||||
auto& json_result = result.get<util::json::Object>();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
|
||||
auto query_iterator = query.begin();
|
||||
auto parameters =
|
||||
|
@ -42,7 +42,7 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters)
|
||||
engine::Status NearestService::RunQuery(std::string &query, ResultT &result)
|
||||
{
|
||||
result = util::json::Object();
|
||||
auto& json_result = result.get<util::json::Object>();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
|
||||
auto query_iterator = query.begin();
|
||||
auto parameters =
|
||||
|
@ -25,7 +25,8 @@ ServiceHandler::ServiceHandler(osrm::EngineConfig &config) : routing_machine(con
|
||||
service_map["tile"] = util::make_unique<service::TileService>(routing_machine);
|
||||
}
|
||||
|
||||
engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, service::BaseService::ResultT &result)
|
||||
engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
|
||||
service::BaseService::ResultT &result)
|
||||
{
|
||||
const auto &service_iter = service_map.find(parsed_url.service);
|
||||
if (service_iter == service_map.end())
|
||||
|
@ -320,8 +320,8 @@ int Storage::Run()
|
||||
boost::iostreams::seek(geometry_input_stream, number_of_geometries_indices * sizeof(unsigned),
|
||||
BOOST_IOS::cur);
|
||||
geometry_input_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned));
|
||||
shared_layout_ptr->SetBlockSize<extractor::CompressedEdgeContainer::CompressedEdge>(SharedDataLayout::GEOMETRIES_LIST,
|
||||
number_of_compressed_geometries);
|
||||
shared_layout_ptr->SetBlockSize<extractor::CompressedEdgeContainer::CompressedEdge>(
|
||||
SharedDataLayout::GEOMETRIES_LIST, number_of_compressed_geometries);
|
||||
// allocate shared memory block
|
||||
util::SimpleLogger().Write() << "allocating shared memory of "
|
||||
<< shared_layout_ptr->GetSizeOfLayout() << " bytes";
|
||||
@ -420,8 +420,9 @@ int Storage::Run()
|
||||
(char *)geometries_index_ptr,
|
||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::GEOMETRIES_INDEX));
|
||||
}
|
||||
extractor::CompressedEdgeContainer::CompressedEdge *geometries_list_ptr = shared_layout_ptr->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge, true>(
|
||||
shared_memory_ptr, SharedDataLayout::GEOMETRIES_LIST);
|
||||
extractor::CompressedEdgeContainer::CompressedEdge *geometries_list_ptr =
|
||||
shared_layout_ptr->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge, true>(
|
||||
shared_memory_ptr, SharedDataLayout::GEOMETRIES_LIST);
|
||||
|
||||
geometry_input_stream.read((char *)&temporary_value, sizeof(unsigned));
|
||||
BOOST_ASSERT(temporary_value ==
|
||||
|
@ -114,8 +114,7 @@ int main(int argc, char *argv[]) try
|
||||
auto number_of_nodes = osrm::tools::loadGraph(argv[1], coordinate_list, graph_edge_list);
|
||||
|
||||
tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
|
||||
const auto graph =
|
||||
std::make_shared<osrm::tools::TarjanGraph>(number_of_nodes, graph_edge_list);
|
||||
const auto graph = std::make_shared<osrm::tools::TarjanGraph>(number_of_nodes, graph_edge_list);
|
||||
graph_edge_list.clear();
|
||||
graph_edge_list.shrink_to_fit();
|
||||
|
||||
@ -181,8 +180,7 @@ int main(int argc, char *argv[]) try
|
||||
{
|
||||
total_network_length +=
|
||||
100 * osrm::util::coordinate_calculation::greatCircleDistance(
|
||||
coordinate_list[source],
|
||||
coordinate_list[target]);
|
||||
coordinate_list[source], coordinate_list[target]);
|
||||
|
||||
BOOST_ASSERT(current_edge != SPECIAL_EDGEID);
|
||||
BOOST_ASSERT(source != SPECIAL_NODEID);
|
||||
@ -203,8 +201,7 @@ int main(int argc, char *argv[]) try
|
||||
static_cast<double>(osrm::util::toFloating(coordinate_list[target].lon)),
|
||||
static_cast<double>(osrm::util::toFloating(coordinate_list[target].lat)));
|
||||
|
||||
OGRFeature *po_feature =
|
||||
OGRFeature::CreateFeature(po_layer->GetLayerDefn());
|
||||
OGRFeature *po_feature = OGRFeature::CreateFeature(po_layer->GetLayerDefn());
|
||||
|
||||
po_feature->SetGeometry(&line_string);
|
||||
if (OGRERR_NONE != po_layer->CreateFeature(po_feature))
|
||||
@ -223,8 +220,8 @@ int main(int argc, char *argv[]) try
|
||||
<< "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000. << "s";
|
||||
|
||||
osrm::util::SimpleLogger().Write()
|
||||
<< "total network distance: "
|
||||
<< static_cast<uint64_t>(total_network_length / 100 / 1000.) << " km";
|
||||
<< "total network distance: " << static_cast<uint64_t>(total_network_length / 100 / 1000.)
|
||||
<< " km";
|
||||
|
||||
osrm::util::SimpleLogger().Write() << "finished component analysis";
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -29,10 +29,11 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
|
||||
|
||||
// declare a group of options that will be allowed both on command line
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
config_options.add_options()("profile,p",
|
||||
boost::program_options::value<boost::filesystem::path>(
|
||||
&extractor_config.profile_path)->default_value("profile.lua"),
|
||||
"Path to LUA routing profile")(
|
||||
config_options.add_options()(
|
||||
"profile,p",
|
||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
|
||||
->default_value("profile.lua"),
|
||||
"Path to LUA routing profile")(
|
||||
"threads,t",
|
||||
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
|
||||
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||
@ -42,8 +43,9 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
|
||||
->implicit_value(true)
|
||||
->default_value(false),
|
||||
"Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")(
|
||||
"small-component-size", boost::program_options::value<unsigned int>(
|
||||
&extractor_config.small_component_size)->default_value(1000),
|
||||
"small-component-size",
|
||||
boost::program_options::value<unsigned int>(&extractor_config.small_component_size)
|
||||
->default_value(1000),
|
||||
"Number of nodes required before a strongly-connected-componennt is considered big "
|
||||
"(affects nearest neighbor snapping)");
|
||||
|
||||
|
@ -64,8 +64,7 @@ int main(int argc, char *argv[]) try
|
||||
osrm::util::LogPolicy::GetInstance().Unmute();
|
||||
if (1 == argc)
|
||||
{
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0]
|
||||
<< " /path/on/device";
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " /path/on/device";
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -89,8 +88,7 @@ int main(int argc, char *argv[]) try
|
||||
fcntl(fileno(fd), F_NOCACHE, 1);
|
||||
fcntl(fileno(fd), F_RDAHEAD, 0);
|
||||
TIMER_START(write_1gb);
|
||||
write(fileno(fd), (char *)random_array,
|
||||
osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||
write(fileno(fd), (char *)random_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||
TIMER_STOP(write_1gb);
|
||||
fclose(fd);
|
||||
#endif
|
||||
@ -148,8 +146,7 @@ int main(int argc, char *argv[]) try
|
||||
osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno);
|
||||
return -1;
|
||||
}
|
||||
char *raw_array =
|
||||
(char *)memalign(512, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||
char *raw_array = (char *)memalign(512, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||
#endif
|
||||
TIMER_START(read_1gb);
|
||||
#ifdef __APPLE__
|
||||
@ -158,8 +155,7 @@ int main(int argc, char *argv[]) try
|
||||
fd = fopen(test_path.string().c_str(), "r");
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
int ret =
|
||||
read(file_desc, raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||
int ret = read(file_desc, raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
|
||||
osrm::util::SimpleLogger().Write(logDEBUG) << "read " << ret
|
||||
<< " bytes, error: " << strerror(errno);
|
||||
close(file_desc);
|
||||
@ -168,8 +164,8 @@ int main(int argc, char *argv[]) try
|
||||
#endif
|
||||
TIMER_STOP(read_1gb);
|
||||
|
||||
osrm::util::SimpleLogger().Write(logDEBUG) << "reading raw 1GB took "
|
||||
<< TIMER_SEC(read_1gb) << "s";
|
||||
osrm::util::SimpleLogger().Write(logDEBUG) << "reading raw 1GB took " << TIMER_SEC(read_1gb)
|
||||
<< "s";
|
||||
osrm::util::SimpleLogger().Write() << "raw read performance: " << std::setprecision(5)
|
||||
<< std::fixed << 1024 * 1024 / TIMER_SEC(read_1gb)
|
||||
<< "MB/sec";
|
||||
@ -184,8 +180,7 @@ int main(int argc, char *argv[]) try
|
||||
lseek(file_desc, 0, SEEK_SET);
|
||||
#endif
|
||||
// make 1000 random access, time each I/O seperately
|
||||
unsigned number_of_blocks =
|
||||
(osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned) - 1) / 4096;
|
||||
unsigned number_of_blocks = (osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned) - 1) / 4096;
|
||||
std::random_device rd;
|
||||
std::default_random_engine e1(rd());
|
||||
std::uniform_int_distribution<unsigned> uniform_dist(0, number_of_blocks - 1);
|
||||
@ -212,15 +207,13 @@ int main(int argc, char *argv[]) try
|
||||
if (((off_t)-1) == ret1)
|
||||
{
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "seek error "
|
||||
<< strerror(errno);
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "seek error " << strerror(errno);
|
||||
throw osrm::util::exception("seek error");
|
||||
}
|
||||
if (-1 == ret2)
|
||||
{
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "read error "
|
||||
<< strerror(errno);
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "read error " << strerror(errno);
|
||||
throw osrm::util::exception("read error");
|
||||
}
|
||||
timing_results_raw_random.push_back(TIMER_SEC(random_access));
|
||||
@ -274,15 +267,13 @@ int main(int argc, char *argv[]) try
|
||||
if (((off_t)-1) == ret1)
|
||||
{
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "seek error "
|
||||
<< strerror(errno);
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "seek error " << strerror(errno);
|
||||
throw osrm::util::exception("seek error");
|
||||
}
|
||||
if (-1 == ret2)
|
||||
{
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "read error "
|
||||
<< strerror(errno);
|
||||
osrm::util::SimpleLogger().Write(logWARNING) << "read error " << strerror(errno);
|
||||
throw osrm::util::exception("read error");
|
||||
}
|
||||
timing_results_raw_seq.push_back(TIMER_SEC(read_every_100));
|
||||
|
@ -60,13 +60,11 @@ int main() try
|
||||
osrm::util::SimpleLogger().Write() << "Releasing all locks";
|
||||
osrm::util::SimpleLogger().Write() << "ATTENTION! BE CAREFUL!";
|
||||
osrm::util::SimpleLogger().Write() << "----------------------";
|
||||
osrm::util::SimpleLogger().Write()
|
||||
<< "This tool may put osrm-routed into an undefined state!";
|
||||
osrm::util::SimpleLogger().Write() << "This tool may put osrm-routed into an undefined state!";
|
||||
osrm::util::SimpleLogger().Write()
|
||||
<< "Type 'Y' to acknowledge that you know what your are doing.";
|
||||
osrm::util::SimpleLogger().Write()
|
||||
<< "\n\nDo you want to purge all shared memory allocated "
|
||||
<< "by osrm-datastore? [type 'Y' to confirm]";
|
||||
osrm::util::SimpleLogger().Write() << "\n\nDo you want to purge all shared memory allocated "
|
||||
<< "by osrm-datastore? [type 'Y' to confirm]";
|
||||
|
||||
const auto letter = getchar();
|
||||
if (letter != 'Y')
|
||||
|
@ -6,49 +6,67 @@
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "contractor/query_edge.hpp"
|
||||
|
||||
namespace osrm {
|
||||
namespace test {
|
||||
|
||||
template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
|
||||
namespace osrm
|
||||
{
|
||||
private:
|
||||
EdgeDataT foo;
|
||||
public:
|
||||
namespace test
|
||||
{
|
||||
|
||||
template <class EdgeDataT>
|
||||
class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
|
||||
{
|
||||
private:
|
||||
EdgeDataT foo;
|
||||
|
||||
public:
|
||||
unsigned GetNumberOfNodes() const { return 0; }
|
||||
unsigned GetNumberOfEdges() const { return 0; }
|
||||
unsigned GetOutDegree(const NodeID /* n */) const { return 0; }
|
||||
NodeID GetTarget(const EdgeID /* e */) const { return SPECIAL_NODEID; }
|
||||
const EdgeDataT &GetEdgeData(const EdgeID /* e */) const {
|
||||
return foo;
|
||||
}
|
||||
const EdgeDataT &GetEdgeData(const EdgeID /* e */) const { return foo; }
|
||||
EdgeID BeginEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; }
|
||||
EdgeID EndEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; }
|
||||
osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const {
|
||||
return util::irange(static_cast<EdgeID>(0),static_cast<EdgeID>(0));
|
||||
osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const
|
||||
{
|
||||
return util::irange(static_cast<EdgeID>(0), static_cast<EdgeID>(0));
|
||||
}
|
||||
EdgeID FindEdge(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; }
|
||||
EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; }
|
||||
EdgeID
|
||||
FindEdgeIndicateIfReverse(const NodeID /* from */, const NodeID /* to */, bool & /* result */) const { return SPECIAL_EDGEID; }
|
||||
util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const {
|
||||
FixedPointCoordinate foo(0,0);
|
||||
EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const
|
||||
{
|
||||
return SPECIAL_EDGEID;
|
||||
}
|
||||
EdgeID FindEdgeIndicateIfReverse(const NodeID /* from */,
|
||||
const NodeID /* to */,
|
||||
bool & /* result */) const
|
||||
{
|
||||
return SPECIAL_EDGEID;
|
||||
}
|
||||
util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const
|
||||
{
|
||||
FixedPointCoordinate foo(0, 0);
|
||||
return foo;
|
||||
}
|
||||
bool EdgeIsCompressed(const unsigned /* id */) const { return false; }
|
||||
unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const { return SPECIAL_NODEID; }
|
||||
void GetUncompressedGeometry(const EdgeID /* id */,
|
||||
std::vector<NodeID> &/* result_nodes */) const {}
|
||||
std::vector<NodeID> & /* result_nodes */) const
|
||||
{
|
||||
}
|
||||
void GetUncompressedWeights(const EdgeID /* id */,
|
||||
std::vector<EdgeWeight> & /* result_weights */) const {}
|
||||
extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const {
|
||||
std::vector<EdgeWeight> & /* result_weights */) const
|
||||
{
|
||||
}
|
||||
extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const
|
||||
{
|
||||
return osrm::extractor::TurnInstruction::NoTurn;
|
||||
}
|
||||
extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const
|
||||
extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const
|
||||
{
|
||||
return TRAVEL_MODE_DEFAULT;
|
||||
}
|
||||
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */,
|
||||
const util::FixedPointCoordinate & /*north_east */) {
|
||||
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf>
|
||||
GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */,
|
||||
const util::FixedPointCoordinate & /*north_east */)
|
||||
{
|
||||
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> foo;
|
||||
return foo;
|
||||
}
|
||||
@ -56,7 +74,8 @@ template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::da
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const float /* max_distance */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
const int /* bearing_range = 180 */)
|
||||
{
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
@ -64,14 +83,17 @@ template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::da
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const unsigned /* max_results */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
const int /* bearing_range = 180 */)
|
||||
{
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
const int /* bearing_range = 180 */)
|
||||
{
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> foo;
|
||||
return foo;
|
||||
}
|
||||
@ -81,7 +103,6 @@ template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::da
|
||||
std::string get_name_for_id(const unsigned /* name_id */) const { return ""; }
|
||||
std::size_t GetCoreSize() const { return 0; }
|
||||
std::string GetTimestamp() const { return ""; }
|
||||
|
||||
};
|
||||
|
||||
using MockDataFacade = MockDataFacadeT<contractor::QueryEdge::EdgeData>;
|
||||
|
@ -80,28 +80,48 @@ template <typename ParameterT> std::size_t testInvalidOptions(std::string option
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_route_urls)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bla=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bearings=foo"), 32UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&uturns=foo"), 30UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&radiuses=foo"), 32UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&hints=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&geometries=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&overview=foo"), 22L);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&alternative=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bla=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bearings=foo"),
|
||||
32UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&uturns=foo"),
|
||||
30UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&radiuses=foo"),
|
||||
32UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&hints=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&geometries=foo"),
|
||||
22UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&overview=foo"),
|
||||
22L);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&alternative=foo"),
|
||||
22UL);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_table_urls)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=1&bla=foo"), 17UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=1&bla=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=1&destinations=1&bla=foo"), 32UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=1&bla=foo"),
|
||||
17UL);
|
||||
BOOST_CHECK_EQUAL(
|
||||
testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=1&bla=foo"), 22UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>(
|
||||
"1,2;3,4?sources=1&destinations=1&bla=foo"),
|
||||
32UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=foo"), 7UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=foo"), 7UL);
|
||||
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=foo"),
|
||||
7UL);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
{
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
|
||||
{util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
|
||||
engine::api::RouteParameters reference_1{};
|
||||
reference_1.coordinates = coords_1;
|
||||
@ -136,7 +156,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
engine::api::RouteParameters::OverviewType::False, uturns_3};
|
||||
reference_3.coordinates = coords_1;
|
||||
auto result_3 = api::parseParameters<engine::api::RouteParameters>(
|
||||
"1,2;3,4?steps=false&alternative=false&geometries=geojson&overview=false&uturns=true;false;");
|
||||
"1,2;3,4?steps=false&alternative=false&geometries=geojson&overview=false&uturns=true;"
|
||||
"false;");
|
||||
BOOST_CHECK(result_3);
|
||||
BOOST_CHECK_EQUAL(reference_3.steps, result_3->steps);
|
||||
BOOST_CHECK_EQUAL(reference_3.alternative, result_3->alternative);
|
||||
@ -165,7 +186,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
std::vector<boost::optional<double>>{},
|
||||
std::vector<boost::optional<engine::api::BaseParameters::Bearing>>{}};
|
||||
auto result_4 = api::parseParameters<engine::api::RouteParameters>(
|
||||
"1,2;3,4?steps=false&hints=rVghAzxMzABMAwAA5h4CAKMIAAAQAAAAGAAAAAYAAAAAAAAAch8BAJ4AAACpWCED_"
|
||||
"1,2;3,4?steps=false&hints="
|
||||
"rVghAzxMzABMAwAA5h4CAKMIAAAQAAAAGAAAAAYAAAAAAAAAch8BAJ4AAACpWCED_"
|
||||
"0vMAAEAAQGLSzmR;_4ghA4JuzAD_"
|
||||
"IAAAo28BAOYAAAAzAAAAAgAAAEwAAAAAAAAAdIwAAJ4AAAAXiSEDfm7MAAEAAQGLSzmR;03AhA0vnzAA_SAAA_____"
|
||||
"3wEAAAYAAAAQAAAAB4AAABAAAAAoUYBAJ4AAADlcCEDSefMAAMAAQGLSzmR");
|
||||
@ -180,20 +202,18 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
CHECK_EQUAL_RANGE(reference_4.coordinates, result_4->coordinates);
|
||||
|
||||
std::vector<boost::optional<engine::api::BaseParameters::Bearing>> bearings_4 = {
|
||||
boost::none,
|
||||
engine::api::BaseParameters::Bearing {200, 10},
|
||||
engine::api::BaseParameters::Bearing {100, 5},
|
||||
boost::none, engine::api::BaseParameters::Bearing{200, 10},
|
||||
engine::api::BaseParameters::Bearing{100, 5},
|
||||
};
|
||||
engine::api::RouteParameters reference_5{
|
||||
false,
|
||||
true,
|
||||
engine::api::RouteParameters::GeometriesType::Polyline,
|
||||
engine::api::RouteParameters::OverviewType::Simplified,
|
||||
std::vector<boost::optional<bool>>{},
|
||||
coords_1,
|
||||
std::vector<boost::optional<engine::Hint>> {},
|
||||
std::vector<boost::optional<double>>{},
|
||||
bearings_4};
|
||||
engine::api::RouteParameters reference_5{false,
|
||||
true,
|
||||
engine::api::RouteParameters::GeometriesType::Polyline,
|
||||
engine::api::RouteParameters::OverviewType::Simplified,
|
||||
std::vector<boost::optional<bool>>{},
|
||||
coords_1,
|
||||
std::vector<boost::optional<engine::Hint>>{},
|
||||
std::vector<boost::optional<double>>{},
|
||||
bearings_4};
|
||||
auto result_5 = api::parseParameters<engine::api::RouteParameters>(
|
||||
"1,2;3,4?steps=false&bearings=;200,10;100,5");
|
||||
BOOST_CHECK(result_5);
|
||||
@ -206,26 +226,29 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
CHECK_EQUAL_RANGE(reference_5.radiuses, result_5->radiuses);
|
||||
CHECK_EQUAL_RANGE(reference_5.coordinates, result_5->coordinates);
|
||||
|
||||
std::vector<util::Coordinate> coords_2 = {{util::FloatLongitude(0), util::FloatLatitude(1)}, {util::FloatLongitude(2), util::FloatLatitude(3)},
|
||||
{util::FloatLongitude(4), util::FloatLatitude(5)}};
|
||||
std::vector<util::Coordinate> coords_2 = {{util::FloatLongitude(0), util::FloatLatitude(1)},
|
||||
{util::FloatLongitude(2), util::FloatLatitude(3)},
|
||||
{util::FloatLongitude(4), util::FloatLatitude(5)}};
|
||||
|
||||
engine::api::RouteParameters reference_6{};
|
||||
reference_6.coordinates = coords_2;
|
||||
auto result_6 = api::parseParameters<engine::api::RouteParameters>("polyline(_ibE?_seK_seK_seK_seK)");
|
||||
auto result_6 =
|
||||
api::parseParameters<engine::api::RouteParameters>("polyline(_ibE?_seK_seK_seK_seK)");
|
||||
BOOST_CHECK(result_6);
|
||||
BOOST_CHECK_EQUAL(reference_6.steps, result_6->steps);
|
||||
BOOST_CHECK_EQUAL(reference_6.steps, result_6->steps);
|
||||
BOOST_CHECK_EQUAL(reference_6.alternative, result_6->alternative);
|
||||
BOOST_CHECK_EQUAL(reference_6.geometries, result_6->geometries);
|
||||
BOOST_CHECK_EQUAL(reference_6.overview, result_6->overview);
|
||||
CHECK_EQUAL_RANGE(reference_6.uturns, result_6->uturns);
|
||||
CHECK_EQUAL_RANGE(reference_6.bearings, result_6->bearings);
|
||||
CHECK_EQUAL_RANGE(reference_6.radiuses, result_6->radiuses);
|
||||
BOOST_CHECK_EQUAL(reference_6.geometries, result_6->geometries);
|
||||
BOOST_CHECK_EQUAL(reference_6.overview, result_6->overview);
|
||||
CHECK_EQUAL_RANGE(reference_6.uturns, result_6->uturns);
|
||||
CHECK_EQUAL_RANGE(reference_6.bearings, result_6->bearings);
|
||||
CHECK_EQUAL_RANGE(reference_6.radiuses, result_6->radiuses);
|
||||
CHECK_EQUAL_RANGE(reference_6.coordinates, result_6->coordinates);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_table_urls)
|
||||
{
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
|
||||
{util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
|
||||
engine::api::TableParameters reference_1{};
|
||||
reference_1.coordinates = coords_1;
|
||||
@ -241,18 +264,20 @@ BOOST_AUTO_TEST_CASE(valid_table_urls)
|
||||
std::vector<std::size_t> destinations_2 = {4, 5};
|
||||
engine::api::TableParameters reference_2{sources_2, destinations_2};
|
||||
reference_2.coordinates = coords_1;
|
||||
auto result_2 = api::parseParameters<engine::api::TableParameters>("1,2;3,4?sources=1;2;3&destinations=4;5");
|
||||
auto result_2 = api::parseParameters<engine::api::TableParameters>(
|
||||
"1,2;3,4?sources=1;2;3&destinations=4;5");
|
||||
BOOST_CHECK(result_2);
|
||||
CHECK_EQUAL_RANGE(reference_2.sources, result_2->sources);
|
||||
CHECK_EQUAL_RANGE(reference_2.sources, result_2->sources);
|
||||
CHECK_EQUAL_RANGE(reference_2.destinations, result_2->destinations);
|
||||
CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings);
|
||||
CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses);
|
||||
CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates);
|
||||
CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings);
|
||||
CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses);
|
||||
CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_match_urls)
|
||||
{
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
|
||||
{util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
|
||||
engine::api::MatchParameters reference_1{};
|
||||
reference_1.coordinates = coords_1;
|
||||
@ -290,7 +315,8 @@ BOOST_AUTO_TEST_CASE(valid_tile_urls)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_trip_urls)
|
||||
{
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
|
||||
{util::FloatLongitude(3), util::FloatLatitude(4)}};
|
||||
|
||||
engine::api::TripParameters reference_1{};
|
||||
reference_1.coordinates = coords_1;
|
||||
|
@ -36,8 +36,7 @@ BOOST_AUTO_TEST_CASE(io_data)
|
||||
osrm::util::deserializeVector(IO_TMP_FILE, data_out);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(data_in.size(), data_out.size());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(data_out.begin(), data_out.end(), data_in.begin(),
|
||||
data_in.end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(data_out.begin(), data_out.end(), data_in.begin(), data_in.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -96,8 +96,8 @@ BOOST_FIXTURE_TEST_CASE(array_test, TestRandomArrayEntryFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(target_test)
|
||||
{
|
||||
std::vector<TestInputEdge> input_edges = {
|
||||
TestInputEdge{0, 1, TestData{1}}, TestInputEdge{3, 0, TestData{2}}};
|
||||
std::vector<TestInputEdge> input_edges = {TestInputEdge{0, 1, TestData{1}},
|
||||
TestInputEdge{3, 0, TestData{2}}};
|
||||
TestStaticGraph simple_graph = TestStaticGraph(4, input_edges);
|
||||
|
||||
auto target = simple_graph.GetTarget(simple_graph.FindEdge(3, 0));
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(static_rtree)
|
||||
|
||||
using namespace osrm;
|
||||
@ -306,8 +305,11 @@ BOOST_AUTO_TEST_CASE(regression_test)
|
||||
{
|
||||
Coord{FloatLongitude{0.0}, FloatLatitude{40.0}}, //
|
||||
Coord{FloatLongitude{5.0}, FloatLatitude{35.0}}, //
|
||||
Coord{FloatLongitude{5.0}, FloatLatitude{5.0,}}, //
|
||||
Coord{FloatLongitude{10.0}, FloatLatitude{0.0}}, //
|
||||
Coord{FloatLongitude{5.0},
|
||||
FloatLatitude{
|
||||
5.0,
|
||||
}}, //
|
||||
Coord{FloatLongitude{10.0}, FloatLatitude{0.0}}, //
|
||||
Coord{FloatLongitude{10.0}, FloatLatitude{20.0}}, //
|
||||
Coord{FloatLongitude{5.0}, FloatLatitude{20.0}}, //
|
||||
Coord{FloatLongitude{100.0}, FloatLatitude{40.0}}, //
|
||||
@ -407,7 +409,8 @@ BOOST_AUTO_TEST_CASE(bearing_tests)
|
||||
build_rtree<GraphFixture, MiniStaticRTree>("test_bearing", &fixture, leaves_path, nodes_path);
|
||||
MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords);
|
||||
std::unique_ptr<MockDataFacade> mockfacade_ptr(new MockDataFacade);
|
||||
engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords, *mockfacade_ptr);
|
||||
engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords,
|
||||
*mockfacade_ptr);
|
||||
|
||||
Coordinate input(FloatLongitude(5.1), FloatLatitude(5.0));
|
||||
|
||||
@ -472,7 +475,8 @@ BOOST_AUTO_TEST_CASE(bbox_search_tests)
|
||||
build_rtree<GraphFixture, MiniStaticRTree>("test_bbox", &fixture, leaves_path, nodes_path);
|
||||
MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords);
|
||||
std::unique_ptr<MockDataFacade> mockfacade_ptr(new MockDataFacade);
|
||||
engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords, *mockfacade_ptr);
|
||||
engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords,
|
||||
*mockfacade_ptr);
|
||||
|
||||
{
|
||||
RectangleInt2D bbox = {FloatLongitude(0.5), FloatLongitude(1.5), FloatLatitude(0.5),
|
||||
|
Loading…
Reference in New Issue
Block a user