Mark Burton schrieb:
> Spotted the problem, some of the patch is relative to 1143 and some of
> it relative to 1148. Don't know how you managed that. Perhaps an svn
> wizard can help.
Ok, I tried a different button in svn and now got a patch relative 1143
only. Is this one better usable?
Gruss
Torsten
Index: src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/SequenceRule.java (Arbeitskopie)
@@ -34,9 +34,9 @@
public class SequenceRule implements Rule, Iterable<Rule> {
private final List<Rule> ruleList = new ArrayList<Rule>();
- public GType resolveType(Element el) {
+ public GType resolveType(Element el, GType pre) {
for (Rule r : ruleList) {
- GType type = r.resolveType(el);
+ GType type = r.resolveType(el, pre);
if (type != null)
return type;
}
Index: src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java (Arbeitskopie)
@@ -23,6 +23,9 @@
}
public GType readType(TokenScanner ts) {
+
+ GType gt;
+
// We should have a '[' to start with
Token t = ts.nextToken();
if (t == null || t.getType() == TokType.EOF)
@@ -34,33 +37,73 @@
ts.skipSpace();
String type = ts.nextValue();
- if (!Character.isDigit(type.charAt(0)))
- throw new SyntaxException(ts, "Garmin type number must be first. Saw '" + type + '\'');
+ if (Character.isDigit(type.charAt(0))) {
- log.debug("gtype", type);
- GType gt = new GType(kind, type);
+ log.debug("gtype", type);
+ gt = new GType(kind, type);
+ gt.setProcessingAndConversion();
- while (!ts.isEndOfFile()) {
- ts.skipSpace();
- String w = ts.nextValue();
- if (w.equals("]"))
- break;
+ while (!ts.isEndOfFile()) {
+ ts.skipSpace();
+ String w = ts.nextValue();
+ if (w.equals("]"))
+ break;
- if (w.equals("level")) {
- setLevel(ts, gt);
- } else if (w.equals("resolution")) {
- setResolution(ts, gt);
- } else if (w.equals("default_name")) {
- gt.setDefaultName(nextValue(ts));
- } else if (w.equals("road_class")) {
- gt.setRoadClass(nextIntValue(ts));
- } else if (w.equals("road_speed")) {
- gt.setRoadSpeed(nextIntValue(ts));
- } else if (w.equals("copy")) {
- // reserved word. not currently used
- } else {
- throw new SyntaxException(ts, "Unrecognised type command '" + w + '\'');
+ if (w.equals("level")) {
+ setLevel(ts, gt);
+ } else if (w.equals("resolution")) {
+ setResolution(ts, gt);
+ } else if (w.equals("default_name")) {
+ gt.setDefaultName(nextValue(ts));
+ } else if (w.equals("road_class")) {
+ gt.setRoadClass(nextIntValue(ts));
+ } else if (w.equals("road_speed")) {
+ gt.setRoadSpeed(nextIntValue(ts));
+ } else if (w.equals("copy")) {
+ // reserved word. not currently used
+ } else if (w.equals("continue")) {
+ gt.setContinue();
+ } else if (w.equals("stop")) {
+ gt.setFinal();
+ } else {
+ throw new SyntaxException(ts, "Unrecognised type command '" + w + '\'');
+ }
}
+
+ } else if (type.equals("continue")) {
+
+ gt = new GType(kind, "0");
+ gt.setContinue();
+ gt.setProcessingOnly();
+
+ while (!ts.isEndOfFile()) {
+ ts.skipSpace();
+ String w = ts.nextValue();
+ if (w.equals("]")) {
+ break;
+ } else {
+ throw new SyntaxException(ts, "Unrecognised type command '" + w + '\'');
+ }
+ }
+
+ } else if (type.equals("stop")) {
+
+ gt = new GType(kind, "0");
+ gt.setFinal();
+ gt.setProcessingOnly();
+
+ while (!ts.isEndOfFile()) {
+ ts.skipSpace();
+ String w = ts.nextValue();
+ if (w.equals("]")) {
+ break;
+ } else {
+ throw new SyntaxException(ts, "Unrecognised type command '" + w + '\'');
+ }
+ }
+
+ } else {
+ throw new SyntaxException(ts, "Garmin type number must be first. Saw '" + type + '\'');
}
gt.fixLevels(levels);
Index: src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/ActionRule.java (Arbeitskopie)
@@ -52,7 +52,7 @@
this.type = null;
}
- public GType resolveType(Element el) {
+ public GType resolveType(Element el, GType pre) {
if (expression == null || expression.eval(el)) {
for (Action a : actions)
a.perform(el);
Index: src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/RuleSet.java (Arbeitskopie)
@@ -63,14 +63,14 @@
return rules.entrySet();
}
- public GType resolveType(Element el) {
+ public GType resolveType(Element el, GType pre) {
GType foundType = null;
for (String tagKey : el) {
Rule rule = rules.get(tagKey);
if (rule != null) {
- GType type = rule.resolveType(el);
+ GType type = rule.resolveType(el, pre);
if (type != null) {
- if (foundType == null || type.isBetterPriority(foundType)) {
+ if ((foundType == null || type.isBetterPriority(foundType)) && (pre == null || pre.isBetterPriority(type))) {
foundType = type;
}
}
Index: src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/ExpressionRule.java (Arbeitskopie)
@@ -28,22 +28,22 @@
* @author Steve Ratcliffe
*/
public class ExpressionRule implements Rule {
- private final Op exression;
+ private final Op expression;
private final GType gtype;
- public ExpressionRule(Op exression, GType gtype) {
- this.exression = exression;
+ public ExpressionRule(Op expression, GType gtype) {
+ this.expression = expression;
this.gtype = gtype;
}
- public GType resolveType(Element el) {
- if (exression.eval(el))
+ public GType resolveType(Element el, GType pre) {
+ if (expression.eval(el))
return gtype;
return null;
}
public String toString() {
- return exression.toString() + ' ' + gtype;
+ return expression.toString() + ' ' + gtype;
}
}
Index: src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/FixedRule.java (Arbeitskopie)
@@ -32,7 +32,7 @@
this.gtype = gtype;
}
- public GType resolveType(Element el) {
+ public GType resolveType(Element el, GType pre) {
return gtype;
}
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (Arbeitskopie)
@@ -247,26 +247,40 @@
foundType = makeGTypeFromTags(way);
if(foundType == null)
return;
+ if (!foundType.isProcessingOnly()){
+ if (foundType.getFeatureKind() == GType.POLYLINE) {
+ if(foundType.isRoad())
+ addRoad(way, foundType);
+ else
+ addLine(way, foundType);
+ }
+ else
+ addShape(way, foundType);
+ }
}
else {
preConvertRules(way);
- foundType = wayRules.resolveType(way);
- if (foundType == null)
- return;
- postConvertRules(way, foundType);
- }
+ do {
+ foundType = wayRules.resolveType(way, foundType);
+ if (foundType == null)
+ return;
+
+ postConvertRules(way, foundType);
- if (foundType.getFeatureKind() == GType.POLYLINE) {
- if(foundType.isRoad() &&
- !MapElement.hasExtendedType(foundType.getType()))
- addRoad(way, foundType);
- else
- addLine(way, foundType);
+ if (!foundType.isProcessingOnly()){
+ if (foundType.getFeatureKind() == GType.POLYLINE) {
+ if(foundType.isRoad())
+ addRoad(way, foundType);
+ else
+ addLine(way, foundType);
+ }
+ else
+ addShape(way, foundType);
+ }
+ } while (!foundType.isFinal());
}
- else
- addShape(way, foundType);
}
/**
@@ -282,18 +296,23 @@
foundType = makeGTypeFromTags(node);
if(foundType == null)
return;
+ if (!foundType.isProcessingOnly())
+ addPoint(node, foundType);
}
else {
preConvertRules(node);
- foundType = nodeRules.resolveType(node);
- if (foundType == null)
- return;
+ do {
+ foundType = nodeRules.resolveType(node, foundType);
+ if (foundType == null)
+ return;
- postConvertRules(node, foundType);
+ postConvertRules(node, foundType);
+
+ if (!foundType.isProcessingOnly())
+ addPoint(node, foundType);
+ } while (!foundType.isFinal());
}
-
- addPoint(node, foundType);
}
/**
@@ -349,7 +368,7 @@
public void convertRelation(Relation relation) {
// Relations never resolve to a GType and so we ignore the return
// value.
- relationRules.resolveType(relation);
+ relationRules.resolveType(relation, null);
if(relation instanceof RestrictionRelation) {
RestrictionRelation rr = (RestrictionRelation)relation;
@@ -382,7 +401,7 @@
clipper.clipShape(shape, collector);
- GType pointType = nodeRules.resolveType(way);
+ GType pointType = nodeRules.resolveType(way, null);
if(pointType != null)
shape.setPoiType(pointType.getType());
Index: src/uk/me/parabola/mkgmap/reader/osm/Rule.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/Rule.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/reader/osm/Rule.java (Arbeitskopie)
@@ -29,7 +29,8 @@
* represent it.
*
* @param el The element as read from an OSM xml file in 'tag' format.
+ * @param pre The previous garmin type generated from the element.
* @return Enough information to represent this as a garmin type.
*/
- public GType resolveType(Element el);
+ public GType resolveType(Element el, GType pre);
}
Index: src/uk/me/parabola/mkgmap/reader/osm/GType.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/GType.java (Revision 1143)
+++ src/uk/me/parabola/mkgmap/reader/osm/GType.java (Arbeitskopie)
@@ -39,6 +39,10 @@
private static int nextPriority = 1;
private static final int PRIORITY_PUSH = 100000;
+ // control flag, whether this is an empty dummy element
+ // for processing rules
+ private boolean RuleWithoutConversion = false;
+
private final int featureKind;
private final int type;
@@ -58,6 +62,11 @@
private boolean road;
+ // control flag, whether this element defines
+ // the final conversion, or whether we shall search
+ // for further matching elements
+ private boolean FinalElement = true;
+
public GType(int featureKind, String type) {
priority = nextPriority();
this.featureKind = featureKind;
@@ -190,6 +199,30 @@
return road;
}
+ public void setFinal() {
+ FinalElement = true;
+ }
+
+ public void setContinue() {
+ FinalElement = false;
+ }
+
+ public boolean isFinal() {
+ return FinalElement;
+ }
+
+ public void setProcessingOnly() {
+ RuleWithoutConversion = true;
+ }
+
+ public void setProcessingAndConversion() {
+ RuleWithoutConversion = false;
+ }
+
+ public boolean isProcessingOnly() {
+ return RuleWithoutConversion;
+ }
+
public static void push() {
nextPriority += PRIORITY_PUSH;
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev