syncronize geometry and steps after post-processing
This commit is contained in:
parent
9681d662cb
commit
b11d3ad1ba
@ -127,6 +127,7 @@ class RouteAPI : public BaseAPI
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
leg.steps = guidance::postProcess(std::move(steps));
|
leg.steps = guidance::postProcess(std::move(steps));
|
||||||
|
leg_geometry = guidance::resyncGeometry(std::move(leg_geometry),leg.steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
leg_geometries.push_back(std::move(leg_geometry));
|
leg_geometries.push_back(std::move(leg_geometry));
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define ENGINE_GUIDANCE_POST_PROCESSING_HPP
|
#define ENGINE_GUIDANCE_POST_PROCESSING_HPP
|
||||||
|
|
||||||
#include "engine/guidance/route_step.hpp"
|
#include "engine/guidance/route_step.hpp"
|
||||||
|
#include "engine/guidance/leg_geometry.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -15,6 +16,13 @@ namespace guidance
|
|||||||
// passed as none-reference to modify in-place and move out again
|
// passed as none-reference to modify in-place and move out again
|
||||||
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps);
|
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps);
|
||||||
|
|
||||||
|
// postProcess will break the connection between the leg geometry
|
||||||
|
// for which a segment is supposed to represent exactly the coordinates
|
||||||
|
// between routing maneuvers and the route steps itself.
|
||||||
|
// If required, we can get both in sync again using this function.
|
||||||
|
// Move in LegGeometry for modification in place.
|
||||||
|
LegGeometry resyncGeometry(LegGeometry leg_geometry, const std::vector<RouteStep> &steps);
|
||||||
|
|
||||||
} // namespace guidance
|
} // namespace guidance
|
||||||
} // namespace engine
|
} // namespace engine
|
||||||
} // namespace osrm
|
} // namespace osrm
|
||||||
|
@ -292,6 +292,29 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LegGeometry resyncGeometry(LegGeometry leg_geometry, const std::vector<RouteStep> &steps)
|
||||||
|
{
|
||||||
|
// The geometry uses an adjacency array-like structure for representation.
|
||||||
|
// To sync it back up with the steps, we cann add a segment for every step.
|
||||||
|
leg_geometry.segment_offsets.clear();
|
||||||
|
leg_geometry.segment_distances.clear();
|
||||||
|
leg_geometry.segment_offsets.push_back(0);
|
||||||
|
|
||||||
|
for (const auto &step : steps)
|
||||||
|
{
|
||||||
|
leg_geometry.segment_distances.push_back(step.distance);
|
||||||
|
// the leg geometry does not follow the begin/end-convetion. So we have to subtract one
|
||||||
|
// to get the back-index.
|
||||||
|
leg_geometry.segment_offsets.push_back(step.geometry_end - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove the data fromt the reached-target step again
|
||||||
|
leg_geometry.segment_offsets.pop_back();
|
||||||
|
leg_geometry.segment_distances.pop_back();
|
||||||
|
|
||||||
|
return leg_geometry;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace guidance
|
} // namespace guidance
|
||||||
} // namespace engine
|
} // namespace engine
|
||||||
} // namespace osrm
|
} // namespace osrm
|
||||||
|
Loading…
Reference in New Issue
Block a user