Try to fix chart
This commit is contained in:
parent
e8fa3363bf
commit
65346c4433
3 changed files with 157 additions and 70 deletions
7
OsmAnd/res/layout-land/track_details.xml
Normal file
7
OsmAnd/res/layout-land/track_details.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</LinearLayout>
|
7
OsmAnd/res/layout/track_details.xml
Normal file
7
OsmAnd/res/layout/track_details.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -1051,38 +1051,44 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
List<Entry> newValues = new ArrayList<>();
|
||||||
values = new ArrayList<>();
|
Entry lastEntry = null;
|
||||||
values.add(new Entry(0, 0));
|
i = -1;
|
||||||
values.add(new Entry(20, 0));
|
lastIndex = values.size() - 1;
|
||||||
values.add(new Entry(45, -47));
|
boolean hasSameY = false;
|
||||||
values.add(new Entry(53, 335));
|
|
||||||
values.add(new Entry(57, 26));
|
|
||||||
values.add(new Entry(62, 387));
|
|
||||||
values.add(new Entry(74, 104));
|
|
||||||
values.add(new Entry(89, 0));
|
|
||||||
values.add(new Entry(95, 100));
|
|
||||||
values.add(new Entry(100, 0));
|
|
||||||
*/
|
|
||||||
|
|
||||||
List<Point2D> points = new ArrayList<>(values.size());
|
|
||||||
for (Entry e : values) {
|
for (Entry e : values) {
|
||||||
|
i++;
|
||||||
|
if (lastEntry != null) {
|
||||||
|
if (lastEntry.getY() == e.getY() && i < lastIndex) {
|
||||||
|
hasSameY = true;
|
||||||
|
continue;
|
||||||
|
} else if (hasSameY) {
|
||||||
|
lastEntry.setX(lastEntry.getX() + (e.getX() - lastEntry.getX()) / 2f);
|
||||||
|
hasSameY = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newValues.add(e);
|
||||||
|
lastEntry = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Point2D> points = new ArrayList<>(newValues.size());
|
||||||
|
for (Entry e : newValues) {
|
||||||
points.add(new Point2D(e.getX(), e.getY()));
|
points.add(new Point2D(e.getX(), e.getY()));
|
||||||
}
|
}
|
||||||
List<Segment> spline = calculateSpline(points);
|
List<Segment> spline = calculateSpline(points);
|
||||||
if (spline != null) {
|
if (spline != null) {
|
||||||
int count = 8;
|
int count = 8;
|
||||||
values = new ArrayList<>();
|
newValues = new ArrayList<>();
|
||||||
for (Segment s : spline) {
|
for (Segment s : spline) {
|
||||||
Point2D p = new Point2D();
|
Point2D p = new Point2D();
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
s.calc((double) i / (double) count, p);
|
s.calc((double) i / (double) count, p);
|
||||||
values.add(new Entry((float) p.x, (float) p.y));
|
newValues.add(new Entry((float) p.x, (float) p.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OrderedLineDataSet dataSet = new OrderedLineDataSet(values, "", GPXDataSetType.ALTITUDE);
|
OrderedLineDataSet dataSet = new OrderedLineDataSet(newValues, "", GPXDataSetType.ALTITUDE);
|
||||||
dataSet.priority = (float) (analysis.avgElevation - analysis.minElevation) * convEle;
|
dataSet.priority = (float) (analysis.avgElevation - analysis.minElevation) * convEle;
|
||||||
dataSet.units = mainUnitY;
|
dataSet.units = mainUnitY;
|
||||||
|
|
||||||
|
@ -1333,68 +1339,135 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ArrayList<Entry> values = new ArrayList<>();
|
List<Entry> values = new ArrayList<>();
|
||||||
List<Elevation> elevationData = analysis.elevationData;
|
List<Elevation> elevationData = analysis.elevationData;
|
||||||
float nextX;
|
float nextX = 0;
|
||||||
float nextY;
|
float nextY;
|
||||||
float nextDistM;
|
float elev;
|
||||||
|
float prevElev = -80000;
|
||||||
|
int i = -1;
|
||||||
|
int lastIndex = elevationData.size() - 1;
|
||||||
|
float shift = 0f;
|
||||||
|
Entry entry = null;
|
||||||
|
for (Elevation e : elevationData) {
|
||||||
|
i++;
|
||||||
|
if (e.distance > 0) {
|
||||||
|
nextX += (float) e.distance;
|
||||||
|
elev = (float) e.elevation;
|
||||||
|
if (prevElev != -80000) {
|
||||||
|
if (elev < prevElev) {
|
||||||
|
shift = .5f;
|
||||||
|
} else if (elev > prevElev) {
|
||||||
|
shift = -.5f;
|
||||||
|
} else if (prevElev == elev && i < lastIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prevElev = elev;
|
||||||
|
nextY = (elev + shift);
|
||||||
|
entry = new Entry(nextX, nextY);
|
||||||
|
values.add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Entry> eleValues = new ArrayList<>();
|
||||||
|
Entry lastEntry = null;
|
||||||
|
i = -1;
|
||||||
|
lastIndex = values.size() - 1;
|
||||||
|
boolean hasSameY = false;
|
||||||
|
for (Entry e : values) {
|
||||||
|
i++;
|
||||||
|
if (lastEntry != null) {
|
||||||
|
if (lastEntry.getY() == e.getY() && i < lastIndex) {
|
||||||
|
hasSameY = true;
|
||||||
|
continue;
|
||||||
|
} else if (hasSameY) {
|
||||||
|
lastEntry.setX(lastEntry.getX() + (e.getX() - lastEntry.getX()) / 2f);
|
||||||
|
hasSameY = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eleValues.add(e);
|
||||||
|
lastEntry = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Point2D> points = new ArrayList<>(eleValues.size());
|
||||||
|
for (Entry e : eleValues) {
|
||||||
|
points.add(new Point2D(e.getX(), e.getY()));
|
||||||
|
}
|
||||||
|
List<Segment> spline = calculateSpline(points);
|
||||||
|
if (spline != null) {
|
||||||
|
int count = 8;
|
||||||
|
eleValues = new ArrayList<>();
|
||||||
|
for (Segment s : spline) {
|
||||||
|
Point2D p = new Point2D();
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
s.calc((double) i / (double) count, p);
|
||||||
|
eleValues.add(new Entry((float) p.x, (float) p.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
values.clear();
|
||||||
|
//List<Elevation> elevationData = analysis.elevationData;
|
||||||
|
//float nextX;
|
||||||
|
//float nextY;
|
||||||
float nextXM;
|
float nextXM;
|
||||||
float nextYM;
|
float nextYM;
|
||||||
float prevXM;
|
float prevXM;
|
||||||
float prevYM;
|
float prevYM;
|
||||||
|
float delta = 150;
|
||||||
float prevDistM = -1;
|
float prevDistM = -1;
|
||||||
//float prevElevM = -80000;
|
float nextDistM;
|
||||||
//float gist = 1.5f; // 1.5 meters
|
|
||||||
float delta = 30f; // 30 meters
|
|
||||||
float d;
|
float d;
|
||||||
if (elevationData.size() > 1) {
|
if (eleValues.size() > 1) {
|
||||||
Elevation e0 = elevationData.get(0);
|
nextXM = eleValues.get(0).getX();
|
||||||
d = (float) e0.distance;
|
nextYM = eleValues.get(0).getY();
|
||||||
if (d > delta) {
|
|
||||||
nextXM = d / 2f;
|
|
||||||
prevDistM = d;
|
|
||||||
} else {
|
|
||||||
nextXM = 0f;
|
|
||||||
}
|
|
||||||
nextYM = 0;
|
|
||||||
prevXM = nextXM;
|
prevXM = nextXM;
|
||||||
prevYM = nextYM;
|
prevYM = 0;
|
||||||
nextX = nextXM / divX;
|
nextX = 0;
|
||||||
nextY = 0;
|
nextY = 0;
|
||||||
for (int i = 1; i < elevationData.size(); i++) {
|
for (i = 1; i < eleValues.size(); i++) {
|
||||||
Elevation e = elevationData.get(i);
|
Entry e = eleValues.get(i);
|
||||||
if (e.distance > 0) {
|
d = e.getX() - prevXM;
|
||||||
d += (float) e.distance;
|
if (d < delta && i < eleValues.size() - 1) {
|
||||||
if (d < delta && i < elevationData.size() - 1) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (prevDistM < 0) {
|
||||||
if (prevDistM < 0) {
|
nextDistM = d / 2f;
|
||||||
nextDistM = d / 2f;
|
} else {
|
||||||
} else {
|
nextDistM = prevDistM / 2f + d / 2f;
|
||||||
nextDistM = prevDistM / 2f + d / 2f;
|
}
|
||||||
}
|
prevDistM = d;
|
||||||
prevDistM = d;
|
if (nextX == 0) {
|
||||||
d = 0;
|
values.add(new Entry(prevXM / divX, 0));
|
||||||
nextXM += nextDistM;
|
prevXM = nextXM;
|
||||||
nextYM = (float) e.elevation;
|
prevYM = nextYM;
|
||||||
//if (Math.abs(prevElevM - nextYM) < gist) {
|
}
|
||||||
// nextX += nextDistM / divX;
|
nextXM = e.getX();
|
||||||
// continue;
|
nextYM = e.getY();
|
||||||
//} else {
|
nextX = (prevXM + nextDistM) / divX;
|
||||||
// prevElevM = nextYM;
|
nextY = (nextYM - prevYM) / (nextXM - prevXM) * 100f;
|
||||||
//}
|
if (Math.abs(nextY) < 120) {
|
||||||
if (nextX == 0) {
|
values.add(new Entry(nextX, nextY));
|
||||||
prevXM = nextXM;
|
prevXM = nextXM;
|
||||||
prevYM = nextYM;
|
prevYM = nextYM;
|
||||||
values.add(new Entry(nextDistM / divX, nextY));
|
}
|
||||||
}
|
}
|
||||||
nextX += nextDistM / divX;
|
}
|
||||||
nextY = (nextYM - prevYM) / (nextXM - prevXM) * 100f;
|
|
||||||
if (Math.abs(nextY) < 120) {
|
points = new ArrayList<>(values.size());
|
||||||
values.add(new Entry(nextX, nextY));
|
for (Entry e : values) {
|
||||||
prevXM = nextXM;
|
points.add(new Point2D(e.getX(), e.getY()));
|
||||||
prevYM = nextYM;
|
}
|
||||||
}
|
spline = calculateSpline(points);
|
||||||
|
if (spline != null) {
|
||||||
|
int count = 8;
|
||||||
|
values = new ArrayList<>();
|
||||||
|
for (Segment s : spline) {
|
||||||
|
Point2D p = new Point2D();
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
s.calc((double) i / (double) count, p);
|
||||||
|
values.add(new Entry((float) p.x, (float) p.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue