Index: src/uk/me/parabola/imgfmt/app/dem/DEMFile.java =================================================================== --- src/uk/me/parabola/imgfmt/app/dem/DEMFile.java (revision 4056) +++ src/uk/me/parabola/imgfmt/app/dem/DEMFile.java (working copy) @@ -22,6 +22,7 @@ import uk.me.parabola.imgfmt.app.ImgFileWriter; import uk.me.parabola.imgfmt.fs.ImgChannel; import uk.me.parabola.mkgmap.reader.hgt.HGTConverter; +import uk.me.parabola.imgfmt.Utils; /** * The DEM file. This consists of information about elevation. It is used for hill shading @@ -55,6 +56,26 @@ HGTConverter hgtConverter = new HGTConverter(pathToHGT, area, demPolygonMapUnits); hgtConverter.setOutsidePolygonHeight(outsidePolygonHeight); + int res = hgtConverter.getHighestRes(); + if (res > 0) { + if (pointDistances.get(0) == -1 || pointDistances.get(0) == (int) ((1 << 29) / (res * 45))) { + // align area with HGT raster + double hgtDis = 1.0D/res; + double top = Utils.toDegrees(area.getMaxLat()); + double bottom = Utils.toDegrees(area.getMinLat()); + double left = Utils.toDegrees(area.getMinLong()); + double right = Utils.toDegrees(area.getMaxLong()); + + top = Math.ceil(top/hgtDis)*hgtDis; + bottom = Math.floor(bottom/hgtDis)*hgtDis; + left = Math.floor(left/hgtDis)*hgtDis; + right = Math.ceil(right/hgtDis)*hgtDis; + + area = new Area(bottom, left, top, right); + //System.out.println("DEM aligned to HGT"); + } + } + int zoom = 0; int lastDist = pointDistances.get(pointDistances.size()-1); for (int pointDist : pointDistances) {