summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2015-12-15 19:20:06 +0100
committermvglasow <michael -at- vonglasow.com>2015-12-15 19:20:06 +0100
commitdcd62808da3c360d3549be1426e00b540ed955dc (patch)
treebd27eea61dd7bae8e34d144d08d72ff55c323761
parentb61fded36b6e11027e18b7042b078285dc7a656f (diff)
downloadnavit-R6419.tar.gz
Refactor:core:Use constants for vehicleprofile.maxspeed_handlingR6419
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r--navit/route.c7
-rw-r--r--navit/vehicleprofile.c2
-rw-r--r--navit/vehicleprofile.h11
3 files changed, 14 insertions, 6 deletions
diff --git a/navit/route.c b/navit/route.c
index a55334149..37d1282a8 100644
--- a/navit/route.c
+++ b/navit/route.c
@@ -2005,18 +2005,17 @@ route_seg_speed(struct vehicleprofile *profile, struct route_segment_data *over,
int speed,maxspeed;
if (!roadprofile || !roadprofile->route_weight)
return 0;
- /* maxspeed_handling: 0=always, 1 only if maxspeed restricts the speed, 2 never */
speed=roadprofile->route_weight;
- if (profile->maxspeed_handling != 2) {
+ if (profile->maxspeed_handling != maxspeed_ignore) {
if (over->flags & AF_SPEED_LIMIT) {
maxspeed=RSD_MAXSPEED(over);
- if (!profile->maxspeed_handling)
+ if (profile->maxspeed_handling == maxspeed_enforce)
speed=maxspeed;
} else
maxspeed=INT_MAX;
if (dist && maxspeed > dist->maxspeed)
maxspeed=dist->maxspeed;
- if (maxspeed != INT_MAX && (profile->maxspeed_handling != 1 || maxspeed < speed))
+ if (maxspeed != INT_MAX && (profile->maxspeed_handling != maxspeed_restrict || maxspeed < speed))
speed=maxspeed;
}
if (over->flags & AF_DANGEROUS_GOODS) {
diff --git a/navit/vehicleprofile.c b/navit/vehicleprofile.c
index b48dddacb..9da721d26 100644
--- a/navit/vehicleprofile.c
+++ b/navit/vehicleprofile.c
@@ -119,7 +119,7 @@ vehicleprofile_clear(struct vehicleprofile *this_)
this_->flags_forward_mask=0;
this_->flags_reverse_mask=0;
this_->flags=0;
- this_->maxspeed_handling=0;
+ this_->maxspeed_handling = maxspeed_enforce;
this_->static_speed=0;
this_->static_distance=0;
g_free(this_->name);
diff --git a/navit/vehicleprofile.h b/navit/vehicleprofile.h
index 67d3f4fa1..4e1b6a340 100644
--- a/navit/vehicleprofile.h
+++ b/navit/vehicleprofile.h
@@ -21,13 +21,22 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+
+enum maxspeed_handling {
+ maxspeed_enforce = 0, /*!< Always enforce maxspeed of segment */
+ maxspeed_restrict = 1, /*!< Enforce maxspeed of segment only if it restricts the speed */
+ maxspeed_ignore = 2, /*!< Ignore maxspeed of segment, always use {@code route_weight} of road profile */
+};
+
+
struct vehicleprofile {
NAVIT_OBJECT
int mode; /**< 0 = Auto, 1 = On-Road, 2 = Off-Road */
int flags_forward_mask; /**< Flags mask for moving in positive direction */
int flags_reverse_mask; /**< Flags mask for moving in reverse direction */
int flags; /**< Required flags to move through a segment */
- int maxspeed_handling; /**< 0 = Always, 1 = Only if lower, 2 = Never */
+ int maxspeed_handling; /**< How to handle maxspeed of segment, see {@code enum maxspeed_handling} */
int static_speed; /**< Maximum speed of vehicle to consider it stationary */
int static_distance; /**< Maximum distance of previous position of vehicle to consider it stationary */
char *name; /**< the vehicle profile name */