public BoundingBox getBboxForGridLoc(SRS srs, int[] gridLoc) { double tileWidth = 180.0 / Math.pow(2, gridLoc[2]); BoundingBox bbox = new BoundingBox( -180.0 + tileWidth * gridLoc[0], -90.0 + tileWidth * gridLoc[1], -180.0 + tileWidth * (gridLoc[0] + 1), -90.0 + tileWidth * (gridLoc[1] + 1)); return bbox; }
public BoundingBox getBboxForGridLoc(SRS srs, int[] gridLoc) { double tileWidth = 180.0 / Math.pow(2, gridLoc[2]); BoundingBox bbox = new BoundingBox(-180.0 + tileWidth * gridLoc[0], -90.0 + tileWidth * gridLoc[1], -180.0 + tileWidth * (gridLoc[0] + 1), -90.0 + tileWidth * (gridLoc[1] + 1)); return bbox; }
public static WMSLayer createWMSLayer(final String format, final GridSetBroker gridSetBroker) { BoundingBox boundingBox = new BoundingBox(-30.0, 15.0, 45.0, 30); return createWMSLayer(format, gridSetBroker, 3, 3, boundingBox); }
public BoundingBox parseLayerBounds(final Reader layerBoundsFile) { EnvelopeN envN = (EnvelopeN) getConfiguredXStream().fromXML(layerBoundsFile); BoundingBox bbox = new BoundingBox(envN.getXmin(), envN.getYmin(), envN.getXmax(), envN.getYmax()); return bbox; } }
public void setUp() { RasterMaskTestUtils.debugToDisk = debugToDisk; layer = TestUtils.createWMSLayer( "image/png", new GridSetBroker(false, false), 3, 3, new BoundingBox(-180, -90, 180, 90)); gridsetId = layer.getGridSubsets().iterator().next(); }
public void testBBOXScale() throws Exception { BoundingBox bbox = new BoundingBox(-180.0, -90.0, 180.0, 90.0); BoundingBox copy = new BoundingBox(bbox); bbox.scale(1.0); bbox.scale(0.5); bbox.scale(2.0); assert (bbox.isSane()); assert (bbox.equals(copy)); }
@Test public void testClosestIndex() throws Exception { BoundingBox box = new BoundingBox(-180.0, -90.0, -90.0, 0); long[] idxTL = gridSetTL.closestIndex(box); long[] idxBL = gridSetBL.closestIndex(box); long[] solution = {0, 0, 1}; assertTrue(Arrays.equals(idxTL, solution)); assertTrue(Arrays.equals(idxBL, solution)); }
public void setUp() { RasterMaskTestUtils.debugToDisk = debugToDisk; layer = TestUtils.createWMSLayer( "image/png", new GridSetBroker(false, false), 3, 3, new BoundingBox(-180, -90, 180, 90)); gridsetId = layer.getGridSubsets().iterator().next(); fullCoverage = layer.getGridSubset(gridsetId).getCoverages(); }
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 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)); }
@Test public void testClosestRectangle() throws Exception { BoundingBox box = new BoundingBox(-180.0, -90.0, 0.0, 0.0); long[] rectTL = gridSetTL.closestRectangle(box); long[] rectBL = gridSetBL.closestRectangle(box); long[] solution = {0, 0, 1, 0, 1}; assertTrue(Arrays.equals(rectTL, solution)); assertTrue(Arrays.equals(rectBL, solution)); }
@Test public void testClosestIndexInvalidBounds1() throws Exception { BoundingBox box = new BoundingBox(0, -180, 180.0, 0); exception.expect(GridAlignmentMismatchException.class); gridSetTL.closestIndex(box); }
@Test public void testClosestIndexInvalidBounds2() throws Exception { BoundingBox box = new BoundingBox(0, 0, 180.0, 180); exception.expect(GridAlignmentMismatchException.class); gridSetTL.closestIndex(box); } }
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)); }
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 testIntersection() throws Exception { BoundingBox bb1 = new BoundingBox(0, 0, 10, 10); BoundingBox bb2 = new BoundingBox(5, 5, 20, 20); BoundingBox intersection = BoundingBox.intersection(bb1, bb2); assertNotNull(intersection); assertEquals(5D, intersection.getWidth()); assertEquals(5D, intersection.getHeight()); assertTrue(intersection.isSane()); assertTrue(Arrays.equals(new double[] {5, 5, 10, 10}, intersection.getCoords())); }
/** Copy constructor */ public XMLGridSubset(XMLGridSubset sset) { setGridSetName(sset.getGridSetName()); setExtent(sset.getExtent() == null ? null : new BoundingBox(sset.getExtent())); setZoomStart(sset.getZoomStart()); setZoomStop(sset.getZoomStop()); setMinCachedLevel(sset.getMinCachedLevel()); setMaxCachedLevel(sset.getMaxCachedLevel()); }
/** Builds an XMLGridSubset out of a {@link GridSubset} */ public XMLGridSubset(GridSubset sset) { setGridSetName(sset.getName()); setExtent( sset.getOriginalExtent() == null ? null : new BoundingBox(sset.getOriginalExtent())); setZoomStart(sset.getZoomStart()); setZoomStop(sset.getZoomStop()); setMinCachedLevel(sset.getMinCachedZoom()); setMaxCachedLevel(sset.getMaxCachedZoom()); }
@Test public void testBoundsFromIndex() throws Exception { long[] index = {0, 0, 1}; BoundingBox bboxTL = gridSetTL.boundsFromIndex(index); BoundingBox bboxBL = gridSetBL.boundsFromIndex(index); BoundingBox bboxTLswap = gridSetTLswap.boundsFromIndex(index); BoundingBox bboxBLswap = gridSetBLswap.boundsFromIndex(index); BoundingBox solution = new BoundingBox(-180.0, -90.0, -90.0, 0); assertThat(bboxTL, closeTo(solution, 0.00000001)); assertThat(bboxBL, closeTo(solution, 0.00000001)); assertThat(bboxTLswap, closeTo(solution, 0.00000001)); assertThat(bboxBLswap, closeTo(solution, 0.00000001)); }
@Test public void testBounds() throws Exception { BoundingBox bboxTL = gridSetTL.getBounds(); BoundingBox bboxBL = gridSetBL.getBounds(); BoundingBox bboxTLswap = gridSetTLswap.getBounds(); BoundingBox bboxBLswap = gridSetBLswap.getBounds(); BoundingBox solution = new BoundingBox(-180.0, -90.0, 180, 90); assertThat(bboxTL, closeTo(solution, 0.00000001)); assertThat(bboxBL, closeTo(solution, 0.00000001)); assertThat(bboxTLswap, closeTo(solution, 0.00000001)); assertThat(bboxBLswap, closeTo(solution, 0.00000001)); }