use of net.osmand.plus.track.GradientScaleType in project Osmand by osmandapp.
the class GpxAppearanceInfo method fromJson.
public static GpxAppearanceInfo fromJson(@NonNull JSONObject json) {
GpxAppearanceInfo gpxAppearanceInfo = new GpxAppearanceInfo();
boolean hasAnyParam = json.has("color");
gpxAppearanceInfo.color = json.optInt("color");
hasAnyParam |= json.has("width");
gpxAppearanceInfo.width = json.optString("width");
hasAnyParam |= json.has("show_arrows");
gpxAppearanceInfo.showArrows = json.optBoolean("show_arrows");
hasAnyParam |= json.has("show_start_finish");
gpxAppearanceInfo.showStartFinish = json.optBoolean("show_start_finish");
hasAnyParam |= json.has("split_type");
gpxAppearanceInfo.splitType = GpxSplitType.getSplitTypeByName(json.optString("split_type")).getType();
hasAnyParam |= json.has("split_interval");
gpxAppearanceInfo.splitInterval = json.optDouble("split_interval");
hasAnyParam |= json.has("coloring_type");
gpxAppearanceInfo.coloringType = json.optString("coloring_type");
if (ColoringType.getNullableTrackColoringTypeByName(gpxAppearanceInfo.coloringType) == null) {
hasAnyParam |= json.has("gradient_scale_type");
GradientScaleType scaleType = getScaleType(json.optString("gradient_scale_type"));
ColoringType coloringType = ColoringType.fromGradientScaleType(scaleType);
gpxAppearanceInfo.coloringType = coloringType == null ? null : coloringType.getName(null);
}
hasAnyParam |= json.has("time_span");
gpxAppearanceInfo.timeSpan = json.optLong("time_span");
hasAnyParam |= json.has("wpt_points");
gpxAppearanceInfo.wptPoints = json.optInt("wpt_points");
hasAnyParam |= json.has("total_distance");
gpxAppearanceInfo.totalDistance = (float) json.optDouble("total_distance");
hasAnyParam |= json.has(TAG_SMOOTHING_THRESHOLD);
gpxAppearanceInfo.smoothingThreshold = json.optDouble(TAG_SMOOTHING_THRESHOLD);
hasAnyParam |= json.has(TAG_MIN_FILTER_SPEED);
gpxAppearanceInfo.minFilterSpeed = json.optDouble(TAG_MIN_FILTER_SPEED);
hasAnyParam |= json.has(TAG_MAX_FILTER_SPEED);
gpxAppearanceInfo.maxFilterSpeed = json.optDouble(TAG_MAX_FILTER_SPEED);
hasAnyParam |= json.has(TAG_MIN_FILTER_ALTITUDE);
gpxAppearanceInfo.minFilterAltitude = json.optDouble(TAG_MIN_FILTER_ALTITUDE);
hasAnyParam |= json.has(TAG_MAX_FILTER_ALTITUDE);
gpxAppearanceInfo.maxFilterAltitude = json.optDouble(TAG_MAX_FILTER_ALTITUDE);
hasAnyParam |= json.has(TAG_MAX_FILTER_HDOP);
gpxAppearanceInfo.maxFilterHdop = json.optDouble(TAG_MAX_FILTER_HDOP);
return hasAnyParam ? gpxAppearanceInfo : null;
}
use of net.osmand.plus.track.GradientScaleType in project Osmand by osmandapp.
the class GPXDatabase method readItem.
private GpxDataItem readItem(SQLiteCursor query) {
String fileName = query.getString(0);
String fileDir = query.getString(1);
float totalDistance = (float) query.getDouble(2);
int totalTracks = query.getInt(3);
long startTime = query.getLong(4);
long endTime = query.getLong(5);
long timeSpan = query.getLong(6);
long timeMoving = query.getLong(7);
float totalDistanceMoving = (float) query.getDouble(8);
double diffElevationUp = query.getDouble(9);
double diffElevationDown = query.getDouble(10);
double avgElevation = query.getDouble(11);
double minElevation = query.getDouble(12);
double maxElevation = query.getDouble(13);
float maxSpeed = (float) query.getDouble(14);
float avgSpeed = (float) query.getDouble(15);
int points = query.getInt(16);
int wptPoints = query.getInt(17);
String color = query.getString(18);
long fileLastModifiedTime = query.getLong(19);
long fileLastUploadedTime = query.getLong(20);
int splitType = query.getInt(21);
double splitInterval = query.getDouble(22);
boolean apiImported = query.getInt(23) == 1;
String wptCategoryNames = query.getString(24);
boolean showAsMarkers = query.getInt(25) == 1;
boolean joinSegments = query.getInt(26) == 1;
boolean showArrows = query.getInt(27) == 1;
boolean showStartFinish = query.getInt(28) == 1;
String width = query.getString(29);
String coloringTypeName = query.getString(33);
double smoothingThreshold = query.getDouble(34);
double minFilterSpeed = query.getDouble(35);
double maxFilterSpeed = query.getDouble(36);
double minFilterAltitude = query.getDouble(37);
double maxFilterAltitude = query.getDouble(38);
double maxFilterHdop = query.getDouble(39);
GPXTrackAnalysis a = new GPXTrackAnalysis();
a.totalDistance = totalDistance;
a.totalTracks = totalTracks;
a.startTime = startTime;
a.endTime = endTime;
a.timeSpan = timeSpan;
a.timeMoving = timeMoving;
a.totalDistanceMoving = totalDistanceMoving;
a.diffElevationUp = diffElevationUp;
a.diffElevationDown = diffElevationDown;
a.avgElevation = avgElevation;
a.minElevation = minElevation;
a.maxElevation = maxElevation;
a.minSpeed = maxSpeed;
a.maxSpeed = maxSpeed;
a.avgSpeed = avgSpeed;
a.points = points;
a.wptPoints = wptPoints;
if (wptCategoryNames != null) {
a.wptCategoryNames = Algorithms.decodeStringSet(wptCategoryNames);
}
File dir;
if (!Algorithms.isEmpty(fileDir)) {
dir = new File(context.getAppPath(IndexConstants.GPX_INDEX_DIR), fileDir);
} else {
dir = context.getAppPath(IndexConstants.GPX_INDEX_DIR);
}
GpxDataItem item = new GpxDataItem(new File(dir, fileName), a);
item.color = parseColor(color);
item.fileLastModifiedTime = fileLastModifiedTime;
item.fileLastUploadedTime = fileLastUploadedTime;
item.splitType = splitType;
item.splitInterval = splitInterval;
item.apiImported = apiImported;
item.showAsMarkers = showAsMarkers;
item.joinSegments = joinSegments;
item.showArrows = showArrows;
item.showStartFinish = showStartFinish;
item.width = width;
if (ColoringType.getNullableTrackColoringTypeByName(coloringTypeName) != null) {
item.coloringType = coloringTypeName;
} else if (GradientScaleType.getGradientTypeByName(coloringTypeName) != null) {
GradientScaleType scaleType = GradientScaleType.getGradientTypeByName(coloringTypeName);
ColoringType coloringType = ColoringType.fromGradientScaleType(scaleType);
item.coloringType = coloringType == null ? null : coloringType.getName(null);
}
item.smoothingThreshold = smoothingThreshold;
item.minFilterSpeed = minFilterSpeed;
item.maxFilterSpeed = maxFilterSpeed;
item.minFilterAltitude = minFilterAltitude;
item.maxFilterAltitude = maxFilterAltitude;
item.maxFilterHdop = maxFilterHdop;
return item;
}
Aggregations