Package org.geoserver.wms

Examples of org.geoserver.wms.GetMapRequest


   
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        if(invocation.getMethod().getName().equals("kml")) {
            try {
                GetMapRequest getMap = (GetMapRequest) invocation.getArguments()[0];
                return KMLReflector.doWms(getMap, webMapService, wms);
            } catch (Exception e) {
                if(e instanceof ServiceException) {
                    throw e;
                } else {
View Full Code Here


                   gpkg.add(e, (SimpleFeatureCollectioncollection);
               }
              
           } else if (layer.getType() == LayerType.TILES) {
               TilesLayer tiles = (TilesLayer) layer;              
               GetMapRequest request = new GetMapRequest();
              
               request.setLayers(new ArrayList<MapLayerInfo>());
               for (QName layerQName : tiles.getLayers()) {
                   LayerInfo layerInfo = null;
                   if ("".equals(layerQName.getNamespaceURI())) {
                       layerInfo = catalog.getLayerByName(layerQName.getLocalPart());
                   } else {
                       layerInfo = catalog.getLayerByName(new NameImpl(layerQName.getNamespaceURI(), layerQName.getLocalPart()));
                   }
                   if (layerInfo == null) {
                       throw new ServiceException("Layer not found: " + layerQName);
                   }
                   request.getLayers().add(new MapLayerInfo(layerInfo));
               }

               if (tiles.getBbox() == null) {
                   try {
                       // generate one from requests layers
                       CoordinateReferenceSystem crs =
                           tiles.getSrs() != null ? CRS.decode(tiles.getSrs().toString()) : null;
   
                       ReferencedEnvelope bbox = null;
                       for (MapLayerInfo l : request.getLayers()) {
                           ResourceInfo r = l.getResource();
                           ReferencedEnvelope b = null;
                           if (crs != null) {
                               // transform from lat lon bbox
                               b = r.getLatLonBoundingBox().transform(crs, true);
                           }
                           else {
                               // use native bbox
                               b = r.getNativeBoundingBox();
                               if (bbox != null) {
                                   // transform
                                   b = b.transform(bbox.getCoordinateReferenceSystem(), true);
                               }
                           }
   
                           if (bbox != null) {
                               bbox.include(b);
                           }
                           else {
                               bbox = b;
                           }
                       }

                       request.setBbox(bbox);
                   }
                   catch(Exception e) {
                       String msg = "Must specify bbox, unable to derive from requested layers";
                       throw new RuntimeException(msg ,e);
                   }
               }
               else {
                   request.setBbox(tiles.getBbox());
               }

               if (tiles.getSrs() == null) {
                   // use srs of first layer
                   ResourceInfo r = request.getLayers().iterator().next().getResource();
                   request.setSRS(r.getSRS());
               }
               else {
                   request.setSRS(tiles.getSrs().toString());
               }

               // Get the request SRS defined and set is as the request CRS
               String srs = request.getSRS();
               if(srs != null && !srs.isEmpty()){
                   try {
                       request.setCrs(CRS.decode(srs));
                   } catch (FactoryException e) {
                       throw new RuntimeException(e);
                   }
               }

               request.setBgColor(tiles.getBgColor());
               request.setTransparent(tiles.isTransparent());
               request.setStyleBody(tiles.getSldBody());
               if (tiles.getSld() != null) {
                   request.setStyleUrl(tiles.getSld().toURL());
               }
               else if (tiles.getSldBody() != null) {
                   request.setStyleBody(tiles.getSldBody());
               }
               else {
                   request.setStyles(new ArrayList<Style>());
                   if (tiles.getStyles() != null) {
                       for (String styleName : tiles.getStyles()) {
                           StyleInfo info = catalog.getStyleByName(styleName);
                           if (info != null){
                               request.getStyles().add(info.getStyle());
                           }                      
                       }
                   }
                   if (request.getStyles().isEmpty()) {
                       for (MapLayerInfo layerInfo : request.getLayers()) {
                           request.getStyles().add(layerInfo.getDefaultStyle());
                       }
                   }
               }
               request.setFormat("none");
               Map formatOptions = new HashMap();
               formatOptions.put("format",tiles.getFormat());
               if (tiles.getCoverage() != null) {
                   if (tiles.getCoverage().getMinZoom() != null) {
                       formatOptions.put("min_zoom", tiles.getCoverage().getMinZoom());
                   }
                   if (tiles.getCoverage().getMaxZoom() != null) {
                       formatOptions.put("max_zoom", tiles.getCoverage().getMaxZoom());
                   }
                   if (tiles.getCoverage().getMinColumn() != null) {                      
                       formatOptions.put("min_column", tiles.getCoverage().getMinColumn());
                   }
                   if (tiles.getCoverage().getMaxColumn() != null) {
                       formatOptions.put("max_column", tiles.getCoverage().getMaxColumn());
                   }
                   if (tiles.getCoverage().getMinRow() != null) {
                       formatOptions.put("min_row", tiles.getCoverage().getMinRow());
                   }
                   if (tiles.getCoverage().getMaxRow() != null) {
                       formatOptions.put("max_row", tiles.getCoverage().getMaxRow());
                   }
               }
               if (tiles.getGridSetName() != null) {
                   formatOptions.put("gridset", tiles.getGridSetName());
               }
               request.setFormatOptions(formatOptions);
                             
               TileEntry e = new TileEntry();                
               addLayerMetadata(e, tiles);
              
               if (tiles.getGrids() != null) {
View Full Code Here

    @SuppressWarnings("rawtypes")
    @Override
    public WMSMapContent beforeRender(WMSMapContent content) {
       
        // is this WMS 1.3.0? If not move along
        final GetMapRequest request = content.getRequest();
        if(!"1.3.0".equalsIgnoreCase(request.getVersion())){
            return super.beforeRender(content);
        }
       

        // === look for BANDS layer
View Full Code Here

        };

        GetMapKvpRequestReader reader = new GetMapKvpRequestReader(wms);
        reader.setHttpRequest(RESTUtils.getServletRequest(getRequest()));

        GetMapRequest getMapRequest = getRequest(layer);
        final String title;
        final String description;
        String[] keywords = {};
        if (layer instanceof LayerInfo) {
            LayerInfo layerInfo = (LayerInfo) layer;
            title = layerInfo.getResource().getTitle();
            description = layerInfo.getResource().getAbstract();
            List<String> kws = layerInfo.getResource().keywordValues();
            if (kws != null) {
                keywords = kws.toArray(new String[kws.size()]);
            }
        } else {
            LayerGroupInfo lgi = (LayerGroupInfo) layer;
            title = getTitle(lgi);
            description = getDescription(lgi);
            keywords = getKeyWords(lgi);
        }

        WMSMapContent context = new WMSMapContent(getMapRequest);
        context.setTitle(title);
        context.setAbstract(description);
        context.setKeywords(keywords);
        context.setMapWidth(getMapRequest.getWidth());
        context.setMapHeight(getMapRequest.getHeight());
        context.getViewport().setBounds((ReferencedEnvelope) getMapRequest.getBbox());

        MapContentWebMap webMap;
        try {
            webMap = (MapContentWebMap) new GetMap(wms).run(getMapRequest, context);
        } catch (Exception e) {
View Full Code Here

        return siteMapFormats;
    }

    @SuppressWarnings("unchecked")
    private GetMapRequest getRequest(CatalogInfo info) {
        GetMapRequest request = new GetMapRequest();
        request.setVersion("1.1.1");
        Catalog catalog = geoserver.getCatalog();
        List<MapLayerInfo> layers = expandLayers(catalog, info);
        request.setLayers(layers);
        request.setFormat(KMZMapOutputFormat.MIME_TYPE);
        request.setBbox(getLatLonBbox(info));
        request.setSRS("EPSG:4326");

        // proxy aware base url?
        String baseurl = getRequest().getRootRef().getParentRef().toString();
        request.setBaseUrl(baseurl);
        request.setRawKvp(new KvpMap());
        int maxFeatures = 1000;
        if (info instanceof LayerGroupInfo) {
            maxFeatures = maxFeatures / ((LayerGroupInfo) info).getLayers().size();
        }
        request.setMaxFeatures(maxFeatures);

        try {
            DefaultWebMapService.autoSetMissingProperties(request);
        } catch (Exception e) {
            throw new RestletException(
View Full Code Here

        final Envelope env = fs.getBounds();

        LOGGER.info("about to create map ctx for BasicPolygons with bounds " + env);

        GetMapRequest request = new GetMapRequest();
        final WMSMapContent map = new WMSMapContent();
        map.getViewport().setBounds(new ReferencedEnvelope(env, DefaultGeographicCRS.WGS84));
        map.setMapWidth(300);
        map.setMapHeight(300);
        map.setBgColor(Color.red);
        map.setTransparent(false);
        map.setRequest(request);

        StyleInfo styleByName = catalog.getStyleByName("Default");
        Style basicStyle = styleByName.getStyle();
        map.addLayer(new FeatureLayer(fs, basicStyle));

        request.setFormat(getMapFormat());
        RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
        BufferedImage image = (BufferedImage) imageMap.getImage();
        imageMap.dispose();
        assertNotBlank("testSimpleGetMapQuery", image);
    }
View Full Code Here

        double shift = env.getWidth() / 6;

        env = new Envelope(env.getMinX() - shift, env.getMaxX() + shift, env.getMinY() - shift,
                env.getMaxY() + shift);

        GetMapRequest request = new GetMapRequest();
        final WMSMapContent map = new WMSMapContent();
        int w = 400;
        int h = (int) Math.round((env.getHeight() * w) / env.getWidth());
        map.setMapWidth(w);
        map.setMapHeight(h);
        map.setBgColor(BG_COLOR);
        map.setTransparent(true);
        map.setRequest(request);

        addToMap(map, MockData.FORESTS);
        addToMap(map, MockData.LAKES);
        addToMap(map, MockData.STREAMS);
        addToMap(map, MockData.NAMED_PLACES);
        addToMap(map, MockData.ROAD_SEGMENTS);
        addToMap(map, MockData.PONDS);
        addToMap(map, MockData.BUILDINGS);
        addToMap(map, MockData.DIVIDED_ROUTES);
        addToMap(map, MockData.BRIDGES);
        addToMap(map, MockData.MAP_NEATLINE);

        map.getViewport().setBounds(new ReferencedEnvelope(env, DefaultGeographicCRS.WGS84));

        request.setFormat(getMapFormat());
        RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
        BufferedImage image = (BufferedImage) imageMap.getImage();
        imageMap.dispose();
        assertNotBlank("testBlueLake", image);
    }
View Full Code Here

        env = new Envelope(env.getMinX() - shift, env.getMaxX() + shift, env.getMinY() - shift,
                env.getMaxY() + shift);

        WMSMapContent map = new WMSMapContent();
        GetMapRequest request = new GetMapRequest();
        map.setRequest(request);
        map.addLayer(new FeatureLayer(fSource, style));
        map.getViewport().setBounds(new ReferencedEnvelope(env, DefaultGeographicCRS.WGS84));
        map.setMapWidth(w);
        map.setMapHeight(h);
        map.setBgColor(BG_COLOR);
        map.setTransparent(false);

        // this.rasterMapProducer.setOutputFormat(getMapFormat());
        // this.rasterMapProducer.setMapContext(map);
        // this.rasterMapProducer.produceMap();
        request.setFormat(getMapFormat());

        RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);

        RenderedImage image = imageMap.getImage();
        imageMap.dispose();
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    private RenderedImage forceRenderingError(final Exception renderExceptionToThrow)
            throws Exception {

        GetMapRequest request = new GetMapRequest();
        final WMSMapContent map = new WMSMapContent();
        map.setMapWidth(100);
        map.setMapHeight(100);
        map.setRequest(request);
        final ReferencedEnvelope bounds = new ReferencedEnvelope(-180, 180, -90, 90,
                DefaultGeographicCRS.WGS84);
        map.getViewport().setBounds(bounds);

        final FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(STREAMS.getNamespaceURI(),
                STREAMS.getLocalPart());

        final SimpleFeatureSource featureSource = (SimpleFeatureSource) ftInfo.getFeatureSource(
                null, null);

        DecoratingFeatureSource source;
        // This source should make the renderer fail when asking for the features
        source = new DecoratingFeatureSource(featureSource) {
            @Override
            public SimpleFeatureCollection getFeatures(Query query) throws IOException {
                throw new RuntimeException(renderExceptionToThrow);
                // return delegate.getFeatures(query);
            }
        };

        StyleInfo someStyle = getCatalog().getStyleByName("line");
        map.addLayer(new FeatureLayer(source, someStyle.getStyle()));
        request.setFormat(getMapFormat());
        RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map);
        BufferedImage image = (BufferedImage) imageMap.getImage();
        imageMap.dispose();

        return image;
View Full Code Here

        final Object[] arguments = invocation.getArguments();

        checkArgument(arguments.length == 1);
        checkArgument(arguments[0] instanceof GetMapRequest);

        final GetMapRequest request = (GetMapRequest) arguments[0];

        WebMap map = (WebMap) invocation.proceed();

        final Map<String, String> rawKvp = request.getRawKvp();
        boolean isSeedingRequest = rawKvp != null
                && rawKvp.containsKey(GeoServerTileLayer.GWC_SEED_INTERCEPT_TOKEN);
        if (isSeedingRequest) {
            GeoServerTileLayer.WEB_MAP.set(map);
            // returning null makes the Dispatcher ignore further processing the request
View Full Code Here

TOP

Related Classes of org.geoserver.wms.GetMapRequest

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.