/** * The URLs are a bit ugly and so we need to find out which area name a certain lat,lon * coordinate has. */ private SRTMProvider init() { try { String strs[] = {"Africa", "Australia", "Eurasia", "Islands", "North_America", "South_America"}; for (String str : strs) { InputStream is = getClass().getResourceAsStream(str + "_names.txt"); for (String line : Helper.readFile(new InputStreamReader(is, Helper.UTF_CS))) { int lat = Integer.parseInt(line.substring(1, 3)); if (line.substring(0, 1).charAt(0) == 'S') lat = -lat; int lon = Integer.parseInt(line.substring(4, 7)); if (line.substring(3, 4).charAt(0) == 'W') lon = -lon; int intKey = calcIntKey(lat, lon); String key = areas.put(intKey, str); if (key != null) throw new IllegalStateException("do not overwrite existing! key " + intKey + " " + key + " vs. " + str); } } return this; } catch (Exception ex) { throw new IllegalStateException("Cannot load area names from classpath", ex); } }
@Override String getFileName(double lat, double lon) { int intKey = calcIntKey(lat, lon); String str = areas.get(intKey); if (str == null) return null; int minLat = Math.abs(down(lat)); int minLon = Math.abs(down(lon)); str += "/"; if (lat >= 0) str += "N"; else str += "S"; if (minLat < 10) str += "0"; str += minLat; if (lon >= 0) str += "E"; else str += "W"; if (minLon < 10) str += "0"; if (minLon < 100) str += "0"; str += minLon; return str; }
/** * The URLs are a bit ugly and so we need to find out which area name a certain lat,lon * coordinate has. */ private SRTMProvider init() { try { String strs[] = {"Africa", "Australia", "Eurasia", "Islands", "North_America", "South_America"}; for (String str : strs) { InputStream is = getClass().getResourceAsStream(str + "_names.txt"); for (String line : Helper.readFile(new InputStreamReader(is, Helper.UTF_CS))) { int lat = Integer.parseInt(line.substring(1, 3)); if (line.substring(0, 1).charAt(0) == 'S') lat = -lat; int lon = Integer.parseInt(line.substring(4, 7)); if (line.substring(3, 4).charAt(0) == 'W') lon = -lon; int intKey = calcIntKey(lat, lon); String key = areas.put(intKey, str); if (key != null) throw new IllegalStateException("do not overwrite existing! key " + intKey + " " + key + " vs. " + str); } } return this; } catch (Exception ex) { throw new IllegalStateException("Cannot load area names from classpath", ex); } }
/** * The URLs are a bit ugly and so we need to find out which area name a certain lat,lon * coordinate has. */ private SRTMProvider init() { try { String strs[] = {"Africa", "Australia", "Eurasia", "Islands", "North_America", "South_America"}; for (String str : strs) { InputStream is = getClass().getResourceAsStream(str + "_names.txt"); for (String line : Helper.readFile(new InputStreamReader(is, Helper.UTF_CS))) { int lat = Integer.parseInt(line.substring(1, 3)); if (line.substring(0, 1).charAt(0) == 'S') lat = -lat; int lon = Integer.parseInt(line.substring(4, 7)); if (line.substring(3, 4).charAt(0) == 'W') lon = -lon; int intKey = calcIntKey(lat, lon); String key = areas.put(intKey, str); if (key != null) throw new IllegalStateException("do not overwrite existing! key " + intKey + " " + key + " vs. " + str); } } return this; } catch (Exception ex) { throw new IllegalStateException("Cannot load area names from classpath", ex); } }
lon = -lon; int intKey = calcIntKey(lat, lon); String key = areas.put(intKey, str); if (key != null)
@Override String getFileName(double lat, double lon) { int intKey = calcIntKey(lat, lon); String str = areas.get(intKey); if (str == null) return null; int minLat = Math.abs(down(lat)); int minLon = Math.abs(down(lon)); str += "/"; if (lat >= 0) str += "N"; else str += "S"; if (minLat < 10) str += "0"; str += minLat; if (lon >= 0) str += "E"; else str += "W"; if (minLon < 10) str += "0"; if (minLon < 100) str += "0"; str += minLon; return str; }
String getFileString( double lat, double lon ) { int intKey = calcIntKey(lat, lon); String str = areas.get(intKey); if (str == null) return null; int minLat = Math.abs(down(lat)); int minLon = Math.abs(down(lon)); str += "/"; if (lat >= 0) str += "N"; else str += "S"; if (minLat < 10) str += "0"; str += minLat; if (lon >= 0) str += "E"; else str += "W"; if (minLon < 10) str += "0"; if (minLon < 100) str += "0"; str += minLon; return str; }
String getFileString(double lat, double lon) { int intKey = calcIntKey(lat, lon); String str = areas.get(intKey); if (str == null) return null; int minLat = Math.abs(down(lat)); int minLon = Math.abs(down(lon)); str += "/"; if (lat >= 0) str += "N"; else str += "S"; if (minLat < 10) str += "0"; str += minLat; if (lon >= 0) str += "E"; else str += "W"; if (minLon < 10) str += "0"; if (minLon < 100) str += "0"; str += minLon; return str; }
lat = (int) (lat * precision) / precision; lon = (int) (lon * precision) / precision; int intKey = calcIntKey(lat, lon); HeightTile demProvider = cacheData.get(intKey); if (demProvider != null)
int intKey = calcIntKey(lat, lon); HeightTile demProvider = cacheData.get(intKey); if (demProvider != null)