From 3084615ff7e39b531316545461b272c128bc75a5 Mon Sep 17 00:00:00 2001 From: Marc CAPDEVILLE Date: Wed, 19 Apr 2017 18:10:06 +0200 Subject: navigation_analyze_roundabout : central_angle may lead to division by 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- navit/navigation.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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. -- cgit v1.2.1