private boolean jumpOld(double wantLat, double wantLon, int[] rectIndex) { int row = Math.max( Math.min(rectIndex[0], nrows-1), 0); int col = Math.max( Math.min(rectIndex[1], ncols-1), 0); double gradientLat = latEdge.get(row + 1, col) - latEdge.get(row, col); double gradientLon = lonEdge.get(row, col + 1) - lonEdge.get(row, col); double diffLat = wantLat - latEdge.get(row, col); double diffLon = wantLon - lonEdge.get(row, col); int drow = (int) Math.round(diffLat / gradientLat); int dcol = (int) Math.round(diffLon / gradientLon); if (debug) System.out.printf(" jump from %d %d (grad=%f %f) (diff=%f %f) (delta=%d %d)", row, col, gradientLat, gradientLon, diffLat, diffLon, drow, dcol); if ((drow == 0) && (dcol == 0)) { if (debug) System.out.printf("%n incr:"); return incr(wantLat, wantLon, rectIndex); } else { rectIndex[0] = Math.max( Math.min(row + drow, nrows-1), 0); rectIndex[1] = Math.max( Math.min(col + dcol, ncols-1), 0); if (debug) System.out.printf(" to (%d %d)%n", rectIndex[0], rectIndex[1]); if ((row == rectIndex[0]) && (col == rectIndex[1])) return false; // nothing has changed } return true; }
private boolean jumpOld(double wantLat, double wantLon, int[] rectIndex) { int row = Math.max( Math.min(rectIndex[0], nrows-1), 0); int col = Math.max( Math.min(rectIndex[1], ncols-1), 0); double gradientLat = latEdge.get(row + 1, col) - latEdge.get(row, col); double gradientLon = lonEdge.get(row, col + 1) - lonEdge.get(row, col); double diffLat = wantLat - latEdge.get(row, col); double diffLon = wantLon - lonEdge.get(row, col); int drow = (int) Math.round(diffLat / gradientLat); int dcol = (int) Math.round(diffLon / gradientLon); if (debug) System.out.printf(" jump from %d %d (grad=%f %f) (diff=%f %f) (delta=%d %d)", row, col, gradientLat, gradientLon, diffLat, diffLon, drow, dcol); if ((drow == 0) && (dcol == 0)) { if (debug) System.out.printf("%n incr:"); return incr(wantLat, wantLon, rectIndex); } else { rectIndex[0] = Math.max( Math.min(row + drow, nrows-1), 0); rectIndex[1] = Math.max( Math.min(col + dcol, ncols-1), 0); if (debug) System.out.printf(" to (%d %d)%n", rectIndex[0], rectIndex[1]); if ((row == rectIndex[0]) && (col == rectIndex[1])) return false; // nothing has changed } return true; }
private boolean jumpOld(double wantLat, double wantLon, int[] rectIndex) { int row = Math.max( Math.min(rectIndex[0], nrows-1), 0); int col = Math.max( Math.min(rectIndex[1], ncols-1), 0); double gradientLat = latEdge.get(row + 1, col) - latEdge.get(row, col); double gradientLon = lonEdge.get(row, col + 1) - lonEdge.get(row, col); double diffLat = wantLat - latEdge.get(row, col); double diffLon = wantLon - lonEdge.get(row, col); int drow = (int) Math.round(diffLat / gradientLat); int dcol = (int) Math.round(diffLon / gradientLon); if (debug) System.out.printf(" jump from %d %d (grad=%f %f) (diff=%f %f) (delta=%d %d)", row, col, gradientLat, gradientLon, diffLat, diffLon, drow, dcol); if ((drow == 0) && (dcol == 0)) { if (debug) System.out.printf("%n incr:"); return incr(wantLat, wantLon, rectIndex); } else { rectIndex[0] = Math.max( Math.min(row + drow, nrows-1), 0); rectIndex[1] = Math.max( Math.min(col + dcol, ncols-1), 0); if (debug) System.out.printf(" to (%d %d)%n", rectIndex[0], rectIndex[1]); if ((row == rectIndex[0]) && (col == rectIndex[1])) return false; // nothing has changed } return true; }
return incr(wantLat, wantLon, rectIndex); } else { rectIndex[0] = Math.max( Math.min(row + drow, nrows-1), 0);
return incr(wantLat, wantLon, rectIndex); } else { rectIndex[0] = Math.max( Math.min(row + drow, nrows-1), 0);
return incr(wantLat, wantLon, rectIndex);
return incr(wantLat, wantLon, rectIndex);
return incr(wantLat, wantLon, rectIndex); } else { rectIndex[0] = Math.max( Math.min(row + drow, nrows-1), 0);
return incr(wantLat, wantLon, rectIndex);