2018-10-26 18:07:14 +02:00
|
|
|
package net.osmand.router;
|
|
|
|
|
2018-10-31 17:00:07 +01:00
|
|
|
import java.util.*;
|
2018-10-26 18:07:14 +02:00
|
|
|
|
|
|
|
public class RouteStatistics {
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
private final List<RouteSegmentResult> route;
|
|
|
|
|
|
|
|
private RouteStatistics(List<RouteSegmentResult> route) {
|
|
|
|
this.route = route;
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
2018-10-26 18:07:14 +02:00
|
|
|
|
2018-10-31 17:00:07 +01:00
|
|
|
public static RouteStatistics newRouteStatistic(List<RouteSegmentResult> route) {
|
2018-11-02 17:33:33 +01:00
|
|
|
return new RouteStatistics(route);
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:29:10 +01:00
|
|
|
public Statistics getRouteSurfaceStatistic() {
|
2018-11-02 17:33:33 +01:00
|
|
|
RouteStatisticComputer statisticComputer = new RouteSurfaceStatisticComputer(route);
|
|
|
|
return statisticComputer.computeStatistic();
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:29:10 +01:00
|
|
|
public Statistics getRouteSmoothnessStatistic() {
|
2018-11-02 17:33:33 +01:00
|
|
|
RouteStatisticComputer statisticComputer = new RouteSmoothnessStatisticComputer(route);
|
|
|
|
return statisticComputer.computeStatistic();
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:29:10 +01:00
|
|
|
public Statistics getRouteClassStatistic() {
|
2018-11-02 17:33:33 +01:00
|
|
|
RouteStatisticComputer statisticComputer = new RouteClassStatisticComputer(route);
|
|
|
|
return statisticComputer.computeStatistic();
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public Statistics getRouteSteepnessStatistic(List<Incline> inclines) {
|
|
|
|
RouteStatisticComputer statisticComputer = new RouteSteepnessStatisticComputer(inclines);
|
2018-11-02 17:33:33 +01:00
|
|
|
return statisticComputer.computeStatistic();
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 17:00:07 +01:00
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
private abstract static class RouteStatisticComputer {
|
|
|
|
|
2018-10-31 17:00:07 +01:00
|
|
|
private final List<RouteSegmentResult> route;
|
|
|
|
|
|
|
|
public RouteStatisticComputer(List<RouteSegmentResult> route) {
|
2018-11-13 17:37:42 +01:00
|
|
|
this.route = route;
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
protected Map<String, RouteSegmentAttribute> makePartition(List<RouteSegmentAttribute> routeAttributes) {
|
|
|
|
Map<String, RouteSegmentAttribute> partition = new TreeMap<>();
|
2018-11-02 17:33:33 +01:00
|
|
|
for (RouteSegmentAttribute attribute : routeAttributes) {
|
|
|
|
String key = attribute.getAttribute();
|
|
|
|
RouteSegmentAttribute pattr = partition.get(key);
|
|
|
|
if (pattr == null) {
|
2018-11-13 17:37:42 +01:00
|
|
|
pattr = new RouteSegmentAttribute(attribute.getIndex(), attribute.getAttribute(), attribute.getColorAttrName());
|
2018-11-02 17:33:33 +01:00
|
|
|
partition.put(key, pattr);
|
|
|
|
}
|
|
|
|
pattr.incrementDistanceBy(attribute.getDistance());
|
|
|
|
}
|
|
|
|
return partition;
|
|
|
|
}
|
|
|
|
|
|
|
|
private float computeTotalDistance(List<RouteSegmentAttribute> attributes) {
|
|
|
|
float distance = 0f;
|
|
|
|
for (RouteSegmentAttribute attribute : attributes) {
|
|
|
|
distance += attribute.getDistance();
|
|
|
|
}
|
|
|
|
return distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected List<RouteSegmentResult> getRoute() {
|
2018-10-31 17:00:07 +01:00
|
|
|
return route;
|
|
|
|
}
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
protected List<RouteSegmentAttribute> processRoute() {
|
2018-10-26 18:07:14 +02:00
|
|
|
int index = 0;
|
2018-11-02 17:33:33 +01:00
|
|
|
List<RouteSegmentAttribute> routes = new ArrayList<>();
|
2018-10-26 18:07:14 +02:00
|
|
|
String prev = null;
|
2018-10-31 17:00:07 +01:00
|
|
|
for (RouteSegmentResult segment : getRoute()) {
|
2018-10-26 18:07:14 +02:00
|
|
|
String current = getAttribute(segment);
|
|
|
|
if (prev != null && !prev.equals(current)) {
|
|
|
|
index++;
|
|
|
|
}
|
2018-11-02 17:33:33 +01:00
|
|
|
if (index >= routes.size()) {
|
2018-11-13 17:37:42 +01:00
|
|
|
String colorAttrName = determineColor(current);
|
|
|
|
routes.add(new RouteSegmentAttribute(index, current, colorAttrName));
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
2018-11-02 17:33:33 +01:00
|
|
|
RouteSegmentAttribute surface = routes.get(index);
|
2018-10-26 18:07:14 +02:00
|
|
|
surface.incrementDistanceBy(segment.getDistance());
|
|
|
|
prev = current;
|
|
|
|
}
|
2018-11-02 17:33:33 +01:00
|
|
|
return routes;
|
|
|
|
}
|
|
|
|
|
2018-11-05 16:29:10 +01:00
|
|
|
public Statistics computeStatistic() {
|
2018-11-02 17:33:33 +01:00
|
|
|
List<RouteSegmentAttribute> routeAttributes = processRoute();
|
|
|
|
Map<String, RouteSegmentAttribute> partition = makePartition(routeAttributes);
|
|
|
|
float totalDistance = computeTotalDistance(routeAttributes);
|
2018-11-05 16:29:10 +01:00
|
|
|
return new Statistics(routeAttributes, partition, totalDistance);
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public abstract String getAttribute(RouteSegmentResult segment);
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public abstract String determineColor(String attribute);
|
2018-10-26 18:07:14 +02:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
}
|
2018-11-02 17:33:33 +01:00
|
|
|
|
|
|
|
private static class RouteSurfaceStatisticComputer extends RouteStatisticComputer {
|
|
|
|
|
|
|
|
public RouteSurfaceStatisticComputer(List<RouteSegmentResult> route) {
|
2018-10-31 17:00:07 +01:00
|
|
|
super(route);
|
|
|
|
}
|
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
@Override
|
|
|
|
public String getAttribute(RouteSegmentResult segment) {
|
2018-10-31 17:00:07 +01:00
|
|
|
String segmentSurface = segment.getSurface();
|
|
|
|
if (segmentSurface == null) {
|
2018-11-13 17:37:42 +01:00
|
|
|
return RoadSurface.UNDEFINED.name().toLowerCase();
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
for (RoadSurface roadSurface : RoadSurface.values()) {
|
|
|
|
if (roadSurface.contains(segmentSurface)) {
|
|
|
|
return roadSurface.name().toLowerCase();
|
|
|
|
}
|
|
|
|
}
|
2018-11-13 17:37:42 +01:00
|
|
|
return RoadSurface.UNDEFINED.name().toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String determineColor(String attribute) {
|
|
|
|
RoadSurface roadSurface = RoadSurface.valueOf(attribute.toUpperCase());
|
|
|
|
return roadSurface.getColorAttrName();
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
private static class RouteSmoothnessStatisticComputer extends RouteStatisticComputer {
|
2018-10-26 18:07:14 +02:00
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
public RouteSmoothnessStatisticComputer(List<RouteSegmentResult> route) {
|
2018-10-31 17:00:07 +01:00
|
|
|
super(route);
|
|
|
|
}
|
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
@Override
|
|
|
|
public String getAttribute(RouteSegmentResult segment) {
|
2018-11-13 17:37:42 +01:00
|
|
|
String segmentSmoothness = segment.getSurface();
|
|
|
|
if (segmentSmoothness == null) {
|
|
|
|
return RoadSmoothness.UNDEFINED.name().toLowerCase();
|
|
|
|
}
|
|
|
|
for (RoadSmoothness roadSmoothness : RoadSmoothness.values()) {
|
|
|
|
if (roadSmoothness.contains(segmentSmoothness)) {
|
|
|
|
return roadSmoothness.name().toLowerCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return RoadSmoothness.UNDEFINED.name().toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String determineColor(String attribute) {
|
|
|
|
RoadSmoothness roadSmoothness = RoadSmoothness.valueOf(attribute.toUpperCase());
|
|
|
|
return roadSmoothness.getColorAttrName();
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
private static class RouteClassStatisticComputer extends RouteStatisticComputer {
|
|
|
|
|
|
|
|
public RouteClassStatisticComputer(List<RouteSegmentResult> route) {
|
2018-10-31 17:00:07 +01:00
|
|
|
super(route);
|
|
|
|
}
|
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
@Override
|
|
|
|
public String getAttribute(RouteSegmentResult segment) {
|
2018-10-31 17:00:07 +01:00
|
|
|
String segmentClass = segment.getHighway();
|
|
|
|
if (segmentClass == null) {
|
2018-11-13 17:37:42 +01:00
|
|
|
return RoadClass.UNDEFINED.name().toLowerCase();
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
for (RoadClass roadClass : RoadClass.values()) {
|
|
|
|
if (roadClass.contains(segmentClass)) {
|
|
|
|
return roadClass.name().toLowerCase();
|
|
|
|
}
|
|
|
|
}
|
2018-11-13 17:37:42 +01:00
|
|
|
return RoadClass.UNDEFINED.name().toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String determineColor(String attribute) {
|
|
|
|
RoadClass roadClass = RoadClass.valueOf(attribute.toUpperCase());
|
|
|
|
return roadClass.getColorAttrName();
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
private static class RouteSteepnessStatisticComputer extends RouteStatisticComputer {
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
private static final String POSITIVE_INCLINE_COLOR_ATTR_NAME = "greenColor";
|
|
|
|
private static final String NEGATIVE_INCLINE_COLOR_ATTR_NAME = "redColor";
|
2018-10-31 17:00:07 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
private final List<Incline> inclines;
|
2018-10-31 17:00:07 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public RouteSteepnessStatisticComputer(List<Incline> inclines) {
|
|
|
|
super(null);
|
|
|
|
this.inclines = inclines;
|
2018-11-02 17:33:33 +01:00
|
|
|
}
|
2018-10-31 17:00:07 +01:00
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
@Override
|
|
|
|
public List<RouteSegmentAttribute> processRoute() {
|
|
|
|
List<RouteSegmentAttribute> routeInclines = new ArrayList<>();
|
|
|
|
int index = 0;
|
|
|
|
String prev = null;
|
2018-11-13 17:37:42 +01:00
|
|
|
Incline prevIncline = null;
|
|
|
|
for (Incline incline : inclines) {
|
2018-11-02 17:33:33 +01:00
|
|
|
String current = incline.getBoundariesAsString();
|
|
|
|
if (prev != null && !prev.equals(current)) {
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
if (index >= routeInclines.size()) {
|
2018-11-13 17:37:42 +01:00
|
|
|
String colorAttrName = determineColor(incline);
|
|
|
|
RouteSegmentAttribute attribute = new RouteSegmentAttribute(index, current, colorAttrName);
|
|
|
|
if (
|
|
|
|
//index > 0 &&
|
|
|
|
prevIncline != null) {
|
|
|
|
attribute.setInitDistance(prevIncline.getDistance());
|
|
|
|
}
|
|
|
|
routeInclines.add(attribute);
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
2018-11-02 17:33:33 +01:00
|
|
|
RouteSegmentAttribute routeIncline = routeInclines.get(index);
|
2018-11-13 17:37:42 +01:00
|
|
|
routeIncline.relativeSum(incline.getDistance());
|
2018-11-02 17:33:33 +01:00
|
|
|
prev = current;
|
2018-11-13 17:37:42 +01:00
|
|
|
prevIncline = incline;
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
return routeInclines;
|
|
|
|
}
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
@Override
|
|
|
|
public String getAttribute(RouteSegmentResult segment) {
|
|
|
|
return null;
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
@Override
|
|
|
|
public String determineColor(String attribute) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String determineColor(Incline incline) {
|
|
|
|
float value = incline.getValue();
|
|
|
|
return value >= 0 ? POSITIVE_INCLINE_COLOR_ATTR_NAME : NEGATIVE_INCLINE_COLOR_ATTR_NAME;
|
|
|
|
}
|
|
|
|
}
|
2018-10-26 18:07:14 +02:00
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
public static class RouteSegmentAttribute {
|
|
|
|
|
|
|
|
private final int index;
|
|
|
|
private final String attribute;
|
2018-11-13 17:37:42 +01:00
|
|
|
private final String colorAttrName;
|
2018-10-26 18:07:14 +02:00
|
|
|
|
|
|
|
private float distance;
|
2018-11-13 17:37:42 +01:00
|
|
|
private float initDistance;
|
2018-10-26 18:07:14 +02:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public RouteSegmentAttribute(int index, String attribute, String colorAttrName) {
|
2018-10-26 18:07:14 +02:00
|
|
|
this.index = index;
|
|
|
|
this.attribute = attribute;
|
2018-11-13 17:37:42 +01:00
|
|
|
this.colorAttrName = colorAttrName;
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getIndex() {
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAttribute() {
|
|
|
|
return attribute;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getDistance() {
|
|
|
|
return distance;
|
|
|
|
}
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public void setInitDistance(float initDistance) {
|
|
|
|
this.initDistance = initDistance;
|
|
|
|
}
|
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
public void incrementDistanceBy(float distance) {
|
|
|
|
this.distance += distance;
|
|
|
|
}
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public void relativeSum(float distance) {
|
|
|
|
this.distance = this.distance + ((distance - this.initDistance) - this.distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getColorAttrName() {
|
|
|
|
return colorAttrName;
|
|
|
|
}
|
|
|
|
|
2018-10-26 18:07:14 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-11-13 17:37:42 +01:00
|
|
|
return "RouteSegmentAttribute{" +
|
2018-10-26 18:07:14 +02:00
|
|
|
"index=" + index +
|
|
|
|
", attribute='" + attribute + '\'' +
|
2018-11-13 17:37:42 +01:00
|
|
|
", colorAttrName='" + colorAttrName + '\'' +
|
2018-10-26 18:07:14 +02:00
|
|
|
", distance=" + distance +
|
|
|
|
'}';
|
|
|
|
}
|
|
|
|
}
|
2018-10-31 17:00:07 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public static class Incline {
|
2018-10-31 17:00:07 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
private float inclineValue;
|
2018-11-02 17:33:33 +01:00
|
|
|
private final float distance;
|
2018-11-13 17:37:42 +01:00
|
|
|
private final Boundaries boundaries;
|
2018-11-02 17:33:33 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public Incline(float inclineValue, float distance) {
|
2018-11-02 17:33:33 +01:00
|
|
|
this.inclineValue = inclineValue;
|
|
|
|
this.distance = distance;
|
2018-11-13 17:37:42 +01:00
|
|
|
this.boundaries = Boundaries.newBoundariesFor(inclineValue);
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public float getValue() {
|
2018-11-02 17:33:33 +01:00
|
|
|
return inclineValue;
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
|
2018-11-02 17:33:33 +01:00
|
|
|
public float getDistance() {
|
|
|
|
return distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getBoundariesAsString() {
|
2018-11-13 17:37:42 +01:00
|
|
|
return String.format("%d-%d", Math.round(boundaries.getLowerBoundary()), Math.round(boundaries.getUpperBoundary()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Boundaries getBoundaries() {
|
|
|
|
return this.boundaries;
|
2018-10-31 17:00:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2018-11-02 17:33:33 +01:00
|
|
|
return "Incline{" +
|
|
|
|
", incline=" + inclineValue +
|
|
|
|
", distance=" + distance +
|
2018-10-31 17:00:07 +01:00
|
|
|
'}';
|
|
|
|
}
|
|
|
|
}
|
2018-11-05 16:29:10 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
public static class Boundaries implements Comparable<Boundaries> {
|
|
|
|
|
|
|
|
private static final int MIN_INCLINE = -100;
|
|
|
|
private static final int MAX_INCLINE = 100;
|
|
|
|
private static final int STEP = 4;
|
|
|
|
private static final int NUM;
|
|
|
|
private static final int[] BOUNDARIES;
|
|
|
|
|
|
|
|
static {
|
|
|
|
NUM = (int) ((MAX_INCLINE - MIN_INCLINE) / STEP + 1);
|
|
|
|
BOUNDARIES = new int[NUM];
|
|
|
|
for (int i = 0; i < NUM; i++) {
|
|
|
|
BOUNDARIES[i] = MIN_INCLINE + i * STEP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final float upperBoundary;
|
|
|
|
private final float lowerBoundary;
|
|
|
|
|
|
|
|
private Boundaries(float upperBoundary, float lowerBoundary) {
|
|
|
|
this.upperBoundary = upperBoundary;
|
|
|
|
this.lowerBoundary = lowerBoundary;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Boundaries newBoundariesFor(float incline) {
|
|
|
|
if (incline > MAX_INCLINE) {
|
|
|
|
return new Boundaries(MAX_INCLINE, MAX_INCLINE - STEP);
|
|
|
|
}
|
|
|
|
if (incline < MIN_INCLINE) {
|
|
|
|
return new Boundaries(MIN_INCLINE + STEP, MIN_INCLINE);
|
|
|
|
}
|
|
|
|
for (int i = 1; i < NUM; i++) {
|
|
|
|
if (incline >= BOUNDARIES[i - 1] && incline < BOUNDARIES[i]) {
|
|
|
|
return new Boundaries(BOUNDARIES[i], BOUNDARIES[i - 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getUpperBoundary() {
|
|
|
|
return upperBoundary;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getLowerBoundary() {
|
|
|
|
return lowerBoundary;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
|
|
Boundaries that = (Boundaries) o;
|
|
|
|
|
|
|
|
if (Float.compare(that.upperBoundary, upperBoundary) != 0) return false;
|
|
|
|
return Float.compare(that.lowerBoundary, lowerBoundary) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
int result = (upperBoundary != +0.0f ? Float.floatToIntBits(upperBoundary) : 0);
|
|
|
|
result = 31 * result + (lowerBoundary != +0.0f ? Float.floatToIntBits(lowerBoundary) : 0);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(Boundaries boundaries) {
|
|
|
|
return (int) (getLowerBoundary() - boundaries.getLowerBoundary());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 16:29:10 +01:00
|
|
|
public static class Statistics {
|
|
|
|
|
|
|
|
private final List<RouteSegmentAttribute> elements;
|
|
|
|
private final Map<String, RouteSegmentAttribute> partition;
|
|
|
|
private final float totalDistance;
|
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
private Statistics(List<RouteSegmentAttribute> elements,
|
2018-11-05 16:29:10 +01:00
|
|
|
Map<String, RouteSegmentAttribute> partition,
|
|
|
|
float totalDistance) {
|
|
|
|
this.elements = elements;
|
|
|
|
this.partition = partition;
|
|
|
|
this.totalDistance = totalDistance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getTotalDistance() {
|
|
|
|
return totalDistance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<RouteSegmentAttribute> getElements() {
|
2018-11-13 17:37:42 +01:00
|
|
|
return elements;
|
2018-11-05 16:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Map<String, RouteSegmentAttribute> getPartition() {
|
2018-11-13 17:37:42 +01:00
|
|
|
return partition;
|
2018-11-05 16:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum RoadClass {
|
2018-11-13 17:37:42 +01:00
|
|
|
UNDEFINED("whitewaterSectionGrade0Color", "undefined"),
|
|
|
|
MOTORWAY("motorwayRoadColor", "motorway", "motorway_link"),
|
|
|
|
STATE_ROAD("trunkRoadColor" , "trunk", "trunk_link", "primary", "primary_link"),
|
|
|
|
ROAD("secondaryRoadColor", "secondary", "secondary_link", "tertiary", "tertiary_link", "unclassified"),
|
|
|
|
STREET("residentialRoadColor" ,"residential", "living_street"),
|
|
|
|
SERVICE("serviceRoadColor", "service"),
|
|
|
|
TRACK("trackColor", "track", "road"),
|
|
|
|
FOOTWAY("footwayColor", "footway"),
|
|
|
|
PATH("pathColor", "path"),
|
|
|
|
CYCLE_WAY("cyclewayColor", "cycleway");
|
2018-11-05 16:29:10 +01:00
|
|
|
|
|
|
|
final Set<String> roadClasses = new TreeSet<>();
|
2018-11-13 17:37:42 +01:00
|
|
|
final String colorAttrName;
|
2018-11-05 16:29:10 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
RoadClass(String colorAttrName, String... classes) {
|
2018-11-05 16:29:10 +01:00
|
|
|
roadClasses.addAll(Arrays.asList(classes));
|
2018-11-13 17:37:42 +01:00
|
|
|
this.colorAttrName = colorAttrName;
|
2018-11-05 16:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean contains(String roadClass) {
|
|
|
|
return roadClasses.contains(roadClass);
|
|
|
|
}
|
2018-11-13 17:37:42 +01:00
|
|
|
|
|
|
|
String getColorAttrName() {
|
|
|
|
return colorAttrName;
|
|
|
|
}
|
2018-11-05 16:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public enum RoadSurface {
|
2018-11-13 17:37:42 +01:00
|
|
|
UNDEFINED("whitewaterSectionGrade0Color", "undefined"),
|
|
|
|
PAVED("motorwayRoadColor", "paved"),
|
|
|
|
UNPAVED("motorwayRoadShadowColor", "unpaved"),
|
|
|
|
ASPHALT("trunkRoadColor", "asphalt"),
|
|
|
|
CONCRETE("primaryRoadColor", "concrete"),
|
|
|
|
COMPACTED("secondaryRoadColor", "compacted"),
|
|
|
|
GRAVEL("tertiaryRoadColor", "gravel"),
|
|
|
|
FINE_GRAVEL("residentialRoadColor", "fine_gravel"),
|
|
|
|
PAVING_STONES("serviceRoadColor", "paving_stones"),
|
|
|
|
SETT("roadRoadColor", "sett"),
|
|
|
|
COBBLESTONE("pedestrianRoadColor", "cobblestone"),
|
|
|
|
PEBBLESTONE("racewayColor", "pebblestone"),
|
|
|
|
STONE("trackColor", "stone"),
|
|
|
|
METAL("footwayColor", "metal"),
|
|
|
|
GROUND("pathColor", "ground", "mud"),
|
|
|
|
WOOD("cycleRouteColor", "wood"),
|
|
|
|
GRASS_PAVER("osmcBlackColor", "grass_paver"),
|
|
|
|
GRASS("osmcBlueColor", "grass"),
|
|
|
|
SAND("osmcGreenColor", "sand"),
|
|
|
|
SALT("osmcRedColor", "salt"),
|
|
|
|
SNOW("osmcYellowColor", "snow"),
|
|
|
|
ICE("osmcOrangeColor", "ice"),
|
|
|
|
CLAY("osmcBrownColor", "clay");
|
2018-11-05 16:29:10 +01:00
|
|
|
|
|
|
|
final Set<String> surfaces = new TreeSet<>();
|
2018-11-13 17:37:42 +01:00
|
|
|
final String colorAttrName;
|
2018-11-05 16:29:10 +01:00
|
|
|
|
2018-11-13 17:37:42 +01:00
|
|
|
RoadSurface(String colorAttrName, String... surfaces) {
|
2018-11-05 16:29:10 +01:00
|
|
|
this.surfaces.addAll(Arrays.asList(surfaces));
|
2018-11-13 17:37:42 +01:00
|
|
|
this.colorAttrName = colorAttrName;
|
2018-11-05 16:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean contains(String surface) {
|
|
|
|
return surfaces.contains(surface);
|
|
|
|
}
|
2018-11-13 17:37:42 +01:00
|
|
|
|
|
|
|
public String getColorAttrName() {
|
|
|
|
return this.colorAttrName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum RoadSmoothness {
|
|
|
|
UNDEFINED("redColor", "undefined"),
|
|
|
|
EXCELLENT("orangeColor", "excellent"),
|
|
|
|
GOOD("brownColor", "good"),
|
|
|
|
INTERMEDIATE("darkyellowColor", "intermediate"),
|
|
|
|
BAD("yellowColor", "bad"),
|
|
|
|
VERY_BAD("lightgreenColor", "very_bad"),
|
|
|
|
HORRIBLE("greenColor", "horrible"),
|
|
|
|
VERY_HORRIBLE("lightblueColor", "very_horrible"),
|
|
|
|
IMPASSABLE("blueColor", "impassable");
|
|
|
|
|
|
|
|
final Set<String> surfaces = new TreeSet<>();
|
|
|
|
final String colorAttrName;
|
|
|
|
|
|
|
|
RoadSmoothness(String colorAttrName, String... surfaces) {
|
|
|
|
this.surfaces.addAll(Arrays.asList(surfaces));
|
|
|
|
this.colorAttrName = colorAttrName;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean contains(String surface) {
|
|
|
|
return surfaces.contains(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getColorAttrName() {
|
|
|
|
return this.colorAttrName;
|
|
|
|
}
|
2018-11-05 16:29:10 +01:00
|
|
|
}
|
2018-10-26 18:07:14 +02:00
|
|
|
}
|