int minLon = getMinLonForTile(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, HEIGHT, LON_DEGREE * precision, LON_DEGREE, LAT_DEGREE); demProvider.setCalcMean(calcMean);
updateHeightsFromFile(lat, lon, heights); } catch (FileNotFoundException ex) { demProvider = new HeightTile(minLat, minLon, DEFAULT_WIDTH, DEFAULT_WIDTH, precision, DEGREE, DEGREE); cacheData.put(intKey, demProvider); demProvider.setHeights(heights); width = DEFAULT_WIDTH; demProvider = new HeightTile(minLat, minLon, width, width, precision, DEGREE, DEGREE); cacheData.put(intKey, demProvider); demProvider.setCalcMean(calcMean);
@Test public void testGetHeightForNegativeTile() { int width = 10; HeightTile instance = new HeightTile(-20, -20, width, width, 1e-6, 10, 10); DataAccess heights = new RAMDirectory().find("tmp"); heights.create(2 * 10 * 10); instance.setHeights(heights); init(heights, width, width, 1); // x,y=1,7 heights.setShort(2 * (7 * width + 1), (short) 70); // x,y=2,9 heights.setShort(2 * (9 * width + 2), (short) 90); assertEquals(1, instance.getHeight(-15, -15), 1e-3); assertEquals(70, instance.getHeight(-17.5, -18.5), 1e-3); // edge cases for one tile with the boundaries [min,min+degree/width) for lat and lon assertEquals(1, instance.getHeight(-17, -18), 1e-3); assertEquals(70, instance.getHeight(-18, -19), 1e-3); }
@Test public void testCalcMean() { int width = 10; HeightTile instance = new HeightTile(0, 0, width, width, 1e-6, 10, 10).setCalcMean(true); DataAccess heights = new RAMDirectory().find("tmp"); heights.create(2 * 10 * 10); instance.setHeights(heights); init(heights, width, width, 1); // x,y=0,9 heights.setShort(2 * (9 * width + 0), (short) 10); // x,y=1,7 heights.setShort(2 * (7 * width + 1), (short) 70); // x,y=2,8 heights.setShort(2 * (8 * width + 2), (short) 90); assertEquals((70 + 4) / 5d, instance.getHeight(2, 1), 1e-3); assertEquals((70 + 90 + 3) / 5d, instance.getHeight(2.5, 2.5), 1e-3); assertEquals((90 + 3) / 4d, instance.getHeight(-0.5, 2.5), 1e-3); assertEquals((10 + 2) / 3d, instance.getHeight(-0.5, -0.5), 1e-3); }
HeightTile instance = new HeightTile(0, 0, width, height, 1e-6, 10, 20); DataAccess heights = new RAMDirectory().find("tmp"); heights.create(2 * width * height);
int minLon = down(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, degree * precision, degree); demProvider.setCalcMean(calcMean);
int minLon = down(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, degree * precision, degree); demProvider.setCalcMean(calcMean);
width = DEFAULT_WIDTH; demProvider = new HeightTile(down(lat), down(lon), width, precision, 1); cacheData.put(intKey, demProvider); demProvider.setCalcMean(calcMean);
int minLon = getMinLonForTile(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, HEIGHT, LON_DEGREE * precision, LON_DEGREE, LAT_DEGREE); demProvider.setCalcMean(calcMean);
width = DEFAULT_WIDTH; demProvider = new HeightTile(down(lat), down(lon), width, precision, 1); demProvider.setCalcMean(calcMean); cacheData.put(intKey, demProvider);
updateHeightsFromFile(lat, lon, heights); } catch (FileNotFoundException ex) { demProvider = new HeightTile(minLat, minLon, DEFAULT_WIDTH, DEFAULT_WIDTH, precision, DEGREE, DEGREE); cacheData.put(intKey, demProvider); demProvider.setHeights(heights); width = DEFAULT_WIDTH; demProvider = new HeightTile(minLat, minLon, width, width, precision, DEGREE, DEGREE); cacheData.put(intKey, demProvider); demProvider.setCalcMean(calcMean);