Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
36155021bf
3 changed files with 64 additions and 57 deletions
|
@ -12,19 +12,10 @@
|
|||
android:background="?attr/bg_color"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/route_altitude"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"/>
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -179,49 +170,6 @@
|
|||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/descent_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_action_altitude_descent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginLeft="18dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/descent_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="164"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descent_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="@string/altitude_descent"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ascent_icon"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -258,6 +206,49 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/descent_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_action_altitude_descent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginLeft="18dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/descent_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="164"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descent_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="@string/altitude_descent"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/list_item_divider"/>
|
||||
|
|
|
@ -54,6 +54,8 @@ import java.io.FileWriter;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||
|
||||
public class ShowRouteInfoDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String TAG = "ShowRouteInfoDialogFragment";
|
||||
|
@ -63,6 +65,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
private ListView listView;
|
||||
private RouteInfoAdapter adapter;
|
||||
private GPXFile gpx;
|
||||
private boolean hasHeights;
|
||||
|
||||
public ShowRouteInfoDialogFragment() {
|
||||
}
|
||||
|
@ -163,7 +166,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
});
|
||||
|
||||
makeGpx();
|
||||
if (!gpx.isEmpty()) {
|
||||
if (hasHeights) {
|
||||
View headerView = inflater.inflate(R.layout.route_info_header, null);
|
||||
buildHeader(headerView);
|
||||
listView.addHeaderView(headerView);
|
||||
|
@ -173,13 +176,17 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
}
|
||||
|
||||
private void makeGpx() {
|
||||
double lastHeight = -1;
|
||||
double lastHeight = HEIGHT_UNDEFINED;
|
||||
gpx = new GPXFile();
|
||||
List<RouteSegmentResult> route = helper.getRoute().getLeftRoute();
|
||||
if (route != null) {
|
||||
Track track = new Track();
|
||||
for (RouteSegmentResult res : route) {
|
||||
TrkSegment seg = new TrkSegment();
|
||||
float[] vls = res.getObject().calculateHeightArray();
|
||||
if (!hasHeights && vls != null && vls.length > 0) {
|
||||
hasHeights = true;
|
||||
}
|
||||
int inc = res.getStartPointIndex() < res.getEndPointIndex() ? 1 : -1;
|
||||
int indexnext = res.getStartPointIndex();
|
||||
for (int index = res.getStartPointIndex(); index != res.getEndPointIndex(); ) {
|
||||
|
@ -189,12 +196,11 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
WptPt point = new WptPt();
|
||||
point.lat = l.getLatitude();
|
||||
point.lon = l.getLongitude();
|
||||
float[] vls = res.getObject().calculateHeightArray();
|
||||
if (vls != null && index * 2 + 1 < vls.length) {
|
||||
point.ele = vls[2 * index + 1];
|
||||
//point.desc = (res.getObject().getId() >> (BinaryInspector.SHIFT_ID )) + " " + index;
|
||||
lastHeight = vls[2 * index + 1];
|
||||
} else if (lastHeight > 0) {
|
||||
} else if (lastHeight != HEIGHT_UNDEFINED) {
|
||||
point.ele = lastHeight;
|
||||
}
|
||||
seg.points.add(point);
|
||||
|
|
|
@ -18,6 +18,8 @@ import net.osmand.util.Algorithms;
|
|||
import net.osmand.util.MapUtils;
|
||||
import android.content.Context;
|
||||
|
||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||
|
||||
public class RouteCalculationResult {
|
||||
private static double distanceClosestToIntermediate = 400;
|
||||
// could not be null and immodifiable!
|
||||
|
@ -229,9 +231,11 @@ public class RouteCalculationResult {
|
|||
List<AlarmInfo> alarms, OsmandApplication ctx) {
|
||||
float prevDirectionTime = 0;
|
||||
float prevDirectionDistance = 0;
|
||||
double lastHeight = HEIGHT_UNDEFINED;
|
||||
List<RouteSegmentResult> segmentsToPopulate = new ArrayList<RouteSegmentResult>();
|
||||
for (int routeInd = 0; routeInd < list.size(); routeInd++) {
|
||||
RouteSegmentResult s = list.get(routeInd);
|
||||
float[] vls = s.getObject().calculateHeightArray();
|
||||
boolean plus = s.getStartPointIndex() < s.getEndPointIndex();
|
||||
int i = s.getStartPointIndex();
|
||||
int prevLocationSize = locations.size();
|
||||
|
@ -243,6 +247,12 @@ public class RouteCalculationResult {
|
|||
if (i == s.getEndPointIndex() && routeInd != list.size() - 1) {
|
||||
break;
|
||||
}
|
||||
if (vls != null && i * 2 + 1 < vls.length) {
|
||||
n.setAltitude(vls[2 * i + 1]);
|
||||
lastHeight = vls[2 * i + 1];
|
||||
} else if (lastHeight != HEIGHT_UNDEFINED) {
|
||||
n.setAltitude(lastHeight);
|
||||
}
|
||||
locations.add(n);
|
||||
attachAlarmInfo(alarms, s, i, locations.size());
|
||||
segmentsToPopulate.add(s);
|
||||
|
|
Loading…
Reference in a new issue