@Test(expected = IllegalArgumentException.class) public void testOutOfBoundsYBin () { SubTileDataView<Integer> underTest = SubTileDataView.fromSourceAbsolute(source16, new TileIndex(1, 1, 1)); underTest.getBin(1,2); }
@Override public T getBin (int x, int y) { if (x < 0 || x >= getDefinition().getXBins()) { throw new IllegalArgumentException("Bin x index is outside of tile's valid bin range"); } if (y < 0 || y >= getDefinition().getYBins()) { throw new IllegalArgumentException("Bin y index is outside of tile's valid bin range"); } return _source.getBin(x + _xOffset, y + _yOffset); }
@Test public void testSimple () { SubTileDataView<Integer> underTest = SubTileDataView.fromSourceAbsolute(source16, new TileIndex(1, 1, 1)); Assert.assertEquals(1, underTest.getDefinition().getLevel()); Assert.assertEquals(1, underTest.getDefinition().getX()); Assert.assertEquals(1, underTest.getDefinition().getY()); Assert.assertEquals(2, underTest.getDefinition().getXBins()); Assert.assertEquals(2, underTest.getDefinition().getYBins()); Assert.assertEquals(2, (int)underTest.getBin(0,0)); Assert.assertEquals(7, (int)underTest.getBin(1,1)); }
data = SubTileDataView.fromSourceAbsolute(tileDatas.get(0), index); } else {
return new SubTileDataView<>(source, new TileIndex(targetIndex.getLevel(), targetIndex.getX(), targetIndex.getY(), sourceIndex.getXBins()/tileCountRatio, sourceIndex.getYBins()/tileCountRatio), xBinStart, yBinStart);
@Test public void testSimpleTwoLevels () { SubTileDataView<Integer> underTest = SubTileDataView.fromSourceAbsolute(source16, new TileIndex(2, 1, 1)); Assert.assertEquals(2, underTest.getDefinition().getLevel()); Assert.assertEquals(1, underTest.getDefinition().getX()); Assert.assertEquals(1, underTest.getDefinition().getY()); Assert.assertEquals(1, underTest.getDefinition().getXBins()); Assert.assertEquals(1, underTest.getDefinition().getYBins()); Assert.assertEquals(9, (int)underTest.getBin(0,0)); }
@Test(expected = IllegalArgumentException.class) public void testBadRelativeIndex () { TileData<Integer> source = new DenseTileData<>(new TileIndex(1, 0, 0)); SubTileDataView.fromSourceAbsolute(source, new TileIndex(2, 2, 1)); }
@Test(expected = IllegalArgumentException.class) public void testOutOfBoundsXBin () { SubTileDataView<Integer> underTest = SubTileDataView.fromSourceAbsolute(source16, new TileIndex(1, 1, 1)); underTest.getBin(2,1); }
@Test(expected = IllegalArgumentException.class) public void testBadRelativeLevel() { TileData<Integer> source = new DenseTileData<>(new TileIndex(3, 0, 0)); SubTileDataView.fromSourceAbsolute(source, new TileIndex(2, 1, 1)); }
@Override public void setBin(int x, int y, T value) { if (x < 0 || x >= getDefinition().getXBins()) { throw new IllegalArgumentException("Bin x index is outside of tile's valid bin range"); } if (y < 0 || y >= getDefinition().getYBins()) { throw new IllegalArgumentException("Bin y index is outside of tile's valid bin range"); } _source.setBin(x + _xOffset, y + _yOffset, value); }