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; }