ISINGrid { public int getBinIndex(Point gridPoint) { final int colIndex = gridPoint.x; final int rowIndex = gridPoint.y; if (rowIndex >= 0 && rowIndex < rowCount) { if (colIndex >= 0 && colIndex < rowLength[rowIndex]) { return binOffsets[rowIndex] + colIndex; } } return -1; } ISINGrid(int rowCount); int getRowCount(); double getBinSize(); double getDeltaLat(); int getTotalBinCount(); double getLat(int rowIndex); double getDeltaLon(int rowIndex); int getRowLength(int rowIndex); int getBinOffset(int rowIndex); int getRowIndex(int binIndex); Point getGridPoint(int binIndex, Point gridPoint); int getBinIndex(Point gridPoint); int getColIndex(int rowIndex, double lon); int getBinIndex(int rowIndex, double lon); static int detectRowCount(String productName); static final double RE; static final int DEFAULT_ROW_COUNT; }
@Test public void test_getBinIndex() { assertEquals((0) + 2, grid.getBinIndex(new Point(2, 0))); assertEquals((3) + 7, grid.getBinIndex(new Point(7, 1))); assertEquals((3 + 9) + 11, grid.getBinIndex(new Point(11, 2))); assertEquals((3 + 9 + 16) + 19, grid.getBinIndex(new Point(19, 3))); assertEquals((3 + 9 + 16 + 22) + 25, grid.getBinIndex(new Point(25, 4))); assertEquals((5940422 / 2 - 4320) + 632, grid.getBinIndex(new Point(632, 2160 / 2 - 1))); assertEquals((5940422 / 2) + 1743, grid.getBinIndex(new Point(1743, 2160 / 2))); assertEquals(5940422 - (3) + 1, grid.getBinIndex(new Point(1, 2160 - 1 - 0))); assertEquals(5940422 - (3 + 9) + 6, grid.getBinIndex(new Point(6, 2160 - 1 - 1))); assertEquals(5940422 - (3 + 9 + 16) + 15, grid.getBinIndex(new Point(15, 2160 - 1 - 2))); assertEquals(5940422 - (3 + 9 + 16 + 22) + 20, grid.getBinIndex(new Point(20, 2160 - 1 - 3))); assertEquals(-1, grid.getBinIndex(new Point(-1, -1))); assertEquals(-1, grid.getBinIndex(new Point(-1, 23))); assertEquals(-1, grid.getBinIndex(new Point(546, -1))); assertEquals(-1, grid.getBinIndex(new Point(4320 + 1, 46))); assertEquals(-1, grid.getBinIndex(new Point(343, 5940422 + 1))); }