Package org.geowebcache.conveyor

Examples of org.geowebcache.conveyor.ConveyorTile


            long startx = srcRectangle[0];
            for (long gridx = startx; gridx <= srcRectangle[2]; gridx++) {

                long[] gridLoc = { gridx, gridy, srcIdx };

                ConveyorTile tile = new ConveyorTile(sb, layer.getName(), gridSubset.getName(),
                        gridLoc, ImageMime.png, fullParameters, null, null);

                // Check whether this tile is to be rendered at all
                try {
                    layer.applyRequestFilters(tile);
                } catch (RequestFilterException e) {
                    log.debug(e.getMessage());
                    continue;
                }

                layer.getTile(tile);

                BufferedImage tileImg = ImageIO.read(tile.getBlob().getInputStream());

                int tilex = 0;
                int canvasx = (int) (gridx - startx) * gridSubset.getTileWidth();
                int tileWidth = gridSubset.getTileWidth();

View Full Code Here


            if (layers == null || layers.length() == 0) {
                layers = ServletUtils.stringFromMap(requestParameterMap, encoding, "layer");
                values.put("LAYERS", layers);
            }

            ConveyorTile tile = new ConveyorTile(sb, layers, request, response);
            tile.setHint(req.toLowerCase());
            tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
            return tile;
        }
        if (layers == null) {
            throw new ServiceException("Unable to parse layers parameter from request.");
        }

        // Check whether this request is missing tiled=true
        final boolean tiled = Boolean.valueOf(values.get("tiled"));
        if (proxyNonTiledRequests && tiled) {
            ConveyorTile tile = new ConveyorTile(sb, layers, request, response);
            tile.setHint(req);
            tile.setRequestHandler(Conveyor.RequestHandler.SERVICE);
            return tile;
        }

        TileLayer tileLayer = tld.getTileLayer(layers);

        String[] paramKeys = { "format", "srs", "bbox" };
        final Map<String, String> paramValues = ServletUtils.selectedStringsFromMap(
                requestParameterMap, encoding, paramKeys);

        final Map<String, String> fullParameters = tileLayer.getModifiableParameters(
                requestParameterMap, encoding);

        final MimeType mimeType;
        String format = paramValues.get("format");
        try {
            mimeType = MimeType.createFromFormat(format);
        } catch (MimeException me) {
            throw new ServiceException("Unable to determine requested format, " + format);
        }

        final SRS srs;
        {
            String requestSrs = paramValues.get("srs");
            if (requestSrs == null) {
                throw new ServiceException("No SRS specified");
            }
            srs = SRS.getSRS(requestSrs);
        }

        GridSubset gridSubset = tileLayer.getGridSubsetForSRS(srs);
        if (gridSubset == null) {
            throw new ServiceException("Unable to match requested SRS " + srs
                    + " to those supported by layer");
        }

        final BoundingBox bbox;
        {
            String requestBbox = paramValues.get("bbox");
            try {
                bbox = new BoundingBox(requestBbox);
                if (bbox == null || !bbox.isSane()) {
                    throw new ServiceException("The bounding box parameter (" + requestBbox
                            + ") is missing or not sane");
                }
            } catch (NumberFormatException nfe) {
                throw new ServiceException("The bounding box parameter (" + requestBbox
                        + ") is invalid");
            }
        }

        final int tileWidth = Integer.parseInt(values.get("width"));
        final int tileHeight = Integer.parseInt(values.get("height"));

        if (fullWMS) {
            // If we support full WMS we need to do a few tests to determine whether
            // this is a request that requires us to recombine tiles to respond.
            long[] tileIndex = null;
            try {
                tileIndex = gridSubset.closestIndex(bbox);
            } catch (GridMismatchException gme) {
                // Do nothing, the null is info enough
            }

            if (tileIndex == null || gridSubset.getTileWidth() != tileWidth
                    || gridSubset.getTileHeight() != tileHeight
                    || !bbox.equals(gridSubset.boundsFromIndex(tileIndex), 0.02)) {
                log.debug("Recombinining tiles to respond to WMS request");
                ConveyorTile tile = new ConveyorTile(sb, layers, request, response);
                tile.setHint("getmap");
                tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
                return tile;
            }
        }

        long[] tileIndex = gridSubset.closestIndex(bbox);

        gridSubset.checkTileDimensions(tileWidth, tileHeight);

        return new ConveyorTile(sb, layers, gridSubset.getName(), tileIndex, mimeType,
                fullParameters, request, response);
    }
View Full Code Here

                fullParameters, request, response);
    }

    public void handleRequest(Conveyor conv) throws GeoWebCacheException {

        ConveyorTile tile = (ConveyorTile) conv;

        if (tile.getHint() != null) {
            if (tile.getHint().equalsIgnoreCase("getcapabilities")) {
                WMSGetCapabilities wmsCap = new WMSGetCapabilities(tld, tile.servletReq);
                wmsCap.writeResponse(tile.servletResp);
            } else if (tile.getHint().equalsIgnoreCase("getmap")) {
                WMSTileFuser wmsFuser = new WMSTileFuser(tld, sb, tile.servletReq);
                try {
                    wmsFuser.writeResponse(tile.servletResp, stats);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else if (tile.getHint().equalsIgnoreCase("getfeatureinfo")) {
                handleGetFeatureInfo(tile);
            } else {
                WMSRequests.handleProxy(tld, tile);
            }
        } else {
View Full Code Here

        } catch (MimeException me) {
            throw new GeoWebCacheException("The info_format parameter ("
                    + values.get("info_format") + ")is missing or not recognized.");
        }

        ConveyorTile gfiConv = new ConveyorTile(sb, tl.getName(), gridSubset.getName(), null,
                mimeType, null, tile.servletReq, tile.servletResp);
        gfiConv.setTileLayer(tl);

        int x, y;
        try {
            x = Integer.parseInt(values.get("x"));
            y = Integer.parseInt(values.get("y"));
View Full Code Here

        long[] gridLoc = tile.getTileIndex();

        // Final preflight check, throws exception if necessary
        getGridSubset(tileGridSetId).checkCoverage(gridLoc);

        ConveyorTile returnTile;

        try {
            if (tryCacheFetch(tile)) {
                returnTile = finalizeTile(tile);
            } else if (mime.supportsTiling()) { // Okay, so we need to go to the backend
View Full Code Here

        while (gridLoc != null && this.terminate == false) {

            checkInterrupted();
            Map<String, String> fullParameters = tr.parameters;
           
            ConveyorTile tile = new ConveyorTile(storageBroker, layerName, tr.gridSetId, gridLoc,
                    tr.mimeType, fullParameters, null, null);

            for (int fetchAttempt = 0; fetchAttempt <= tileFailureRetryCount; fetchAttempt++) {
                try {
                    checkInterrupted();
                    tl.seedTile(tile, tryCache);
                    break;// success, let it go
                } catch (Exception e) {
                    // if GWC_SEED_RETRY_COUNT was not set then none of the settings have effect, in
                    // order to keep backwards compatibility with the old behaviour
                    if (tileFailureRetryCount == 0) {
                        if (e instanceof GeoWebCacheException) {
                            throw (GeoWebCacheException) e;
                        }
                        throw new GeoWebCacheException(e);
                    }

                    long sharedFailureCount = sharedFailureCounter.incrementAndGet();
                    if (sharedFailureCount >= totalFailuresBeforeAborting) {
                        log.info("Aborting seed thread " + Thread.currentThread().getName()
                                + ". Error count reached configured maximum of "
                                + totalFailuresBeforeAborting);
                        super.state = GWCTask.STATE.DEAD;
                        return;
                    }
                    String logMsg = "Seed failed at " + tile.toString() + " after "
                            + (fetchAttempt + 1) + " of " + (tileFailureRetryCount + 1)
                            + " attempts.";
                    if (fetchAttempt < tileFailureRetryCount) {
                        log.debug(logMsg);
                        if (tileFailureRetryWaitTime > 0) {
View Full Code Here

        if (conv.reqHandler == Conveyor.RequestHandler.SERVICE) {
            // A3 The service object takes it from here
            service.handleRequest(conv);

        } else {
            ConveyorTile convTile = (ConveyorTile) conv;

            // B3) Get the configuration that has to respond to this request
            TileLayer layer = tileLayerDispatcher.getTileLayer(layerName);

            // Save it for later
            convTile.setTileLayer(layer);

            // Apply the filters
            layer.applyRequestFilters(convTile);

            // Keep the URI
View Full Code Here

        long[][] tiles;
        int tileW;
        int tileH;
        String format;
        if (tileRespRecv instanceof ConveyorTile) {
            ConveyorTile conveyorTile = (ConveyorTile) tileRespRecv;
            long[] tileIndex = conveyorTile.getTileIndex();
            tiles = new long[1][1];
            tiles[0] = tileIndex;
            format = conveyorTile.getMimeType().getInternalName().toUpperCase();
            tileW = conveyorTile.getGridSubset().getTileWidth();
            tileH = conveyorTile.getGridSubset().getTileHeight();
        } else {
            WMSMetaTile metaTile = (WMSMetaTile) tileRespRecv;
            tiles = metaTile.getTilesGridPositions();
            format = metaTile.getResponseFormat().getInternalName().toUpperCase();
            GridSubset gridSubset = layer.getGridSubsets().values().iterator().next();
View Full Code Here

        long[] gridLoc = { 0, 0, 0 };// x, y, level
        MimeType mimeType = layer.getMimeTypes().get(0);
        GridSet gridSet = gridSetBroker.WORLD_EPSG4326;
        String gridSetId = gridSet.getName();
        ConveyorTile tile = new ConveyorTile(mockStorageBroker, layerId, gridSetId, gridLoc,
                mimeType, null, servletReq, servletResp);

        boolean tryCache = false;
        layer.seedTile(tile, tryCache);
View Full Code Here

        } else {
            req = req.toLowerCase();
        }

        if (req.equals("gettile")) {
            ConveyorTile tile = getTile(values, request, response, RequestType.TILE);
            return tile;
        } else if (req.equals("getcapabilities")) {
            ConveyorTile tile = new ConveyorTile(sb, values.get("layer"), request, response);
            tile.setHint(req);
            tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
            return tile;
        } else if (req.equals("getfeatureinfo")) {
            ConveyorTile tile = getTile(values, request, response, RequestType.FEATUREINFO);
            tile.setHint(req);
            tile.setRequestHandler(Conveyor.RequestHandler.SERVICE);
            return tile;
        } else {
            throw new OWSException(501, "OperationNotSupported", "request", req
                    + " is not implemented");
        }
View Full Code Here

TOP

Related Classes of org.geowebcache.conveyor.ConveyorTile

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.