Fix crash and other fixes
This commit is contained in:
parent
13b6b74e13
commit
4de1aa9193
3 changed files with 11 additions and 21 deletions
|
@ -200,7 +200,7 @@ public class RouteColorize {
|
|||
|
||||
public int getColorByValue(double value) {
|
||||
if (Double.isNaN(value)) {
|
||||
value = (minValue + maxValue) / 2;
|
||||
value = colorizationType == ColorizationType.SLOPE ? minValue : (minValue + maxValue) / 2;
|
||||
}
|
||||
for (int i = 0; i < palette.length - 1; i++) {
|
||||
if (value == palette[i][VALUE_INDEX])
|
||||
|
|
|
@ -2124,9 +2124,12 @@ public class GpxUiHelper {
|
|||
|
||||
|
||||
public static GPXFile makeGpxFromRoute(RouteCalculationResult route, OsmandApplication app) {
|
||||
return makeGpxFromLocations(route.getRouteLocations(), app);
|
||||
}
|
||||
|
||||
public static GPXFile makeGpxFromLocations(List<Location> locations, OsmandApplication app) {
|
||||
double lastHeight = HEIGHT_UNDEFINED;
|
||||
GPXFile gpx = new GPXUtilities.GPXFile(Version.getFullVersion(app));
|
||||
List<Location> locations = route.getRouteLocations();
|
||||
if (locations != null) {
|
||||
GPXUtilities.Track track = new GPXUtilities.Track();
|
||||
GPXUtilities.TrkSegment seg = new GPXUtilities.TrkSegment();
|
||||
|
@ -2139,8 +2142,7 @@ public class GpxUiHelper {
|
|||
float h = (float) l.getAltitude();
|
||||
point.ele = h;
|
||||
if (lastHeight == HEIGHT_UNDEFINED && seg.points.size() > 0) {
|
||||
for (int i = seg.points.size() - 1; i >= 0; i--) {
|
||||
GPXUtilities.WptPt pt = seg.points.get(i);
|
||||
for (GPXUtilities.WptPt pt : seg.points) {
|
||||
if (Double.isNaN(pt.ele)) {
|
||||
pt.ele = h;
|
||||
}
|
||||
|
@ -2152,16 +2154,6 @@ public class GpxUiHelper {
|
|||
}
|
||||
seg.points.add(point);
|
||||
}
|
||||
if (lastHeight == HEIGHT_UNDEFINED && gpx.hasAltitude) {
|
||||
int start = seg.points.size() - 1;
|
||||
while (start > 0 && Double.isNaN(seg.points.get(start).ele)) {
|
||||
start--;
|
||||
}
|
||||
double ele = seg.points.get(start).ele;
|
||||
for (int i = start + 1; i < seg.points.size(); i++) {
|
||||
seg.points.get(i).ele = ele;
|
||||
}
|
||||
}
|
||||
track.segments.add(seg);
|
||||
gpx.tracks.add(track);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
updateWay(locations, tb);
|
||||
return;
|
||||
}
|
||||
GPXFile gpxFile = GpxUiHelper.makeGpxFromRoute(route, app);
|
||||
GPXFile gpxFile = GpxUiHelper.makeGpxFromLocations(locations, app);
|
||||
if (!gpxFile.hasAltitude) {
|
||||
updateWay(locations, tb);
|
||||
return;
|
||||
|
@ -127,11 +127,9 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
if (scaleType != null) {
|
||||
int lastIdx = tx.size() - 1;
|
||||
((GeometryGradientWayStyle) style).startXY = new PointF(tx.get(lastIdx), ty.get(lastIdx));
|
||||
((GeometryGradientWayStyle) style).endXY = new PointF(tx.get(lastIdx), ty.get(lastIdx));
|
||||
((GeometryGradientWayStyle) style).startColor = getGradientLocationProvider().getColor(0);
|
||||
((GeometryGradientWayStyle) style).endColor = getGradientLocationProvider().getColor(0);
|
||||
if (lastIdx != 0) {
|
||||
((GeometryGradientWayStyle) styles.get(lastIdx - 1)).endXY = new PointF(tx.get(lastIdx - 1), ty.get(lastIdx - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +148,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
float width = customWidth != null ? customWidth : paint.getStrokeWidth();
|
||||
return scaleType == null ?
|
||||
new GeometrySolidWayStyle(getContext(), color, width, customPointColor) :
|
||||
new GeometryGradientWayStyle(getContext(), width);
|
||||
new GeometryGradientWayStyle(getContext(), color, width);
|
||||
}
|
||||
|
||||
private GeometryGradientWayStyle getGradientWayStyle() {
|
||||
|
@ -240,8 +238,8 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
public PointF startXY;
|
||||
public PointF endXY;
|
||||
|
||||
public GeometryGradientWayStyle(RouteGeometryWayContext context, Float width) {
|
||||
super(context, 0xFFFFFFFF, width);
|
||||
public GeometryGradientWayStyle(RouteGeometryWayContext context, Integer color, Float width) {
|
||||
super(context, color, width);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue