public void checkCoverage(long[] index) throws OutsideCoverageException { if (covers(index)) { return; } if (index[2] < getZoomStart() || index[2] > getZoomStop()) { throw new OutsideCoverageException(index, getZoomStart(), getZoomStop()); } long[] coverage = getCoverage((int) index[2]); throw new OutsideCoverageException(index, coverage); }
@Override public double getScaleDenominator(int level) { if(level<0) return Double.POSITIVE_INFINITY; if(level>=gridset.getNumLevels()) return 0; return gridset.getGrid(level).getScaleDenominator(); }
/** * The base cordinates in x/y order, used to map tile indexes to coordinate bounding boxes. * These can either be top left or bottom left, so must be kept private. * * <p>This is a derived property of {@link #getOriginalExtent()} and {@link * #isTopLeftAligned()}. */ public double[] tileOrigin() { BoundingBox extent = getOriginalExtent(); double[] tileOrigin = {extent.getMinX(), yBaseToggle ? extent.getMaxY() : extent.getMinY()}; return tileOrigin; }
public void testBoundingBoxTricky2() throws Exception { BoundingBox extent = new BoundingBox(-180, -90, 180, 82); SRS srs = SRS.getEPSG4326(); GridSet gridSet = GridSetFactory.createGridSet( "test", srs, extent, false, 4, null, 0.00028, 256, 256, false); assertEquals("test", gridSet.getName()); assertEquals(-180.0, gridSet.tileOrigin()[0]); assertEquals(-90.0, gridSet.tileOrigin()[1]); assertEquals(4, gridSet.getGridLevels().length); Grid grid0 = gridSet.getGridLevels()[0]; assertEquals(180.0 / 256, grid0.getResolution()); assertEquals(2L, grid0.getNumTilesWide()); assertEquals(1L, grid0.getNumTilesHigh()); }
public void testGridNames() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180, 90); int zoomStart = 3; int zoomStop = 9; GridSubset grid = GridSubsetFactory.createGridSubSet( gridSetBroker.getWorldEpsg4326(), bbox, zoomStart, zoomStop); String[] gridNames = grid.getGridNames(); final int nlevels = 1 + (grid.getZoomStop() - grid.getZoomStart()); assertEquals(nlevels, gridNames.length); for (String name : gridNames) { assertNotNull(name); } }
public void testCoverageBounds2() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180, 90); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 1); long[] ret = grid.getCoverage(1); long[] correct = {2, 1, 3, 1, 1}; assertTrue(Arrays.equals(correct, ret)); }
public void testGridIndex() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180, 90); int zoomStart = 3; int zoomStop = 9; GridSubset grid = GridSubsetFactory.createGridSubSet( gridSetBroker.getWorldEpsg4326(), bbox, zoomStart, zoomStop); String[] gridNames = grid.getGridNames(); for (int i = 0, z = zoomStart; i < gridNames.length; i++, z++) { assertEquals(z, grid.getGridIndex(gridNames[i])); } } }
public void test5gridLevels4326() throws Exception { BoundingBox bbox = new BoundingBox(-124.731422, 24.955967, -66.969849, 49.371735); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[][] solution = {{0, 0, 0, 0, 0}, {0, 1, 1, 1, 1}, {1, 2, 2, 3, 2}, {2, 5, 5, 6, 3}}; for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); if (!Arrays.equals(solution[i], bounds)) { System.out.println(Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); } assertTrue(Arrays.equals(solution[i], bounds)); } }
public void testWMTSCoverage() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180, 90); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 1, 3); long[][] coverages = grid.getWMTSCoverages(); assertEquals(3, coverages.length); long[] correct = {2, 0, 3, 0}; assertTrue(Arrays.equals(correct, coverages[0])); }
public void test5gridBoundsLoc4326() throws Exception { BoundingBox bbox = new BoundingBox(-124.73, 24.96, -66.97, 49.37); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[] bestFit = grid.getCoverageBestFit(); long[] solution = {0, 0, 0, 0, 0}; assertTrue(Arrays.equals(bestFit, solution)); }
public double[] getResolutions() { double[] ret = new double[gridCoverageLevels.size()]; final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); final Grid[] gridLevels = gridSet.getGridLevels(); for (int z = zoomStart, i = 0; z <= zoomStop; z++, i++) { Grid grid = gridLevels[z]; ret[i] = grid.getResolution(); } return ret; }
public long getGridIndex(String gridId) { final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); for (int index = zoomStart; index <= zoomStop; index++) { if (gridSet.getGrid(index).getName().equals(gridId)) { return index; } } return -1L; }
public synchronized void put(GridSet gridSet) { remove(gridSet.getName()); addGridSet(gridSet); }
public static GridSubset createGridSubSet(GridSet gridSet) { GridSubset ret = createGridSubSet( gridSet, gridSet.getOriginalExtent(), 0, gridSet.getGridLevels().length - 1); return ret; }
public void checkTileDimensions(int width, int height) throws TileDimensionsMismatchException { if (width != gridSet.getTileWidth() || height != gridSet.getTileHeight()) { throw new TileDimensionsMismatchException( width, height, gridSet.getTileWidth(), gridSet.getTileWidth()); } }
public BoundingBox getCoverageBounds(int level) { long[] coverage = getCoverage(level); return gridSet.boundsFromRectangle(coverage); }
public long getNumTilesHigh(int zoomLevel) { return gridSet.getGridLevels()[zoomLevel].getNumTilesHigh(); }
public long getNumTilesWide(int zoomLevel) { return gridSet.getGridLevels()[zoomLevel].getNumTilesWide(); }
public BoundingBox getOriginalExtent() { if (this.subSetExtent == null) { return gridSet.getOriginalExtent(); } return this.subSetExtent; }
public void testCoverageBounds() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180, 90); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 0); long[] ret = grid.getCoverage(0); long[] correct = {1, 0, 1, 0, 0}; assertTrue(Arrays.equals(correct, ret)); }