From 091119d06ce4de2881c25e8043e261bb4a6dba57 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 8 Jul 2019 15:21:47 +0300 Subject: [PATCH 1/2] Add check for empty or single undefined partition --- .../net/osmand/router/RouteStatisticsHelper.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteStatisticsHelper.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteStatisticsHelper.java index 371f3261e1..3aecefa06e 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteStatisticsHelper.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteStatisticsHelper.java @@ -1,5 +1,10 @@ package net.osmand.router; +import net.osmand.binary.BinaryMapRouteReaderAdapter; +import net.osmand.binary.RouteDataObject; +import net.osmand.render.RenderingRuleSearchRequest; +import net.osmand.render.RenderingRulesStorage; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -8,11 +13,6 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import net.osmand.binary.BinaryMapRouteReaderAdapter; -import net.osmand.binary.RouteDataObject; -import net.osmand.render.RenderingRuleSearchRequest; -import net.osmand.render.RenderingRulesStorage; - public class RouteStatisticsHelper { public static final String UNDEFINED_ATTR = "undefined"; @@ -106,7 +106,10 @@ public class RouteStatisticsHelper { for(String attributeName : attributeNames) { RouteStatisticComputer statisticComputer = new RouteStatisticComputer(currentRenderer, defaultRenderer, currentSearchRequest, defaultSearchRequest); - result.add(statisticComputer.computeStatistic(routeSegmentWithInclines, attributeName)); + RouteStatistics routeStatistics = statisticComputer.computeStatistic(routeSegmentWithInclines, attributeName); + if (!routeStatistics.partition.isEmpty() && (routeStatistics.partition.size() != 1 || !routeStatistics.partition.containsKey(UNDEFINED_ATTR))) { + result.add(routeStatistics); + } } return result; From 03ff085914e143ba15d8ad388c88c26fcd403f90 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 8 Jul 2019 14:31:12 +0200 Subject: [PATCH 2/2] Fix #7175 --- .../main/java/net/osmand/LocationConvert.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java b/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java index 5102498dea..26f3d18a1f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java +++ b/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java @@ -158,16 +158,14 @@ public class LocationConvert { StringBuilder sb = new StringBuilder(); // Handle negative values and append cardinal directions if necessary - if (addCardinalDirection) { - sb.append(latitude < 0 ? 'S' : 'N'); - } else if (latitude < 0) { + if (!addCardinalDirection && latitude < 0) { sb.append('-'); } - if (latitude < 0) { - latitude = -latitude; + formatDegrees(latitude < 0 ? -latitude : latitude, outputType, sb); + if (addCardinalDirection) { + sb.append(' ').append(latitude < 0 ? 'S' : 'N'); } - - return formatDegrees(latitude, outputType, sb); + return sb.toString(); } public static String convertLongitude(double longitude, int outputType, boolean addCardinalDirection) { @@ -181,16 +179,14 @@ public class LocationConvert { StringBuilder sb = new StringBuilder(); // Handle negative values and append cardinal directions if necessary - if (addCardinalDirection) { - sb.append(longitude < 0 ? 'W' : 'E'); - } else if (longitude < 0) { + if (!addCardinalDirection && longitude < 0) { sb.append('-'); } - if (longitude < 0) { - longitude = -longitude; + formatDegrees(longitude < 0 ? -longitude : longitude, outputType, sb); + if (addCardinalDirection) { + sb.append(' ').append(longitude < 0 ? 'W' : 'E'); } - - return formatDegrees(longitude, outputType, sb); + return sb.toString(); } private static double formatCoordinate(double coordinate, StringBuilder sb, char delimiter) {