SEAGrid implements PlanetaryGrid { @Override public long getBinIndex(double lat, double lon) { final int row = getRowIndex(lat); final int col = getColIndex(lon, row); return baseBin[row] + col; } 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 testGetBinIndex() { SEAGrid grid = new SEAGrid(6); assertEquals(0, grid.getBinIndex(+75.0, -500.0)); assertEquals(0, grid.getBinIndex(+100, -120.0)); assertEquals(0, grid.getBinIndex(+75.0, -120.0)); assertEquals(2, grid.getBinIndex(+75.0, +120.0)); assertEquals(3, grid.getBinIndex(+45.0, -157.5)); assertEquals(3 + 7, grid.getBinIndex(+45.0, +157.5)); assertEquals(3 + 8, grid.getBinIndex(+15.0, -165.0)); assertEquals(3 + 8 + 11, grid.getBinIndex(+15.0, +165.0)); assertEquals(3 + 8 + 12, grid.getBinIndex(-15.0, -165.0)); assertEquals(3 + 8 + 12 + 11, grid.getBinIndex(-15.0, +165.0)); assertEquals(3 + 8 + 12 + 12, grid.getBinIndex(-45.0, -157.5)); assertEquals(3 + 8 + 12 + 12 + 7, grid.getBinIndex(-45.0, +157.5)); assertEquals(3 + 8 + 12 + 12 + 8, grid.getBinIndex(-75.0, -120.0)); assertEquals(3 + 8 + 12 + 12 + 8 + 2, grid.getBinIndex(-75.0, +120.0)); assertEquals(3 + 8 + 12 + 12 + 8 + 2, grid.getBinIndex(-75.0, +500.0)); assertEquals(3 + 8 + 12 + 12 + 8 + 2, grid.getBinIndex(-100.0, +120.0)); }