use of uk.me.parabola.mkgmap.reader.hgt.HGTConverter in project mkgmap by openstreetmap.
the class DEMFile method calc.
/**
* Calculate the DEM data for a tile.
*
* @param area
* the bounding box of the tile
* @param demPolygonMapUnits
* a bounding polygon which might be smaller than the area
* @param pathToHGT
* comma separated list of directories or zip files
* @param pointDistances
* list of distances which determine the resolution
* @param outsidePolygonHeight
* the height value that should be used for points outside of the
* bounding polygon
* @return a new bounding box that should be used for the TRE file
*/
public Area calc(Area area, java.awt.geom.Area demPolygonMapUnits, String pathToHGT, List<Integer> pointDistances, short outsidePolygonHeight, InterpolationMethod interpolationMethod) {
// HGT area is extended by EXTRA degrees in each direction
HGTConverter hgtConverter = new HGTConverter(pathToHGT, area, demPolygonMapUnits, EXTRA);
hgtConverter.setInterpolationMethod(interpolationMethod);
hgtConverter.setOutsidePolygonHeight(outsidePolygonHeight);
log.info("orig bounds", area);
int alignment = 4;
Area treArea = calcTREBounds(area, alignment);
log.info("TRE bounds", treArea);
int top = treArea.getMaxLat() * 256;
int bottom = treArea.getMinLat() * 256;
int left = treArea.getMinLong() * 256;
int right = treArea.getMaxLong() * 256;
int zoom = 0;
int lastDist = pointDistances.get(pointDistances.size() - 1);
for (int pointDist : pointDistances) {
int distance = pointDist;
if (distance == -1) {
int res = (hgtConverter.getHighestRes() > 0) ? hgtConverter.getHighestRes() : 1200;
distance = (int) Math.round((1 << 29) / (res * 45.0D));
}
// last 4 bits of distance should be 0
distance = ((distance + 8) / 16) * 16;
int xTop = top;
int xLeft = left;
// widening of HGT area
if (distance < (int) Math.floor((EXTRA / 45.0D * (1 << 29)))) {
xTop = moveUp(top, distance);
xLeft = moveLeft(left, distance);
}
DEMSection section = new DEMSection(zoom++, xTop, xLeft, xTop - bottom, right - xLeft, hgtConverter, distance, pointDist == lastDist);
demHeader.addSection(section);
}
return treArea;
}
Aggregations