reserve when possible
This commit is contained in:
@@ -42,7 +42,8 @@ std::string modeToString(const extractor::TravelMode mode);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <unsigned POLYLINE_PRECISION, typename ForwardIter> util::json::String makePolyline(ForwardIter begin, ForwardIter end)
|
||||
template <unsigned POLYLINE_PRECISION, typename ForwardIter>
|
||||
util::json::String makePolyline(ForwardIter begin, ForwardIter end)
|
||||
{
|
||||
return {encodePolyline<POLYLINE_PRECISION>(begin, end)};
|
||||
}
|
||||
|
||||
@@ -196,16 +196,16 @@ class RouteAPI : public BaseAPI
|
||||
[this, &leg_geometry](const guidance::RouteStep &step) {
|
||||
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
|
||||
{
|
||||
return static_cast<util::json::Value>(
|
||||
json::makePolyline<100000>(leg_geometry.locations.begin() + step.geometry_begin,
|
||||
leg_geometry.locations.begin() + step.geometry_end));
|
||||
return static_cast<util::json::Value>(json::makePolyline<100000>(
|
||||
leg_geometry.locations.begin() + step.geometry_begin,
|
||||
leg_geometry.locations.begin() + step.geometry_end));
|
||||
}
|
||||
|
||||
if (parameters.geometries == RouteParameters::GeometriesType::Polyline6)
|
||||
{
|
||||
return static_cast<util::json::Value>(
|
||||
json::makePolyline<1000000>(leg_geometry.locations.begin() + step.geometry_begin,
|
||||
leg_geometry.locations.begin() + step.geometry_end));
|
||||
return static_cast<util::json::Value>(json::makePolyline<1000000>(
|
||||
leg_geometry.locations.begin() + step.geometry_begin,
|
||||
leg_geometry.locations.begin() + step.geometry_end));
|
||||
}
|
||||
|
||||
BOOST_ASSERT(parameters.geometries == RouteParameters::GeometriesType::GeoJSON);
|
||||
|
||||
@@ -233,7 +233,6 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
||||
WaypointType::Arrive,
|
||||
0};
|
||||
|
||||
|
||||
BOOST_ASSERT(!leg_geometry.locations.empty());
|
||||
steps.push_back(RouteStep{target_node.name_id,
|
||||
facade.GetNameForID(target_node.name_id),
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/assert.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -13,17 +13,17 @@ namespace osrm
|
||||
namespace engine
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
constexpr double POLYLINE_DECODING_PRECISION = 1e5;
|
||||
constexpr double POLYLINE_TO_COORDINATE = COORDINATE_PRECISION / POLYLINE_DECODING_PRECISION;
|
||||
{
|
||||
constexpr double POLYLINE_DECODING_PRECISION = 1e5;
|
||||
constexpr double POLYLINE_TO_COORDINATE = COORDINATE_PRECISION / POLYLINE_DECODING_PRECISION;
|
||||
|
||||
std::string encode(std::vector<int> &numbers);
|
||||
}
|
||||
std::string encode(std::vector<int> &numbers);
|
||||
}
|
||||
using CoordVectorForwardIter = std::vector<util::Coordinate>::const_iterator;
|
||||
// Encodes geometry into polyline format.
|
||||
// See: https://developers.google.com/maps/documentation/utilities/polylinealgorithm
|
||||
|
||||
template<unsigned POLYLINE_PRECISION=100000>
|
||||
template <unsigned POLYLINE_PRECISION = 100000>
|
||||
std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter end)
|
||||
{
|
||||
double coordinate_to_polyline = POLYLINE_PRECISION / COORDINATE_PRECISION;
|
||||
@@ -39,7 +39,10 @@ std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter
|
||||
int current_lat = 0;
|
||||
int current_lon = 0;
|
||||
std::for_each(
|
||||
begin, end, [&delta_numbers, ¤t_lat, ¤t_lon, coordinate_to_polyline](const util::Coordinate loc) {
|
||||
begin,
|
||||
end,
|
||||
[&delta_numbers, ¤t_lat, ¤t_lon, coordinate_to_polyline](
|
||||
const util::Coordinate loc) {
|
||||
const int lat_diff =
|
||||
std::round(static_cast<int>(loc.lat) * coordinate_to_polyline) - current_lat;
|
||||
const int lon_diff =
|
||||
|
||||
@@ -87,7 +87,8 @@ struct LengthLimitedCoordinateAccumulator
|
||||
};
|
||||
|
||||
/*
|
||||
* The SelectRoadByNameOnlyChoiceAndStraightness tries to follow a given name along a route. We offer methods to skip
|
||||
* The SelectRoadByNameOnlyChoiceAndStraightness tries to follow a given name along a route. We
|
||||
* offer methods to skip
|
||||
* over bridges/similar situations if desired, following narrow turns
|
||||
* This struct offers an example implementation of a possible road selector for traversing the
|
||||
* node-based graph using the NodeBasedGraphWalker
|
||||
@@ -115,14 +116,13 @@ struct SelectRoadByNameOnlyChoiceAndStraightness
|
||||
// find the next intersection given a hop limit
|
||||
struct IntersectionFinderAccumulator
|
||||
{
|
||||
IntersectionFinderAccumulator(const std::uint8_t hop_limit, const IntersectionGenerator &intersection_generator);
|
||||
IntersectionFinderAccumulator(const std::uint8_t hop_limit,
|
||||
const IntersectionGenerator &intersection_generator);
|
||||
// true if the path has traversed enough distance
|
||||
bool terminate();
|
||||
|
||||
// update the accumulator
|
||||
void update(const NodeID from_node,
|
||||
const EdgeID via_edge,
|
||||
const NodeID to_node);
|
||||
void update(const NodeID from_node, const EdgeID via_edge, const NodeID to_node);
|
||||
|
||||
std::uint8_t hops;
|
||||
const std::uint8_t hop_limit;
|
||||
@@ -136,8 +136,6 @@ struct IntersectionFinderAccumulator
|
||||
Intersection intersection;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class accumulator_type, class selector_type>
|
||||
boost::optional<std::pair<NodeID, EdgeID>>
|
||||
NodeBasedGraphWalker::TraverseRoad(NodeID current_node_id,
|
||||
|
||||
@@ -25,8 +25,8 @@ inline void print(const engine::guidance::RouteStep &step)
|
||||
{
|
||||
std::cout << static_cast<int>(step.maneuver.instruction.type) << " "
|
||||
<< static_cast<int>(step.maneuver.instruction.direction_modifier) << " "
|
||||
<< static_cast<int>(step.maneuver.waypoint_type) << " "
|
||||
<< step.maneuver.location << " "
|
||||
<< static_cast<int>(step.maneuver.waypoint_type) << " " << step.maneuver.location
|
||||
<< " "
|
||||
<< " Duration: " << step.duration << " Distance: " << step.distance
|
||||
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end
|
||||
<< "\n\tIntersections: " << step.intersections.size() << " [";
|
||||
@@ -44,7 +44,8 @@ inline void print(const engine::guidance::RouteStep &step)
|
||||
std::cout << " " << (entry ? "true" : "false");
|
||||
std::cout << ")";
|
||||
}
|
||||
std::cout << "] name[" << step.name_id << "]: " << step.name << " Ref: " << step.ref << " Pronunciation: " << step.pronunciation;
|
||||
std::cout << "] name[" << step.name_id << "]: " << step.name << " Ref: " << step.ref
|
||||
<< " Pronunciation: " << step.pronunciation;
|
||||
}
|
||||
|
||||
inline void print(const std::vector<engine::guidance::RouteStep> &steps)
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace guidance
|
||||
class BearingClass
|
||||
{
|
||||
public:
|
||||
BearingClass();
|
||||
|
||||
// Add a bearing to the set
|
||||
void add(const DiscreteBearing bearing);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user