Package org.geowebcache.grid

Examples of org.geowebcache.grid.BoundingBox


        // hard to trigger an onclick event for a GeoServerAjaxSubmitLink, to invoking directly
        page.computeBounds();
        // print(page, true, true);

        {
            BoundingBox expected = gridSetBroker.get("EPSG:900913").getOriginalExtent();
            Double minx = ((DecimalTextField) tester
                    .getComponentFromLastRenderedPage("gridSetForm:bounds:minX")).getModelObject();
            Double miny = ((DecimalTextField) tester
                    .getComponentFromLastRenderedPage("gridSetForm:bounds:minY")).getModelObject();
            Double maxx = ((DecimalTextField) tester
                    .getComponentFromLastRenderedPage("gridSetForm:bounds:maxX")).getModelObject();
            Double maxy = ((DecimalTextField) tester
                    .getComponentFromLastRenderedPage("gridSetForm:bounds:maxY")).getModelObject();

            assertEquals(expected.getMinX(), minx, 1.0E-2);// cm resolution
            assertEquals(expected.getMinY(), miny, 1.0E-2);
            assertEquals(expected.getMaxX(), maxx, 1.0E-2);
            assertEquals(expected.getMaxY(), maxy, 1.0E-2);

            EnvelopePanel envPanel = (EnvelopePanel) tester
                    .getComponentFromLastRenderedPage("gridSetForm:bounds");
            assertNotNull(envPanel.getModelObject());
View Full Code Here


            }
            tileEntryName = tileEntryName.substring(0, tileEntryName.length()-1);
        }

        // figure out the actual bounds of the tiles to be renderered
        BoundingBox bbox = bbox(request);
        GridSubset gridSubset = findBestGridSubset(request);
        int[] minmax = findMinMaxZoom(gridSubset, request);
        //ReferencedEnvelope bounds = new ReferencedEnvelope(findTileBounds(gridSubset, bbox,
        //        minmax[0]), getCoordinateReferenceSystem(map));

        // create a prototype getmap request
        GetMapRequest req = new GetMapRequest();
        OwsUtils.copy(request, req, GetMapRequest.class);
        req.setLayers(mapLayers);

        String imageFormat = formatOpts.containsKey("format") ? parseFormatFromOpts(formatOpts)
                : findBestFormat(request);

        req.setFormat(imageFormat);
        req.setWidth(gridSubset.getTileWidth());
        req.setHeight(gridSubset.getTileHeight());
        req.setCrs(getCoordinateReferenceSystem(request));

        // store metadata
        tiles.setMetadata(tileEntryName, bounds(request), imageFormat, srid(request), mapLayers, minmax,
                gridSubset);
       
        //column and row bounds
        Integer minColumn = null, maxColumn = null, minRow = null, maxRow = null;
        if (formatOpts.containsKey("min_column")) {
            minColumn = Integer.parseInt(formatOpts.get("min_column").toString());
        }
        if (formatOpts.containsKey("max_column")) {
            maxColumn = Integer.parseInt(formatOpts.get("max_column").toString());
        }
        if (formatOpts.containsKey("min_row")) {
            minRow = Integer.parseInt(formatOpts.get("min_row").toString());
        }
        if (formatOpts.containsKey("max_row")) {
            maxRow = Integer.parseInt(formatOpts.get("max_row").toString());
        }

        // flag determining if tile row indexes we store in database should be inverted
        boolean flipy = Boolean.valueOf((String) formatOpts.get("flipy"));
        for (int z = minmax[0]; z < minmax[1]; z++) {
            long[] intersect = gridSubset.getCoverageIntersection(z, bbox);
            long minX = minColumn == null? intersect[0] : Math.max(minColumn, intersect[0]);
            long maxX = maxColumn == null? intersect[2] : Math.min(maxColumn, intersect[2]);
            long minY = minRow == null? intersect[1] : Math.max(minRow, intersect[1]);
            long maxY = maxRow == null? intersect[3] : Math.min(maxRow, intersect[3]);
            for (long x = minX; x <= maxX; x++) {
                for (long y = minY; y <= maxY; y++) {
                    BoundingBox box = gridSubset.boundsFromIndex(new long[] { x, y, z });
                    req.setBbox(new Envelope(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY()));
                    WebMap result = webMapService.getMap(req);
                    tiles.addTile(z, (int) x, (int) (flipy ? gridSubset.getNumTilesHigh(z)
                            - (y + 1) : y), toBytes(result));
                    // Cleanup
                    cleaner.finished(null);
View Full Code Here

    // utility methods:

    protected BoundingBox bbox(GetMapRequest req) {
        Envelope bnds = bounds(req);
        return new BoundingBox(bnds.getMinX(), bnds.getMinY(), bnds.getMaxX(), bnds.getMaxY());
    }
View Full Code Here

    protected Envelope findTileBounds(GridSubset gridSubset, BoundingBox bbox, int z) {

        long[] i = gridSubset.getCoverageIntersection(z, bbox);

        BoundingBox b1 = gridSubset.boundsFromIndex(new long[] { i[0], i[1], i[4] });
        BoundingBox b2 = gridSubset.boundsFromIndex(new long[] { i[2], i[3], i[4] });
        return new Envelope(Math.min(b1.getMinX(), b2.getMinX()), Math.max(b1.getMaxX(),
                b2.getMaxX()), Math.min(b1.getMinY(), b2.getMinY()), Math.max(b1.getMaxY(),
                b2.getMaxY()));
    }
View Full Code Here

        return Math.max(i, 0);
    }

    protected Integer findMaxZoomAuto(GridSubset gridSubset, Integer minZoom, GetMapRequest req) {
        BoundingBox bbox = bbox(req);

        int zoom = minZoom;
        int ntiles = 0;

        while (ntiles < 256 && zoom < gridSubset.getGridSet().getNumLevels()) {
View Full Code Here

            final GWC gwc = GWC.get();
            for (XMLGridSubset subset : gridSubsets) {
                final String gridSetName = subset.getGridSetName();
                final Integer zoomStart = subset.getZoomStart();
                final Integer zoomStop = subset.getZoomStop();
                final BoundingBox extent = subset.getExtent();

                if (gridSetName == null) {
                    throw new IllegalStateException("GridSet name is null");
                }

                if (zoomStart != null && zoomStop != null) {
                    if (zoomStart.intValue() > zoomStop.intValue()) {
                        error(validatable, "GridSubsetsEditor.validation.zoomLevelsError");
                        return;
                    }
                }

                final GridSetBroker gridSetBroker = gwc.getGridSetBroker();
                final GridSet gridSet = gridSetBroker.get(gridSetName);

                if (null == gridSet) {
                    error(validatable, "GridSubsetsEditor.validation.gridSetNotFound", gridSetName);
                    return;
                }

                if (extent != null) {
                    if (extent.isNull() || !extent.isSane()) {
                        error(validatable, "GridSubsetsEditor.validation.invalidBounds");
                    }
                    final BoundingBox fullBounds = gridSet.getOriginalExtent();
                    final boolean intersects = fullBounds.intersects(extent);
                    if (!intersects) {
                        error(validatable, "GridSubsetsEditor.validation.boundsOutsideCoverage");
                    }
                }
            }
View Full Code Here

            this.crs = CRS.decode(code, longitudeFirst);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        BoundingBox gridsetBounds = gridset.getOriginalExtent();
        double x1 = gridsetBounds.getMinX();
        double x2 = gridsetBounds.getMaxX();
        double y1 = gridsetBounds.getMinY();
        double y2 = gridsetBounds.getMaxY();
        this.bounds = new ReferencedEnvelope(x1, x2, y1, y2, this.crs);

        this.pixelSize = gridset.getPixelSize();
        this.tileWidth = gridset.getTileWidth();
        this.tileHeight = gridset.getTileHeight();
View Full Code Here

    public void addZoomLevel(ReferencedEnvelope bbox, int tileWidth, int tileHeight) {
        List<Grid> list = grids.getModelObject();
        final Grid newGrid = new Grid();
        if (list.isEmpty()) {
            BoundingBox extent = new BoundingBox(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(),
                    bbox.getMaxY());
            final int levels = 1;
            GridSet tmpGridset = GridSetFactory.createGridSet("stub", SRS.getEPSG4326(), extent,
                    false, levels, 1D, GridSetFactory.DEFAULT_PIXEL_SIZE_METER, tileWidth,
                    tileHeight, false);
View Full Code Here

        if (bounds.getWidth() <= 0 || bounds.getHeight() <= 0) {
            throw new IllegalArgumentException("Bounds can't be empty. Witdh: " + bounds.getWidth()
                    + ". Height: " + bounds.getHeight());
        }

        BoundingBox extent = new BoundingBox(bounds.getMinimum(0), bounds.getMinimum(1),
                bounds.getMaximum(0), bounds.getMaximum(1));

        boolean alignTopLeft = info.isAlignTopLeft();

        final List<Grid> levels = checkNotNull(info.getLevels(), "GridSet levels not set");
View Full Code Here

        String layerName = tileLayer.getName();
        ReferencedEnvelope bounds;
        // bounds outside layer bounds (which are -180,0,0,90)
        bounds = new ReferencedEnvelope(10, 20, 10, 20, DefaultGeographicCRS.WGS84);
        BoundingBox layerBounds = tileLayer.getGridSubset("EPSG:4326").getGridSet()
                .getOriginalExtent();

        assertFalse(bounds.intersects(layerBounds.getMinX(), layerBounds.getMinY()));
        assertFalse(bounds.intersects(layerBounds.getMaxX(), layerBounds.getMaxY()));

        mediator.truncate(layerName, bounds);

        verify(tileBreeder, never()).dispatchTasks(any(GWCTask[].class));
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.