@Test public void testBoundingBoxDirection () { TileIndex tile = new TileIndex(5, 23, 17); BinIndex bin = new BinIndex(34, 78); Rectangle2D bounds = _mercator.getBinBounds(tile, bin); Assert.assertTrue(bounds.getMaxX() > bounds.getMinX()); Assert.assertTrue(bounds.getMaxY() > bounds.getMinY()); }
@Test public void testBoundingBoxes () { TileIndex tile = new TileIndex(10, 14, 6, 256, 256); Rectangle2D tileBounds = _mercator.getTileBounds(tile); BinIndex bll = new BinIndex(0, 255); BinIndex bur = new BinIndex(255, 0); Rectangle2D llBounds = _mercator.getBinBounds(tile, bll); Rectangle2D urBounds = _mercator.getBinBounds(tile, bur); Assert.assertEquals(llBounds.getMinX(), tileBounds.getMinX(), EPSILON); Assert.assertEquals(urBounds.getMaxX(), tileBounds.getMaxX(), EPSILON); Assert.assertEquals(llBounds.getMinY(), tileBounds.getMinY(), EPSILON); Assert.assertEquals(urBounds.getMaxY(), tileBounds.getMaxY(), EPSILON); }
for (int y=-3; y<4; ++y) { BinIndex bin = new BinIndex(127+x, 127+y); Rectangle2D bounds = mercator.getBinBounds(tile, bin); int reps = Math.max(0, 16-((x*x+y*y))); for (int i=0; i<reps; ++i) { BinIndex xbin = new BinIndex(131+n, 127); BinIndex ybin = new BinIndex(127, 131+n); Rectangle2D xbounds = mercator.getBinBounds(tile, xbin); Rectangle2D ybounds = mercator.getBinBounds(tile, ybin); for (int i=0; i<16; ++i) { System.out.println(String.format("ais(3.0), 0, 'test ship', '', %.6f, %.6f, 0.0, 0.0, 1207040300, 'TEST', 0203011000",
Rectangle2D realBounds = _mercator.getBinBounds(tile, bin); Assert.assertEquals(1.0, _mercator.getBinOverlap(tile, bin, realBounds),
@Test public void testRoundTripTransformation () { for (int level=0; level<4; ++level) { int pow2 = 1 << level; for (int x = 0; x<pow2; ++x) { for (int y=0; y<pow2; ++y) { TileIndex t0 = new TileIndex(level, x, y); Rectangle2D tileBounds = _mercator.getTileBounds(t0); TileIndex t1 = _mercator.rootToTile(getCenter(tileBounds), level); Assert.assertEquals(t0, t1); for (int dx=0; dx<t0.getXBins(); ++dx) { for (int dy=0; dy<t0.getYBins(); ++dy) { BinIndex b0 = new BinIndex(dx, dy); Rectangle2D binBounds = _mercator.getBinBounds(t0, b0); BinIndex b1 = _mercator.rootToBin(getCenter(binBounds), t0); Assert.assertEquals(b0, b1); } } } } } }