logo separator

[mkgmap-dev] HGT - getElevation()

From Andrzej Popowski popej at poczta.onet.pl on Sun Jan 14 13:29:57 GMT 2018

Hi Gerd,

I have attempted to reduce interpolation, when DEM pixel size is the 
same as HGT pixel. I have stretched a bit area of DEM, so edges are 
aligned with HGT. I'm attaching a patch.

Resulting map looks similar, only shading has moved a bit. I'm not sure 
if this is the result of differences in interpolation or maybe change 
introduced by moving DEM borders.

-- 
Best regards,
Andrzej
-------------- next part --------------
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) {


More information about the mkgmap-dev mailing list