From 2048b14bd166128a8466fdb8388dcfe3f0f910a9 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 13 Feb 2017 00:52:07 +0100 Subject: [PATCH] Fix rounding error when summing integers --- OsmAnd-java/src/net/osmand/binary/RouteDataObject.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java index dddb23c7d7..fac1ef116f 100644 --- a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java @@ -77,13 +77,13 @@ public class RouteDataObject { heightDistanceArray = new float[2*getPointsLength()]; double plon = 0; double plat = 0; - int prevHeight = startHeight; + float prevHeight = startHeight; for(int k = 0; k < getPointsLength(); k++) { double lon = MapUtils.get31LongitudeX(getPoint31XTile(k)); double lat = MapUtils.get31LatitudeY(getPoint31YTile(k)); if(k > 0) { double dd = MapUtils.getDistance(plat, plon, lat, lon); - int height = HEIGHT_UNDEFINED; + float height = HEIGHT_UNDEFINED; if(k == getPointsLength() - 1) { height = endHeight; } else { @@ -92,10 +92,10 @@ public class RouteDataObject { for (int id : tps) { RouteTypeRule rt = region.quickGetEncodingRule(id); if (rt.getTag().equals("osmand_ele_asc")) { - height = (int) (prevHeight + Float.parseFloat(rt.getValue())); + height = (prevHeight + Float.parseFloat(rt.getValue())); break; } else if (rt.getTag().equals("osmand_ele_desc")) { - height = (int) (prevHeight - Float.parseFloat(rt.getValue())); + height = (prevHeight - Float.parseFloat(rt.getValue())); break; } }