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 ) == ' ' ) lat = - lat ; int lon = Integer . parseInt ( line . substring ( 4 , 7 ) ) ; if ( line . substring ( 3 , 4 ) . charAt ( 0 ) == ' ' ) 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 .