From d60b22de0c126b6a93544c39ee43232da60763bd Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 8 Feb 2017 22:02:47 +0100 Subject: [PATCH] Fix exception --- .../src/net/osmand/router/RouteSegmentResult.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java b/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java index 9be9f387de..77db8130f2 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java +++ b/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java @@ -44,12 +44,17 @@ public class RouteSegmentResult { int end = Math.max(startPointIndex, endPointIndex); float[] res = new float[(end - st + 1) * 2]; for (int k = 0; k < res.length / 2; k++) { + int ind = reverse ? (2 * (end - k)) : (2 * (k + st)); if (k == 0) { res[2 * k] = 0; } else { - res[2 * k] = pf[reverse ? (2 * (end - k)) : (2 * (k + st))]; + if(ind < pf.length) { + res[2 * k] = pf[k]; + } + } + if(ind < pf.length) { + res[2 * k + 1] = pf[ind + 1]; } - res[2 * k + 1] = pf[reverse ? (2 * (end - k) + 1) : (2 * (k + st) + 1)]; } return res; }