get next shield
This commit is contained in:
parent
45c8df4c63
commit
0534fda25c
4 changed files with 110 additions and 66 deletions
|
@ -5,7 +5,6 @@ import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
|
@ -15,10 +14,7 @@ import net.osmand.data.QuadRect;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.render.MapRenderRepositories;
|
|
||||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||||
import net.osmand.render.RenderingRuleSearchRequest;
|
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
|
||||||
import net.osmand.router.ExitInfo;
|
import net.osmand.router.ExitInfo;
|
||||||
import net.osmand.router.RouteSegmentResult;
|
import net.osmand.router.RouteSegmentResult;
|
||||||
import net.osmand.router.RoutingContext;
|
import net.osmand.router.RoutingContext;
|
||||||
|
@ -32,6 +28,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
|
|
||||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||||
|
|
||||||
public class RouteCalculationResult {
|
public class RouteCalculationResult {
|
||||||
|
@ -335,17 +333,50 @@ public class RouteCalculationResult {
|
||||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get()));
|
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get()));
|
||||||
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection()));
|
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection()));
|
||||||
|
|
||||||
if (s.getObject().isExitPoint() && next.getObject().getHighway().equals("motorway_link")) {
|
if (s.getObject().isExitPoint() && next.getObject().getHighway().equals("motorway_link")) {
|
||||||
ExitInfo exitInfo = new ExitInfo();
|
ExitInfo exitInfo = new ExitInfo();
|
||||||
exitInfo.setRef(next.getObject().getExitRef());
|
exitInfo.setRef(next.getObject().getExitRef());
|
||||||
exitInfo.setExitStreetName(next.getObject().getExitName());
|
exitInfo.setExitStreetName(next.getObject().getExitName());
|
||||||
info.setExitInfo(exitInfo);
|
info.setExitInfo(exitInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ref != null) {
|
||||||
|
RouteDataObject nextRoad = next.getObject();
|
||||||
|
boolean isNextShieldFound = false;
|
||||||
|
int[] nextSegmentNameIds = nextRoad.nameIds;
|
||||||
|
for (int nm = 0; nm < nextSegmentNameIds.length; nm++) {
|
||||||
|
int nmId = nextSegmentNameIds[nm];
|
||||||
|
if (nextRoad.region.quickGetEncodingRule(nextSegmentNameIds[nm]).getTag().startsWith("road_ref")) {// && nextSegmentNames.get(nmId).equals(ref)) {
|
||||||
|
info.setRouteDataObject(nextRoad);
|
||||||
|
isNextShieldFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNextShieldFound) {
|
||||||
|
for (int ind = lind; ind < list.size(); ind++) {
|
||||||
|
if (list.get(ind).getTurnType() != null) {
|
||||||
|
info.setRouteDataObject(null);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
RouteDataObject obj = list.get(ind).getObject();
|
||||||
|
int[] nameIds = obj.nameIds;
|
||||||
|
for (int idx = 0; idx < nameIds.length; idx ++) {
|
||||||
|
if (obj.region.routeEncodingRules.get(obj.nameIds[idx]).getTag().startsWith("road_ref")) {
|
||||||
|
info.setRouteDataObject(obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (info.getRouteDataObject() != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String description = toString(turn, ctx, false) + " " + RoutingHelper.formatStreetName(info.getStreetName(),
|
String description = toString(turn, ctx, false) + " " + RoutingHelper.formatStreetName(info.getStreetName(),
|
||||||
info.getRef(), info.getDestinationName(), ctx.getString(R.string.towards));
|
null, info.getDestinationName(), ctx.getString(R.string.towards));
|
||||||
description = description.trim();
|
description = description.trim();
|
||||||
String[] pointNames = s.getObject().getPointNames(s.getStartPointIndex());
|
String[] pointNames = s.getObject().getPointNames(s.getStartPointIndex());
|
||||||
if(pointNames != null) {
|
if(pointNames != null) {
|
||||||
|
@ -362,7 +393,8 @@ public class RouteCalculationResult {
|
||||||
prevDirectionDistance = 0;
|
prevDirectionDistance = 0;
|
||||||
prevDirectionTime = 0;
|
prevDirectionTime = 0;
|
||||||
}
|
}
|
||||||
info.setRouteDataObject(s.getObject());
|
|
||||||
|
|
||||||
directions.add(info);
|
directions.add(info);
|
||||||
}
|
}
|
||||||
prevDirectionDistance += s.getDistance();
|
prevDirectionDistance += s.getDistance();
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class RouteDirectionInfo {
|
||||||
|
|
||||||
private String destinationName;
|
private String destinationName;
|
||||||
|
|
||||||
private RouteDataObject routeDataObject;
|
private RouteDataObject routeDataObject = null;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ExitInfo exitInfo;
|
private ExitInfo exitInfo;
|
||||||
|
|
|
@ -825,7 +825,8 @@ public class RoutingHelper {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n) {
|
public synchronized String getCurrentName(TurnType[] next){
|
||||||
|
NextDirectionInfo n = getNextRouteDirectionInfo(new NextDirectionInfo(), true);
|
||||||
Location l = lastFixedLocation;
|
Location l = lastFixedLocation;
|
||||||
float speed = 0;
|
float speed = 0;
|
||||||
if(l != null && l.hasSpeed()) {
|
if(l != null && l.hasSpeed()) {
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.jwetherell.openmap.common.UTMPoint;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.LocationConvert;
|
import net.osmand.LocationConvert;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -75,6 +76,8 @@ import net.osmand.router.TurnType;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
@ -924,6 +927,7 @@ public class MapInfoWidgetsFactory {
|
||||||
private TurnDrawable turnDrawable;
|
private TurnDrawable turnDrawable;
|
||||||
private boolean showMarker;
|
private boolean showMarker;
|
||||||
private int shadowRad;
|
private int shadowRad;
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(TopTextView.class);
|
||||||
|
|
||||||
public TopTextView(OsmandApplication app, MapActivity map) {
|
public TopTextView(OsmandApplication app, MapActivity map) {
|
||||||
topBar = map.findViewById(R.id.map_top_bar);
|
topBar = map.findViewById(R.id.map_top_bar);
|
||||||
|
@ -974,16 +978,14 @@ public class MapInfoWidgetsFactory {
|
||||||
boolean showNextTurn = false;
|
boolean showNextTurn = false;
|
||||||
boolean showMarker = this.showMarker;
|
boolean showMarker = this.showMarker;
|
||||||
boolean showExitInfo = false;
|
boolean showExitInfo = false;
|
||||||
|
boolean showShield = false;
|
||||||
ExitInfo exitInfo = null;
|
ExitInfo exitInfo = null;
|
||||||
|
RouteDataObject object = null;
|
||||||
|
|
||||||
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
||||||
if (routingHelper.isFollowingMode()) {
|
if (routingHelper.isFollowingMode()) {
|
||||||
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(
|
|
||||||
new RouteCalculationResult.NextDirectionInfo(), true);
|
|
||||||
|
|
||||||
if (settings.SHOW_STREET_NAME.get()) {
|
if (settings.SHOW_STREET_NAME.get()) {
|
||||||
text = routingHelper.getCurrentName(type, nextDirInfo);
|
text = routingHelper.getCurrentName(type);
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
text = "";
|
text = "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -994,7 +996,10 @@ public class MapInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextDirInfo != null) {
|
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(
|
||||||
|
new RouteCalculationResult.NextDirectionInfo(), true);
|
||||||
|
|
||||||
|
|
||||||
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
||||||
|
|
||||||
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
||||||
|
@ -1008,35 +1013,12 @@ public class MapInfoWidgetsFactory {
|
||||||
text = exitInfo.getExitStreetName();
|
text = exitInfo.getExitStreetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextDirInfo != null && nextDirInfo.directionInfo.getRouteDataObject() != null) {
|
if (nextDirInfo.directionInfo.getRouteDataObject() != null) {
|
||||||
RouteDataObject object = nextDirInfo.directionInfo.getRouteDataObject();
|
object = nextDirInfo.directionInfo.getRouteDataObject();
|
||||||
String nameTag = null;
|
showShield = true;
|
||||||
String name = null;
|
|
||||||
StringBuilder additional = new StringBuilder();
|
|
||||||
if (object != null) {
|
|
||||||
if (object.nameIds != null) {
|
|
||||||
for (int i = 0; i < object.nameIds.length; i++) {
|
|
||||||
String key = object.region.routeEncodingRules.get(object.nameIds[i]).getTag();
|
|
||||||
String val = object.names.get(object.nameIds[i]);
|
|
||||||
if (key.equals("road_ref_1")) {
|
|
||||||
nameTag = key;
|
|
||||||
name = val;
|
|
||||||
} else {
|
|
||||||
additional.append(key).append("=").append(val).append(";");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (name != null && setRoadShield(shieldIcon, object, nameTag, name, additional)) {
|
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
|
||||||
} else {
|
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int di = MapRouteInfoMenu.getDirectionInfo();
|
int di = MapRouteInfoMenu.getDirectionInfo();
|
||||||
|
@ -1047,7 +1029,9 @@ public class MapInfoWidgetsFactory {
|
||||||
type[0] = next.getTurnType();
|
type[0] = next.getTurnType();
|
||||||
turnDrawable.setColor(R.color.nav_arrow_distant);
|
turnDrawable.setColor(R.color.nav_arrow_distant);
|
||||||
text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»");
|
text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»");
|
||||||
|
if (text == null) {
|
||||||
|
text = "";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
text = null;
|
text = null;
|
||||||
}
|
}
|
||||||
|
@ -1060,11 +1044,10 @@ public class MapInfoWidgetsFactory {
|
||||||
//ref = rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation));
|
//ref = rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation));
|
||||||
text = RoutingHelper.formatStreetName(
|
text = RoutingHelper.formatStreetName(
|
||||||
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
||||||
null,
|
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||||
"»");
|
"»");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
text = "";
|
text = "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -1095,6 +1078,18 @@ public class MapInfoWidgetsFactory {
|
||||||
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
||||||
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
||||||
this.showMarker = showMarker;
|
this.showMarker = showMarker;
|
||||||
|
|
||||||
|
if (showShield) {
|
||||||
|
|
||||||
|
if (setRoadShield(shieldIcon, object)) {
|
||||||
|
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||||
|
} else {
|
||||||
|
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (showExitInfo) {
|
if (showExitInfo) {
|
||||||
String exitRef = exitInfo.getRef();
|
String exitRef = exitInfo.getRef();
|
||||||
if (!Algorithms.isEmpty(exitRef)) {
|
if (!Algorithms.isEmpty(exitRef)) {
|
||||||
|
@ -1127,7 +1122,23 @@ public class MapInfoWidgetsFactory {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setRoadShield(ImageView view, RouteDataObject object, String nameTag, String name, StringBuilder additional) {
|
private boolean setRoadShield(ImageView view, RouteDataObject object) {
|
||||||
|
|
||||||
|
String nameTag = null;
|
||||||
|
String name = null;
|
||||||
|
StringBuilder additional = new StringBuilder();
|
||||||
|
for (int i = 0; i < object.nameIds.length; i++) {
|
||||||
|
String key = object.region.routeEncodingRules.get(object.nameIds[i]).getTag();
|
||||||
|
String val = object.names.get(object.nameIds[i]);
|
||||||
|
if (key.startsWith("road_ref")) {
|
||||||
|
nameTag = key;
|
||||||
|
name = val;
|
||||||
|
} else {
|
||||||
|
additional.append(key).append("=").append(val).append(";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG.debug("Additionals (names): " + additional.toString() );
|
||||||
|
|
||||||
Context context = topBar.getContext();
|
Context context = topBar.getContext();
|
||||||
int[] tps = object.getTypes();
|
int[] tps = object.getTypes();
|
||||||
OsmandApplication app = ((OsmandApplication) context.getApplicationContext());
|
OsmandApplication app = ((OsmandApplication) context.getApplicationContext());
|
||||||
|
@ -1138,8 +1149,8 @@ public class MapInfoWidgetsFactory {
|
||||||
|
|
||||||
for (int i : tps) {
|
for (int i : tps) {
|
||||||
BinaryMapRouteReaderAdapter.RouteTypeRule tp = object.region.quickGetEncodingRule(i);
|
BinaryMapRouteReaderAdapter.RouteTypeRule tp = object.region.quickGetEncodingRule(i);
|
||||||
if (tp.getTag().equals("highway")) {
|
if (tp.getTag().equals("highway") || tp.getTag().equals("route")) {
|
||||||
rreq.setInitialTagValueZoom(tp.getTag(), tp.getValue(), 15, null);
|
rreq.setInitialTagValueZoom(tp.getTag(), tp.getValue(), 13, null);
|
||||||
} else {
|
} else {
|
||||||
additional.append(tp.getTag()).append("=").append(tp.getValue()).append(";");
|
additional.append(tp.getTag()).append("=").append(tp.getValue()).append(";");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue