diff options
author | mvglasow <michael -at- vonglasow.com> | 2019-08-04 22:33:55 +0200 |
---|---|---|
committer | mvglasow <michael -at- vonglasow.com> | 2019-08-04 22:33:55 +0200 |
commit | 691dc5384a83f6bc4f8a6bc50f8aae8cd11ca721 (patch) | |
tree | 9613462b9c5c52028af964085d51c7acc41d717c | |
parent | d50469fa4a456bfbb521a4facb13507f5ef58ddd (diff) | |
download | navit-691dc5384a83f6bc4f8a6bc50f8aae8cd11ca721.tar.gz |
Refactor:traffic:Move traffic_get_item_delay() into separate function
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r-- | navit/traffic.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/navit/traffic.c b/navit/traffic.c index 7901459f9..a65d1616c 100644 --- a/navit/traffic.c +++ b/navit/traffic.c @@ -2782,6 +2782,20 @@ static int traffic_get_item_speed(struct item * item, struct seg_data * data, in } /** + * @brief Gets the delay for a traffic distortion item + * + * @param delay Total delay for all items associated with the same message and direction + * @param item_len Length of the current item + * @param len Combined length of all items associated with the same message and direction + */ +static int traffic_get_item_delay(int delay, int item_len, int len) { + if (delay) + return delay * item_len / len; + else + return delay; +} + +/** * @brief Generates segments affected by a traffic message. * * This translates the approximate coordinates in the `from`, `at`, `to`, `via` and `not_via` members of @@ -3241,10 +3255,7 @@ static int traffic_message_add_segments(struct traffic_message * this_, struct m speed = traffic_get_item_speed(&(s->data.item), data, (s->data.flags & AF_SPEED_LIMIT) ? RSD_MAXSPEED(&s->data) : INT_MAX); - if (data->delay) - delay = data->delay * s->data.len / len; - else - delay = data->delay; + delay = traffic_get_item_delay(data->delay, s->data.len, len); for (i = 0; i < ccnt; i++) { *cd++ = *c++; |