public int getTileHeight() { return gridSet.getTileHeight(); }
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 long[] closestRectangle(BoundingBox rectangleBounds) { double rectWidth = rectangleBounds.getWidth(); double rectHeight = rectangleBounds.getHeight(); double bestError = Double.MAX_VALUE; int bestLevel = -1; // Now we loop over the resolutions until for (int i = 0; i < getGridLevels().length; i++) { Grid grid = getGridLevels()[i]; double countX = rectWidth / (grid.getResolution() * getTileWidth()); double countY = rectHeight / (grid.getResolution() * getTileHeight()); double error = Math.abs(countX - Math.round(countX)) + Math.abs(countY - Math.round(countY)); if (error < bestError) { bestError = error; bestLevel = i; } else if (error >= bestError) { break; } } return closestRectangle(bestLevel, rectangleBounds); }
protected long[] closestIndex(int level, BoundingBox tileBounds) throws GridAlignmentMismatchException { Grid grid = getGridLevels()[level]; double width = grid.getResolution() * getTileWidth(); double height = grid.getResolution() * getTileHeight(); double x = (tileBounds.getMinX() - tileOrigin()[0]) / width; double y = (tileBounds.getMinY() - tileOrigin()[1]) / height; long posX = (long) Math.round(x); long posY = (long) Math.round(y); if (Math.abs(x - posX) > 0.1 || Math.abs(y - posY) > 0.1) { throw new GridAlignmentMismatchException(x, posX, y, posY); } if (yBaseToggle) { posY = posY + grid.getNumTilesHigh(); } long[] ret = {posX, posY, level}; return ret; }
double dTileHeight = getTileHeight(); double dGridExtent = grid.getNumTilesHigh();
private String buildGetMap(final boolean directWMSIntegrationEndpoint, final String queryLayerName, final String gridsetId, String styles, final TileLayer tileLayer) { final GridSubset gridSubset = tileLayer.getGridSubset(gridsetId); long[] coverage = gridSubset.getCoverage(0); long[] tileIndex = { coverage[0], coverage[1], coverage[4] }; BoundingBox bounds = gridSubset.boundsFromIndex(tileIndex); final String endpoint = directWMSIntegrationEndpoint ? "wms" : "gwc/service/wms"; StringBuilder sb = new StringBuilder(endpoint); sb.append("?service=WMS&request=GetMap&version=1.1.1&format=image/png"); sb.append("&layers=").append(queryLayerName); sb.append("&srs=").append(gridSubset.getSRS()); sb.append("&width=").append(gridSubset.getGridSet().getTileWidth()); sb.append("&height=").append(gridSubset.getGridSet().getTileHeight()); sb.append("&styles="); if (styles != null) { sb.append(styles); } sb.append("&bbox=").append(bounds.toString()); return sb.toString(); }
public static byte[] createFakeSourceImage(final WMSLayer layer, final String gridsetId) throws IOException { int tileWidth = layer.getGridSubset(gridsetId).getGridSet().getTileWidth(); int tileHeight = layer.getGridSubset(gridsetId).getGridSet().getTileHeight(); int width = tileWidth * layer.getMetaTilingFactors()[0]; int height = tileHeight * layer.getMetaTilingFactors()[1]; ByteArrayOutputStream out = new ByteArrayOutputStream(); RenderedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); String formatName = layer.getMimeTypes().get(0).getInternalName(); ImageIO.write(image, formatName, out); return out.toByteArray(); }
/** * 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; }
if (gridSet.getTileHeight() < j || j < 0) { throw new OWSException( 400, "PointIJOutOfRange", "J", "J was " + j + ", must be between 0 and " + gridSet.getTileHeight());
public BoundingBox boundsFromIndex(long[] tileIndex) { final int tileZ = (int) tileIndex[2]; Grid grid = getGrid(tileZ); final long tileX = tileIndex[0]; final long tileY; if (yBaseToggle) { tileY = tileIndex[1] - grid.getNumTilesHigh(); } else { tileY = tileIndex[1]; } double width = grid.getResolution() * getTileWidth(); double height = grid.getResolution() * getTileHeight(); final double[] tileOrigin = tileOrigin(); BoundingBox tileBounds = new BoundingBox( tileOrigin[0] + width * tileX, tileOrigin[1] + height * (tileY), tileOrigin[0] + width * (tileX + 1), tileOrigin[1] + height * (tileY + 1)); return tileBounds; }
/** * Finds the spatial bounding box of a rectangular group of tiles. * * @param rectangleExtent the rectangle of tiles. {minx, miny, maxx, maxy} in tile coordinates * @return the spatial bounding box in the coordinates of the SRS used by the GridSet */ protected BoundingBox boundsFromRectangle(long[] rectangleExtent) { Grid grid = getGridLevels()[(int) rectangleExtent[4]]; double width = grid.getResolution() * getTileWidth(); double height = grid.getResolution() * getTileHeight(); long bottomY = rectangleExtent[1]; long topY = rectangleExtent[3]; if (yBaseToggle) { bottomY = bottomY - grid.getNumTilesHigh(); topY = topY - grid.getNumTilesHigh(); } double[] tileOrigin = tileOrigin(); double minx = tileOrigin[0] + width * rectangleExtent[0]; double miny = tileOrigin[1] + height * (bottomY); double maxx = tileOrigin[0] + width * (rectangleExtent[2] + 1); double maxy = tileOrigin[1] + height * (topY + 1); BoundingBox rectangleBounds = new BoundingBox(minx, miny, maxx, maxy); return rectangleBounds; }
needsTruncate |= isTopLeftAligned() != another.isTopLeftAligned(); needsTruncate |= getTileWidth() != another.getTileWidth(); needsTruncate |= getTileHeight() != another.getTileHeight(); needsTruncate |= !getSrs().equals(another.getSrs());
when(subset.getGridSet()).thenReturn(set); when(set.getTileHeight()).thenReturn(256); when(set.getTileWidth()).thenReturn(256);
when(subset.getGridSet()).thenReturn(set); when(set.getTileHeight()).thenReturn(256); when(set.getTileWidth()).thenReturn(256);
@Override public boolean equals(Object obj) { if (!(obj instanceof GridSet)) return false; GridSet other = (GridSet) obj; if (this == other) return true; boolean equals = ObjectUtils.equals(getSrs(), other.getSrs()) && ObjectUtils.equals(getName(), other.getName()) && ObjectUtils.equals(getDescription(), other.getDescription()) && ObjectUtils.equals(getTileWidth(), other.getTileWidth()) && ObjectUtils.equals(getTileHeight(), other.getTileHeight()) && ObjectUtils.equals(isTopLeftAligned(), other.isTopLeftAligned()) && ObjectUtils.equals(isyCoordinateFirst(), other.isyCoordinateFirst()) && ObjectUtils.equals(getOriginalExtent(), other.getOriginalExtent()) && Arrays.equals(getGridLevels(), other.getGridLevels()); return equals; }
public static byte[] createFakeSourceImage(final WMSLayer layer) throws IOException { int tileWidth = layer.getGridSubset(gridSetBroker.getWorldEpsg4326().getName()) .getGridSet() .getTileWidth(); int tileHeight = layer.getGridSubset(gridSetBroker.getWorldEpsg4326().getName()) .getGridSet() .getTileHeight(); int width = tileWidth * layer.getMetaTilingFactors()[0]; int height = tileHeight * layer.getMetaTilingFactors()[1]; ByteArrayOutputStream out = new ByteArrayOutputStream(); RenderedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); String formatName = layer.getMimeTypes().get(0).getInternalName(); ImageIO.write(image, formatName, out); return out.toByteArray(); }
private void tileMatrixSet(XMLBuilder xml, GridSet gridSet) throws IOException { xml.indentElement("TileMatrixSet"); xml.simpleElement("ows:Identifier", gridSet.getName(), true); // If the following is not good enough, please get in touch and we will try to fix it :) xml.simpleElement( "ows:SupportedCRS", "urn:ogc:def:crs:EPSG::" + gridSet.getSrs().getNumber(), true); // TODO detect these str.append(" // <WellKnownScaleSet>urn:ogc:def:wkss:GlobalCRS84Pixel</WellKnownScaleSet>\n"); Grid[] grids = gridSet.getGridLevels(); for (int i = 0; i < grids.length; i++) { double[] tlCoordinates = gridSet.getOrderedTopLeftCorner(i); tileMatrix( xml, grids[i], tlCoordinates, gridSet.getTileWidth(), gridSet.getTileHeight(), gridSet.isScaleWarning()); } xml.endElement("TileMatrixSet"); }
/** Builds an XMLGridSet from a GridSet */ public XMLGridSet(GridSet gset) { setAlignTopLeft(gset.isTopLeftAligned()); setYCoordinateFirst(gset.isyCoordinateFirst()); setExtent(gset.getOriginalExtent()); setLevels(null); if (gset.isResolutionsPreserved()) { setResolutions(resolutions(gset.getGridLevels())); setScaleDenominators(null); } else { setResolutions(null); setScaleDenominators(scaleDenominators(gset.getGridLevels())); } setMetersPerUnit(gset.getMetersPerUnit()); setName(gset.getName()); setDescription(gset.getDescription()); setPixelSize(gset.getPixelSize()); setScaleNames(scaleNames(gset.getGridLevels())); setSrs(gset.getSrs()); setTileWidth(gset.getTileWidth()); setTileHeight(gset.getTileHeight()); }