private KMLDebugGridLayer() { super.subSets = new Hashtable<String, GridSubset>(); subSets.put(gridSetBroker.WORLD_EPSG4326.getName(), GridSubsetFactory.createGridSubSet( gridSetBroker.WORLD_EPSG4326, BoundingBox.WORLD4326, 0, 3)); }
private KMLDebugGridLayer() { super.subSets = new Hashtable<String, GridSubset>(); subSets.put( gridSetBroker.getWorldEpsg4326().getName(), GridSubsetFactory.createGridSubSet( gridSetBroker.getWorldEpsg4326(), BoundingBox.WORLD4326, 0, 3)); }
public static GridSubset createGridSubSet(GridSet gridSet) { GridSubset ret = createGridSubSet( gridSet, gridSet.getOriginalExtent(), 0, gridSet.getGridLevels().length - 1); return ret; }
private Hashtable<String, GridSubset> createGridSubsets(final GridSetBroker gridSetBroker) { final CacheInfo info = this.cacheInfo; final TileCacheInfo tileCacheInfo = info.getTileCacheInfo(); final String layerName = getName(); final GridSetBuilder gsBuilder = new GridSetBuilder(); GridSet gridSet = gsBuilder.buildGridset(layerName, info, layerBounds); getGridsetConfiguration(gridSetBroker).addInternal(gridSet); final List<LODInfo> lodInfos = tileCacheInfo.getLodInfos(); Integer zoomStart = lodInfos.get(0).getLevelID(); Integer zoomStop = lodInfos.get(lodInfos.size() - 1).getLevelID(); GridSubset subSet = GridSubsetFactory.createGridSubSet(gridSet, this.layerBounds, zoomStart, zoomStop); Hashtable<String, GridSubset> subsets = new Hashtable<String, GridSubset>(); subsets.put(gridSet.getName(), subSet); return subsets; }
@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 GridSubset getGridSubSet(GridSetBroker gridSetBroker) { GridSet gridSet = gridSetBroker.get(getGridSetName()); if (gridSet == null) { log.error("Unable to find GridSet for \"" + getGridSetName() + "\""); return null; } return GridSubsetFactory.createGridSubSet( gridSet, getExtent(), getZoomStart(), getZoomStop(), minCachedLevel, maxCachedLevel); }
public void test1gridLevels900913() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 20037508.34, 20037508.34); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg3857(), bbox, 0, 10); long[][] solution = { {0, 0, 0, 0, 0}, {1, 1, 1, 1, 1}, {2, 2, 3, 3, 2}, {4, 4, 7, 7, 3}, {8, 8, 15, 15, 4} }; for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); if (!Arrays.equals(solution[i], bounds)) { System.out.println("test1gridLevels900913, level " + i); 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)); } }
/** * Truncates the cache for the default style of the given layer * * @param layerName */ public void truncateByLayerDefaultStyle(final String layerName) { checkNotNull(layerName, "layerName can't be null"); log.fine("truncating '" + layerName + "' for default style"); final TileLayer layer = getTileLayerByName(layerName); final Set<String> gridSetIds = layer.getGridSubsets(); // all of them final List<MimeType> mimeTypes = layer.getMimeTypes(); // all of them final BoundingBox bounds = null; // all of them final Map<String, String> parameters = null; // only default style for (String gridSetId : gridSetIds) { GridSubset gridSubset = layer.getGridSubset(gridSetId); if (gridSubset == null) { // layer may no longer have this gridsubset, but we want to truncate any remaining // tiles GridSet gridSet = gridSetBroker.get(gridSetId); gridSubset = GridSubsetFactory.createGridSubSet(gridSet); } for (MimeType mime : mimeTypes) { String formatName = mime.getFormat(); truncate(layer, bounds, gridSubset, formatName, parameters); } } }
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 test2gridLevels900913() throws Exception { BoundingBox bbox = new BoundingBox(0, 0, 20037508.34, 20037508.34); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg3857(), bbox, 0, 10); long[][] solution = { {0, 0, 0, 0, 0}, {1, 1, 1, 1, 1}, {2, 2, 3, 3, 2}, {4, 4, 7, 7, 3}, {8, 8, 15, 15, 4}, {16, 16, 31, 31, 5}, {32, 32, 63, 63, 6} }; for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); if (!Arrays.equals(solution[i], bounds)) { System.out.println("test2gridLevels900913, level " + i); 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 test3gridLevels900913() throws Exception { BoundingBox bbox = new BoundingBox(-500000, -500000, 500000, 500000); GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.getWorldEpsg3857(), bbox, 0, 10); long[][] solution = { {0, 0, 0, 0, 0}, {0, 0, 1, 1, 1}, {1, 1, 2, 2, 2}, {3, 3, 4, 4, 3}, {7, 7, 8, 8, 4}, {15, 15, 16, 16, 5}, {31, 31, 32, 32, 6}, {62, 62, 65, 65, 7} }; for (int i = 0; i < solution.length; i++) { long[] bounds = grid.getCoverage(i); if (!Arrays.equals(solution[i], bounds)) { System.out.println("test3gridLevels900913, level " + i); 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 static WMSLayer createWMSLayer( String format, GridSetBroker gridSetBroker, int metaTileFactorX, int metaTileFactorY, BoundingBox boundingBox) { String[] urls = {"http://localhost:38080/wms"}; List<String> formatList = Collections.singletonList(format); Hashtable<String, GridSubset> grids = new Hashtable<String, GridSubset>(); GridSubset grid = GridSubsetFactory.createGridSubSet( gridSetBroker.getWorldEpsg4326(), boundingBox, 0, 10); grids.put(grid.getName(), grid); int[] metaWidthHeight = {metaTileFactorX, metaTileFactorY}; WMSLayer layer = new WMSLayer( "test:layer", urls, "aStyle", "test:layer", formatList, grids, null, metaWidthHeight, "vendorparam=true", false, null); layer.initialize(gridSetBroker); return layer; }