mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
[traffic] Pass toJunctions parameter to TruncateRoute()
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -878,7 +878,7 @@ void RoutingTraffDecoder::AddDecodedSegment(traffxml::MultiMwmColoring & decoded
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RoutingTraffDecoder::TruncateRoute(std::vector<routing::RouteSegment> & rsegments,
|
void RoutingTraffDecoder::TruncateRoute(std::vector<routing::RouteSegment> & rsegments,
|
||||||
routing::Checkpoints const & checkpoints)
|
routing::Checkpoints const & checkpoints, bool toJunctions)
|
||||||
{
|
{
|
||||||
double const endWeight = rsegments.back().GetTimeFromBeginningSec();
|
double const endWeight = rsegments.back().GetTimeFromBeginningSec();
|
||||||
|
|
||||||
@@ -901,8 +901,8 @@ void RoutingTraffDecoder::TruncateRoute(std::vector<routing::RouteSegment> & rse
|
|||||||
// Cost saved by omitting the last `end` segments.
|
// Cost saved by omitting the last `end` segments.
|
||||||
double endSaving = 0;
|
double endSaving = 0;
|
||||||
|
|
||||||
TruncateStart(rsegments, checkpoints, start, startSaving);
|
TruncateStart(rsegments, checkpoints, start, startSaving, toJunctions);
|
||||||
TruncateEnd(rsegments, checkpoints, end, endSaving, endWeight);
|
TruncateEnd(rsegments, checkpoints, end, endSaving, endWeight, toJunctions);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If start <= end, we can truncate both ends at the same time.
|
* If start <= end, we can truncate both ends at the same time.
|
||||||
@@ -920,7 +920,7 @@ void RoutingTraffDecoder::TruncateRoute(std::vector<routing::RouteSegment> & rse
|
|||||||
rsegments.erase(rsegments.begin(), rsegments.begin() + start);
|
rsegments.erase(rsegments.begin(), rsegments.begin() + start);
|
||||||
end = rsegments.size() - 1;
|
end = rsegments.size() - 1;
|
||||||
endSaving = 0;
|
endSaving = 0;
|
||||||
TruncateEnd(rsegments, checkpoints, end, endSaving, endWeight);
|
TruncateEnd(rsegments, checkpoints, end, endSaving, endWeight, toJunctions);
|
||||||
rsegments.erase(rsegments.begin() + end + 1, rsegments.end());
|
rsegments.erase(rsegments.begin() + end + 1, rsegments.end());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -929,7 +929,7 @@ void RoutingTraffDecoder::TruncateRoute(std::vector<routing::RouteSegment> & rse
|
|||||||
rsegments.erase(rsegments.begin() + end + 1, rsegments.end());
|
rsegments.erase(rsegments.begin() + end + 1, rsegments.end());
|
||||||
start = 0;
|
start = 0;
|
||||||
startSaving = 0;
|
startSaving = 0;
|
||||||
TruncateStart(rsegments, checkpoints, start, startSaving);
|
TruncateStart(rsegments, checkpoints, start, startSaving, toJunctions);
|
||||||
rsegments.erase(rsegments.begin(), rsegments.begin() + start);
|
rsegments.erase(rsegments.begin(), rsegments.begin() + start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1028,7 +1028,9 @@ void RoutingTraffDecoder::DecodeLocationDirection(traffxml::TraffMessage & messa
|
|||||||
{
|
{
|
||||||
std::vector<routing::RouteSegment> rsegments(route->GetRouteSegments());
|
std::vector<routing::RouteSegment> rsegments(route->GetRouteSegments());
|
||||||
|
|
||||||
TruncateRoute(rsegments, checkpoints);
|
TruncateRoute(rsegments, checkpoints,
|
||||||
|
message.m_location.value().m_fuzziness
|
||||||
|
&& (message.m_location.value().m_fuzziness.value() == traffxml::Fuzziness::LowRes));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* `m_onRoundabout` is set only for the first segment after the junction. In order to identify
|
* `m_onRoundabout` is set only for the first segment after the junction. In order to identify
|
||||||
@@ -1291,7 +1293,7 @@ std::vector<std::string> ParseRef(std::string & ref)
|
|||||||
|
|
||||||
void TruncateStart(std::vector<routing::RouteSegment> & rsegments,
|
void TruncateStart(std::vector<routing::RouteSegment> & rsegments,
|
||||||
routing::Checkpoints const & checkpoints,
|
routing::Checkpoints const & checkpoints,
|
||||||
size_t & start, double & startSaving)
|
size_t & start, double & startSaving, bool toJunction)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < rsegments.size(); i++)
|
for (size_t i = 0; i < rsegments.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -1308,7 +1310,7 @@ void TruncateStart(std::vector<routing::RouteSegment> & rsegments,
|
|||||||
|
|
||||||
void TruncateEnd(std::vector<routing::RouteSegment> & rsegments,
|
void TruncateEnd(std::vector<routing::RouteSegment> & rsegments,
|
||||||
routing::Checkpoints const & checkpoints,
|
routing::Checkpoints const & checkpoints,
|
||||||
size_t & end, double & endSaving, double const endWeight)
|
size_t & end, double & endSaving, double const endWeight, bool toJunction)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < rsegments.size(); i++)
|
for (size_t i = 0; i < rsegments.size(); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -415,9 +415,10 @@ protected:
|
|||||||
*
|
*
|
||||||
* @param rsegments The segments of the route
|
* @param rsegments The segments of the route
|
||||||
* @param checkpoints The reference points (at least two)
|
* @param checkpoints The reference points (at least two)
|
||||||
|
* @param toJunctions Whether the truncated route should begin and end at a junction
|
||||||
*/
|
*/
|
||||||
void TruncateRoute(std::vector<routing::RouteSegment> & rsegments,
|
void TruncateRoute(std::vector<routing::RouteSegment> & rsegments,
|
||||||
routing::Checkpoints const & checkpoints);
|
routing::Checkpoints const & checkpoints, bool toJunctions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void LogCode(routing::RouterResultCode code, double const elapsedSec);
|
static void LogCode(routing::RouterResultCode code, double const elapsedSec);
|
||||||
@@ -483,10 +484,11 @@ std::vector<std::string> ParseRef(std::string & ref);
|
|||||||
* @param checkpoints The reference points (at least two)
|
* @param checkpoints The reference points (at least two)
|
||||||
* @param start Index of the first segment to keep
|
* @param start Index of the first segment to keep
|
||||||
* @param startSaving Cost saved by truncating
|
* @param startSaving Cost saved by truncating
|
||||||
|
* @param toJunction Whether the truncated route should start at a junction
|
||||||
*/
|
*/
|
||||||
void TruncateStart(std::vector<routing::RouteSegment> & rsegments,
|
void TruncateStart(std::vector<routing::RouteSegment> & rsegments,
|
||||||
routing::Checkpoints const & checkpoints,
|
routing::Checkpoints const & checkpoints,
|
||||||
size_t & start, double & startSaving);
|
size_t & start, double & startSaving, bool toJunction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculates the segments to truncate at the start of the route.
|
* @brief Calculates the segments to truncate at the start of the route.
|
||||||
@@ -501,8 +503,9 @@ void TruncateStart(std::vector<routing::RouteSegment> & rsegments,
|
|||||||
* @param checkpoints The reference points (at least two)
|
* @param checkpoints The reference points (at least two)
|
||||||
* @param end Index of the last segment to keep
|
* @param end Index of the last segment to keep
|
||||||
* @param endSaving Cost saved by truncating
|
* @param endSaving Cost saved by truncating
|
||||||
|
* @param toJunction Whether the truncated route should end at a junction
|
||||||
*/
|
*/
|
||||||
void TruncateEnd(std::vector<routing::RouteSegment> & rsegments,
|
void TruncateEnd(std::vector<routing::RouteSegment> & rsegments,
|
||||||
routing::Checkpoints const & checkpoints,
|
routing::Checkpoints const & checkpoints,
|
||||||
size_t & end, double & endSaving, double const endWeight);
|
size_t & end, double & endSaving, double const endWeight, bool ToJunction);
|
||||||
} // namespace traffxml
|
} // namespace traffxml
|
||||||
|
|||||||
Reference in New Issue
Block a user