Fix issues
This commit is contained in:
parent
6a9e6b89a0
commit
f62a349b47
1 changed files with 39 additions and 14 deletions
|
@ -1,6 +1,9 @@
|
||||||
package net.osmand.router;
|
package net.osmand.router;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
@ -58,7 +61,7 @@ public class RouteStatisticsHelper {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder s = new StringBuilder("Statistic '").append(name).append("':");
|
StringBuilder s = new StringBuilder("Statistic '").append(name).append("':");
|
||||||
for (RouteSegmentAttribute a : elements) {
|
for (RouteSegmentAttribute a : elements) {
|
||||||
s.append(String.format(" %.2fm %s,", a.distance, a.propertyName));
|
s.append(String.format(" %.0fm %s,", a.distance, a.getUserPropertyName()));
|
||||||
}
|
}
|
||||||
s.append("\n Partition: ").append(partition);
|
s.append("\n Partition: ").append(partition);
|
||||||
return s.toString();
|
return s.toString();
|
||||||
|
@ -260,7 +263,20 @@ public class RouteStatisticsHelper {
|
||||||
}
|
}
|
||||||
attr.incrementDistanceBy(attribute.getDistance());
|
attr.incrementDistanceBy(attribute.getDistance());
|
||||||
}
|
}
|
||||||
return partition;
|
List<String> keys = new ArrayList<String>(partition.keySet());
|
||||||
|
Collections.sort(keys, new Comparator<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
return -Float.compare(partition.get(o1).getDistance(), partition.get(o2).getDistance());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Map<String, RouteSegmentAttribute> sorted = new LinkedHashMap<String, RouteStatisticsHelper.RouteSegmentAttribute>();
|
||||||
|
for(String k : keys ) {
|
||||||
|
sorted.put(k, partition.get(k));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float computeTotalDistance(List<RouteSegmentAttribute> attributes) {
|
private float computeTotalDistance(List<RouteSegmentAttribute> attributes) {
|
||||||
|
@ -298,11 +314,12 @@ public class RouteStatisticsHelper {
|
||||||
prev.getPropertyName().equals(current.getPropertyName())) {
|
prev.getPropertyName().equals(current.getPropertyName())) {
|
||||||
prev.incrementDistanceBy(current.distance);
|
prev.incrementDistanceBy(current.distance);
|
||||||
} else {
|
} else {
|
||||||
|
if(segment.slopeClass[i].endsWith(current.propertyName)) {
|
||||||
|
current.setUserPropertyName(segment.slopeClassUserString[i]);
|
||||||
|
}
|
||||||
routes.add(current);
|
routes.add(current);
|
||||||
prev = current;
|
prev = current;
|
||||||
}
|
}
|
||||||
// TODO pass slope user name
|
|
||||||
// prev.propertyUserName = segment.slopeClassUserString;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +338,8 @@ public class RouteStatisticsHelper {
|
||||||
} else {
|
} else {
|
||||||
RenderingRuleSearchRequest defaultRequest = new RenderingRuleSearchRequest(defaultRenderingRuleSearchRequest);
|
RenderingRuleSearchRequest defaultRequest = new RenderingRuleSearchRequest(defaultRenderingRuleSearchRequest);
|
||||||
if (searchRenderingAttribute(attribute, defaultRenderer, defaultRequest, segment, slopeClass)) {
|
if (searchRenderingAttribute(attribute, defaultRenderer, defaultRequest, segment, slopeClass)) {
|
||||||
res = new RouteSegmentAttribute(defaultRequest.getStringPropertyValue(defaultRenderer.PROPS.R_ATTR_STRING_VALUE),
|
res = new RouteSegmentAttribute(
|
||||||
|
defaultRequest.getStringPropertyValue(defaultRenderer.PROPS.R_ATTR_STRING_VALUE),
|
||||||
defaultRequest.getIntPropertyValue(defaultRenderer.PROPS.R_ATTR_COLOR_VALUE));
|
defaultRequest.getIntPropertyValue(defaultRenderer.PROPS.R_ATTR_COLOR_VALUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,10 +360,11 @@ public class RouteStatisticsHelper {
|
||||||
req.setStringFilter(rrs.PROPS.R_TAG, tp.getTag());
|
req.setStringFilter(rrs.PROPS.R_TAG, tp.getTag());
|
||||||
req.setStringFilter(rrs.PROPS.R_VALUE, tp.getValue());
|
req.setStringFilter(rrs.PROPS.R_VALUE, tp.getValue());
|
||||||
} else {
|
} else {
|
||||||
if (additional.length() > 0) {
|
// TODO
|
||||||
additional += ";";
|
// if (additional.length() > 0) {
|
||||||
}
|
// additional += ";";
|
||||||
additional += tp.getTag() + "=" + tp.getValue();
|
// }
|
||||||
|
// additional += tp.getTag() + "=" + tp.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.setStringFilter(rrs.PROPS.R_ADDITIONAL, additional);
|
req.setStringFilter(rrs.PROPS.R_ADDITIONAL, additional);
|
||||||
|
@ -358,6 +377,7 @@ public class RouteStatisticsHelper {
|
||||||
private final int color;
|
private final int color;
|
||||||
private final String propertyName;
|
private final String propertyName;
|
||||||
private float distance;
|
private float distance;
|
||||||
|
private String userPropertyName;
|
||||||
|
|
||||||
RouteSegmentAttribute(String propertyName, int color) {
|
RouteSegmentAttribute(String propertyName, int color) {
|
||||||
this.propertyName = propertyName == null ? UNDEFINED_ATTR : propertyName;
|
this.propertyName = propertyName == null ? UNDEFINED_ATTR : propertyName;
|
||||||
|
@ -367,6 +387,15 @@ public class RouteStatisticsHelper {
|
||||||
RouteSegmentAttribute(RouteSegmentAttribute segmentAttribute) {
|
RouteSegmentAttribute(RouteSegmentAttribute segmentAttribute) {
|
||||||
this.propertyName = segmentAttribute.getPropertyName();
|
this.propertyName = segmentAttribute.getPropertyName();
|
||||||
this.color = segmentAttribute.getColor();
|
this.color = segmentAttribute.getColor();
|
||||||
|
this.userPropertyName = segmentAttribute.userPropertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserPropertyName() {
|
||||||
|
return userPropertyName == null ? propertyName : userPropertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserPropertyName(String userPropertyName) {
|
||||||
|
this.userPropertyName = userPropertyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDistance() {
|
public float getDistance() {
|
||||||
|
@ -387,11 +416,7 @@ public class RouteStatisticsHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RouteSegmentAttribute{" +
|
return String.format("%s - %.0f m %d", getUserPropertyName(), getDistance(), getColor());
|
||||||
"propertyName='" + propertyName + '\'' +
|
|
||||||
", color='" + color + '\'' +
|
|
||||||
", distance=" + distance +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue