osrm-backend/include/engine/guidance/leg_geometry.hpp

66 lines
1.6 KiB
C++
Raw Normal View History

2016-01-28 10:28:44 -05:00
#ifndef ENGINE_GUIDANCE_LEG_GEOMETRY_HPP
#define ENGINE_GUIDANCE_LEG_GEOMETRY_HPP
#include "util/coordinate.hpp"
#include "util/integer_range.hpp"
2016-05-18 16:09:14 -04:00
#include "util/typedefs.hpp"
2016-01-28 10:28:44 -05:00
#include <boost/assert.hpp>
#include <cstddef>
2016-01-28 10:28:44 -05:00
#include <cstdlib>
2016-05-27 15:05:04 -04:00
#include <vector>
2016-01-28 10:28:44 -05:00
namespace osrm::engine::guidance
2016-01-28 10:28:44 -05:00
{
// locations 0---1---2-...-n-1---n
// turns s x y t
2016-03-15 12:07:49 -04:00
// segment | 0 | 1 | 2 | sentinel
2016-01-28 10:28:44 -05:00
// offsets 0 2 n-1 n
struct LegGeometry
{
std::vector<util::Coordinate> locations;
2016-01-28 10:28:44 -05:00
// segment_offset[i] .. segment_offset[i+1] (inclusive)
// contains the geometry of segment i
std::vector<std::size_t> segment_offsets;
// length of the segment in meters
std::vector<double> segment_distances;
2016-05-18 16:09:14 -04:00
// original OSM node IDs for each coordinate
Lazily generate optional route path data (#6045) Currently route results are annotated with additional path information, such as geometries, turn-by-turn steps and other metadata. These annotations are generated if they are not requested or returned in the response. Datasets needed to generate these annotations are loaded and available to the OSRM process even when unused. This commit is a first step towards making the loading of these datasets optional. We refactor the code so that route annotations are only generated if explicitly requested and needed in the response. Specifically, we change the following annotations to be lazily generated: - Turn-by-turn steps - Route Overview geometry - Route segment metadata For example. a /route/v1 request with steps=false&overview=false&annotations=false would no longer call the following data facade methods: - GetOSMNodeIDOfNode - GetTurnInstructionForEdgeID - GetNameIndex - GetNameForID - GetRefForID - GetTurnInstructionForEdgeID - GetClassData - IsLeftHandDriving - GetTravelMode - IsSegregated - PreTurnBearing - PostTurnBearing - HasLaneData - GetLaneData - GetEntryClass Requests that include segment metadata and/or overview geometry but not turn-by-turn instructions will also benefit from this, although there is some interdependency with the step instructions - a call to GetTurnInstructionForEdgeID is still required. Requests for OSM annotations will understandably still need to call GetOSMNodeIDOfNode. Making these changes unlocks the optional loading of data contained in the following OSRM files: - osrm.names - osrm.icd - osrm.nbg_nodes (partial) - osrm.ebg_nodes (partial) - osrm.edges
2022-08-22 07:59:20 -04:00
std::vector<NodeID> node_ids;
2016-01-28 10:28:44 -05:00
// Per-coordinate metadata
2016-05-27 15:05:04 -04:00
struct Annotation
{
double distance; // distance in meters
// Total duration of a segment, in seconds, NOT including
// the turn penalty if the segment preceeds a turn
double duration;
double weight; // weight value, NOT including the turn weight
DatasourceID datasource;
};
std::vector<Annotation> annotations;
2016-01-28 10:28:44 -05:00
std::size_t FrontIndex(std::size_t segment_index) const
{
return segment_offsets[segment_index];
}
std::size_t BackIndex(std::size_t segment_index) const
{
return segment_offsets[segment_index + 1];
}
std::size_t GetNumberOfSegments() const
{
BOOST_ASSERT(segment_offsets.size() > 0);
return segment_offsets.size() - 1;
}
};
2022-12-20 12:00:11 -05:00
} // namespace osrm::engine::guidance
2016-01-28 10:28:44 -05:00
#endif