Interpolation for slope chart
This commit is contained in:
parent
baff8ee1b4
commit
3c89a03605
3 changed files with 21 additions and 6 deletions
|
@ -26,6 +26,8 @@ import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
@ -51,6 +53,7 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||||
|
@ -222,7 +225,15 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
|
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
|
||||||
GpxUiHelper.setGPXElevationChartData(app, mChart, analysis, false, true);
|
List<ILineDataSet> dataSets = new ArrayList<>();
|
||||||
|
GpxUiHelper.OrderedLineDataSet elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, mChart, analysis, false, true);
|
||||||
|
dataSets.add(elevationDataSet);
|
||||||
|
if (analysis.elevationData.size() > 1) {
|
||||||
|
GpxUiHelper.OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, mChart, analysis, true, true);
|
||||||
|
dataSets.add(slopeDataSet);
|
||||||
|
}
|
||||||
|
LineData data = new LineData(dataSets);
|
||||||
|
mChart.setData(data);
|
||||||
|
|
||||||
((TextView) headerView.findViewById(R.id.average_text))
|
((TextView) headerView.findViewById(R.id.average_text))
|
||||||
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||||
|
|
|
@ -1268,12 +1268,12 @@ public class GpxUiHelper {
|
||||||
nextXRaw += e.distance;
|
nextXRaw += e.distance;
|
||||||
nextYRaw = (float) e.elevation;
|
nextYRaw = (float) e.elevation;
|
||||||
nextX += (float) e.distance / divX;
|
nextX += (float) e.distance / divX;
|
||||||
if (nextXRaw - prevXRaw > 10) {
|
nextY = (nextYRaw - prevYRaw) / (nextXRaw - prevXRaw) * 100f;
|
||||||
nextY = (nextYRaw - prevYRaw) / (nextXRaw - prevXRaw) * 100f;
|
if (nextXRaw - prevXRaw > 50 && Math.abs(nextY) < 120) {
|
||||||
values.add(new Entry(nextX, nextY));
|
values.add(new Entry(nextX, nextY));
|
||||||
prevXRaw = nextXRaw;
|
|
||||||
prevYRaw = nextYRaw;
|
|
||||||
}
|
}
|
||||||
|
prevXRaw = nextXRaw;
|
||||||
|
prevYRaw = nextYRaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1304,12 +1304,16 @@ public class GpxUiHelper {
|
||||||
dataSet.setDrawHorizontalHighlightIndicator(false);
|
dataSet.setDrawHorizontalHighlightIndicator(false);
|
||||||
dataSet.setHighLightColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
|
dataSet.setHighLightColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
|
||||||
|
|
||||||
|
dataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
|
||||||
|
|
||||||
|
/*
|
||||||
dataSet.setFillFormatter(new IFillFormatter() {
|
dataSet.setFillFormatter(new IFillFormatter() {
|
||||||
@Override
|
@Override
|
||||||
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
|
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
|
||||||
return dataProvider.getYChartMin();
|
return dataProvider.getYChartMin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
if (useRightAxis) {
|
if (useRightAxis) {
|
||||||
dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT);
|
dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ public class TrackSegmentFragment extends SelectedGPXFragment {
|
||||||
OrderedLineDataSet elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, analysis, false, true);
|
OrderedLineDataSet elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, analysis, false, true);
|
||||||
dataSets.add(elevationDataSet);
|
dataSets.add(elevationDataSet);
|
||||||
if (analysis.elevationData.size() > 1) {
|
if (analysis.elevationData.size() > 1) {
|
||||||
OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis, true, false);
|
OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis, true, true);
|
||||||
dataSets.add(slopeDataSet);
|
dataSets.add(slopeDataSet);
|
||||||
}
|
}
|
||||||
LineData data = new LineData(dataSets);
|
LineData data = new LineData(dataSets);
|
||||||
|
|
Loading…
Reference in a new issue