String[] boundsPrep(BoundingBox bbox) { String[] bs = { Double.toString(bbox.getMinX()), Double.toString(bbox.getMinY()), Double.toString(bbox.getMaxX()), Double.toString(bbox.getMaxY()) }; return bs; } }
String[] boundsPrep(BoundingBox bbox) { String[] bs = { Double.toString(bbox.getMinX()), Double.toString(bbox.getMinY()), Double.toString(bbox.getMaxX()), Double.toString(bbox.getMaxY()) }; return bs; } }
String[] boundsPrep(BoundingBox bbox) { String[] bs = { Double.toString(bbox.getMinX()), Double.toString(bbox.getMinY()), Double.toString(bbox.getMaxX()), Double.toString(bbox.getMaxY()) }; return bs; }
String[] boundsPrep(BoundingBox bbox) { String[] bs = { Double.toString(bbox.getMinX()), Double.toString(bbox.getMinY()), Double.toString(bbox.getMaxX()), Double.toString(bbox.getMaxY()) }; return bs; } }
/** * 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)); } }
private static Envelope toEnvelope(BoundingBox bounds) { return new Envelope(bounds.getMinX(), bounds.getMaxX(), bounds.getMinY(), bounds.getMaxY()); } }
/** * Find the rectangle of tiles that most closely covers the given rectangle * * @param level integer zoom level to consider tiles at * @param rectangeBounds rectangle to match * @return Array of long, the rectangle of tiles in tile coordinates: {minx, miny, maxx, maxy, * level} */ protected long[] closestRectangle(int level, BoundingBox rectangeBounds) { Grid grid = getGridLevels()[level]; double width = grid.getResolution() * getTileWidth(); double height = grid.getResolution() * getTileHeight(); long minX = (long) Math.floor((rectangeBounds.getMinX() - tileOrigin()[0]) / width); long minY = (long) Math.floor((rectangeBounds.getMinY() - tileOrigin()[1]) / height); long maxX = (long) Math.ceil(((rectangeBounds.getMaxX() - tileOrigin()[0]) / width)); long maxY = (long) Math.ceil(((rectangeBounds.getMaxY() - tileOrigin()[1]) / height)); if (yBaseToggle) { minY = minY + grid.getNumTilesHigh(); maxY = maxY + grid.getNumTilesHigh(); } // We substract one, since that's the tile at that position long[] ret = {minX, minY, maxX - 1, maxY - 1, level}; return ret; }
@Override public void checkSecurity(TileLayer layer, BoundingBox extent, SRS srs) throws SecurityException, GeoWebCacheException { if (GWC.get().getConfig().isSecurityEnabled()) { try { ReferencedEnvelope env; if (Objects.nonNull(extent)) { env = new ReferencedEnvelope( extent.getMinX(), extent.getMaxX(), extent.getMinY(), extent.getMaxY(), CRS.decode(srs.toString())); } else { env = null; } GWC.get().verifyAccessLayer(layer.getName(), env); } catch (ServiceException | MismatchedDimensionException | FactoryException e) { throw new GeoWebCacheException(e); } } } }
private static String getLookAt(BoundingBox bbox) { double lon1 = bbox.getMinX(); double lat1 = bbox.getMinY(); double lon2 = bbox.getMaxX(); double lat2 = bbox.getMaxY(); double R_EARTH = 6.371 * 1000000; // meters // double VIEWER_WIDTH = 22 * Math.PI / 180; // The field of view of the // // google maps camera, in // // radians double[] p1 = getRect(lon1, lat1, R_EARTH); double[] p2 = getRect(lon2, lat2, R_EARTH); double[] midpoint = new double[] { (p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2, (p1[2] + p2[2]) / 2 }; midpoint = getGeographic(midpoint[0], midpoint[1], midpoint[2]); // averaging the longitudes; using the rectangular coordinates makes the // calculated center tend toward the corner that's closer to the // equator. midpoint[0] = ((lon1 + lon2) / 2); double distance = distance(p1, p2); // double height = distance / (2 * Math.tan(VIEWER_WIDTH)); return "<LookAt id=\"superoverlay\">" + "\n<longitude>" + ((lon1 + lon2) / 2) + "</longitude>" + "\n<latitude>" + midpoint[1] + "</latitude>" + "\n<altitude>0</altitude>" + "\n<heading>0</heading>" + "\n<tilt>0</tilt>" + "\n<range>" + distance + "</range>" + "\n<altitudeMode>clampToGround</altitudeMode>" // + "\n<!--kml:altitudeModeEnum:clampToGround, relativeToGround, absolute -->" + "\n</LookAt>\n"; }
assertFalse(bounds.intersects(layerBounds.getMaxX(), layerBounds.getMaxY()));
double lat1 = bbox.getMinY(); double lon2 = bbox.getMaxX(); double lat2 = bbox.getMaxY();
bounds.getMaxY()); request.setBbox(reqBbox);
metaTileHeight += gutterConfig; gutter[3] = gutterConfig; metaBbox.setMaxY(metaBbox.getMaxY() + coordHeightDelta);
Matcher<BoundingBox> closeTo(BoundingBox expected, double error) { return allOf( hasProperty("minX", Matchers.closeTo(expected.getMinX(), error)), hasProperty("minY", Matchers.closeTo(expected.getMinY(), error)), hasProperty("maxX", Matchers.closeTo(expected.getMaxX(), error)), hasProperty("maxY", Matchers.closeTo(expected.getMaxY(), error))); }
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); }
BoundingBox prescribedBounds = gridSetBroker.WORLD_EPSG3857.getBounds(); return JTS.toGeometry(new Envelope(prescribedBounds.getMinX(), prescribedBounds .getMaxX(), prescribedBounds.getMinY(), prescribedBounds.getMaxY()));
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)); }
bounds.getMaxY()); request.setBbox(reqBbox);