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) {
|
public int getColorByValue(double value) {
|
||||||
if (Double.isNaN(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++) {
|
for (int i = 0; i < palette.length - 1; i++) {
|
||||||
if (value == palette[i][VALUE_INDEX])
|
if (value == palette[i][VALUE_INDEX])
|
||||||
|
|
|
@ -2124,9 +2124,12 @@ public class GpxUiHelper {
|
||||||
|
|
||||||
|
|
||||||
public static GPXFile makeGpxFromRoute(RouteCalculationResult route, OsmandApplication app) {
|
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;
|
double lastHeight = HEIGHT_UNDEFINED;
|
||||||
GPXFile gpx = new GPXUtilities.GPXFile(Version.getFullVersion(app));
|
GPXFile gpx = new GPXUtilities.GPXFile(Version.getFullVersion(app));
|
||||||
List<Location> locations = route.getRouteLocations();
|
|
||||||
if (locations != null) {
|
if (locations != null) {
|
||||||
GPXUtilities.Track track = new GPXUtilities.Track();
|
GPXUtilities.Track track = new GPXUtilities.Track();
|
||||||
GPXUtilities.TrkSegment seg = new GPXUtilities.TrkSegment();
|
GPXUtilities.TrkSegment seg = new GPXUtilities.TrkSegment();
|
||||||
|
@ -2139,8 +2142,7 @@ public class GpxUiHelper {
|
||||||
float h = (float) l.getAltitude();
|
float h = (float) l.getAltitude();
|
||||||
point.ele = h;
|
point.ele = h;
|
||||||
if (lastHeight == HEIGHT_UNDEFINED && seg.points.size() > 0) {
|
if (lastHeight == HEIGHT_UNDEFINED && seg.points.size() > 0) {
|
||||||
for (int i = seg.points.size() - 1; i >= 0; i--) {
|
for (GPXUtilities.WptPt pt : seg.points) {
|
||||||
GPXUtilities.WptPt pt = seg.points.get(i);
|
|
||||||
if (Double.isNaN(pt.ele)) {
|
if (Double.isNaN(pt.ele)) {
|
||||||
pt.ele = h;
|
pt.ele = h;
|
||||||
}
|
}
|
||||||
|
@ -2152,16 +2154,6 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
seg.points.add(point);
|
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);
|
track.segments.add(seg);
|
||||||
gpx.tracks.add(track);
|
gpx.tracks.add(track);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
||||||
updateWay(locations, tb);
|
updateWay(locations, tb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GPXFile gpxFile = GpxUiHelper.makeGpxFromRoute(route, app);
|
GPXFile gpxFile = GpxUiHelper.makeGpxFromLocations(locations, app);
|
||||||
if (!gpxFile.hasAltitude) {
|
if (!gpxFile.hasAltitude) {
|
||||||
updateWay(locations, tb);
|
updateWay(locations, tb);
|
||||||
return;
|
return;
|
||||||
|
@ -127,11 +127,9 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
||||||
if (scaleType != null) {
|
if (scaleType != null) {
|
||||||
int lastIdx = tx.size() - 1;
|
int lastIdx = tx.size() - 1;
|
||||||
((GeometryGradientWayStyle) style).startXY = new PointF(tx.get(lastIdx), ty.get(lastIdx));
|
((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).startColor = getGradientLocationProvider().getColor(0);
|
||||||
((GeometryGradientWayStyle) style).endColor = 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();
|
float width = customWidth != null ? customWidth : paint.getStrokeWidth();
|
||||||
return scaleType == null ?
|
return scaleType == null ?
|
||||||
new GeometrySolidWayStyle(getContext(), color, width, customPointColor) :
|
new GeometrySolidWayStyle(getContext(), color, width, customPointColor) :
|
||||||
new GeometryGradientWayStyle(getContext(), width);
|
new GeometryGradientWayStyle(getContext(), color, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GeometryGradientWayStyle getGradientWayStyle() {
|
private GeometryGradientWayStyle getGradientWayStyle() {
|
||||||
|
@ -240,8 +238,8 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
||||||
public PointF startXY;
|
public PointF startXY;
|
||||||
public PointF endXY;
|
public PointF endXY;
|
||||||
|
|
||||||
public GeometryGradientWayStyle(RouteGeometryWayContext context, Float width) {
|
public GeometryGradientWayStyle(RouteGeometryWayContext context, Integer color, Float width) {
|
||||||
super(context, 0xFFFFFFFF, width);
|
super(context, color, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue