From fbec2abd195c9b0a3d0cb4cc35f4e35c8fc83458 Mon Sep 17 00:00:00 2001 From: cepprice Date: Fri, 16 Apr 2021 19:23:54 +0500 Subject: [PATCH] Small fixes --- .../java/net/osmand/router/RouteColorize.java | 2 + .../views/layers/geometry/GeometryWay.java | 7 ++ .../layers/geometry/GeometryWayContext.java | 4 ++ .../layers/geometry/RouteGeometryWay.java | 66 ++++++++++--------- .../geometry/RouteGeometryWayDrawer.java | 1 - 5 files changed, 47 insertions(+), 33 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java index 62186a8bb3..0db39d0695 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteColorize.java @@ -266,6 +266,8 @@ public class RouteColorize { List sublist = dataList.subList(prevId, currentId); simplified.addAll(getExtremums(sublist)); } + Node lastSurvivedPoint = result.get(result.size() - 1); + simplified.add(dataList.get((int) lastSurvivedPoint.getId())); return simplified; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java index 2cfb950200..9bb4bf9445 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java @@ -139,6 +139,11 @@ public abstract class GeometryWay getDefaultWayStyle(); + @NonNull + protected Map> getStyleMap() { + return styleMap; + } + public Location getNextVisiblePoint() { return null; } @@ -380,6 +385,8 @@ public abstract class GeometryWay style : getStyleMap().values()) { + style.width = width; + } + } this.customColor = color; this.customWidth = width; this.customPointColor = pointColor; @@ -54,50 +60,46 @@ public class RouteGeometryWay extends GeometryWay locations = route != null ? route.getImmutableAllLocations() : Collections.emptyList(); + + if (scaleType == null || locations.size() < 2) { + updateWay(locations, tb); + return; + } + GPXFile gpxFile = GpxUiHelper.makeGpxFromRoute(route, app); + if (!gpxFile.hasAltitude) { + updateWay(locations, tb); + return; + } + + // Start point can have wrong zero altitude + List pts = gpxFile.tracks.get(0).segments.get(0).points; + GPXUtilities.WptPt firstPt = pts.get(0); + if (firstPt.ele == 0) { + firstPt.ele = pts.get(1).ele; + } + + RouteColorize routeColorize = new RouteColorize(tb.getZoom(), gpxFile, null, scaleType.toColorizationType(), 0); + List points = routeColorize.getResult(false); + + updateWay(new GradientGeometryWayProvider(routeColorize, points), createStyles(points), tb); } - - this.route = route; - List locations = route != null ? route.getImmutableAllLocations() : Collections.emptyList(); - - if (scaleType == null || locations.size() < 2) { - updateWay(locations, tb); - return; - } - GPXFile gpxFile = GpxUiHelper.makeGpxFromRoute(route, app); - if (!gpxFile.hasAltitude) { - updateWay(locations, tb); - return; - } - - // Start point can have wrong zero altitude - List pts = gpxFile.tracks.get(0).segments.get(0).points; - GPXUtilities.WptPt firstPt = pts.get(0); - if (firstPt.ele == 0) { - firstPt.ele = pts.get(1).ele; - } - - RouteColorize routeColorize = new RouteColorize(tb.getZoom(), gpxFile, null, scaleType.toColorizationType(), 0); - List points = routeColorize.getResult(false); - - updateWay(new GradientGeometryWayProvider(routeColorize), createStyles(points), tb); } private Map> createStyles(List points) { Map> styleMap = new TreeMap<>(); - for (int i = 1; i < points.size(); i++) { GeometryGradientWayStyle style = getGradientWayStyle(); style.startColor = points.get(i - 1).color; style.endColor = points.get(i).color; styleMap.put(i, style); } - return styleMap; } @@ -183,9 +185,9 @@ public class RouteGeometryWay extends GeometryWay locations; - public GradientGeometryWayProvider(RouteColorize routeColorize) { + public GradientGeometryWayProvider(RouteColorize routeColorize, List locations) { this.routeColorize = routeColorize; - locations = routeColorize.getResult(false); + this.locations = locations; } public List simplify(int zoom) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWayDrawer.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWayDrawer.java index 060370e546..746283a180 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWayDrawer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWayDrawer.java @@ -44,7 +44,6 @@ public class RouteGeometryWayDrawer extends GeometryWayDrawer