Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add route legend card #21619

Merged
merged 13 commits into from
Feb 7, 2025
25 changes: 8 additions & 17 deletions OsmAnd-java/src/main/java/net/osmand/osm/OsmRouteType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.osmand.osm;

import static net.osmand.osm.OsmRouteType.RenderingPropertyAttr.*;
import static net.osmand.osm.RenderingPropertyAttr.*;

import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader;
Expand Down Expand Up @@ -443,8 +443,13 @@ public RouteActivityTypeBuilder icon(String icon) {
return this;
}

public RouteActivityTypeBuilder renderingPropertyAttr(String renderingPropertyAttr) {
osmRouteType.renderingPropertyAttr = renderingPropertyAttr;
public RouteActivityTypeBuilder renderingPropertyAttr(String propertyAttr) {
osmRouteType.renderingPropertyAttr = propertyAttr;
return this;
}

public RouteActivityTypeBuilder renderingPropertyAttr(RenderingPropertyAttr propertyAttr) {
renderingPropertyAttr(propertyAttr.getAttrName());
return this;
}

Expand All @@ -453,18 +458,4 @@ private OsmRouteType reg() {
return osmRouteType;
}
}

protected static class RenderingPropertyAttr {
static final String HIKING_ROUTES = "hikingRoutesOSMC";
static final String CYCLE_ROUTES = "showCycleRoutes";
static final String MTB_ROUTES = "showMtbRoutes";
static final String ALPINE_HIKING = "alpineHiking";
static final String HORSE_ROUTES = "horseRoutes";
static final String PISTE_ROUTES = "pisteRoutes";
static final String WHITE_WATER_SPORTS = "whiteWaterSports";
static final String RUNNING_ROUTES = "showRunningRoutes";
static final String FITNESS_TRAILS = "showFitnessTrails";
static final String DIRTBIKE_ROUTES = "showDirtbikeTrails";
static final String CLIMBING_ROUTES = "showClimbingRoutes";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.osmand.osm;

public enum RenderingPropertyAttr {

HIKING_ROUTES("hikingRoutesOSMC", ".route.hiking"),
CYCLE_ROUTES("showCycleRoutes", ".route.bicycle"),
MTB_ROUTES("showMtbRoutes", ".route.mtb"),
ALPINE_HIKING("alpineHiking", ".road.alpinehiking"),
HORSE_ROUTES("horseRoutes", ".route.horse"),
PISTE_ROUTES("pisteRoutes", ".route.piste"),
WHITE_WATER_SPORTS("whiteWaterSports", null),
RUNNING_ROUTES("showRunningRoutes", ".route.running"),
FITNESS_TRAILS("showFitnessTrails", ".route.fitness_trail"),
DIRTBIKE_ROUTES("showDirtbikeTrails", ".route.dirtbike"),
CLIMBING_ROUTES("showClimbingRoutes", null),
SHOW_MTB_SCALE("showMtbScale", ".route.mtb.mtb_scale"),
SHOW_MTB_IMBA_SCALE("showMtbScaleIMBATrails", ".route.mtb.mtb_scale_imba");

private final String attrName;
private final String renderingClassName;

RenderingPropertyAttr(String attrName, String renderingClassName) {
this.attrName = attrName;
this.renderingClassName = renderingClassName;
}

public String getAttrName() {
return attrName;
}

public String getRenderingClassName() {
return renderingClassName;
}

public static String getRenderingClassName(String attrName) {
RenderingPropertyAttr attr = fromAttrName(attrName);
return attr != null && attr.renderingClassName != null ? attr.renderingClassName : attrName;
}

public static RenderingPropertyAttr fromAttrName(String attrName) {
for (RenderingPropertyAttr attr : values()) {
if (attr.attrName.equals(attrName)) {
return attr;
}
}
return null;
}
}
81 changes: 81 additions & 0 deletions OsmAnd-java/src/main/java/net/osmand/render/RenderingClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package net.osmand.render;

public class RenderingClass {

private final String title;
private final String description;
private final String category;
private final String legendObject;
private final String innerLegendObject;
private final String innerTitle;
private final String innerDescription;
private final String innerCategory;
private final String innerNames;
private final boolean enabledByDefault;
private final String name;

public RenderingClass(String title, String description, String category, String legendObject,
String innerLegendObject, String innerTitle, String innerDescription,
String innerCategory, String innerNames, boolean enabledByDefault, String name) {
this.title = title;
this.description = description;
this.category = category;
this.legendObject = legendObject;
this.innerLegendObject = innerLegendObject;
this.innerTitle = innerTitle;
this.innerDescription = innerDescription;
this.innerCategory = innerCategory;
this.innerNames = innerNames;
this.enabledByDefault = enabledByDefault;
this.name = name;
}

public String getTitle() {
return title;
}

public String getDescription() {
return description;
}

public String getCategory() {
return category;
}

public String getLegendObject() {
return legendObject;
}

public String getInnerLegendObject() {
return innerLegendObject;
}

public String getInnerTitle() {
return innerTitle;
}

public String getInnerDescription() {
return innerDescription;
}

public String getInnerCategory() {
return innerCategory;
}

public String getInnerNames() {
return innerNames;
}

public boolean isEnabledByDefault() {
return enabledByDefault;
}

public String getName() {
return name;
}

@Override
public String toString() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ public void init(Map<String, String> attributes) {
attributesRef = new RenderingRule[attributes.size()];
}
attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1));
if (attributesRef[i] == null) {
attributesRef[i] = storage.getRenderingAssociationRule(vl.substring(1));
}
} else if (property.isString()) {
intProperties[i] = storage.getDictionaryValue(vl);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,6 @@ public boolean searchRenderingAttribute(String attribute) {
return searchResult;
}

public boolean searchRenderingAssociation(String association) {
searchResult = false;
RenderingRule rule = storage.getRenderingAssociationRule(association);
if (rule == null) {
return false;
}
searchResult = visitRule(rule, true);
return searchResult;
}

public boolean search(int state) {
return search(state, true);
}
Expand Down
Loading
Loading