private KMLDebugGridLayer() { super.subSets = new Hashtable<String, GridSubset>(); subSets.put( gridSetBroker.getWorldEpsg4326().getName(), GridSubsetFactory.createGridSubSet( gridSetBroker.getWorldEpsg4326(), BoundingBox.WORLD4326, 0, 3)); }
protected String profileForGridSet(GridSet gridSet) { if (gridSet == gsb.getWorldEpsg4326()) { return "global-geodetic"; } else if (gridSet == gsb.getWorldEpsg3857()) { return "global-mercator"; } else { return "local"; } }
private void writeSiteMapIndexLoop() throws IOException { OutputStream os = tile.servletResp.getOutputStream(); String urlPrefix = tile.getUrlPrefix(); Iterable<TileLayer> iter = tLD.getLayerList(); for (TileLayer tl : iter) { if (!tl.isEnabled()) { continue; } Set<String> grids = tl.getGridSubsets(); List<MimeType> mimeTypes = tl.getMimeTypes(); if (grids != null && grids.contains(gridSetBroker.getWorldEpsg4326().getName()) && mimeTypes != null && mimeTypes.contains(XMLMime.kml)) { String smStr = "<sitemap><loc>" + urlPrefix + tl.getName() + "/sitemap.xml</loc></sitemap>"; os.write(smStr.getBytes()); } } }
@Override protected TileLayer getGoodInfo(String id, int rand) throws Exception { return new WMSLayer( id, new String[] {"http://foo"}, "style", Integer.toString(rand), Collections.<String>emptyList(), Collections.<String, GridSubset>singletonMap( "EPSG:4326", GridSubsetFactory.createGridSubSet(broker.getWorldEpsg4326())), Collections.<ParameterFilter>emptyList(), new int[] {3, 3}, "", false, null); } /*(String layerName, String[] wmsURL, String wmsStyles, String wmsLayers,
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 test1gridLevels4326() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180.0, 90.0); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[][] solution = {{1, 0, 1, 0, 0}, {2, 1, 3, 1, 1}, {4, 2, 7, 3, 2}, {8, 4, 15, 7, 3}}; for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); if (!Arrays.equals(solution[i], bounds)) { System.out.println( i + " " + Arrays.toString(solution[i]) + " " + Arrays.toString(bounds)); } assertTrue(Arrays.equals(solution[i], bounds)); } }
public void test3gridLevels4326() throws Exception { BoundingBox bbox = new BoundingBox(-10.0, -10.0, 10.0, 10.0); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[][] solution = { {0, 0, 1, 0, 0}, {1, 0, 2, 1, 1}, {3, 1, 4, 2, 2}, {7, 3, 8, 4, 3}, {15, 7, 16, 8, 4}, {30, 14, 33, 17, 5}, {60, 28, 67, 35, 6}, {120, 56, 135, 71, 7} }; 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 test2gridLevels4326() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 180, 90); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[][] solution = { {1, 0, 1, 0, 0}, {2, 1, 3, 1, 1}, {4, 2, 7, 3, 2}, {8, 4, 15, 7, 3}, {16, 8, 31, 15, 4}, {32, 16, 63, 31, 5}, {64, 32, 127, 63, 6} }; 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 test4gridLevels4326() throws Exception { BoundingBox bbox = new BoundingBox(175.0, 87.0, 180.0, 90.0); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[][] solution = { {1, 0, 1, 0, 0}, {3, 1, 3, 1, 1}, {7, 3, 7, 3, 2}, {15, 7, 15, 7, 3}, {31, 15, 31, 15, 4}, {63, 31, 63, 31, 5}, {126, 62, 127, 63, 6}, {252, 125, 255, 127, 7}, {504, 251, 511, 255, 8} }; 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 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)); }
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)); }
private WMSLayer createWMSLayer(BoundingBox layerBounds) { String[] urls = {"http://localhost:38080/wms"}; List<String> formatList = new LinkedList<String>(); formatList.add("image/png"); Hashtable<String, GridSubset> grids = new Hashtable<String, GridSubset>(); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326()); grids.put(grid.getName(), grid); int[] metaWidthHeight = {3, 3}; WMSLayer layer = new WMSLayer( "test:layer", urls, "aStyle", "test:layer", formatList, grids, null, metaWidthHeight, "vendorparam=true", false, null); layer.initialize(gridSetBroker); return layer; }
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 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(); }
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 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); } }
private void writeSiteMap() throws GeoWebCacheException, IOException { TileLayer layer = tile.getLayer(); GridSubset gridSubset = layer.getGridSubset(gridSetBroker.getWorldEpsg4326().getName()); writeSiteMapHeader(); long[] gridRect = gridSubset.getCoverageBestFit(); // Check whether we need two tiles for world bounds or not if (gridRect[4] > 0 && (gridRect[2] != gridRect[0] || gridRect[3] != gridRect[1])) { throw new GeoWebCacheException( layer.getName() + " is too big for the sub grid set for " + gridSubset.getName() + ", allow for smaller zoom levels."); } else if (gridRect[0] != gridRect[2]) { long[] gridLocWest = {0, 0, 0}; long[] gridLocEast = {1, 0, 0}; writeSiteMapLoop(gridLocWest); writeSiteMapLoop(gridLocEast); } else { long[] gridLoc = {gridRect[0], gridRect[1], gridRect[4]}; writeSiteMapLoop(gridLoc); } writeSiteMapFooter(); }
public void test6gridLoctoBounds4326() throws Exception { BoundingBox bbox = new BoundingBox(-124.73, 24.96, -66.97, 49.37); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg4326(), bbox, 0, 10); long[] gridLoc1 = {1, 1, 1}; BoundingBox box1 = grid.boundsFromIndex(gridLoc1); boolean box1_comparison = box1.equals(new BoundingBox(-90.0, 0.0, 0.0, 90.0)); assertTrue(box1_comparison); boolean box1_kml = box1.toKMLLatLonBox() .equals( "<LatLonBox><north>90.0</north><south>0.0</south>" + "<east>0.0</east><west>-90.0</west></LatLonBox>"); assertTrue(box1_kml); long[] gridLoc2 = {5, 1, 2}; BoundingBox box2 = grid.boundsFromIndex(gridLoc2); boolean box2_comparison = box2.equals(new BoundingBox(45.0, -45.0, 90.0, 0.0)); assertTrue(box2_comparison); boolean box2_kml = box2.toKMLLatLonAltBox() .equals( "<LatLonAltBox><north>0.0</north><south>-45.0</south>" + "<east>90.0</east><west>45.0</west></LatLonAltBox>"); assertTrue(box2_kml); }
private void commonCreateTileFromMetaTileTest(Color[][] colors, RenderedImage metaTileImage) throws Exception { // creating the meta tile BoundingBox boundingBox = new BoundingBox(0, 0, 180, 90); int metaHeight = 2; int metaWidth = 2; GridSubset grid = GridSubsetFactory.createGridSubSet( gridSetBroker.getWorldEpsg4326(), boundingBox, 0, 21); long[] gridPos = {0, 0, 0}; MetaTile metaTile = new MetaTile(grid, ImageMime.png, null, gridPos, metaWidth, metaHeight, null); metaTile.setImage(metaTileImage); // extracting the tiles using the create tile method int width = metaTile.getMetaTileWidth(); int height = metaTile.getMetaTileHeight(); checkImageBorderSameColor(metaTile.createTile(0, 0, width, height), colors[0][0]); checkImageBorderSameColor(metaTile.createTile(width, 0, width, height), colors[0][1]); checkImageBorderSameColor(metaTile.createTile(0, height, width, height), colors[1][0]); checkImageBorderSameColor(metaTile.createTile(width, height, width, height), colors[1][1]); }