X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FLookupSrtmFunction.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FLookupSrtmFunction.java;h=0ae2e45c04a42a1f76c9b22db13677b0be0656ad;hb=778406047438abc2330bc44c774c1bcd88ded872;hp=15997448e038e6f4bb6e9f4b9437c99491b18a6e;hpb=822d2d8e3d90b0ca7ae76c353f87095dbcd3bc04;p=GpsPrune.git diff --git a/src/tim/prune/function/srtm/LookupSrtmFunction.java b/src/tim/prune/function/srtm/LookupSrtmFunction.java index 1599744..0ae2e45 100644 --- a/src/tim/prune/function/srtm/LookupSrtmFunction.java +++ b/src/tim/prune/function/srtm/LookupSrtmFunction.java @@ -44,7 +44,8 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable private boolean _running = false; /** Expected size of hgt file in bytes */ - private static final long HGT_SIZE = 2884802L; + private static final int HGT_ROW = 3601; + private static final int HGT_SIZE = 2 * HGT_ROW * HGT_ROW; /** Altitude below which is considered void */ private static final int VOID_VAL = -32768; @@ -182,7 +183,7 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable { // Set progress _progress.setValue(t); - final int ARRLENGTH = 1201 * 1201; + final int ARRLENGTH = HGT_ROW * HGT_ROW; int[] heights = new int[ARRLENGTH]; // Open zipinputstream on url and check size ZipInputStream inStream = getStreamToHgtFile(urls[t]); @@ -218,12 +219,12 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable { if (new SrtmTile(point).equals(tile)) { - double x = (point.getLongitude().getDouble() - tile.getLongitude()) * 1200; - double y = 1201 - (point.getLatitude().getDouble() - tile.getLatitude()) * 1200; - int idx1 = ((int)y)*1201 + (int)x; + double x = (point.getLongitude().getDouble() - tile.getLongitude()) * (HGT_ROW - 1); + double y = HGT_ROW - (point.getLatitude().getDouble() - tile.getLatitude()) * (HGT_ROW - 1); + int idx1 = ((int)y)*HGT_ROW + (int)x; try { - int[] fouralts = {heights[idx1], heights[idx1+1], heights[idx1-1201], heights[idx1-1200]}; + int[] fouralts = {heights[idx1], heights[idx1+1], heights[idx1-HGT_ROW], heights[idx1-HGT_ROW+1]}; int numVoids = (fouralts[0]==VOID_VAL?1:0) + (fouralts[1]==VOID_VAL?1:0) + (fouralts[2]==VOID_VAL?1:0) + (fouralts[3]==VOID_VAL?1:0); // if (numVoids > 0) System.out.println(numVoids + " voids found"); @@ -316,7 +317,8 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable // System.out.println("Lookup: Trying online: " + inUrl.toString()); _hadToDownload = true; // MAYBE: Only download if we're in online mode? - return new ZipInputStream(inUrl.openStream()); + // return new ZipInputStream(inUrl.openStream()); + return null; } /**