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); demProvider.setSeaLevel(true); width = DEFAULT_WIDTH; demProvider = new HeightTile(minLat, minLon, width, width, precision, DEGREE, DEGREE); cacheData.put(intKey, demProvider); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); if (demProvider.isSeaLevel()) return 0; return demProvider.getHeight(lat, lon);
double deltaLon = Math.abs(lon - minLon); if (deltaLat > latHigherBound || deltaLat < lowerBound) throw new IllegalStateException("latitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); if (deltaLon > lonHigherBound || deltaLon < lowerBound) throw new IllegalStateException("longitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); value += includePoint(daPointer - 2, counter); value += includePoint(daPointer + 2, counter); value += includePoint(daPointer - 2 * width, counter); value += includePoint(daPointer + 2 * width, counter);
public void toImage(String imageFile) throws IOException { ImageIO.write(makeARGB(), "PNG", new File(imageFile)); }
@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); }
@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); }
HeightTile demProvider = cacheData.get(intKey); if (demProvider != null) return demProvider.getHeight(lat, lon); width = DEFAULT_WIDTH; demProvider = new HeightTile(down(lat), down(lon), width, precision, 1); cacheData.put(intKey, demProvider); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); return demProvider.getHeight(lat, lon);
HeightTile instance = new HeightTile(0, 0, width, height, 1e-6, 10, 20); DataAccess heights = new RAMDirectory().find("tmp"); heights.create(2 * width * height); instance.setHeights(heights); init(heights, width, height, 1); assertEquals(1, instance.getHeight(5, 5), 1e-3); assertEquals(70, instance.getHeight(2.5, 1.5), 1e-3); assertEquals(1, instance.getHeight(3, 2), 1e-3); assertEquals(70, instance.getHeight(2, 1), 1e-3); assertEquals(1, instance.getHeight(+1.0, 2), 1e-3); assertEquals(90, instance.getHeight(0.5, 2.5), 1e-3); assertEquals(90, instance.getHeight(0.0, 2.5), 1e-3); assertEquals(1, instance.getHeight(+0.0, 3), 1e-3); assertEquals(1, instance.getHeight(-0.5, 3.5), 1e-3); assertEquals(1, instance.getHeight(-0.5, 3.0), 1e-3); assertEquals(90, instance.getHeight(-0.5, 2.5), 1e-3); assertEquals(1, instance.getHeight(0, 0), 1e-3); assertEquals(1, instance.getHeight(9, 10), 1e-3); assertEquals(1, instance.getHeight(10, 9), 1e-3); assertEquals(1, instance.getHeight(10, 10), 1e-3); assertEquals(1, instance.getHeight(10.5, 5), 1e-3); assertEquals(1, instance.getHeight(-0.5, 5), 1e-3); assertEquals(1, instance.getHeight(1, -0.5), 1e-3);
int minLon = getMinLonForTile(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, HEIGHT, LON_DEGREE * precision, LON_DEGREE, LAT_DEGREE); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); boolean loadExisting = false; try { downloadFile(file, zippedURL); } catch (IOException e) { demProvider.setSeaLevel(true); if (demProvider.isSeaLevel()) return 0; return demProvider.getHeight(lat, lon);
HeightTile demProvider = cacheData.get(intKey); if (demProvider != null) return demProvider.getHeight(lat, lon); width = DEFAULT_WIDTH; demProvider = new HeightTile(down(lat), down(lon), width, precision, 1); demProvider.setCalcMean(calcMean); cacheData.put(intKey, demProvider); demProvider.setHeights(heights); return demProvider.getHeight(lat, lon);
double deltaLon = Math.abs(lon - minLon); if (deltaLat > higherBound || deltaLat < lowerBound) throw new IllegalStateException("latitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); if (deltaLon > higherBound || deltaLon < lowerBound) throw new IllegalStateException("longitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); value += includePoint(daPointer - 2, counter); value += includePoint(daPointer + 2, counter); value += includePoint(daPointer - 2 * width, counter); value += includePoint(daPointer + 2 * width, counter);
public void toImage(String imageFile) throws IOException { ImageIO.write(makeARGB(), "PNG", new File(imageFile)); }
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); demProvider.setSeaLevel(true); width = DEFAULT_WIDTH; demProvider = new HeightTile(minLat, minLon, width, width, precision, DEGREE, DEGREE); cacheData.put(intKey, demProvider); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); if (demProvider.isSeaLevel()) return 0; return demProvider.getHeight(lat, lon);
double deltaLon = Math.abs(lon - minLon); if (deltaLat > higherBound || deltaLat < lowerBound) throw new IllegalStateException("latitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); if (deltaLon > higherBound || deltaLon < lowerBound) throw new IllegalStateException("longitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); value += includePoint(daPointer - 2, counter); value += includePoint(daPointer + 2, counter); value += includePoint(daPointer - 2 * width, counter); value += includePoint(daPointer + 2 * width, counter);
public void toImage( String imageFile ) throws IOException { ImageIO.write(makeARGB(), "PNG", new File(imageFile)); }
int minLon = getMinLonForTile(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, HEIGHT, LON_DEGREE * precision, LON_DEGREE, LAT_DEGREE); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); boolean loadExisting = false; try { downloadFile(file, zippedURL); } catch (IOException e) { demProvider.setSeaLevel(true); if (demProvider.isSeaLevel()) return 0; return demProvider.getHeight(lat, lon);
double deltaLon = Math.abs(lon - minLon); if (deltaLat > latHigherBound || deltaLat < lowerBound) throw new IllegalStateException("latitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); if (deltaLon > lonHigherBound || deltaLon < lowerBound) throw new IllegalStateException("longitude not in boundary of this file:" + lat + "," + lon + ", this:" + this.toString()); value += includePoint(daPointer - 2, counter); value += includePoint(daPointer + 2, counter); value += includePoint(daPointer - 2 * width, counter); value += includePoint(daPointer + 2 * width, counter);
public void toImage(String imageFile) throws IOException { ImageIO.write(makeARGB(), "PNG", new File(imageFile)); }
int minLon = down(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, degree * precision, degree); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); boolean loadExisting = false; try { continue; } catch (IOException ex) { demProvider.setSeaLevel(true); if (demProvider.isSeaLevel()) return 0; return demProvider.getHeight(lat, lon);
int minLon = down(lon); demProvider = new HeightTile(minLat, minLon, WIDTH, degree * precision, degree); demProvider.setCalcMean(calcMean); demProvider.setHeights(heights); boolean loadExisting = false; try } catch (IOException ex) demProvider.setSeaLevel(true); if (demProvider.isSeaLevel()) return 0; return demProvider.getHeight(lat, lon);