Examples of GetLegendGraphicRequest


Examples of org.geoserver.wms.GetLegendGraphicRequest

    @org.junit.Test
    public void testRenderingTransformationRasterVector() throws Exception {
                
        Style transformStyle = readSLD("RenderingTransformRasterVector.sld");
       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        CoverageInfo cInfo = getCatalog()
                .getCoverageByName(MockData.TASMANIA_DEM.getNamespaceURI(),
                        MockData.TASMANIA_DEM.getLocalPart());
        assertNotNull(cInfo);

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
            SimpleFeatureCollection feature;
            feature = FeatureUtilities.wrapGridCoverage((GridCoverage2D) coverage);
            req.setLayer(feature.getSchema());
            req.setStyle(transformStyle);
            req.setLegendOptions(new HashMap());
           
            this.legendProducer.buildLegendGraphic(req);

            BufferedImage image = this.legendProducer.buildLegendGraphic(req);  
           
View Full Code Here

Examples of org.geoserver.wms.GetLegendGraphicRequest

    @org.junit.Test
    public void testRenderingTransformationVectorRaster() throws Exception {
                
        Style transformStyle = readSLD("RenderingTransformVectorRaster.sld");
       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.NAMED_PLACES.getNamespaceURI(),
                        MockData.NAMED_PLACES.getLocalPart());
        assertNotNull(ftInfo);
        
        req.setLayer(ftInfo.getFeatureType());
        req.setStyle(transformStyle);
        req.setLegendOptions(new HashMap());
       
        this.legendProducer.buildLegendGraphic(req);

        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

Examples of org.geoserver.wms.GetLegendGraphicRequest

        // load a style with 3 rules
        Style externalGraphicStyle = readSLD("ExternalGraphicDemo.sld");

        assertNotNull(externalGraphicStyle);

        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        CoverageInfo cInfo = getCatalog().getCoverageByName("world");
        assertNotNull(cInfo);

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
            req.setStyle(externalGraphicStyle);
            req.setLayer(null);
            req.setScale(1.0);
           
            final int HEIGHT_HINT = 30;
            req.setHeight(HEIGHT_HINT);
           
            // use default values for the rest of parameters
            this.legendProducer.buildLegendGraphic(req);

            BufferedImage image = this.legendProducer.buildLegendGraphic(req);
View Full Code Here

Examples of org.geotools.data.wms.request.GetLegendGraphicRequest

                    ISharedImages.GRID_OBJ);
        }

        ImageDescriptor imageDescriptor = null;
        try {
            GetLegendGraphicRequest request = wms.createGetLegendGraphicRequest();
            request.setLayer(layer.getName());
            request.setWidth("16"); //$NON-NLS-1$
            request.setHeight("16"); //$NON-NLS-1$

            List<String> formats = wms.getCapabilities().getRequest().getGetLegendGraphic()
                    .getFormats();

            Collections.sort(formats, new Comparator<String>(){
View Full Code Here

Examples of org.geotools.data.wms.request.GetLegendGraphicRequest

            org.geotools.data.ows.Layer layer = target.getResource(
                    org.geotools.data.ows.Layer.class, null);

            if (wms.getCapabilities().getRequest().getGetLegendGraphic() != null) {

                GetLegendGraphicRequest request = wms.createGetLegendGraphicRequest();
                request.setLayer(layer.getName());

                String desiredFormat = null;
                List formats = wms.getCapabilities().getRequest()
                        .getGetLegendGraphic().getFormats();
                if (formats.contains("image/png")) { //$NON-NLS-1$
                    desiredFormat = "image/png"; //$NON-NLS-1$
                }
                if (desiredFormat == null && formats.contains("image/gif")) { //$NON-NLS-1$
                    desiredFormat = "image/gif"; //$NON-NLS-1$
                }
                if (desiredFormat == null) {
                    return null;
                }
                request.setFormat(desiredFormat);

                return ImageDescriptor.createFromURL(request.getFinalURL());
            }
        } catch (Exception e) {
            // darn
        }
        return null;
View Full Code Here

Examples of org.geotools.data.wms.request.GetLegendGraphicRequest

        URL onlineResource = getCapabilities().getRequest().getGetLegendGraphic().getGet();
        if (onlineResource == null) {
            onlineResource = serverURL;
        }
       
        GetLegendGraphicRequest request = getSpecification().createGetLegendGraphicRequest(onlineResource);
       
        return request;       
    }
View Full Code Here

Examples of org.geotools.data.wms.request.GetLegendGraphicRequest

                OperationType getLegendGraphic = getCapabilities().getRequest().getGetLegendGraphic();
                if( getLegendGraphic == null ){
                    // this wms server does not support legend graphics
                    return icon;
                }
                GetLegendGraphicRequest request = createGetLegendGraphicRequest();
                request.setLayer( layer.getName() );
                request.setWidth("16");
                request.setHeight("16");

                String desiredFormat = null;
                List<String> formats = getLegendGraphic.getFormats();
                if (formats.contains("image/png")) {
                    desiredFormat = "image/png";
                }
                else if (formats.contains("image/gif")) {
                    desiredFormat = "image/gif";
                }
                else {
                    // there is no format that I am sure we can deal with :-(
                    // the danger here is requesting PDF from geoserver
                    // (because everyone wants a PDF legend graphics - wot?)
                    return icon;
                }
                request.setFormat(desiredFormat);
                request.setStyle("");

                URL legendGraphics = request.getFinalURL();
                icon = new ImageIcon( legendGraphics );
            }
            return icon;
        }
View Full Code Here

Examples of org.vfny.geoserver.wms.requests.GetLegendGraphicRequest

       
        Rule rule = multipleRulesStyle.getFeatureTypeStyles()[0].getRules()[0];
        LOGGER.info("testing single rule " + rule.getName() + " from style "
            + multipleRulesStyle.getName());

        GetLegendGraphicRequest req = new GetLegendGraphicRequest(getWMS());
        FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(MockData.ROAD_SEGMENTS.getNamespaceURI(), MockData.ROAD_SEGMENTS.getLocalPart());
        req.setLayer(ftInfo.getFeatureType());
        req.setStyle(multipleRulesStyle);
        req.setRule(rule);
        req.setLegendOptions(new HashMap());

        final int HEIGHT_HINT = 30;
        req.setHeight(HEIGHT_HINT);

        //use default values for the rest of parameters
        this.legendProducer.produceLegendGraphic(req);

        BufferedImage legend = this.legendProducer.getLegendGraphic();
View Full Code Here

Examples of org.vfny.geoserver.wms.requests.GetLegendGraphicRequest

      Style multipleRulesStyle = getCatalog().getStyleByName("rainfall").getStyle();
     
      assertNotNull(multipleRulesStyle);
     
 
      GetLegendGraphicRequest req = new GetLegendGraphicRequest(getWMS());
      CoverageInfo cInfo = getCatalog().getCoverageByName("world");
      assertNotNull(cInfo);
     
        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        FeatureCollection<SimpleFeatureType, SimpleFeature> feature;
        feature = FeatureUtilities.wrapGridCoverage((GridCoverage2D) coverage);
        req.setLayer(feature.getSchema());
      req.setStyle(multipleRulesStyle);
      req.setLegendOptions(new HashMap());
 
      final int HEIGHT_HINT = 30;
      req.setHeight(HEIGHT_HINT);
 
      //use default values for the rest of parameters
      this.legendProducer.produceLegendGraphic(req);
 
      BufferedImage legend = this.legendProducer.getLegendGraphic();
View Full Code Here

Examples of org.vfny.geoserver.wms.requests.GetLegendGraphicRequest

     */
    public void testNoLayerProvidedAndNonStrictRequest() throws Exception {
        Style style = getCatalog().getStyleByName("rainfall").getStyle();
        assertNotNull(style);

        GetLegendGraphicRequest req = new GetLegendGraphicRequest(getWMS());
        req.setStrict(false);
        req.setLayer(null);
        req.setStyle(style);

        final int HEIGHT_HINT = 30;
        req.setHeight(HEIGHT_HINT);

        // use default values for the rest of parameters
        this.legendProducer.produceLegendGraphic(req);

        BufferedImage legend = this.legendProducer.getLegendGraphic();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.