Package org.geoserver.wms

Examples of org.geoserver.wms.GetLegendGraphicRequest


        assertEquals(Locale.ENGLISH, request.getLocale());
    }
   
    @org.junit.Test
    public void testStylesForLayerGroup() throws Exception {
        GetLegendGraphicRequest request;
              
        requiredParameters.put("LAYER", NATURE_GROUP);
        requiredParameters.put("STYLE", "style1,style2");
        request = requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
        assertTrue(request.getStyles().size() == 2);
    }
View Full Code Here


        assertTrue(request.getStyles().size() == 2);
    }
   
    @org.junit.Test
    public void testRulesForLayerGroup() throws Exception {
        GetLegendGraphicRequest request;
              
        requiredParameters.put("LAYER", NATURE_GROUP);
        requiredParameters.put("RULE", "rule1,rule2");
        request = requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
        assertTrue(request.getRules().size() == 2);
    }
View Full Code Here

        assertTrue(request.getRules().size() == 2);
    }
   
    @org.junit.Test
    public void testLabelsForLayerGroup() throws Exception {
        GetLegendGraphicRequest request;
              
        requiredParameters.put("LAYER", NATURE_GROUP);
        request = requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
        assertNotNull(request.getTitle(new NameImpl("http://www.opengis.net/cite","Lakes")));
    }
View Full Code Here

        } else {
          layers.add(candidateLayer);
        }
       
        // get the request object
        GetLegendGraphicRequest getLegend = (GetLegendGraphicRequest) operation.getParameters()[0];
       
        for(LayerInfo layer : layers) {
          ResourceInfo resource = layer.getResource();

            // get the rule, it contains default and allowed styles
            RuleFilter ruleFilter = new RuleFilter(RuleFilter.SpecialFilterType.ANY);
            setRuleFilterUserOrRole(user, ruleFilter);           
            ruleFilter.setInstance(configurationManager.getConfiguration().getInstanceName());
            ruleFilter.setService(service);
            ruleFilter.setRequest(request);
            ruleFilter.setWorkspace(resource.getStore().getWorkspace().getName());
            ruleFilter.setLayer(resource.getName());

            LOGGER.log(Level.FINE, "Getting access limits for getLegendGraphic", ruleFilter);

            AccessInfo rule = rules.getAccessInfo(ruleFilter);
           
            // get the requested style
            String styleName = (String) gsRequest.getKvp().get("STYLE");
            if (styleName == null) {
                if (rule.getDefaultStyle() != null) {
                    try {
                        StyleInfo si = catalog.getStyleByName(rule.getDefaultStyle());
                        if (si == null) {
                            throw new ServiceException("Could not find default style suggested "
                                    + "by GeoRepository: " + rule.getDefaultStyle());
                        }
                        getLegend.setStyle(si.getStyle());
                    } catch (IOException e) {
                        throw new ServiceException("Unable to load the style suggested by GeoRepository: "
                                + rule.getDefaultStyle(), e);
                    }
                }
View Full Code Here

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

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

        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

        // load a style with 3 rules
        Style multipleRulesStyle = getCatalog().getStyleByName("rainfall").getStyle();

        assertNotNull(multipleRulesStyle);

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

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
            SimpleFeatureCollection 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.buildLegendGraphic(req);

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

    @org.junit.Test
    public void testNoLayerProvidedAndNonStrictRequest() throws Exception {
        Style style = getCatalog().getStyleByName("rainfall").getStyle();
        assertNotNull(style);

        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        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.buildLegendGraphic(req);

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

    /**
     * Tests that the legend graphic is produced for multiple layers
     */
    @org.junit.Test
    public void testMultipleLayers() throws Exception {             
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        int titleHeight = getTitleHeight(req);
       
        FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(
                MockData.ROAD_SEGMENTS.getNamespaceURI(), MockData.ROAD_SEGMENTS.getLocalPart());
        List<FeatureType> layers=new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
       
        req.setLayers(layers);
       
        List<Style> styles=new ArrayList<Style>();
        styles.add(getCatalog().getStyleByName(
                MockData.ROAD_SEGMENTS.getLocalPart()).getStyle());
        req.setStyles(styles);
       
        this.legendProducer.buildLegendGraphic(req);

        BufferedImage image = this.legendProducer.buildLegendGraphic(req);

View Full Code Here

     * Tests that with forceTitles option off no title is rendered
     */
    @org.junit.Test
    public void testForceTitlesOff() throws Exception {       
       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        Map<String,String> options = new HashMap<String,String>();
        options.put("forceTitles", "off");
        req.setLegendOptions(options);
        FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(
                MockData.ROAD_SEGMENTS.getNamespaceURI(), MockData.ROAD_SEGMENTS.getLocalPart());
        List<FeatureType> layers=new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
       
        req.setLayers(layers);
       
        List<Style> styles = new ArrayList<Style>();
        styles.add(getCatalog().getStyleByName(
                MockData.ROAD_SEGMENTS.getLocalPart()).getStyle());
        req.setStyles(styles);
       
        this.legendProducer.buildLegendGraphic(req);

        BufferedImage image = this.legendProducer.buildLegendGraphic(req);

View Full Code Here

     * Tests that the legend graphic is produced for multiple layers
     * with different style for each layer.
     */
    @org.junit.Test
    public void testMultipleLayersWithDifferentStyles() throws Exception {       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        int titleHeight = getTitleHeight(req);
       
        FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(
                MockData.ROAD_SEGMENTS.getNamespaceURI(), MockData.ROAD_SEGMENTS.getLocalPart());
        List<FeatureType> layers=new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
       
        List<Style> styles=new ArrayList<Style>();
        Style style1= getCatalog().getStyleByName(
                MockData.ROAD_SEGMENTS.getLocalPart()).getStyle();
        styles.add(style1);
       
        Style style2= getCatalog().getStyleByName(
                MockData.LAKES.getLocalPart()).getStyle();
        styles.add(style2);
        req.setStyles(styles);
       
        this.legendProducer.buildLegendGraphic(req);

        BufferedImage image = this.legendProducer.buildLegendGraphic(req);

View Full Code Here

TOP

Related Classes of org.geoserver.wms.GetLegendGraphicRequest

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.