Here is a patch that implements mkgmap:drawLevel

It is used in conjunction with --order-by-decreasing-area and overrides
the natural polygon area that is used for output sorting, hence
influencing which polygons are rendered over others.

The higher the value, the later the polygon is written and hence should
show over other areas. Values range from 1 to 100, 1..50 will be larger
than any natural area and so output earlier. 51..100 will be smaller
and written later.

So, if you wanted the standard sea polygons to show, rather than any
mapped area beyond the coastline, could have:

natural=sea { add mkgmap:skipSizeFilter=true; set mkgmap:drawLevel=99 }
[0x32 resolution 10]

The default for sea is drawLevel=2 (drawLevel 1 might be needed for the
map background / 0x4b). Nothing else has a default and so behaves as if
between 50 and 51.

The Garmin device will still respect any in-build or TYP specified
_draworder. With --order-by-decreasing-area it works best if everything
has the same _draworder. If your Garmin device has strange rules, like
not showing City (0x01..0x03) or having green areas (0x14..0x21) at a
lower _draworder than most other things, consider a TYP file giving
0x01..0x55 the same value (1) except 0x4b with a lower value (0).


Ticker
Index: doc/options.txt
===================================================================
--- doc/options.txt	(revision 3702)
+++ doc/options.txt	(working copy)
@@ -710,3 +710,6 @@
 :	Puts area/polygons into the mapfile in decreasing size so
 that smaller features are rendered over larger ones
 (assuming _drawOrder is equal).
+The tag mkgmap:drawLevel can be used to override the
+natural area of a polygon, so forcing changes to the rendering order. 
+
Index: doc/styles/internal-tags.txt
===================================================================
--- doc/styles/internal-tags.txt	(revision 3702)
+++ doc/styles/internal-tags.txt	(working copy)
@@ -133,6 +133,5 @@
 | +mkgmap:highest-resolution-only+  | If set to +true+ the object will only be added for the highest resolution configured in the element type definition.
 | +mkgmap:execute_finalize_rules+  | If set to +true+ mkgmap will execute the finalize rules even if no object is created fot the element.
 | +mkgmap:numbers+  | If set to +false+ for a node or way mkgmap will ignore the object in the calculations for the --housenumber option   
+| +mkgmap:drawLevel+  | Set to a number from 1 to 100. Overrides the polygon area that is used by --order-by-decreasing-area. 1..50 are larger than typical polygons and be overwritten by them, 51..100 are smaller and will show. Higher drawLevels will show over lower values.
 |=========================================================
-
-
Index: resources/help/en/options
===================================================================
--- resources/help/en/options	(revision 3702)
+++ resources/help/en/options	(working copy)
@@ -703,4 +703,5 @@
 --order-by-decreasing-area
 	Puts polygons/areas into the mapfile in decreasing size so that
 	smaller features are rendered over larger ones (assuming _drawOrder
-	is equal)
+	is equal). The tag mkgmap:drawLevel can be used to override the
+	natural area of a polygon, so forcing changes to the rendering order. 
Index: resources/styles/default/inc/water_polygons
===================================================================
--- resources/styles/default/inc/water_polygons	(revision 3702)
+++ resources/styles/default/inc/water_polygons	(working copy)
@@ -8,6 +8,6 @@
 natural=wetland [0x51 resolution 20]
 natural=water [0x3c resolution 18]
 natural=waterfall | waterway=waterfall [0x47 resolution 21]
-natural=sea { add mkgmap:skipSizeFilter=true } [0x32 resolution 10]
+natural=sea { add mkgmap:skipSizeFilter=true; set mkgmap:drawLevel=2 } [0x32 resolution 10]
 
 waterway=riverbank [0x46 resolution 20]
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 3702)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -989,8 +989,27 @@
 		final MapShape shape = new MapShape(way.getId());
 		elementSetup(shape, gt, way);
 		shape.setPoints(way.getPoints());
-		shape.setFullArea(way.getFullArea());
 
+		long areaVal = 0;
+		String tagStringVal = way.getTag(drawLevelTagKey);
+		if (tagStringVal != null) {
+			try {
+				areaVal = Integer.parseInt(tagStringVal);
+				if (areaVal < 1 || areaVal > 100) {
+					log.error("mkgmap:drawLevel must be in range 1..100, not", areaVal);
+					areaVal = 0;
+				} else if (areaVal <= 50)
+					areaVal = Long.MAX_VALUE - areaVal; // 1 => MAX_VALUE-1, 50 => MAX_VALUE-50
+				else
+					areaVal = 101 - areaVal; // 51 => 50, 100 => 1
+			} catch (NumberFormatException e) {
+				log.error("mkgmap:drawLevel invalid integer:", tagStringVal);
+			}
+		}
+		if (areaVal == 0)
+			areaVal = way.getFullArea();
+		shape.setFullArea(areaVal);
+
 		clipper.clipShape(shape, collector);
 	}
 
@@ -1071,6 +1090,7 @@
 	};
 	private static final short highResOnlyTagKey = TagDict.getInstance().xlate("mkgmap:highest-resolution-only");
 	private static final short skipSizeFilterTagKey = TagDict.getInstance().xlate("mkgmap:skipSizeFilter");
+	private static final short drawLevelTagKey = TagDict.getInstance().xlate("mkgmap:drawLevel");
 
 	private static final short countryTagKey = TagDict.getInstance().xlate("mkgmap:country");
 	private static final short regionTagKey = TagDict.getInstance().xlate("mkgmap:region");
Index: src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java	(revision 3702)
+++ src/uk/me/parabola/mkgmap/reader/osm/SeaGenerator.java	(working copy)
@@ -110,9 +110,9 @@
 	 * coastline to be shown. To hide these and have the sea show up to the high-tide
 	 * coastline, can set this to be very small instead (or use _draworder).
 	 * <p>
-	 * Maybe this could be a mkgmap:variable specified in the style something like:
-	 * natural=sea {add mkgmap:skipSizeFilter=true;set mkgmap:drawLevel=6} [0x32 resolution 10]
-	 * and mkgmap:drawLevel is suitably scaled and used as the fullArea.
+	 * mkgmap:drawLevel can be used to override this value in the style - the default style has:
+	 * natural=sea { add mkgmap:skipSizeFilter=true; set mkgmap:drawLevel=2 } [0x32 resolution 10]
+	 * which is equivalent to Long.MAX_VALUE-2.
 	 */
 	private static final long seaSize = Long.MAX_VALUE-2; // sea is BIG
 
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to