SEAGrid implements PlanetaryGrid { @Override public double[] getCenterLatLon(long binIndex) { final int row = getRowIndex(binIndex); return new double[]{ latBin[row], getCenterLon(row, (int) (binIndex - baseBin[row])) }; } 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; }
@Test public void testGetCenterLatLon() { SEAGrid grid = new SEAGrid(6); try { grid.getCenterLatLon(-1); fail("ArrayIndexOutOfBoundsException?"); } catch (ArrayIndexOutOfBoundsException e) { } assertArrayEquals(new double[]{+75.0, -120.0}, grid.getCenterLatLon(0), 1E-10); assertArrayEquals(new double[]{+75.0, +120.0}, grid.getCenterLatLon(2), 1E-10); assertArrayEquals(new double[]{+45.0, -157.5}, grid.getCenterLatLon(3), 1E-10); assertArrayEquals(new double[]{+45.0, +157.5}, grid.getCenterLatLon(3 + 7), 1E-10); assertArrayEquals(new double[]{+15.0, -165.0}, grid.getCenterLatLon(3 + 8), 1E-10); assertArrayEquals(new double[]{+15.0, +165.0}, grid.getCenterLatLon(3 + 8 + 11), 1E-10); assertArrayEquals(new double[]{-15.0, -165.0}, grid.getCenterLatLon(3 + 8 + 12), 1E-10); assertArrayEquals(new double[]{-15.0, +165.0}, grid.getCenterLatLon(3 + 8 + 12 + 11), 1E-10); assertArrayEquals(new double[]{-45.0, -157.5}, grid.getCenterLatLon(3 + 8 + 12 + 12), 1E-10); assertArrayEquals(new double[]{-45.0, +157.5}, grid.getCenterLatLon(3 + 8 + 12 + 12 + 7), 1E-10); assertArrayEquals(new double[]{-75.0, -120.0}, grid.getCenterLatLon(3 + 8 + 12 + 12 + 8), 1E-10); assertArrayEquals(new double[]{-75.0, +120.0}, grid.getCenterLatLon(3 + 8 + 12 + 12 + 8 + 2), 1E-10); try { grid.getCenterLatLon(grid.getNumBins()); } catch (ArrayIndexOutOfBoundsException e) { } }