On 19/07/11 18:46, Jiri Klement wrote:
Hi,
[1] says that resolution or level range is not supported but in fact
it works (tested on gpsmap 62s). It only needs to be written in
opposite order (ie 3-1 instead of 1-3). Can you please change it so it
works in both ways? It's really a minor issue but it should make it a
bit easier for beginners :-)
Thanks for reporting this. In my testing however it seems that level
works as expected, but resolution does not.
level 1-3 Works
resolution 18-20 No
resolution 20-18 'Works'
Attached patch fixes the problem that I see. Could you double-check and
if it really is level that doesn't work for you, can you provide some
kind of example?
Thanks
..Steve
Index: src/uk/me/parabola/mkgmap/general/MapElement.java
===================================================================
--- src/uk/me/parabola/mkgmap/general/MapElement.java (revision 1880)
+++ src/uk/me/parabola/mkgmap/general/MapElement.java (revision )
@@ -215,6 +215,14 @@
this.minResolution = minResolution;
}
+ /**
+ * The maximum resolution at which the element will be visible. This is normally
+ * 24, in other words the element is visible at all resolutions above the minimum.
+ * You can however set this lower, so that it will disappear as you zoom in, presumably to be
+ * replaced by another element.
+ *
+ * @return The max resolution (<= 24), default is 24.
+ */
public int getMaxResolution() {
return maxResolution;
}
Index: src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java (revision 1870)
+++ src/uk/me/parabola/mkgmap/osmstyle/TypeReader.java (revision )
@@ -111,8 +111,8 @@
try {
if (str.indexOf('-') >= 0) {
String[] minmax = HYPHEN_PATTERN.split(str, 2);
- gt.setMaxResolution(Integer.parseInt(minmax[0]));
- gt.setMinResolution(Integer.parseInt(minmax[1]));
+ gt.setMinResolution(Integer.parseInt(minmax[0]));
+ gt.setMaxResolution(Integer.parseInt(minmax[1]));
} else {
gt.setMinResolution(Integer.parseInt(str));
}
Index: test/uk/me/parabola/mkgmap/osmstyle/TypeReaderTest.java
===================================================================
--- test/uk/me/parabola/mkgmap/osmstyle/TypeReaderTest.java (revision )
+++ test/uk/me/parabola/mkgmap/osmstyle/TypeReaderTest.java (revision )
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2011.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 or
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+package uk.me.parabola.mkgmap.osmstyle;
+
+import java.io.StringReader;
+
+import uk.me.parabola.mkgmap.general.LevelInfo;
+import uk.me.parabola.mkgmap.reader.osm.GType;
+import uk.me.parabola.mkgmap.scan.TokenScanner;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TypeReaderTest {
+
+ @Test
+ public void testLevel() {
+ GType gType = makeType("[0x1 level 2]");
+
+ assertEquals("min level 0", 0, gType.getMinLevel());
+ assertEquals("max level", 2, gType.getMaxLevel());
+
+ assertEquals("min res", 18, gType.getMinResolution());
+ assertEquals("max res", 24, gType.getMaxResolution());
+ }
+
+ @Test
+ public void testLevelRange() {
+ GType gType = makeType("[0x1 level 1-3]");
+
+ assertEquals("min level", 1, gType.getMinLevel());
+ assertEquals("max level", 3, gType.getMaxLevel());
+
+ assertEquals("min res", 16, gType.getMinResolution());
+ assertEquals("min res", 20, gType.getMaxResolution());
+ }
+
+ @Test
+ public void testResolution() {
+ GType gType = makeType("[0x1 resolution 18]");
+
+ assertEquals("min level 0", 0, gType.getMinLevel());
+ assertEquals("max level", 2, gType.getMaxLevel());
+
+ assertEquals("min res", 18, gType.getMinResolution());
+ assertEquals("max res", 24, gType.getMaxResolution());
+ }
+
+ @Test
+ public void testResolutionRange() {
+ GType gType = makeType("[0x1 resolution 16-20]");
+
+ assertEquals("min res", 16, gType.getMinResolution());
+ assertEquals("max res", 20, gType.getMaxResolution());
+
+ assertEquals("min level", 1, gType.getMinLevel());
+ assertEquals("max level", 3, gType.getMaxLevel());
+
+ }
+
+ private GType makeType(String in) {
+ LevelInfo[] levels = LevelInfo.createFromString("0:24 1:20 2:18 3:16 4:14");
+
+ TypeReader tr = new TypeReader(GType.POLYLINE, levels);
+ TokenScanner ts = new TokenScanner("string", new StringReader(in));
+ ts.setExtraWordChars("-:");
+
+ return tr.readType(ts);
+ }
+}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev