public BoundingBox getBounds(SRS srs) { return new BoundingBox(-180.0, -90.0, 180.0, 90.0); }
private void makeBboxHints(StringBuilder doc, TileLayer tl) { for (String gridSetId : tl.getGridSubsets()) { GridSubset subset = tl.getGridSubset(gridSetId); doc.append( "<li>" + gridSetId + ": " + subset.getOriginalExtent().toString() + "</li>\n"); } }
/** * 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; }
protected void determineCanvasLayout() { srcRectangle = gridSubset.getCoverageIntersection(srcIdx, reqBounds); srcBounds = gridSubset.boundsFromRectangle(srcRectangle); // We now have the complete area, lets figure out our offsets // Positive means that there is blank space to the first tile, // negative means we will not use the entire tile boundOfs[0] = srcBounds.getMinX() - reqBounds.getMinX(); boundOfs[1] = srcBounds.getMinY() - reqBounds.getMinY(); boundOfs[2] = reqBounds.getMaxX() - srcBounds.getMaxX(); boundOfs[3] = reqBounds.getMaxY() - srcBounds.getMaxY(); canvasSize[0] = (int) Math.round(reqBounds.getWidth() / this.srcResolution); canvasSize[1] = (int) Math.round(reqBounds.getHeight() / this.srcResolution); // Calculate the corresponding pixel offsets. We'll stick to sane, // i.e. bottom left, coordinates at this point for (int i = 0; i < 4; i++) { canvOfs[i] = (int) Math.round(boundOfs[i] / this.srcResolution); } if (log.isDebugEnabled()) { log.debug("intersection rectangle: " + Arrays.toString(srcRectangle)); log.debug("intersection bounds: " + srcBounds + " (" + reqBounds + ")"); log.debug("Bound offsets: " + Arrays.toString(boundOfs)); log.debug("Canvas size: " + Arrays.toString(canvasSize) + "(" + reqWidth + "," + reqHeight + ")"); log.debug("Canvas offsets: " + Arrays.toString(canvOfs)); } }
Assert.notNull(srs, "srs is null"); Assert.notNull(extent, "extent is null"); Assert.isTrue(!extent.isNull() && extent.isSane(), "Extent is invalid: " + extent); Assert.isTrue(resolutions != null || scaleDenoms != null); Assert.isTrue( (long) Math.ceil((extent.getWidth() - mapUnitWidth * 0.01) / mapUnitWidth); final long tilesHigh = (long) Math.ceil((extent.getHeight() - mapUnitHeight * 0.01) / mapUnitHeight); final boolean yCoordinateFirst) { final double extentWidth = extent.getWidth(); final double extentHeight = extent.getHeight(); final double adjustedExtentHeight = tilesHigh * tileHeight * res; BoundingBox adjExtent = new BoundingBox(extent); adjExtent.setMaxX(adjExtent.getMinX() + adjustedExtentWidth); adjExtent.setMinY(adjExtent.getMaxY() - adjustedExtentHeight); } else { adjExtent.setMaxY(adjExtent.getMinY() + adjustedExtentHeight);
double heightRelDelta = ((1.0 * metaTileHeight + gutterConfig) / metaTileHeight) - 1.0; double coordWidth = metaBbox.getWidth(); double coordHeight = metaBbox.getHeight(); metaTileWidth += gutterConfig; gutter[0] = gutterConfig; metaBbox.setMinX(metaBbox.getMinX() - coordWidthDelta); metaBbox.setMinY(metaBbox.getMinY() - coordHeightDelta); metaBbox.setMaxX(metaBbox.getMaxX() + coordWidthDelta); metaBbox.setMaxY(metaBbox.getMaxY() + coordHeightDelta);
@Test public void testTileFuserSuperset() throws Exception { TileLayer layer = createWMSLayer(); // request larger than -30.0,15.0,45.0,30 BoundingBox bounds = new BoundingBox(-35.0, 14.0, 55.0, 39); // One in between int width = (int) bounds.getWidth() * 25; int height = (int) bounds.getHeight() * 25; GridSubset gridSubset = layer.getGridSubset(layer.getGridSubsets().iterator().next()); TileLayerDispatcher tld = mock(TileLayerDispatcher.class); Mockito.when(tld.getTileLayer("test:layer")).thenReturn(layer); StorageBroker sb = mock(StorageBroker.class); WMSTileFuser tileFuser = new WMSTileFuser(tld, sb, fuserRequest(layer, gridSubset, bounds, width, height)); tileFuser.setSecurityDispatcher(secDisp); tileFuser.determineSourceResolution(); tileFuser.determineCanvasLayout(); }
public void testTopLeftNaive() throws Exception { // This mimics the Spearfish layer BoundingBox bbox = new BoundingBox(-180.0, -90.0, 180.0, 90.0); BoundingBox gridBase = new BoundingBox(-180.0, -90.0, 180.0, 90.0); GridSet gridSet = GridSetFactory.createGridSet( "bogus", SRS.getSRS(4326), gridBase, true, 30, null, 0.00028, 256, 256, false); GridSubset gridSubset = GridSubsetFactory.createGridSubSet(gridSet, bbox, 0, 20); // Check the actual max bounds long[] solution = {0, 0, 0}; long[] closest = gridSubset.closestIndex(new BoundingBox(-180.0, -90.0, 0.0, 90.0)); assertTrue(Arrays.equals(solution, closest)); long[] solution2 = {1, 0, 0}; closest = gridSubset.closestIndex(new BoundingBox(0.0, -90.0, 180.0, 90.0)); assertTrue(Arrays.equals(solution2, closest)); long[] t1 = {0, 0, 1}; // 90x90 degrees BoundingBox test1 = gridSubset.boundsFromIndex(t1); assertTrue(Math.abs(test1.getMinX() + 180.0) < 0.01); assertTrue(Math.abs(test1.getMinY() + 90.0) < 0.01); assertTrue(Math.abs(test1.getMaxY()) < 0.01); }
private BoundingBox createApproximateTileBounds( GridSubset gridSubset, BoundingBox bbox, double resolution, int tileWidth, int tileHeight) { double width = tileWidth * resolution; double height = tileHeight * resolution; BoundingBox ret = new BoundingBox( bbox.getMinX() + width, bbox.getMinY() + height, bbox.getMinX() + width * 2, bbox.getMinY() + height * 2); return ret; } }
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())); }
double ymin = layerBounds.getMinY(); double xmax = layerBounds.getMaxX(); gridSetExtent = new BoundingBox(xmin, ymin, xmax, ymax);
final TileLayer layer = createWMSLayer(); BoundingBox bounds = new BoundingBox(-35.0, 14.0, 55.0, 39); int width = (int) bounds.getWidth() * 25; int height = (int) bounds.getHeight() * 25; layer.getGridSubset(layer.getGridSubsets().iterator().next()); File temp = File.createTempFile("gwc", "wms"); request.addParameter("width", width + ""); request.addParameter("height", height + ""); request.addParameter("bbox", bounds.toString()); final File imageTile = new File(getClass().getResource("/image.png").toURI());
double maxY = layer.getLatLonBoundingBox().getMaxY(); BoundingBox bounds4326 = new BoundingBox(minX, minY, maxX, maxY); + bounds4326.toString()); BoundingBox bounds3785 = new BoundingBox(longToSphericalMercatorX(minX), latToSphericalMercatorY(minY), longToSphericalMercatorX(maxX), latToSphericalMercatorY(maxY));
/** * Verifies that this functions output remains as expected, since we communicate a lot using * strings. * * <p>Ff not you should figure out where it is used. * * @throws Exception */ public void testBBOX() throws Exception { BoundingBox bbox = new BoundingBox(-180.0, -90.0, 180.0, 90.0); assert (bbox.isSane()); String bboxStr = bbox.toString(); if (bboxStr.equalsIgnoreCase("-180.0,-90.0,180.0,90.0")) { assertTrue(true); } else { assertTrue(false); } }
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 testTileFuserSubset() throws Exception { TileLayer layer = createWMSLayer(); // request fits inside -30.0,15.0,45.0,30 BoundingBox bounds = new BoundingBox(-25.0, 17.0, 40.0, 22); // One in between int width = (int) bounds.getWidth() * 10; int height = (int) bounds.getHeight() * 10; GridSubset gridSubset = layer.getGridSubset(layer.getGridSubsets().iterator().next()); TileLayerDispatcher tld = mock(TileLayerDispatcher.class); Mockito.when(tld.getTileLayer("test:layer")).thenReturn(layer); StorageBroker sb = mock(StorageBroker.class); WMSTileFuser tileFuser = new WMSTileFuser(tld, sb, fuserRequest(layer, gridSubset, bounds, width, height)); tileFuser.setSecurityDispatcher(secDisp); tileFuser.determineSourceResolution(); tileFuser.determineCanvasLayout(); assertTrue(tileFuser.srcBounds.contains(bounds)); WMSTileFuser.PixelOffsets comparison = new WMSTileFuser.PixelOffsets(); // -228, -193, -56, -6 comparison.left = -228; comparison.bottom = -193; comparison.right = -56; comparison.top = -6; assertEquals(comparison.left, tileFuser.canvOfs.left); assertEquals(comparison.bottom, tileFuser.canvOfs.bottom); assertEquals(comparison.right, tileFuser.canvOfs.right); assertEquals(comparison.top, tileFuser.canvOfs.top); }
/** * Two bboxes don't intersect, BoundingBox.intersection()'s result should be the empty bbox * * @throws Exception */ public void testIntersectionNonIntersecting() throws Exception { BoundingBox bb1 = new BoundingBox(0, 0, 10, 10); BoundingBox bb2 = new BoundingBox(11, 11, 20, 20); BoundingBox intersection = BoundingBox.intersection(bb1, bb2); assertNotNull(intersection); assertTrue(intersection.isNull()); assertFalse(intersection.isSane()); } }
public void testBounds() { assertTrue(gridset.isTopLeftAligned()); BoundingBox bounds = gridset.getBounds(); TileOrigin tileOrigin = cacheInfo.getTileCacheInfo().getTileOrigin(); assertEquals(tileOrigin.getX(), bounds.getMinX()); assertEquals(tileOrigin.getY(), bounds.getMaxY()); assertTrue(bounds.contains(layerBounds)); }