osrm-backend/unit_tests/engine/guidance_assembly.cpp

109 lines
4.8 KiB
C++
Raw Normal View History

2017-11-03 13:57:11 -04:00
#include "extractor/travel_mode.hpp"
2016-03-15 12:08:16 -04:00
#include "engine/guidance/assemble_geometry.hpp"
#include "engine/guidance/assemble_leg.hpp"
2016-05-27 15:05:04 -04:00
#include "engine/guidance/assemble_overview.hpp"
#include "engine/guidance/assemble_route.hpp"
#include "engine/guidance/assemble_steps.hpp"
#include "engine/guidance/post_processing.hpp"
2016-03-15 12:08:16 -04:00
2016-05-27 15:05:04 -04:00
#include <boost/test/unit_test.hpp>
2016-03-15 12:08:16 -04:00
BOOST_AUTO_TEST_SUITE(guidance_assembly)
BOOST_AUTO_TEST_CASE(trim_short_segments)
{
2017-11-03 13:57:11 -04:00
using namespace osrm::extractor;
using namespace osrm::guidance;
using namespace osrm::engine::guidance;
using namespace osrm::engine;
using namespace osrm::util;
IntermediateIntersection intersection1{{FloatLongitude{-73.981154}, FloatLatitude{40.767762}},
{302},
{1},
IntermediateIntersection::NO_INDEX,
0,
{0, 255},
{},
{}};
IntermediateIntersection intersection2{{FloatLongitude{-73.981495}, FloatLatitude{40.768275}},
{180},
{1},
0,
IntermediateIntersection::NO_INDEX,
{0, 255},
{},
{}};
// Check that duplicated coordinate in the end is removed
2018-02-09 13:32:09 -05:00
std::vector<RouteStep> steps = {{0,
324,
false,
"Central Park West",
"",
"",
"",
"",
"",
2017-06-30 05:13:52 -04:00
"",
0.2,
1.9076601161280742,
0.2,
2017-11-03 13:57:11 -04:00
TRAVEL_MODE_DRIVING,
{{FloatLongitude{-73.981492}, FloatLatitude{40.768258}},
329,
348,
{TurnType::ExitRotary, DirectionModifier::Straight},
WaypointType::Depart,
0},
0,
3,
{intersection1},
false},
2018-02-09 13:32:09 -05:00
{0,
324,
false,
"Central Park West",
"",
"",
"",
"",
"",
2017-06-30 05:13:52 -04:00
"",
0,
0,
0,
2017-11-03 13:57:11 -04:00
TRAVEL_MODE_DRIVING,
{{FloatLongitude{-73.981495}, FloatLatitude{40.768275}},
0,
0,
{TurnType::NoTurn, DirectionModifier::UTurn},
WaypointType::Arrive,
0},
2,
3,
{intersection2},
false}};
LegGeometry geometry;
geometry.locations = {{FloatLongitude{-73.981492}, FloatLatitude{40.768258}},
{FloatLongitude{-73.981495}, FloatLatitude{40.768275}},
{FloatLongitude{-73.981495}, FloatLatitude{40.768275}}};
geometry.segment_offsets = {0, 2};
geometry.segment_distances = {1.9076601161280742};
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
geometry.node_ids = {NodeID{0}, NodeID{1}, NodeID{2}};
geometry.annotations = {{1.9076601161280742, 0.2, 0.2, 0}, {0, 0, 0, 0}};
trimShortSegments(steps, geometry);
BOOST_CHECK_EQUAL(geometry.segment_distances.size(), 1);
BOOST_CHECK_EQUAL(geometry.segment_offsets.size(), 2);
BOOST_CHECK_EQUAL(geometry.segment_offsets.back(), 1);
BOOST_CHECK_EQUAL(geometry.annotations.size(), 1);
BOOST_CHECK_EQUAL(geometry.locations.size(), 2);
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
BOOST_CHECK_EQUAL(geometry.node_ids.size(), 2);
}
2016-03-15 12:08:16 -04:00
BOOST_AUTO_TEST_SUITE_END()