Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c9369560ba
3 changed files with 80 additions and 54 deletions
|
@ -286,6 +286,11 @@ public class GPXUtilities {
|
||||||
public WptPt locationStart;
|
public WptPt locationStart;
|
||||||
public WptPt locationEnd;
|
public WptPt locationEnd;
|
||||||
|
|
||||||
|
public double left = 0;
|
||||||
|
public double right = 0;
|
||||||
|
public double top = 0;
|
||||||
|
public double bottom = 0;
|
||||||
|
|
||||||
public boolean isTimeSpecified() {
|
public boolean isTimeSpecified() {
|
||||||
return startTime != Long.MAX_VALUE && startTime != 0;
|
return startTime != Long.MAX_VALUE && startTime != 0;
|
||||||
}
|
}
|
||||||
|
@ -298,6 +303,10 @@ public class GPXUtilities {
|
||||||
return maxElevation != -100;
|
return maxElevation != -100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBoundsCalculated() {
|
||||||
|
return left !=0 && right != 0 && top != 0 && bottom != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Elevation> elevationData;
|
public List<Elevation> elevationData;
|
||||||
public List<Speed> speedData;
|
public List<Speed> speedData;
|
||||||
|
|
||||||
|
@ -359,6 +368,18 @@ public class GPXUtilities {
|
||||||
endTime = Math.max(endTime, time);
|
endTime = Math.max(endTime, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (left == 0 && right == 0) {
|
||||||
|
left = point.getLongitude();
|
||||||
|
right = point.getLongitude();
|
||||||
|
top = point.getLatitude();
|
||||||
|
bottom = point.getLatitude();
|
||||||
|
} else {
|
||||||
|
left = Math.min(left, point.getLongitude());
|
||||||
|
right = Math.max(right, point.getLongitude());
|
||||||
|
top = Math.max(top, point.getLatitude());
|
||||||
|
bottom = Math.min(bottom, point.getLatitude());
|
||||||
|
}
|
||||||
|
|
||||||
double elevation = point.ele;
|
double elevation = point.ele;
|
||||||
Elevation elevation1 = new Elevation();
|
Elevation elevation1 = new Elevation();
|
||||||
if (!Double.isNaN(elevation)) {
|
if (!Double.isNaN(elevation)) {
|
||||||
|
|
|
@ -305,6 +305,16 @@ public class TrackDetailsMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateView(final View parentView) {
|
private void updateView(final View parentView) {
|
||||||
|
GPXTrackAnalysis analysis = gpxItem.analysis;
|
||||||
|
if (analysis == null || gpxItem.chartTypes == null) {
|
||||||
|
parentView.setVisibility(View.GONE);
|
||||||
|
if (analysis != null && analysis.isBoundsCalculated()) {
|
||||||
|
mapActivity.getMapView()
|
||||||
|
.fitRectToMap(analysis.left, analysis.right, analysis.top, analysis.bottom, 0, 0, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final LineChart chart = (LineChart) parentView.findViewById(R.id.chart);
|
final LineChart chart = (LineChart) parentView.findViewById(R.id.chart);
|
||||||
chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -380,71 +390,66 @@ public class TrackDetailsMenu {
|
||||||
|
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
final IconsCache ic = app.getIconsCache();
|
final IconsCache ic = app.getIconsCache();
|
||||||
GPXTrackAnalysis analysis = gpxItem.analysis;
|
|
||||||
if (analysis != null) {
|
|
||||||
GpxUiHelper.setupGPXChart(app, chart, 4);
|
|
||||||
|
|
||||||
if (gpxItem.chartTypes != null) {
|
GpxUiHelper.setupGPXChart(app, chart, 4);
|
||||||
List<ILineDataSet> dataSets = new ArrayList<>();
|
|
||||||
if (gpxItem.chartTypes != null && gpxItem.chartTypes.length > 0) {
|
List<ILineDataSet> dataSets = new ArrayList<>();
|
||||||
for (int i = 0; i < gpxItem.chartTypes.length; i++) {
|
if (gpxItem.chartTypes != null && gpxItem.chartTypes.length > 0) {
|
||||||
OrderedLineDataSet dataSet = null;
|
for (int i = 0; i < gpxItem.chartTypes.length; i++) {
|
||||||
switch (gpxItem.chartTypes[i]) {
|
OrderedLineDataSet dataSet = null;
|
||||||
case ALTITUDE:
|
switch (gpxItem.chartTypes[i]) {
|
||||||
dataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, analysis,
|
case ALTITUDE:
|
||||||
gpxItem.chartAxisType, false, true);
|
dataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, analysis,
|
||||||
break;
|
gpxItem.chartAxisType, false, true);
|
||||||
case SPEED:
|
break;
|
||||||
dataSet = GpxUiHelper.createGPXSpeedDataSet(app, chart, analysis,
|
case SPEED:
|
||||||
gpxItem.chartAxisType, gpxItem.chartTypes.length > 1, true);
|
dataSet = GpxUiHelper.createGPXSpeedDataSet(app, chart, analysis,
|
||||||
break;
|
gpxItem.chartAxisType, gpxItem.chartTypes.length > 1, true);
|
||||||
case SLOPE:
|
break;
|
||||||
dataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis,
|
case SLOPE:
|
||||||
gpxItem.chartAxisType, null, gpxItem.chartTypes.length > 1, true);
|
dataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis,
|
||||||
break;
|
gpxItem.chartAxisType, null, gpxItem.chartTypes.length > 1, true);
|
||||||
}
|
break;
|
||||||
if (dataSet != null) {
|
}
|
||||||
dataSets.add(dataSet);
|
if (dataSet != null) {
|
||||||
}
|
dataSets.add(dataSet);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(dataSets, new Comparator<ILineDataSet>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ILineDataSet ds1, ILineDataSet ds2) {
|
|
||||||
OrderedLineDataSet dataSet1 = (OrderedLineDataSet) ds1;
|
|
||||||
OrderedLineDataSet dataSet2 = (OrderedLineDataSet) ds2;
|
|
||||||
return dataSet1.getPriority() > dataSet2.getPriority() ? -1 : (dataSet1.getPriority() == dataSet2.getPriority() ? 0 : 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
chart.setData(new LineData(dataSets));
|
|
||||||
updateChart(chart);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collections.sort(dataSets, new Comparator<ILineDataSet>() {
|
||||||
|
@Override
|
||||||
|
public int compare(ILineDataSet ds1, ILineDataSet ds2) {
|
||||||
|
OrderedLineDataSet dataSet1 = (OrderedLineDataSet) ds1;
|
||||||
|
OrderedLineDataSet dataSet2 = (OrderedLineDataSet) ds2;
|
||||||
|
return dataSet1.getPriority() > dataSet2.getPriority() ? -1 : (dataSet1.getPriority() == dataSet2.getPriority() ? 0 : 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
chart.setData(new LineData(dataSets));
|
||||||
|
updateChart(chart);
|
||||||
|
|
||||||
View yAxis = parentView.findViewById(R.id.y_axis);
|
View yAxis = parentView.findViewById(R.id.y_axis);
|
||||||
ImageView yAxisIcon = (ImageView) parentView.findViewById(R.id.y_axis_icon);
|
ImageView yAxisIcon = (ImageView) parentView.findViewById(R.id.y_axis_icon);
|
||||||
TextView yAxisTitle = (TextView) parentView.findViewById(R.id.y_axis_title);
|
TextView yAxisTitle = (TextView) parentView.findViewById(R.id.y_axis_title);
|
||||||
View yAxisArrow = parentView.findViewById(R.id.y_axis_arrow);
|
View yAxisArrow = parentView.findViewById(R.id.y_axis_arrow);
|
||||||
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
|
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
|
||||||
boolean hasSlopeChart = false;
|
boolean hasSlopeChart = false;
|
||||||
if (analysis != null) {
|
if (analysis.hasElevationData) {
|
||||||
if (analysis.hasElevationData) {
|
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE });
|
||||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE });
|
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME) {
|
||||||
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME) {
|
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SLOPE});
|
||||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SLOPE});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (analysis.hasSpeedData) {
|
|
||||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.SPEED });
|
|
||||||
}
|
|
||||||
if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME) {
|
|
||||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE });
|
|
||||||
}
|
|
||||||
if (analysis.hasElevationData && analysis.hasSpeedData) {
|
|
||||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (analysis.hasSpeedData) {
|
||||||
|
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.SPEED });
|
||||||
|
}
|
||||||
|
if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME) {
|
||||||
|
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE });
|
||||||
|
}
|
||||||
|
if (analysis.hasElevationData && analysis.hasSpeedData) {
|
||||||
|
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED });
|
||||||
|
}
|
||||||
|
|
||||||
for (GPXDataSetType t : gpxItem.chartTypes) {
|
for (GPXDataSetType t : gpxItem.chartTypes) {
|
||||||
if (t == GPXDataSetType.SLOPE) {
|
if (t == GPXDataSetType.SLOPE) {
|
||||||
hasSlopeChart = true;
|
hasSlopeChart = true;
|
||||||
|
@ -494,7 +499,7 @@ public class TrackDetailsMenu {
|
||||||
xAxisIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_marker_dark));
|
xAxisIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_marker_dark));
|
||||||
xAxisTitle.setText(app.getString(R.string.distance));
|
xAxisTitle.setText(app.getString(R.string.distance));
|
||||||
}
|
}
|
||||||
if (analysis != null && analysis.isTimeSpecified() && !hasSlopeChart) {
|
if (analysis.isTimeSpecified() && !hasSlopeChart) {
|
||||||
xAxis.setOnClickListener(new View.OnClickListener() {
|
xAxis.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -812,7 +812,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
List<GPXTabItemType> tabTypeList = new ArrayList<>();
|
List<GPXTabItemType> tabTypeList = new ArrayList<>();
|
||||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||||
if (gpxItem != null && gpxItem.analysis != null) {
|
if (gpxItem != null && gpxItem.analysis != null) {
|
||||||
if (gpxItem.analysis.elevationData != null) {
|
if (gpxItem.analysis.hasElevationData) {
|
||||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_ALTITUDE);
|
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_ALTITUDE);
|
||||||
}
|
}
|
||||||
if (gpxItem.analysis.isSpeedSpecified()) {
|
if (gpxItem.analysis.isSpeedSpecified()) {
|
||||||
|
|
Loading…
Reference in a new issue