summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc CAPDEVILLE <marc@icrea-technologies.fr>2017-04-19 18:10:06 +0200
committerMarc CAPDEVILLE <marc@icrea-technologies.fr>2017-05-03 10:55:59 +0200
commit3084615ff7e39b531316545461b272c128bc75a5 (patch)
tree13ab383ffb816cc0ccaa159235fd012898e58ee9
parent6c7688b74364681bcaf034be15ae039cbf72c50b (diff)
downloadnavit-3084615ff7e39b531316545461b272c128bc75a5.tar.gz
navigation_analyze_roundabout : central_angle may lead to division by 0
On the path from orange (france) to valence (france) by highway, the third roundabout after highway exit lead to central_angle=0, leading to divide by 0 (near line 2488). from osm_id : 160627295 (44°54'10N"4°52'43"E) to osm_id : 4277896 (44°54'12"N4°52'41"E) (delta1 + delta2) seams to be 360, so I just set roundabout_length to len in that case. Added error log displaying delta1 and delta2.
-rw-r--r--navit/navigation.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/navit/navigation.c b/navit/navigation.c
index cdad6331c..964b6bf17 100644
--- a/navit/navigation.c
+++ b/navit/navigation.c
@@ -2486,7 +2486,12 @@ void navigation_analyze_roundabout(struct navigation *this_, struct navigation_c
* The central angle is approximated using the unweighted average of delta1 and delta2,
* which is somewhat crude but sufficient for our purposes. */
central_angle = abs((delta1 + delta2) / 2 + ((cmd->delta < dtsir) ? 180 : -180));
- roundabout_length = len * 360 / central_angle;
+ if (central_angle)
+ roundabout_length = len * 360 / central_angle;
+ else {
+ dbg(lvl_error,"central_angle in roundabout_length computation lead to divide by zero (delta1 = %d, delta2 = %d, cmd->delta = %d, dtsir = %d, len = %d)",delta1,delta2,cmd->delta,dtsir,len);
+ roundabout_length = len;
+ }
dbg(lvl_debug,"roundabout_length = %dm (for central_angle = %d degrees)\n", roundabout_length, central_angle);
/* in the case of separate carriageways, approach roads become hard to identify, thus we keep a cap on distance.