shields in top bar
This commit is contained in:
parent
37961c5123
commit
44e2fe3c72
4 changed files with 112 additions and 49 deletions
|
@ -695,16 +695,16 @@ public class RouteDataObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isMotorWayLink() {
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if (r.getTag().equals("highway") && r.getValue().equals("motorway_link")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// public boolean isMotorWayLink() {
|
||||
// int sz = types.length;
|
||||
// for (int i = 0; i < sz; i++) {
|
||||
// RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
// if (r.getTag().equals("highway") && r.getValue().equals("motorway_link")) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public String getExitName() {
|
||||
if (pointNames != null && pointNameTypes != null) {
|
||||
|
@ -742,27 +742,33 @@ public class RouteDataObject {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String getShieldColor() {
|
||||
public BinaryMapIndexReader.TagValuePair getShieldColor() {
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if (r.getTag().equals("road_shield_color_1")
|
||||
|| r.getTag().equals("road_shield_color_2")
|
||||
|| r.getTag().equals("road_shield_color_3")) {
|
||||
return r.getValue();
|
||||
switch (r.getTag()) {
|
||||
case "road_shield_color_1":
|
||||
return new BinaryMapIndexReader.TagValuePair("road_shield_color_1", r.getValue(), 0);
|
||||
case "road_shield_color_2":
|
||||
return new BinaryMapIndexReader.TagValuePair("road_shield_color_2", r.getValue(), 0);
|
||||
case "road_shield_color_3":
|
||||
return new BinaryMapIndexReader.TagValuePair("road_shield_color_3", r.getValue(), 0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getShieldShape() {
|
||||
public BinaryMapIndexReader.TagValuePair getShieldShape() {
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
if (r.getTag().equals("road_shield_shape_1")
|
||||
|| r.getTag().equals("road_shield_shape_2")
|
||||
|| r.getTag().equals("road_shield_shape_3")) {
|
||||
return r.getValue();
|
||||
switch (r.getTag()) {
|
||||
case "road_shield_shape_1":
|
||||
return new BinaryMapIndexReader.TagValuePair("road_shield_shape_1", r.getValue(), 0);
|
||||
case "road_shield_shape_2":
|
||||
return new BinaryMapIndexReader.TagValuePair("road_shield_shape_2", r.getValue(), 0);
|
||||
case "road_shield_shape_3":
|
||||
return new BinaryMapIndexReader.TagValuePair("road_shield_shape_3", r.getValue(), 0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context;
|
|||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
|
@ -24,6 +26,8 @@ import net.osmand.router.TurnType;
|
|||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -31,6 +35,8 @@ import java.util.List;
|
|||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||
|
||||
public class RouteCalculationResult {
|
||||
private final static Log log = PlatformUtil.getLog(RouteCalculationResult.class);
|
||||
|
||||
private static double distanceClosestToIntermediate = 3000;
|
||||
private static double distanceThresholdToIntermediate = 25;
|
||||
// could not be null and immodifiable!
|
||||
|
@ -330,6 +336,14 @@ public class RouteCalculationResult {
|
|||
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection()));
|
||||
|
||||
if (s.getObject().isExitPoint() && next.getObject().getHighway().equals("motorway_link")) {
|
||||
ExitInfo exitInfo = new ExitInfo();
|
||||
exitInfo.setRef(next.getObject().getExitRef());
|
||||
exitInfo.setExitStreetName(next.getObject().getExitName());
|
||||
info.setExitInfo(exitInfo);
|
||||
}
|
||||
|
||||
String highwayTag = s.getObject().getHighway();
|
||||
// Search for nearest shield properties
|
||||
for (int j = lind; j < list.size(); j++) {
|
||||
RouteSegmentResult segment = list.get(j);
|
||||
|
@ -337,22 +351,20 @@ public class RouteCalculationResult {
|
|||
segment.isForwardDirection());
|
||||
// if it's the same road
|
||||
if (segmentRef != null && segmentRef.equals(ref)) {
|
||||
String shieldColor = segment.getObject().getShieldColor();
|
||||
String shieldShape = segment.getObject().getShieldShape();
|
||||
if (shieldColor != null || shieldShape != null) {
|
||||
info.setShieldColor(shieldColor != null ? shieldColor : "white");
|
||||
info.setShieldShape(shieldShape != null ? shieldShape : "square");
|
||||
BinaryMapIndexReader.TagValuePair colorPair = segment.getObject().getShieldColor();
|
||||
BinaryMapIndexReader.TagValuePair shapePair = segment.getObject().getShieldShape();
|
||||
if (colorPair != null || shapePair != null) {
|
||||
info.setShieldColorValue(colorPair != null ? colorPair.value : "white");
|
||||
info.setShieldShapeValue(shapePair != null ? shapePair.value : "square");
|
||||
if (colorPair != null) {
|
||||
info.setShieldIconName(getShieldIconName(ctx, ref, highwayTag, colorPair));
|
||||
} else {
|
||||
info.setShieldIconName(getShieldIconName(ctx, ref, highwayTag, shapePair));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s.getObject().isExitPoint() && next.getObject().isMotorWayLink()) {
|
||||
ExitInfo exitInfo = new ExitInfo();
|
||||
exitInfo.setRef(next.getObject().getExitRef());
|
||||
exitInfo.setExitStreetName(next.getObject().getExitName());
|
||||
info.setExitInfo(exitInfo);
|
||||
}
|
||||
}
|
||||
|
||||
String description = toString(turn, ctx, false) + " " + RoutingHelper.formatStreetName(info.getStreetName(),
|
||||
|
@ -384,6 +396,32 @@ public class RouteCalculationResult {
|
|||
}
|
||||
return segmentsToPopulate;
|
||||
}
|
||||
|
||||
private static String getShieldIconName(OsmandApplication ctx, String ref, String highwayTag,
|
||||
BinaryMapIndexReader.TagValuePair pair) {
|
||||
String shieldId = null;
|
||||
RenderingRulesStorage currentRenderer = ctx.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
MapRenderRepositories maps = ctx.getResourceManager().getRenderer();
|
||||
boolean nightMode = ctx.getDaynightHelper().isNightMode();
|
||||
RenderingRuleSearchRequest request = maps.getSearchRequestWithAppliedCustomRules(currentRenderer, nightMode);
|
||||
request.setInitialTagValueZoom("highway", highwayTag, 10, null);
|
||||
request.setIntFilter(request.ALL.R_TEXT_LENGTH, ref.length());
|
||||
request.setStringFilter(request.ALL.R_NAME_TAG, "road_ref_1");
|
||||
request.setStringFilter(request.ALL.R_ADDITIONAL,
|
||||
pair.tag + "=" + pair.value);
|
||||
if (request.search(RenderingRulesStorage.TEXT_RULES)) {
|
||||
if (request.getFloatPropertyValue(request.ALL.R_TEXT_SIZE) > 0) {
|
||||
if (request.isSpecified(request.ALL.R_TEXT_SHIELD)) {
|
||||
shieldId = request.getStringPropertyValue(request.ALL.R_TEXT_SHIELD);
|
||||
}
|
||||
if (request.isSpecified(request.ALL.R_ICON)) {
|
||||
shieldId = request.getStringPropertyValue(request.ALL.R_ICON);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("Shield name: " + shieldId);
|
||||
return shieldId;
|
||||
}
|
||||
|
||||
protected static void addMissingTurnsToRoute(List<Location> locations,
|
||||
List<RouteDirectionInfo> originalDirections, Location start, LatLon end, ApplicationMode mode, Context ctx,
|
||||
|
|
|
@ -25,9 +25,11 @@ public class RouteDirectionInfo {
|
|||
|
||||
private String destinationName;
|
||||
|
||||
private String shieldColor;
|
||||
private String shieldColorValue;
|
||||
|
||||
private String shieldShape;
|
||||
private String shieldShapeValue;
|
||||
|
||||
private String shieldIconName;
|
||||
|
||||
@Nullable
|
||||
private ExitInfo exitInfo;
|
||||
|
@ -126,19 +128,27 @@ public class RouteDirectionInfo {
|
|||
this.exitInfo = exitInfo;
|
||||
}
|
||||
|
||||
public String getShieldColor() {
|
||||
return shieldColor;
|
||||
public String getShieldColorValue() {
|
||||
return shieldColorValue;
|
||||
}
|
||||
|
||||
public void setShieldColor(String shieldColor) {
|
||||
this.shieldColor = shieldColor;
|
||||
public void setShieldColorValue(String shieldColorValue) {
|
||||
this.shieldColorValue = shieldColorValue;
|
||||
}
|
||||
|
||||
public String getShieldShape() {
|
||||
return shieldShape;
|
||||
public String getShieldShapeValue() {
|
||||
return shieldShapeValue;
|
||||
}
|
||||
|
||||
public void setShieldShape(String shieldShape) {
|
||||
this.shieldShape = shieldShape;
|
||||
public void setShieldShapeValue(String shieldShapeValue) {
|
||||
this.shieldShapeValue = shieldShapeValue;
|
||||
}
|
||||
|
||||
public String getShieldIconName() {
|
||||
return shieldIconName;
|
||||
}
|
||||
|
||||
public void setShieldIconName(String shieldIconName) {
|
||||
this.shieldIconName = shieldIconName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1003,8 +1003,11 @@ public class MapInfoWidgetsFactory {
|
|||
} else {
|
||||
ref = directionInfo != null ? directionInfo.getRef() : null;
|
||||
if (ref != null) {
|
||||
setShield(shieldIcon, assembleShieldString(directionInfo.getShieldColor(),
|
||||
directionInfo.getShieldShape(), ref.length()), ref);
|
||||
setShield(shieldIcon, assembleShieldString(directionInfo.getShieldColorValue(),
|
||||
directionInfo.getShieldShapeValue(), ref.length()), ref);
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||
}
|
||||
turnDrawable.setColor(R.color.nav_arrow);
|
||||
}
|
||||
|
@ -1028,9 +1031,12 @@ public class MapInfoWidgetsFactory {
|
|||
text = "";
|
||||
}
|
||||
if (ref != null) {
|
||||
setShield(shieldIcon, assembleShieldString(next.getShieldColor(),
|
||||
next.getShieldShape(),
|
||||
setShield(shieldIcon, assembleShieldString(next.getShieldColorValue(),
|
||||
next.getShieldShapeValue(),
|
||||
ref.length()), ref);
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||
}
|
||||
} else {
|
||||
text = null;
|
||||
|
@ -1049,9 +1055,12 @@ public class MapInfoWidgetsFactory {
|
|||
"»");
|
||||
}
|
||||
if (ref != null) {
|
||||
setShield(shieldIcon, assembleShieldString(rt.getShieldColor(),
|
||||
rt.getShieldShape(),
|
||||
setShield(shieldIcon, assembleShieldString(rt.getShieldColor().value,
|
||||
rt.getShieldShape().value,
|
||||
ref.length()), ref);
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||
}else {
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
|
@ -1126,10 +1135,10 @@ public class MapInfoWidgetsFactory {
|
|||
boolean nightMode = app.getDaynightHelper().isNightMode();
|
||||
RenderingRuleSearchRequest renderingReq =
|
||||
mapRenderRepo.getSearchRequestWithAppliedCustomRules(storage, nightMode);
|
||||
|
||||
renderingReq.setInitialTagValueZoom("highway", "secondary", 15, null);
|
||||
renderingReq.setIntFilter(renderingReq.ALL.R_TEXT_LENGTH, ref.length());
|
||||
renderingReq.setStringFilter(renderingReq.ALL.R_NAME_TAG, "ref");
|
||||
renderingReq.search(RenderingRulesStorage.POINT_RULES);
|
||||
|
||||
OsmandRenderer.RenderingContext rc = new OsmandRenderer.RenderingContext(context);
|
||||
TextRenderer textRenderer = new TextRenderer(context);
|
||||
|
|
Loading…
Reference in a new issue