Fix compilation
This commit is contained in:
parent
8406e7b20a
commit
a43dae3a58
3 changed files with 32 additions and 34 deletions
|
@ -21,7 +21,7 @@ public class RouteStatisticsHelper {
|
|||
|
||||
List<RouteStatistics> result = new ArrayList<>();
|
||||
|
||||
String[] colorAttrNames = { "surfaceColor", "roadClassColor", "smoothnessColor" };
|
||||
String[] colorAttrNames = {"surfaceColor", "roadClassColor", "smoothnessColor"};
|
||||
|
||||
for (int i = 0; i < colorAttrNames.length; i++) {
|
||||
String colorAttrName = colorAttrNames[i];
|
||||
|
@ -86,7 +86,7 @@ public class RouteStatisticsHelper {
|
|||
RouteSegmentClass prev = null;
|
||||
for (RouteSegmentResult segment : route) {
|
||||
RouteSegmentClass current = getAttribute(segment);
|
||||
if (prev != null && !prev.className.equals(current.className)) {
|
||||
if (prev != null && prev.className != null && !prev.className.equals(current.className)) {
|
||||
index++;
|
||||
}
|
||||
if (index >= routes.size()) {
|
||||
|
@ -134,17 +134,17 @@ public class RouteStatisticsHelper {
|
|||
RouteDataObject obj = segment.getObject();
|
||||
int[] tps = obj.getTypes();
|
||||
String additional = "";
|
||||
for(int k = 0; k < tps.length; k++) {
|
||||
for (int k = 0; k < tps.length; k++) {
|
||||
BinaryMapRouteReaderAdapter.RouteTypeRule tp = obj.region.quickGetEncodingRule(tps[k]);
|
||||
if(tp.getTag().equals("highway") || tp.getTag().equals("route") ||
|
||||
if (tp.getTag().equals("highway") || tp.getTag().equals("route") ||
|
||||
tp.getTag().equals("railway") || tp.getTag().equals("aeroway") || tp.getTag().equals("aerialway")) {
|
||||
req.setStringFilter(rrs.PROPS.R_TAG, tp.getTag());
|
||||
req.setStringFilter(rrs.PROPS.R_TAG, tp.getValue());
|
||||
} else {
|
||||
if(additional.length() > 0) {
|
||||
if (additional.length() > 0) {
|
||||
additional += ";";
|
||||
}
|
||||
additional = tp.getTag() +"=" +tp.getValue();
|
||||
additional += tp.getTag() + "=" + tp.getValue();
|
||||
}
|
||||
}
|
||||
req.setStringFilter(rrs.PROPS.R_ADDITIONAL, additional);
|
||||
|
@ -153,20 +153,20 @@ public class RouteStatisticsHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static class RouteBoundariesStatisticComputer extends RouteStatisticComputer<Boundaries> {
|
||||
private static class RouteBoundariesStatisticComputer extends RouteStatisticComputer {
|
||||
|
||||
private final List<Incline> inclines;
|
||||
|
||||
public RouteBoundariesStatisticComputer(List<Incline> inclines, String attrName, String colorAttrName,
|
||||
public RouteBoundariesStatisticComputer(List<Incline> inclines, String colorAttrName,
|
||||
RenderingRulesStorage currentRenderer, RenderingRulesStorage defaultRenderer,
|
||||
RenderingRuleSearchRequest currentSearchRequest, RenderingRuleSearchRequest defaultSearchRequest) {
|
||||
super(null, attrName, colorAttrName, currentRenderer, defaultRenderer, currentSearchRequest, defaultSearchRequest);
|
||||
super(null, colorAttrName, currentRenderer, defaultRenderer, currentSearchRequest, defaultSearchRequest);
|
||||
this.inclines = inclines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteSegmentAttribute<Boundaries>> processRoute() {
|
||||
List<RouteSegmentAttribute<Boundaries>> routeInclines = new ArrayList<>();
|
||||
public List<RouteSegmentAttribute> processRoute() {
|
||||
List<RouteSegmentAttribute> routeInclines = new ArrayList<>();
|
||||
int index = 0;
|
||||
Boundaries prev = null;
|
||||
Incline prevIncline = null;
|
||||
|
@ -177,8 +177,8 @@ public class RouteStatisticsHelper {
|
|||
}
|
||||
if (index >= routeInclines.size()) {
|
||||
String propertyName = getPropertyName(current);
|
||||
int color = getColor(current);
|
||||
RouteSegmentAttribute<Boundaries> attribute = new RouteSegmentAttribute<>(index, current, propertyName, color);
|
||||
int color = 0;//getColor(current);
|
||||
RouteSegmentAttribute attribute = new RouteSegmentAttribute(index, propertyName, color);
|
||||
if (prevIncline != null) {
|
||||
attribute.setInitDistance(prevIncline.getDistance());
|
||||
}
|
||||
|
@ -193,11 +193,10 @@ public class RouteStatisticsHelper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boundaries getAttribute(RouteSegmentResult segment) {
|
||||
public RouteSegmentClass getAttribute(RouteSegmentResult segment) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyName(Boundaries attribute) {
|
||||
int lowerBoundary = Math.round(attribute.getLowerBoundary());
|
||||
int upperBoundary = Math.round(attribute.getUpperBoundary());
|
||||
|
@ -207,7 +206,6 @@ public class RouteStatisticsHelper {
|
|||
return String.format(Locale.US, "%d%% ... %d%%", lowerBoundary, upperBoundary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean searchRenderingAttribute(RenderingRulesStorage rrs, RenderingRuleSearchRequest req, Boundaries attribute) {
|
||||
int lowerBoundary = Math.round(attribute.getLowerBoundary());
|
||||
int upperBoundary = Math.round(attribute.getUpperBoundary());
|
||||
|
@ -223,8 +221,8 @@ public class RouteStatisticsHelper {
|
|||
range.append(lowerBoundary);
|
||||
range.append(upperBoundary < 0 ? "_" : "-");
|
||||
range.append(upperBoundary);
|
||||
String additional = attrName + "=" + range;
|
||||
req.setStringFilter(rrs.PROPS.R_ADDITIONAL, additional);
|
||||
//String additional = attrName + "=" + range;
|
||||
//req.setStringFilter(rrs.PROPS.R_ADDITIONAL, additional);
|
||||
return req.searchRenderingAttribute(colorAttrName);
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +433,7 @@ public class RouteStatisticsHelper {
|
|||
return elements;
|
||||
}
|
||||
|
||||
public Map<E, RouteSegmentAttribute> getPartition() {
|
||||
public Map<String, RouteSegmentAttribute> getPartition() {
|
||||
return partition;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ import net.osmand.plus.routing.RouteCalculationResult;
|
|||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.RouteStatisticsHelper;
|
||||
import net.osmand.router.RouteStatisticsHelper.RouteSegmentAttribute;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -1269,7 +1270,7 @@ public class GpxUiHelper {
|
|||
|
||||
public static <E> BarData buildStatisticChart(@NonNull OsmandApplication app,
|
||||
@NonNull HorizontalBarChart mChart,
|
||||
@NonNull RouteStatisticsHelper.RouteStatistics<E> routeStatistics,
|
||||
@NonNull RouteStatisticsHelper.RouteStatistics routeStatistics,
|
||||
@NonNull GPXTrackAnalysis analysis,
|
||||
boolean useRightAxis,
|
||||
boolean nightMode) {
|
||||
|
@ -1286,12 +1287,12 @@ public class GpxUiHelper {
|
|||
}
|
||||
float divX = setupAxisDistance(app, yAxis, analysis.totalDistance);
|
||||
|
||||
List<RouteStatisticsHelper.RouteSegmentAttribute<E>> segments = routeStatistics.getElements();
|
||||
List<RouteSegmentAttribute> segments = routeStatistics.getElements();
|
||||
List<BarEntry> entries = new ArrayList<>();
|
||||
float[] stacks = new float[segments.size()];
|
||||
int[] colors = new int[segments.size()];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
RouteStatisticsHelper.RouteSegmentAttribute segment = segments.get(i);
|
||||
RouteSegmentAttribute segment = segments.get(i);
|
||||
stacks[i] = segment.getDistance() / divX;
|
||||
colors[i] = segment.getColor();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.router.RouteStatisticsHelper;
|
||||
import net.osmand.router.RouteStatisticsHelper.Boundaries;
|
||||
import net.osmand.router.RouteStatisticsHelper.RouteSegmentAttribute;
|
||||
import net.osmand.router.RouteStatisticsHelper.RouteStatistics;
|
||||
|
@ -72,7 +71,7 @@ public class RouteInfoCard extends BaseCard {
|
|||
return (HorizontalBarChart) view.findViewById(R.id.chart);
|
||||
}
|
||||
|
||||
private <E> void updateContent(final RouteStatisticsHelper.RouteStatistics<E> routeStatistics) {
|
||||
private void updateContent(final RouteStatistics routeStatistics) {
|
||||
updateHeader();
|
||||
final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart);
|
||||
GpxUiHelper.setupHorizontalGPXChart(app, chart, 5, 9, 24, true, nightMode);
|
||||
|
@ -83,7 +82,7 @@ public class RouteInfoCard extends BaseCard {
|
|||
chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
List<RouteSegmentAttribute<E>> elems = routeStatistics.getElements();
|
||||
List<RouteSegmentAttribute> elems = routeStatistics.getElements();
|
||||
int i = h.getStackIndex();
|
||||
if (i >= 0 && elems.size() > i) {
|
||||
selectedPropertyName = elems.get(i).getPropertyName();
|
||||
|
@ -118,7 +117,7 @@ public class RouteInfoCard extends BaseCard {
|
|||
});
|
||||
}
|
||||
|
||||
protected <E> void updateLegend(RouteStatisticsHelper.RouteStatistics<E> routeStatistics) {
|
||||
protected void updateLegend(RouteStatistics routeStatistics) {
|
||||
LinearLayout container = (LinearLayout) view.findViewById(R.id.route_items);
|
||||
container.removeAllViews();
|
||||
attachLegend(container, routeStatistics);
|
||||
|
@ -153,14 +152,14 @@ public class RouteInfoCard extends BaseCard {
|
|||
return "000";
|
||||
}
|
||||
|
||||
private <E> void attachLegend(ViewGroup container, RouteStatisticsHelper.RouteStatistics<E> routeStatistics) {
|
||||
Map<E, RouteSegmentAttribute<E>> partition = routeStatistics.getPartition();
|
||||
List<Map.Entry<E, RouteSegmentAttribute<E>>> list = new ArrayList<>(partition.entrySet());
|
||||
private void attachLegend(ViewGroup container, RouteStatistics routeStatistics) {
|
||||
Map<String, RouteSegmentAttribute> partition = routeStatistics.getPartition();
|
||||
List<Map.Entry<String, RouteSegmentAttribute>> list = new ArrayList<>(partition.entrySet());
|
||||
sortRouteSegmentAttributes(list);
|
||||
ContextThemeWrapper ctx = new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||
LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||
for (Map.Entry<E, RouteSegmentAttribute<E>> entry : list) {
|
||||
RouteSegmentAttribute<E> segment = entry.getValue();
|
||||
for (Map.Entry<String, RouteSegmentAttribute> entry : list) {
|
||||
RouteSegmentAttribute segment = entry.getValue();
|
||||
View view = inflater.inflate(R.layout.route_details_legend, container, false);
|
||||
int segmentColor = segment.getColor();
|
||||
Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, segmentColor);
|
||||
|
@ -180,10 +179,10 @@ public class RouteInfoCard extends BaseCard {
|
|||
}
|
||||
}
|
||||
|
||||
private <E> void sortRouteSegmentAttributes(List<Map.Entry<E, RouteSegmentAttribute<E>>> list) {
|
||||
Collections.sort(list, new Comparator<Map.Entry<E, RouteSegmentAttribute<E>>>() {
|
||||
private void sortRouteSegmentAttributes(List<Map.Entry<String, RouteSegmentAttribute>> list) {
|
||||
Collections.sort(list, new Comparator<Map.Entry<String, RouteSegmentAttribute>>() {
|
||||
@Override
|
||||
public int compare(Map.Entry<E, RouteSegmentAttribute<E>> o1, Map.Entry<E, RouteSegmentAttribute<E>> o2) {
|
||||
public int compare(Map.Entry<String, RouteSegmentAttribute> o1, Map.Entry<String, RouteSegmentAttribute> o2) {
|
||||
Object key1 = o1.getKey();
|
||||
Object key2 = o2.getKey();
|
||||
if (key1 instanceof String && key2 instanceof String) {
|
||||
|
|
Loading…
Reference in a new issue