Package org.geowebcache.layer

Examples of org.geowebcache.layer.TileLayer


        }

        // 1) Check that cite:Lakes
        boolean foundLakes = false;
        while(tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            if(tl.getName().equals("cite:Lakes")) {
                //tl.isInitialized();
                foundLakes = true;
                break;
            }
        }                   
        assertTrue(foundLakes);

        // 2) Check sf:GenerictEntity is present and initialized
        boolean foudAGF = false;
        while(tlIter.hasNext()) {
            TileLayer tl = tlIter.next();
            System.out.println(tl.getName());
            if(tl.getName().equals("sf:AggregateGeoFeature")) {
                //tl.isInitialized();
                foudAGF = true;
                GridSubset epsg4326 = tl.getGridSubset(gwcListener.gridSetBroker.WORLD_EPSG4326.getName());
                assertTrue(epsg4326.getGridSetBounds().equals( new BoundingBox(-180.0,-90.0,180.0,90.0)));
                String mime = tl.getMimeTypes().get(1).getMimeType();
                assertTrue(mime.startsWith("image/") || mime.startsWith("application/vnd.google-earth.kml+xml"));
            }
        }
       
        assertTrue(foudAGF);
       
       
        // 3) Basic get
        LayerInfo li = cat.getLayers().get(1);
        String layerName = li.getResource().getPrefixedName();
       
        TileLayer tl = tld.getTileLayer(layerName);
       
        assertEquals(layerName, tl.getName());
       
       
        // 4) Removal of LayerInfo from catalog
        cat.remove(li);
       
        assertTrue(cat.getLayerByName(tl.getName()) == null);
       
        boolean caughtException = false;
        try {
            TileLayer tl2 = tld.getTileLayer(layerName);
        } catch (GeoWebCacheException gwce) {
            caughtException = true;
        }
        assertTrue(caughtException);
       
        // 5) Introducing new LayerInfo
        LayerInfo layerInfo = cat.getFactory().createLayer();
        layerInfo.setName("hithere");
        ResourceInfo resInfo = li.getResource();
        resInfo.setName("hithere");
        resInfo.getNamespace().setPrefix("sf");
        layerInfo.setResource(resInfo);
       
        cat.add(layerInfo);
        TileLayer tl3 = tld.getTileLayer("sf:hithere");
        assertEquals(tl3.getName(),"sf:hithere");
    }
View Full Code Here


       
        // Adding vector layers
        Iterator<LayerInfo> lIter = cat.getLayers().iterator();
        while(lIter.hasNext()) {
            LayerInfo li = lIter.next();           
            TileLayer tl = getLayer(li.getResource());
            //System.out.println(tl.getName() + " layerinfo");
            list.add(tl);
        }
               
        // Adding layer groups
        Iterator<LayerGroupInfo> lgIter = cat.getLayerGroups().iterator();
        while(lgIter.hasNext()) {
            LayerGroupInfo lgi = lgIter.next();
           
            TileLayer tl = getLayer(lgi);
            //System.out.println(tl.getName() + " layergroupinfo");
            list.add(tl);
        }
       
        log.fine("Responding with " + list.size() + " to getTileLayers() request from TileLayerDispatcher");
View Full Code Here

    synchronized private void removeFromList(String layerName) {
        if(this.list != null) {
            Iterator<TileLayer> iter = list.iterator();
            int i = 0;
            while(iter.hasNext()) {
                TileLayer tl = iter.next();
                if(tl != null && tl.getName().equals(layerName)) {
                    list.remove(i);
                    return;
                }
                i++;
            }
View Full Code Here

public class WMSTileFuserTest extends TestCase {
    GridSetBroker gridSetBroker = new GridSetBroker(false, false);
   
    public void testTileFuserResolution() 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;
        WMSTileFuser tileFuser = new WMSTileFuser(layer, layer.getGridSubsets().values().iterator().next(), bounds, width, height);
        tileFuser.determineSourceResolution();
        assertEquals(0.087890625, tileFuser.srcResolution, 0.087890625*0.001);
       
        // Zoomed too far out
        height = (int) bounds.getWidth() / 10;
        width = (int) bounds.getWidth() / 10;
        tileFuser = new WMSTileFuser(layer, layer.getGridSubsets().values().iterator().next(), bounds, width, height);
        tileFuser.determineSourceResolution();
        assertEquals(0,tileFuser.srcIdx);
       
        // Zoomed too far in
        height = (int) bounds.getWidth() * 10000;
        width = (int) bounds.getWidth() * 10000;
        tileFuser = new WMSTileFuser(layer, layer.getGridSubsets().values().iterator().next(), bounds, width, height);
        tileFuser.determineSourceResolution();
        assertEquals(10,tileFuser.srcIdx);
    }
View Full Code Here

        tileFuser.determineSourceResolution();
        assertEquals(10,tileFuser.srcIdx);
    }
   
    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;
        WMSTileFuser tileFuser = new WMSTileFuser(layer, layer.getGridSubsets().values().iterator().next(), bounds, width, height);
        tileFuser.determineSourceResolution();
        tileFuser.determineCanvasLayout();
       
        assertTrue(tileFuser.srcBounds.contains(bounds));
        int[] comparison = {-228, -193, -57, -6};
View Full Code Here

        int[] comparison = {-228, -193, -57, -6};
        assertTrue(Arrays.equals(tileFuser.canvOfs,comparison));
    }
   
    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;
        WMSTileFuser tileFuser = new WMSTileFuser(layer, layer.getGridSubsets().values().iterator().next(), bounds, width, height);
        tileFuser.determineSourceResolution();
        tileFuser.determineCanvasLayout();
    }
View Full Code Here

            }
        }
    }

    private void writeSiteMap() throws GeoWebCacheException, IOException {
        TileLayer layer = tile.getLayer();
       
        GridSubset gridSubset = layer.getGridSubset(gridSetBroker.WORLD_EPSG4326.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};
View Full Code Here

        tile.servletResp.getOutputStream().write(footer.getBytes());      
    }

    public void writeSiteMapLoop(long[] gridLoc) throws GeoWebCacheException, IOException {
        OutputStream os = tile.servletResp.getOutputStream();
        TileLayer tileLayer = tile.getLayer();
        String urlPrefix = tile.getUrlPrefix();
       
        // Add a link to the super overlay first
        String  superOverlayLoc =
            "<url><loc>" + urlPrefix.substring(0, urlPrefix.length() - 1)
            + ".kml.kml</loc><geo:geo><geo:format>kml</geo:format></geo:geo></url>\n";
        os.write(superOverlayLoc.getBytes());
       
       
        LinkedList<long[]> subTileList = new LinkedList<long[]>();
           
        subTileList.addFirst(gridLoc);
       
        while(subTileList.peek() != null) {
            String gridSetId = gridSetBroker.WORLD_EPSG4326.getName();
            long[] curLoc = subTileList.removeFirst();
            long[][] linkGridLocs = tileLayer.getGridSubset(gridSetId).getSubGrid(curLoc);
            linkGridLocs = KMZHelper.filterGridLocs(storageBroker, tileLayer, gridSetId, XMLMime.kml, linkGridLocs);
        
            // Save the links we still need to follow for later
            for(long[] subTile : linkGridLocs) {
                if(subTile[2] > 0) {
View Full Code Here

        if(layerName == null || layerName.length() == 0) {
            throw new RestletException("Layer not specified",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
       
        TileLayer layer = null;
        try {
            layer = layerDispatcher.getTileLayer(layerName);
        } catch (GeoWebCacheException gwce) {
            throw new RestletException("Encountered error: " + gwce.getMessage(),
                    Status.SERVER_ERROR_INTERNAL);
View Full Code Here

     * @return
     * @throws RestletException
     */
    protected Representation doGetInternal(String layerName, String formatExtension)
    throws RestletException {
        TileLayer tl = findTileLayer(layerName, layerDispatcher);
       
        if(formatExtension.equalsIgnoreCase("xml")) {
            return getXMLRepresentation(tl);
        } else if(formatExtension.equalsIgnoreCase("json")) {
            return getJsonRepresentation(tl);
View Full Code Here

TOP

Related Classes of org.geowebcache.layer.TileLayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.