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 locationEnd;
|
||||
|
||||
public double left = 0;
|
||||
public double right = 0;
|
||||
public double top = 0;
|
||||
public double bottom = 0;
|
||||
|
||||
public boolean isTimeSpecified() {
|
||||
return startTime != Long.MAX_VALUE && startTime != 0;
|
||||
}
|
||||
|
@ -298,6 +303,10 @@ public class GPXUtilities {
|
|||
return maxElevation != -100;
|
||||
}
|
||||
|
||||
public boolean isBoundsCalculated() {
|
||||
return left !=0 && right != 0 && top != 0 && bottom != 0;
|
||||
}
|
||||
|
||||
public List<Elevation> elevationData;
|
||||
public List<Speed> speedData;
|
||||
|
||||
|
@ -359,6 +368,18 @@ public class GPXUtilities {
|
|||
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;
|
||||
Elevation elevation1 = new Elevation();
|
||||
if (!Double.isNaN(elevation)) {
|
||||
|
|
|
@ -305,6 +305,16 @@ public class TrackDetailsMenu {
|
|||
}
|
||||
|
||||
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);
|
||||
chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||
@Override
|
||||
|
@ -380,11 +390,9 @@ public class TrackDetailsMenu {
|
|||
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
final IconsCache ic = app.getIconsCache();
|
||||
GPXTrackAnalysis analysis = gpxItem.analysis;
|
||||
if (analysis != null) {
|
||||
|
||||
GpxUiHelper.setupGPXChart(app, chart, 4);
|
||||
|
||||
if (gpxItem.chartTypes != null) {
|
||||
List<ILineDataSet> dataSets = new ArrayList<>();
|
||||
if (gpxItem.chartTypes != null && gpxItem.chartTypes.length > 0) {
|
||||
for (int i = 0; i < gpxItem.chartTypes.length; i++) {
|
||||
|
@ -419,8 +427,6 @@ public class TrackDetailsMenu {
|
|||
});
|
||||
chart.setData(new LineData(dataSets));
|
||||
updateChart(chart);
|
||||
}
|
||||
}
|
||||
|
||||
View yAxis = parentView.findViewById(R.id.y_axis);
|
||||
ImageView yAxisIcon = (ImageView) parentView.findViewById(R.id.y_axis_icon);
|
||||
|
@ -428,7 +434,6 @@ public class TrackDetailsMenu {
|
|||
View yAxisArrow = parentView.findViewById(R.id.y_axis_arrow);
|
||||
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
|
||||
boolean hasSlopeChart = false;
|
||||
if (analysis != null) {
|
||||
if (analysis.hasElevationData) {
|
||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE });
|
||||
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME) {
|
||||
|
@ -444,7 +449,7 @@ public class TrackDetailsMenu {
|
|||
if (analysis.hasElevationData && analysis.hasSpeedData) {
|
||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED });
|
||||
}
|
||||
}
|
||||
|
||||
for (GPXDataSetType t : gpxItem.chartTypes) {
|
||||
if (t == GPXDataSetType.SLOPE) {
|
||||
hasSlopeChart = true;
|
||||
|
@ -494,7 +499,7 @@ public class TrackDetailsMenu {
|
|||
xAxisIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_marker_dark));
|
||||
xAxisTitle.setText(app.getString(R.string.distance));
|
||||
}
|
||||
if (analysis != null && analysis.isTimeSpecified() && !hasSlopeChart) {
|
||||
if (analysis.isTimeSpecified() && !hasSlopeChart) {
|
||||
xAxis.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -812,7 +812,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
|||
List<GPXTabItemType> tabTypeList = new ArrayList<>();
|
||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||
if (gpxItem != null && gpxItem.analysis != null) {
|
||||
if (gpxItem.analysis.elevationData != null) {
|
||||
if (gpxItem.analysis.hasElevationData) {
|
||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_ALTITUDE);
|
||||
}
|
||||
if (gpxItem.analysis.isSpeedSpecified()) {
|
||||
|
|
Loading…
Reference in a new issue