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 29877)
@@ -20,4 +20,6 @@
  */
 public class HgtReader {
+    private static final int SECONDS_PER_MINUTE = 60;
+
     public static final String HGT_EXT = ".hgt";
     
@@ -25,4 +27,5 @@
     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
+    public static final int HGT_VOID = -32768; // magic number which indicates 'void data' in HGT file
     
     private HashMap<String, ShortBuffer> cache = new HashMap<String, ShortBuffer>(); 
@@ -38,9 +41,9 @@
 		// but is not there'
 		cache.put(file, null);
-		 // Try all other resource directories
+		 // Try all resource directories
 	        for (String location : Main.pref.getAllPossiblePreferenceDirs()) {	            
 	    		String fullPath = new File(location + File.separator + "elevation", file).getPath();
 	    			  
-	    		System.out.println("Search in " + location);
+	    		System.out.println(fullPath);
     	    		File f = new File(fullPath);
     	    		if (f.exists()) {
@@ -108,15 +111,26 @@
 	
 	// 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;
+	double fLat = frac(coor.lat()) * SECONDS_PER_MINUTE;
+	double fLon = frac(coor.lon()) * SECONDS_PER_MINUTE;
 	
-	
-	int row = (int)Math.round(fLat * 60 / HGT_RES); 
-	int col = (int)Math.round(fLon * 60 / HGT_RES);
+	// compute offset within HGT file
+	int row = (int)Math.round(fLat * SECONDS_PER_MINUTE / HGT_RES); 
+	int col = (int)Math.round(fLon * SECONDS_PER_MINUTE / HGT_RES);
 	
 	row = HGT_ROW_LENGTH - row;
 	int cell = (HGT_ROW_LENGTH*  (row - 1)) + col;
 
-	return sb.get(cell);
+	// valid position in buffer?
+	if (cell < sb.limit()) {
+	    short ele = sb.get(cell);
+	    // check for data voids 
+	    if (ele == HGT_VOID) {
+		return Double.NaN;
+	    } else {
+		return ele;
+	    }
+	} else {
+	    return Double.NaN;
+	}
     }
     
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 29877)
@@ -38,5 +38,6 @@
 	double d = hr.getElevationFromHgt(l);
 	System.out.println(d);
-	assert(!Double.isNaN(d));
+	assertFalse("Data missing or void for coor " + l, Double.isNaN(d));
+	
 	assertEquals((int)d, expHeight);
     }
