@Test public void testGetRowIndex() { SEAGrid grid = new SEAGrid(6); try { grid.getRowIndex(-1); fail("ArrayIndexOutOfBoundsException?"); } catch (ArrayIndexOutOfBoundsException e) { } assertEquals(0, grid.getRowIndex(0)); assertEquals(0, grid.getRowIndex(1)); assertEquals(0, grid.getRowIndex(2)); assertEquals(1, grid.getRowIndex(3)); assertEquals(1, grid.getRowIndex(4)); assertEquals(1, grid.getRowIndex(5)); assertEquals(1, grid.getRowIndex(6)); assertEquals(1, grid.getRowIndex(7)); assertEquals(1, grid.getRowIndex(8)); assertEquals(1, grid.getRowIndex(9)); assertEquals(1, grid.getRowIndex(10)); assertEquals(2, grid.getRowIndex(11)); assertEquals(2, grid.getRowIndex(12)); assertEquals(2, grid.getRowIndex(13)); assertEquals(2, grid.getRowIndex(14)); assertEquals(2, grid.getRowIndex(15)); assertEquals(2, grid.getRowIndex(16)); assertEquals(2, grid.getRowIndex(17)); assertEquals(2, grid.getRowIndex(18)); assertEquals(2, grid.getRowIndex(19)); assertEquals(2, grid.getRowIndex(20)); assertEquals(2, grid.getRowIndex(21)); assertEquals(2, grid.getRowIndex(22)); assertEquals(3, grid.getRowIndex(23)); assertEquals(3, grid.getRowIndex(24)); assertEquals(3, grid.getRowIndex(25)); assertEquals(3, grid.getRowIndex(26)); assertEquals(3, grid.getRowIndex(27)); assertEquals(3, grid.getRowIndex(28)); assertEquals(3, grid.getRowIndex(29)); assertEquals(3, grid.getRowIndex(30)); assertEquals(3, grid.getRowIndex(31)); assertEquals(3, grid.getRowIndex(32)); assertEquals(3, grid.getRowIndex(33)); assertEquals(3, grid.getRowIndex(34)); assertEquals(4, grid.getRowIndex(35)); assertEquals(4, grid.getRowIndex(36)); assertEquals(4, grid.getRowIndex(37)); assertEquals(4, grid.getRowIndex(38)); assertEquals(4, grid.getRowIndex(39)); assertEquals(4, grid.getRowIndex(40)); assertEquals(4, grid.getRowIndex(41)); assertEquals(4, grid.getRowIndex(42)); assertEquals(5, grid.getRowIndex(43)); assertEquals(5, grid.getRowIndex(44)); assertEquals(5, grid.getRowIndex(45)); try { grid.getRowIndex(46); } catch (ArrayIndexOutOfBoundsException e) { } }
@Override public int getRowIndex(long binIndex) { final int max = baseBin.length - 1; final long[] rowBinIds = this.baseBin; int low = 0; int high = max; while (true) { int mid = (low + high) >>> 1; if (binIndex < rowBinIds[mid]) { high = mid - 1; } else if (mid == max) { return mid; } else if (binIndex < rowBinIds[mid + 1]) { return mid; } else { low = mid + 1; } } }
SEAGrid implements PlanetaryGrid { @Override public int getRowIndex(long binIndex) { final int max = baseBin.length - 1; final long[] rowBinIds = this.baseBin; int low = 0; int high = max; while (true) { int mid = (low + high) >>> 1; if (binIndex < rowBinIds[mid]) { high = mid - 1; } else if (mid == max) { return mid; } else if (binIndex < rowBinIds[mid + 1]) { return mid; } else { low = mid + 1; } } } }
SEAGrid implements PlanetaryGrid { @Override public int getRowIndex(long binIndex) { final int max = baseBin.length - 1; final long[] rowBinIds = this.baseBin; int low = 0; int high = max; while (true) { int mid = (low + high) >>> 1; if (binIndex < rowBinIds[mid]) { high = mid - 1; } else if (mid == max) { return mid; } else if (binIndex < rowBinIds[mid + 1]) { return mid; } else { low = mid + 1; } } } SEAGrid();  SEAGrid(int numRows); }
SEAGrid implements PlanetaryGrid { @Override public int getRowIndex(long binIndex) { final int max = baseBin.length - 1; final long[] rowBinIds = this.baseBin; int low = 0; int high = max; while (true) { int mid = (low + high) >>> 1; if (binIndex < rowBinIds[mid]) { high = mid - 1; } else if (mid == max) { return mid; } else if (binIndex < rowBinIds[mid + 1]) { return mid; } else { low = mid + 1; } } } SEAGrid();  SEAGrid(int numRows); static int computeRowCount(double res); @Override int getNumRows(); @Override int getNumCols(int row); @Override long getNumBins(); @Override long getFirstBinIndex(int row); @Override double getCenterLat(int row); @Override long getBinIndex(double lat, double lon); @Override int getRowIndex(long binIndex); @Override double[] getCenterLatLon(long binIndex); double getCenterLon(int row, int col); int getColIndex(double lon, int row); int getRowIndex(double lat); }
SEAGrid implements PlanetaryGrid { @Override public int getRowIndex(long binIndex) { final int max = baseBin.length - 1; final long[] rowBinIds = this.baseBin; int low = 0; int high = max; while (true) { int mid = (low + high) >>> 1; if (binIndex < rowBinIds[mid]) { high = mid - 1; } else if (mid == max) { return mid; } else if (binIndex < rowBinIds[mid + 1]) { return mid; } else { low = mid + 1; } } } SEAGrid();  SEAGrid(int numRows); static int computeRowCount(double res); @Override int getNumRows(); @Override int getNumCols(int row); @Override long getNumBins(); @Override long getFirstBinIndex(int row); @Override double getCenterLat(int row); @Override long getBinIndex(double lat, double lon); @Override int getRowIndex(long binIndex); @Override double[] getCenterLatLon(long binIndex); double getCenterLon(int row, int col); int getColIndex(double lon, int row); int getRowIndex(double lat); static final int DEFAULT_NUM_ROWS; static double RE; }