Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java	(revision 29875)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java	(revision 29876)
@@ -48,4 +48,6 @@
 	    e1.printStackTrace();
 	}
+	
+	getPluginDir();
     }
 
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java	(revision 29876)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java	(revision 29876)
@@ -0,0 +1,155 @@
+package org.openstreetmap.josm.plugins.elevation;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.ShortBuffer;
+import java.nio.channels.FileChannel;
+import java.util.HashMap;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.tools.CheckParameterUtil;
+
+
+/**
+ *  Class HgtReader reads data from SRTM HGT files. Currently this the routines are restricted to a resolution of 3 arc seconds.
+ *  @author Oliver Wieland <oliver.wieland@online.de>
+ */
+public class HgtReader {
+    public static final String HGT_EXT = ".hgt";
+    
+    // alter these values for different SRTM resolutions
+    public static final int HGT_RES = 3; // resolution in arc seconds
+    public static final int HGT_ROW_LENGTH = 1201; // number of elevation values per line
+    
+    private HashMap<String, ShortBuffer> cache = new HashMap<String, ShortBuffer>(); 
+    
+    public double getElevationFromHgt(LatLon coor) {
+	try {
+	    String file = getHgtFileName(coor);
+	    // given area in cache?
+	    if (!cache.containsKey(file)) {
+			
+		// fill initial cache value. If no file is found, then
+		// we use it as a marker to indicate 'file has been searched
+		// but is not there'
+		cache.put(file, null);
+		 // Try all other resource directories
+	        for (String location : Main.pref.getAllPossiblePreferenceDirs()) {	            
+	    		String fullPath = new File(location + File.separator + "elevation", file).getPath();
+	    			  
+	    		System.out.println("Search in " + location);
+    	    		File f = new File(fullPath);
+    	    		if (f.exists()) {
+    	    		    // nope: read HGT file...
+    	    		    ShortBuffer data = readHgtFile(fullPath);
+    	    		    // ... and store result in cache
+    	    		    cache.put(file, data);
+    	    		    break;
+    	    		}
+	        }
+	    }
+	    
+	    // read elevation value
+	    return readElevation(coor);
+	} catch (FileNotFoundException e) {
+	    // no problem... file not there
+	    return Double.NaN;
+	} catch (Exception ioe) {
+	    // oops...
+	    ioe.printStackTrace();	    
+	    // fallback
+	    return Double.NaN;	    
+	} 
+    }
+    
+    @SuppressWarnings("resource")
+    private ShortBuffer readHgtFile(String file) throws Exception {
+	CheckParameterUtil.ensureParameterNotNull(file);
+
+	FileChannel fc = null;
+	ShortBuffer sb = null;
+	try {	    
+	    // Eclipse complains here about resource leak on 'fc' - even with 'finally' clause???
+	    fc = new FileInputStream(file).getChannel();
+	    // choose the right endianness
+	    
+	    ByteBuffer bb = ByteBuffer.allocateDirect((int) fc.size());
+	    while (bb.remaining() > 0) fc.read(bb);
+	    
+	    bb.flip();
+	    //sb = bb.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();	
+	    sb = bb.order(ByteOrder.BIG_ENDIAN).asShortBuffer();
+	} finally {
+	    if (fc != null) fc.close();
+	}
+		    
+	return sb;	
+    }
+    
+    /**
+     * Reads the elevation value for the given coordinate.
+     *
+     * See also <a href="http://gis.stackexchange.com/questions/43743/how-to-extract-elevation-from-hgt-file">stackexchange.com</a>
+     * @param coor the coordinate to get the elevation data for
+     * @return the elevation value or <code>Double.NaN</code>, if no value is present
+     */
+    public double readElevation(LatLon coor) {
+	String tag = getHgtFileName(coor);
+		
+	ShortBuffer sb = cache.get(tag);
+	
+	if (sb == null) {
+	    return Double.NaN;
+	}
+	
+	// see http://gis.stackexchange.com/questions/43743/how-to-extract-elevation-from-hgt-file
+	double fLat = frac(coor.lat()) * 60;
+	double fLon = frac(coor.lon()) * 60;
+	
+	
+	int row = (int)Math.round(fLat * 60 / HGT_RES); 
+	int col = (int)Math.round(fLon * 60 / HGT_RES);
+	
+	row = HGT_ROW_LENGTH - row;
+	int cell = (HGT_ROW_LENGTH*  (row - 1)) + col;
+
+	return sb.get(cell);
+    }
+    
+    /**
+     * Gets the associated HGT file name for the given way point. Usually the
+     * format is <tt>[N|S]nn[W|E]mmm.hgt</tt> where <i>nn</i> is the integral latitude
+     * without decimals and <i>mmm</i> is the longitude.
+     *
+     * @param latLon the coordinate to get the filename for
+     * @return the file name of the HGT file
+     */
+    public String getHgtFileName(LatLon latLon) {
+	int lat = (int) latLon.lat();
+	int lon = (int) latLon.lon();
+	
+	String latPref = "N";
+	if (lat < 0) latPref = "S";
+	
+	String lonPref = "E";
+	if (lon < 0) {
+	    lonPref = "W";
+	}
+	
+	return String.format("%s%02d%s%03d%s", latPref, lat, lonPref, lon, HGT_EXT);
+    }
+    
+    public static double frac(double d) {
+	long iPart;
+	double fPart;
+
+	// Get user input
+	iPart = (long) d;
+	fPart = d - iPart;
+	return fPart;
+    }
+}
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/WayPointHelper.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/WayPointHelper.java	(revision 29875)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/WayPointHelper.java	(revision 29876)
@@ -21,4 +21,5 @@
 import java.util.Locale;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.gpx.WayPoint;
 
@@ -41,4 +42,6 @@
 	};
 	
+	
+	
 	/**
 	 * The name of the elevation height of a way point.
@@ -49,5 +52,8 @@
 		
 	private static GeoidCorrectionKind geoidKind = GeoidCorrectionKind.None;
-
+	
+	/** The HGT reader instance. */
+	private static HgtReader hgt = new HgtReader();
+	
 	/**
 	 * Gets the current mode of GEOID correction.
@@ -217,4 +223,12 @@
 	private static double getInternalElevation(WayPoint wpt) {
 		if (wpt != null) {
+		    	// Try to read data from SRTM file
+		    	// TODO: Option to switch this off
+		    	double eleHgt = hgt.getElevationFromHgt(wpt.getCoor());
+		    	
+		    	if (!Double.isNaN(eleHgt)) {		    	    
+		    	    return eleHgt;
+		    	}
+		    
 			if (!wpt.attr.containsKey(HEIGHT_ATTRIBUTE)) {
 				return 0;
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 29875)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 29876)
@@ -222,5 +222,4 @@
 	// plain way point by default
 	ElevationWayPointKind kind = ElevationWayPointKind.Plain;
-	System.out.println("Slope: " + slope + "%");
 	
 	// check, if we passed an elevation level
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java	(revision 29876)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java	(revision 29876)
@@ -0,0 +1,44 @@
+package org.openstreetmap.josm.plugins.elevation.tests;
+
+
+
+import junit.framework.TestCase;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.Preferences;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.plugins.elevation.HgtReader;
+
+public class HgtReaderTest extends TestCase {
+
+    /**
+     * Setup test.
+     */
+    public void setUp() {
+        Main.pref = new Preferences();
+    }
+
+    public void testGetElevationFromHgt() {
+	// Staufenberg, Hessen
+	testHgtData(50.6607106, 8.7337029, "N50E008.hgt", 199);
+	// Ulrichstein, Hessen
+	testHgtData(50.5767627, 9.1938483, "N50E009.hgt", 560);
+	// Fujijama
+	//testHgtData(35.360555, 138.727777, "N35E138.hgt", 3741);
+    }
+
+    private void testHgtData(final double lat, final double lon,
+	    final String expTag, final int expHeight) {
+	LatLon l = new LatLon(lat, lon);
+	HgtReader hr = new HgtReader();
+	String text = hr.getHgtFileName(l);
+	
+	assertEquals(expTag, text);
+	
+	double d = hr.getElevationFromHgt(l);
+	System.out.println(d);
+	assert(!Double.isNaN(d));
+	assertEquals((int)d, expHeight);
+    }
+
+}
