Re: [mkgmap-dev] [PATCH v1] finalizer style file

2013-10-28 Thread Henning Scholland
Hi WanMil,
just to make sure, I've got it right.

way with:
a=b
c=d
e=f

actual in lines:
a=b  c=d {set x=y }
x=y  ef [0x01 ...]

with finalizer:
-in lines:
x=y  e=f [0x01 ..]
- in finalizer:
a=b  c=d  type()=way {set x=y}

If this is true, also the hole addr-part could be moved to finalizer.

Regarding type I think it should better return line, point, relation and
polygon.

Henning

___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Re: [mkgmap-dev] [PATCH v1] finalizer style file

2013-10-28 Thread Steve Ratcliffe

Hi WanMil


I had a look how much effort it is to add a finalizer style file that is
used each time a rule with an element type definition matches. This
might make it more easy to implement general rules (like the
mkgmap:access tag which seems to be useful for complex styles). The
finalize file must contain actions only. Otherwise mkgmap stops with an
error message.


This is interesting, early on I though that access rules would have
to be in a separate file and this might be it.

It also fits in with something else that I want to do, which is
to remove all the other getTag() calls from StyledConverter.


@Steve: do you think it would be possible to add a finalize section to
the bottom of each style file (especially points, lines and polygons)? I
have the feeling that this is more understandable and maybe better to
have different finalize styles for each element type.


Sounds like a good idea, I can't think of a syntax for it I like just
yet though.  You could also have different files lines_final,
points_final etc.

..Steve
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


[mkgmap-dev] [PATCH v1] finalizer style file

2013-10-27 Thread WanMil

Hi,
I had a look how much effort it is to add a finalizer style file that is 
used each time a rule with an element type definition matches. This 
might make it more easy to implement general rules (like the 
mkgmap:access tag which seems to be useful for complex styles). The 
finalize file must contain actions only. Otherwise mkgmap stops with an 
error message.


Attached patch for the mergeroads branch realizes this. Maybe have a 
look on it and reply if you find it useful or superfluous.


The patch also contains an additional style function
  type()
returns node, way or relation depending on the elements type.

@Steve: do you think it would be possible to add a finalize section to 
the bottom of each style file (especially points, lines and polygons)? I 
have the feeling that this is more understandable and maybe better to 
have different finalize styles for each element type.


WanMil
Index: resources/styles/default/finalizer
===
--- resources/styles/default/finalizer	(revision 0)
+++ resources/styles/default/finalizer	(revision 0)
@@ -0,0 +1,4 @@
+# The finalize file contains actions that are performed on each
+# element when a rule matches with an element type definition. 
+
+# highway=* { echo Next highway; set test=yes }
\ No newline at end of file
Index: src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java
===
--- src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java	(revision 2788)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyleImpl.java	(working copy)
@@ -107,6 +107,7 @@
 	private final RuleSet polygons = new RuleSet();
 	private final RuleSet nodes = new RuleSet();
 	private final RuleSet relations = new RuleSet();
+	private final RuleSet finalizer = new RuleSet();
 
 	private OverlayReader overlays;
 	private final boolean performChecks;
@@ -203,6 +204,11 @@
 		relations.prepare();
 		return relations;
 	}
+	
+	public Rule getFinalizerRules() {
+		finalizer.prepare();
+		return finalizer;
+	}
 
 	public LineAdder getOverlays(final LineAdder lineAdder) {
 		LineAdder adder = null;
@@ -223,6 +229,7 @@
 		set.addAll(lines.getUsedTags());
 		set.addAll(polygons.getUsedTags());
 		set.addAll(nodes.getUsedTags());
+		set.addAll(finalizer.getUsedTags());
 
 		// this is to allow style authors to say that tags are really used even
 		// if they are not found in the style file.  This is mostly to work
@@ -290,7 +297,7 @@
 		}
 
 		try {
-			RuleFileReader reader = new RuleFileReader(FeatureKind.RELATION, levels, relations, performChecks, getOverlaidTypeMap());
+			RuleFileReader reader = new RuleFileReader(FeatureKind.RELATION, levels, relations, performChecks, getOverlaidTypeMap(), false);
 			reader.load(fileLoader, relations);
 		} catch (FileNotFoundException e) {
 			// it is ok for this file to not exist.
@@ -298,7 +305,7 @@
 		}
 
 		try {
-			RuleFileReader reader = new RuleFileReader(FeatureKind.POINT, levels, nodes, performChecks, getOverlaidTypeMap());
+			RuleFileReader reader = new RuleFileReader(FeatureKind.POINT, levels, nodes, performChecks, getOverlaidTypeMap(), false);
 			reader.load(fileLoader, points);
 		} catch (FileNotFoundException e) {
 			// it is ok for this file to not exist.
@@ -306,18 +313,25 @@
 		}
 
 		try {
-			RuleFileReader reader = new RuleFileReader(FeatureKind.POLYLINE, levels, lines, performChecks, getOverlaidTypeMap());
+			RuleFileReader reader = new RuleFileReader(FeatureKind.POLYLINE, levels, lines, performChecks, getOverlaidTypeMap(), false);
 			reader.load(fileLoader, lines);
 		} catch (FileNotFoundException e) {
 			log.debug(no lines file);
 		}
 
 		try {
-			RuleFileReader reader = new RuleFileReader(FeatureKind.POLYGON, levels, polygons, performChecks, getOverlaidTypeMap());
+			RuleFileReader reader = new RuleFileReader(FeatureKind.POLYGON, levels, polygons, performChecks, getOverlaidTypeMap(), false);
 			reader.load(fileLoader, polygons);
 		} catch (FileNotFoundException e) {
 			log.debug(no polygons file);
 		}
+		
+		try {
+			RuleFileReader reader = new RuleFileReader(FeatureKind.ALL, levels, finalizer, performChecks, getOverlaidTypeMap(), true);
+			reader.load(fileLoader, finalizer);
+		} catch (FileNotFoundException e) {
+			log.debug(no finalizer file);
+		}
 	}
 
 	/**
@@ -466,6 +480,7 @@
 		polygons.merge(other.polygons);
 		nodes.merge(other.nodes);
 		relations.merge(other.relations);
+		finalizer.merge(other.finalizer);
 	}
 
 	private void checkVersion() throws FileNotFoundException {
@@ -498,6 +513,7 @@
 		stylePrinter.setLines(lines);
 		stylePrinter.setNodes(nodes);
 		stylePrinter.setPolygons(polygons);
+		stylePrinter.setFinalizer(finalizer);
 		stylePrinter.dumpToFile(out);
 	}
 
Index: src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java
===
--- src/uk/me/parabola/mkgmap/osmstyle/eval/ExpressionReader.java	(revision 2788)
+++