logo separator

[mkgmap-dev] [PATCH] TYP compiler and type >= 0x100

From Jiri Klement jiri.klement at gmail.com on Thu Sep 27 10:08:20 BST 2012

Hi,

Thanks for the workaround but anyway I think it shouldn't ignore
SubType. Attached is small patch that make it use SubType whenever
it's specified. It's still a bit confusing as it's not obvious what
Type=0x101 without Subtype means, but it's better than throwing away
Subtype completely.

On Mon, Sep 17, 2012 at 9:07 PM, aighes <osm at aighes.de> wrote:
> Am 17.09.2012 20:55, schrieb Jiri Klement:
>> Hi,
>>
>> I have TYP file created using editor on ati.land.cz that contains
>> lines with Type=0x100. It works fine on my GpsMap 62s. Now I've tried
>> to use built in TYP compiler in mkgmap, but it converts Type to 0x01.
> Hi, you'll have to specify sub-id's like 0x10000, 0x10001, ... 0x10100,....
>
> Henning
>
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev at lists.mkgmap.org.uk
> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-------------- next part --------------
Index: src/uk/me/parabola/imgfmt/app/typ/TypElement.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/typ/TypElement.java	(revision 2337)
+++ src/uk/me/parabola/imgfmt/app/typ/TypElement.java	(working copy)
@@ -31,7 +31,7 @@
  */
 public abstract class TypElement {
 	private int type;
-	private int subType;
+	private int subType = -1;
 
 	protected final List<TypLabel> labels = new ArrayList<TypLabel>();
 
@@ -59,7 +59,21 @@
 	 * Get the type in the format required for writing in the typ file sections.
 	 */
 	public int getTypeForFile() {
-		return (type << 5) | (subType & 0x1f);
+		int type2;
+		int subType2;
+		if (subType == -1) {
+			if (type >= 0x100) {
+				type2 = type >>> 8;
+				subType2 = type & 0xff;
+			} else {
+				type2 = type;
+				subType2 = 0;
+			}
+		} else {
+			type2 = type;
+			subType2 = subType;
+		}
+		return (type2 << 5) | (subType2 & 0x1f);
 	}
 
 	public void addLabel(String text) {
Index: src/uk/me/parabola/mkgmap/typ/CommonSection.java
===================================================================
--- src/uk/me/parabola/mkgmap/typ/CommonSection.java	(revision 2337)
+++ src/uk/me/parabola/mkgmap/typ/CommonSection.java	(working copy)
@@ -47,27 +47,20 @@
 	/**
 	 * Deal with all the keys that are common to the different element types.
 	 * Most tags are in fact the same for every element.
-	 * 
+	 *
 	 * @return True if this routine has processed the tag.
 	 */
 	protected boolean commonKey(TokenScanner scanner, TypElement current, String name, String value) {
 		if (name.equalsIgnoreCase("Type")) {
 			try {
-				int ival = Integer.decode(value);
-				if (ival >= 0x100) {
-					current.setType(ival >>> 8);
-					current.setSubType(ival & 0xff);
-				} else {
-					current.setType(ival & 0xff);
-				}
+				current.setType(Integer.decode(value));
 			} catch (NumberFormatException e) {
 				throw new SyntaxException(scanner, "Bad number " + value);
 			}
 
 		} else if (name.equalsIgnoreCase("SubType")) {
 			try {
-				int ival = Integer.decode(value);
-				current.setSubType(ival);
+				current.setSubType(Integer.decode(value));
 			} catch (NumberFormatException e) {
 				throw new SyntaxException(scanner, "Bad number for sub type " + value);
 			}
@@ -351,6 +344,7 @@
 			 *
 			 * @param alpha A true alpha value ie 0 is transparent, 255 opaque.
 			 */
+			@Override
 			public void addAlpha(int alpha) {
 				image[lastColourIndex] = (image[lastColourIndex] & ~0xff) | (alpha & 0xff);
 			}


More information about the mkgmap-dev mailing list