Here is a possible patch for maxspeed.
Around here lots of roads have been tagged with their speed limit (which
is 60mph). However, these are unclassified roads and you are unlikely to
get above 40mph. At the moment the default behaviour of mkgmap is set
overide the style file for these roads and set the road class
appropriate to 60mph, which is too fast.
I could turn on ignore-maxspeeds which would fix these roads but in turn
that would result in the trunk roads in town getting too high a speed.
The patch attempts to overcome this by offerring an extra option for
ignore-maxspeed, so the options become
[Default] - Use maxspeed if it exists, otherwise Road Class from the style
"ignore-maxspeeds" - Use road class from the style file
"ignore-maxspeeds:0" - Use road class from the style file
"ignore-maxspeeds:1" - Use maxspeed from the style file
"ignore-maxspeeds:2" - Use the lower of road class and maxspeed
Effectively option 2 solves my problem. The other numbered options are
there to reproduce existing behaviour using a number. The non-numbered
option is to keep compatiblity with existing code.
Note:
- This is the first patch I've done so I might have gone about it
completely the wrong way. If so I'm sorry and please give me some hints
- It is also the first Java code I've ever edited so I might have done
something wrong! All I can say is that it worked for me !
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (revision 1145)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (working copy)
@@ -100,7 +100,7 @@
private final Rule nodeRules;
private final Rule relationRules;
- private boolean ignoreMaxspeeds;
+ private int ignoreMaxspeeds=1;
class AccessMapping {
private final String type;
@@ -141,8 +141,17 @@
wayRules = style.getWayRules();
nodeRules = style.getNodeRules();
relationRules = style.getRelationRules();
- ignoreMaxspeeds = props.getProperty("ignore-maxspeeds") != null;
+ String ignoreMaxspeedsPar =
props.getProperty("ignore-maxspeeds", null);
+ if(ignoreMaxspeedsPar != null){
+ try {
+ ignoreMaxspeeds =
Integer.parseInt(ignoreMaxspeedsPar);
+ }
+ catch (Exception e) {
+ ignoreMaxspeeds = 0;
+ }
+ }
+
LineAdder overlayAdder = style.getOverlays(lineAdder);
if (overlayAdder != null)
lineAdder = overlayAdder;
@@ -903,17 +912,28 @@
}
int speedIdx = -1;
- if(!ignoreMaxspeeds) {
- // maxspeed attribute overrides default for road type
- String maxSpeed = way.getTag("maxspeed");
- if(maxSpeed != null) {
- speedIdx = getSpeedIdx(maxSpeed);
- log.info(debugWayName + " maxspeed=" + maxSpeed
+ ", speedIndex=" + speedIdx);
- }
+ String maxSpeed;
+ switch(ignoreMaxspeeds)
+ {
+ case 0:
+ // Use the style file and ignore the maxspeed tag
+ road.setSpeed(gt.getRoadSpeed());
+ break;
+ case 1:
+ // Use maxspeed tag, only use the style file if
maxspeed is missing (the default if ignoreMaxspeeds is not defined)
+ maxSpeed = way.getTag("maxspeed");
+ if(maxSpeed!=null) speedIdx = getSpeedIdx(maxSpeed);
+ road.setSpeed(speedIdx >= 0? speedIdx :
gt.getRoadSpeed());
+ break;
+
+ case 2:
+ // Use the lower of the maxspeed tag and the style file
value
+ maxSpeed = way.getTag("maxspeed");
+ if(maxSpeed!=null) speedIdx = getSpeedIdx(maxSpeed);
+ road.setSpeed(speedIdx >= 0?
Math.min(gt.getRoadSpeed(),speedIdx ) : gt.getRoadSpeed());
+ break;
}
- road.setSpeed(speedIdx >= 0? speedIdx : gt.getRoadSpeed());
-
boolean[] noAccess = new boolean[RoadNetwork.NO_MAX];
String highwayType = way.getTag("highway");
if(highwayType == null) {
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev