logo separator

[mkgmap-dev] My findings about the crash in MapSource

From Andrzej Popowski popej at poczta.onet.pl on Sat Feb 3 19:39:36 GMT 2018

Hi Gerd,

I have compiled baddem6 and I confirm your observations. I have no idea, 
what to do with it.

I have found a minor error, see attached patch. Mkgmap calculates 
min/max heights for header using values form tiles, which have bitstream 
data. This is wrong for flat surfaces, which have height but no 
bitstream and for voids, which have bitstream without real heights.

I also removed bitstream for tiles with all voids, but I don't know the 
reason for putting it in first place, so maybe it is wrong change.

-- 
Best regards,
Andrzej
-------------- next part --------------
Index: src/uk/me/parabola/imgfmt/app/dem/DEMSection.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/dem/DEMSection.java	(revision 4104)
+++ src/uk/me/parabola/imgfmt/app/dem/DEMSection.java	(working copy)
@@ -126,8 +126,7 @@
 				tiles.add(tile);
 				if (tile.getEncodingType() != 0)
 					hasExtra = true;
-				int bsLen = tile.getBitStreamLen();
-				if (bsLen > 0) {
+				if (tile.validHeights()) {
 					if (tile.getBaseHeight() < minBaseHeight)
 						minBaseHeight = tile.getBaseHeight();
 					if (tile.getBaseHeight() > maxBaseHeight)
@@ -136,8 +135,8 @@
 						maxHeight = tile.getMaxHeight();
 					if (tile.getMaxDeltaHeight() > maxDeltaHeight)
 						maxDeltaHeight = tile.getMaxDeltaHeight();
-					dataLen += bsLen;
 				}
+				dataLen += tile.getBitStreamLen();
 			}
 			if (lastLevel) {
 				hgtConverter.freeMem();
Index: src/uk/me/parabola/imgfmt/app/dem/DEMTile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/dem/DEMTile.java	(revision 4104)
+++ src/uk/me/parabola/imgfmt/app/dem/DEMTile.java	(working copy)
@@ -43,6 +43,7 @@
 	private final int baseHeight;		// base or minimum height in this tile 
 	private final int maxDeltaHeight;	// delta between max height and base height
 	private final byte encodingType;  	// determines how the highest values are displayed 
+	private final boolean hasData;		// not all voids
 
 	private int bitPos;
 	private byte currByte;
@@ -94,18 +95,18 @@
 		}
 		if (min == Integer.MAX_VALUE) {
 			// all values are invalid 
+			hasData = false;
 			encodingType = 2;
 			min = 0;
-			max = 1;
-			// seems we still need a bit stream in this case
-			realHeights = new short[width * height];
-			Arrays.fill(realHeights, HGTReader.UNDEF);
+			max = 0;
 		} else if (countInvalid > 0) {
 			// some values are invalid
+			hasData = true;
 			encodingType = 2; // don't display highest value 
 			max++;
 		} else {
 			// all height values are valid
+			hasData = true;
 			encodingType = 0;
 		}
 
@@ -117,6 +118,10 @@
 		createBitStream(realHeights);
 	}
 	
+	public boolean validHeights() {
+		return hasData;
+	}
+
 	public int getBaseHeight() {
 		return baseHeight;
 	}


More information about the mkgmap-dev mailing list