Package org.geowebcache.grid

Examples of org.geowebcache.grid.BoundingBox


        resp.setEntity(doc.toString(), MediaType.TEXT_HTML);
    }

    private void handleDoSeedPost(Form form, TileLayer tl, Response resp) throws RestletException,
            GeoWebCacheException {
        BoundingBox bounds = null;

        if (form.getFirst("minX").getValue() != null) {
            bounds = new BoundingBox(parseDouble(form, "minX"), parseDouble(form, "minY"),
                    parseDouble(form, "maxX"), parseDouble(form, "maxY"));
        }

        String gridSetId = form.getFirst("gridSetId").getValue();
View Full Code Here


        gridSubset = layer.getGridSubsetForSRS(SRS.getSRS(values.get("srs")));

        outputFormat = (ImageMime) ImageMime.createFromFormat(values.get("format"));

        reqBounds = new BoundingBox(values.get("bbox"));

        reqWidth = Integer.valueOf(values.get("width"));

        reqHeight = Integer.valueOf(values.get("height"));
View Full Code Here

        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;
View Full Code Here

                tile.servletReq.getParameterMap(), tile.servletReq.getCharacterEncoding(), keys);

        // TODO Arent we missing some format stuff here?
        GridSubset gridSubset = tl.getGridSubsetForSRS(SRS.getSRS(values.get("srs")));

        BoundingBox bbox = null;
        try {
            bbox = new BoundingBox(values.get("bbox"));
        } catch (NumberFormatException nfe) {
            log.debug(nfe.getMessage());
        }

        if (bbox == null || !bbox.isSane()) {
            throw new ServiceException("The bounding box parameter (" + values.get("srs")
                    + ") is missing or not sane");
        }

        // long[] tileIndex = gridSubset.closestIndex(bbox);
View Full Code Here

        final TileCacheInfo tileCacheInfo = info.getTileCacheInfo();
        final SpatialReference spatialReference = tileCacheInfo.getSpatialReference();

        final SRS srs;
        final BoundingBox gridSetExtent;

        final boolean alignTopLeft = true;
        final double[] resolutions;
        /*
         * let scale denoms be null so GridSetFactory computes them based on resolutions. The
         * resulting values will be pretty close to the ones defined in the ArcGIS tiling scheme
         */
        final double[] scaleDenominators = null;
        final Double metersPerUnit;
        final String[] scaleNames = null;
        final int tileWidth = tileCacheInfo.getTileCols();
        final int tileHeight = tileCacheInfo.getTileRows();
        final boolean yCoordinateFirst = false;
        final double pixelSize = 0.0254 / tileCacheInfo.getDPI();// see GridSubset.getDotsPerInch()
        {
            int epsgNumber = spatialReference.getWKID();
            if (0 == epsgNumber) {
            }
            srs = SRS.getSRS(epsgNumber);
        }
        {
            final List<LODInfo> lodInfos = tileCacheInfo.getLodInfos();
            double[][] resAndScales = getResolutions(lodInfos);

            resolutions = resAndScales[0];

            double[] scales = resAndScales[1];
            metersPerUnit = (0.00028 * scales[0]) / resolutions[0];
        }
        {
            // See "How to calculate the -x parameter used in the examples above" at
            // http://resources.arcgis.com/content/kbase?q=content/kbase&fa=articleShow&d=15558&print=true
            // double XOrigin = spatialReference.getXOrigin();
            // double YOrigin = spatialReference.getYOrigin();
            // XYScale = 40075017 / 360 = ~111319, where 40075017 is the circumference of the earth
            // at the ecuator and 360 the map units at the ecuator
            // final double xyScale = spatialReference.getXYScale();

            final TileOrigin tileOrigin = tileCacheInfo.getTileOrigin();// top left coordinate

            double xmin = tileOrigin.getX();
            double ymax = tileOrigin.getY();
            double ymin = layerBounds.getMinY();
            double xmax = layerBounds.getMaxX();

            // make it so the gridset height matches an integer number of tiles in order for
            // clients (OpenLayers) assuming the tile origin is the lower left corner instead of
            // the upper right to compute tile bounding boxes right
            final double resolution = resolutions[resolutions.length - 1];
            double width = resolution * tileWidth;
            double height = resolution * tileHeight;

            long numTilesWide = (long) Math.ceil((xmax - xmin) / width);
            long numTilesHigh = (long) Math.ceil((ymax - ymin) / height);

            xmax = xmin + (numTilesWide * width);
            ymin = ymax - (numTilesHigh * height);
            gridSetExtent = new BoundingBox(xmin, ymin, xmax, ymax);
        }

        String gridsetName = srs.toString() + "_" + layerName;
        GridSet layerGridset = GridSetFactory.createGridSet(gridsetName, srs, gridSetExtent,
                alignTopLeft, resolutions, scaleDenominators, metersPerUnit, pixelSize, scaleNames,
View Full Code Here

            throw new GeoWebCacheException("Unknown grid set " + gridSetId);
        }

        long[][] coveredGridLevels;

        BoundingBox bounds = req.getBounds();
        if (bounds == null) {
            coveredGridLevels = gridSubset.getCoverages();
        } else {
            coveredGridLevels = gridSubset.getCoverageIntersections(bounds);
        }
View Full Code Here

                double minX = layer.getLatLonBoundingBox().getMinX();
                double minY = layer.getLatLonBoundingBox().getMinY();
                double maxX = layer.getLatLonBoundingBox().getMaxX();
                double maxY = layer.getLatLonBoundingBox().getMaxY();

                BoundingBox bounds4326 = new BoundingBox(minX, minY, maxX, maxY);

                log.info("Found layer: " + layer.getName() + " with LatLon bbox "
                        + bounds4326.toString());

                BoundingBox bounds3785 = new BoundingBox(longToSphericalMercatorX(minX),
                        latToSphericalMercatorY(minY), longToSphericalMercatorX(maxX),
                        latToSphericalMercatorY(maxY));

                String[] wmsUrls = { wmsUrl };
View Full Code Here

                } else if (srs.getNumber() == 4326 || srs.getNumber() == 900913
                        || srs.getNumber() == 3857) {
                    log.debug("Skipping " + srs.toString() + " for " + name);
                } else {
                    String gridSetName = name + ":" + srs.toString();
                    BoundingBox extent = new BoundingBox(env.getMinX(), env.getMinY(),
                            env.getMaxX(), env.getMaxY());

                    GridSet gridSet = GridSetFactory.createGridSet(gridSetName, srs, extent, false,
                            25, null, 0.00028, 256, 256, false);
                    grids.put(gridSetName, GridSubsetFactory.createGridSubSet(gridSet));
View Full Code Here

        wmsParams.put("SRS", layer.backendSRSOverride(gridSubset.getSRS()));
        wmsParams.put("HEIGHT", String.valueOf(gridSubset.getTileHeight()));
        wmsParams.put("WIDTH", String.valueOf(gridSubset.getTileWidth()));
        // strBuilder.append("&TILED=").append(requestTiled);

        BoundingBox bbox = gridSubset.boundsFromIndex(tile.getTileIndex());

        wmsParams.put("BBOX", bbox.toString());

        Map<String, String> fullParameters = tile.getFullParameters();
        if (fullParameters.isEmpty()) {
            fullParameters = layer.getDefaultParameterFilters();
        }
View Full Code Here

    throws GeoWebCacheException {
        String layerName = layer.getName();
       
        GridSubset gridSubset = layer.getGridSubset(gridSetStr);
       
        BoundingBox bbox = gridSubset.getGridSetBounds();
        BoundingBox zoomBounds = gridSubset.getOriginalExtent();
       
        String res = "resolutions: " + Arrays.toString(gridSubset.getResolutions()) + ",\n";
       
        String units = "units: \""+gridSubset.getGridSet().guessMapUnits()+"\",\n";

        String openLayersPath;
        if(asPlugin) {
            openLayersPath = "../../openlayers/OpenLayers.js";
        } else {
            openLayersPath = "../openlayers/OpenLayers.js";
        }
       
        String page =
            "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>\n"
            +"<meta http-equiv=\"imagetoolbar\" content=\"no\">\n"
            +"<title>"+layerName+" "+gridSubset.getName()+" "+formatStr+"</title>\n"
            +"<style type=\"text/css\">\n"
            +"body { font-family: sans-serif; font-weight: bold; font-size: .8em; }\n"
            +"body { border: 0px; margin: 0px; padding: 0px; }\n"
            +"#map { width: 85%; height: 85%; border: 0px; padding: 0px; }\n"
            +"</style>\n"

            +"<script src=\""+openLayersPath+"\"></script>    \n"
            +"<script type=\"text/javascript\">               \n"
            +"var map, demolayer;                               \n"
            + "  // sets the chosen modifiable parameter        \n"
            + "  function setParam(name, value){                \n"
            + "   str = \"demolayer.mergeNewParams({\" + name + \": '\" + value + \"'})\" \n"
            + "   //alert(str);                                   \n"
            + "   eval(str);                                    \n"
            + "  }                                              \n"
           
            +"OpenLayers.DOTS_PER_INCH = "+gridSubset.getDotsPerInch()+";\n"
            +"OpenLayers.Util.onImageLoadErrorColor = 'transparent';\n"
           
            +"function init(){\n"
            +"var mapOptions = { \n"
            + res
            +"projection: new OpenLayers.Projection('"+gridSubset.getSRS().toString()+"'),\n"
            +"maxExtent: new OpenLayers.Bounds("+bbox.toString()+"),\n"
            + units
      +"controls: []\n"
      +"};\n"
            +"map = new OpenLayers.Map('map', mapOptions );\n"
      +"map.addControl(new OpenLayers.Control.PanZoomBar({\n"
      +"    position: new OpenLayers.Pixel(2, 15)\n"
      +"}));\n"
      +"map.addControl(new OpenLayers.Control.Navigation());\n"
      +"map.addControl(new OpenLayers.Control.Scale($('scale')));\n"
      +"map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));\n"
            +"demolayer = new OpenLayers.Layer.WMS(\n"
            +"\""+layerName+"\",\"../service/wms\",\n"
            +"{layers: '"+layerName+"', format: '"+formatStr+"' },\n"
            +"{ tileSize: new OpenLayers.Size("+gridSubset.getTileWidth()+","+gridSubset.getTileHeight()+")";
       
            /*
             * If the gridset has a top left tile origin, lets tell that to open layers. Otherwise it'll
             * calculate tile bounds based on the bbox bottom left corner, leading to misaligned
             * requests.
             */
            GridSet gridSet = gridSubset.getGridSet();
            if (gridSet.isTopLeftAligned()) {
                page += ",\n tileOrigin: new OpenLayers.LonLat(" + bbox.getMinX() + ", "
                        + bbox.getMaxY() + ")";
            }
          
            page += "});\n"
            +"map.addLayer(demolayer);\n"
            +"map.zoomToExtent(new OpenLayers.Bounds("+zoomBounds.toString()+"));\n"
            +"// The following is just for GetFeatureInfo, which is not cached. Most people do not need this \n"
            +"map.events.register('click', map, function (e) {\n"
            +"  document.getElementById('nodelist').innerHTML = \"Loading... please wait...\";\n"
            +"  var params = {\n"
            +"    REQUEST: \"GetFeatureInfo\",\n"
View Full Code Here

TOP

Related Classes of org.geowebcache.grid.BoundingBox

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.