Package org.geoserver.wms

Examples of org.geoserver.wms.GetLegendGraphicRequest


     * Tests that the legend graphic is produced for multiple layers
     * with vector and coverage layers.
     */
    @org.junit.Test   
  public void testMultipleLayersWithVectorAndCoverage() 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());
       
        CoverageInfo cInfo = getCatalog().getCoverageByName("world");
        assertNotNull(cInfo);

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
          SimpleFeatureCollection feature;
          feature = FeatureUtilities.wrapGridCoverage((GridCoverage2D) coverage);
          layers.add(feature.getSchema());
         
          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("rainfall").getStyle();
          styles.add(style2);
          req.setStyles(styles);
         
          this.legendProducer.buildLegendGraphic(req);
 
          BufferedImage image = this.legendProducer.buildLegendGraphic(req);
 
View Full Code Here


     * with vector and coverage layers, when coverage is not visible
     * at current scale.
     */   
    @org.junit.Test
    public void testMultipleLayersWithVectorAndInvisibleCoverage() throws Exception {       
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
        req.setScale(1000);
        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());
       
        CoverageInfo cInfo = getCatalog().getCoverageByName("world");
        assertNotNull(cInfo);

        GridCoverage coverage = cInfo.getGridCoverage(null, null);
        try {
          SimpleFeatureCollection feature;
          feature = FeatureUtilities.wrapGridCoverage((GridCoverage2D) coverage);
          layers.add(feature.getSchema());
         
          req.setLayers(layers);
         
          List<Style> styles=new ArrayList<Style>();
          Style style1= getCatalog().getStyleByName(
                  MockData.ROAD_SEGMENTS.getLocalPart()).getStyle();
          styles.add(style1);
         
          styles.add(readSLD("InvisibleRaster.sld"));
         
         
          req.setStyles(styles);
         
          this.legendProducer.buildLegendGraphic(req);
 
          BufferedImage image = this.legendProducer.buildLegendGraphic(req);
         
View Full Code Here

          }
      }
    }

  public void testMixedGeometry() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
   
        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.setName("MIXEDGEOMETRY");
        builder.setNamespaceURI("test");
        builder.setDefaultGeometry("GEOMETRY");
        CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
        builder.setCRS(crs);
   
        GeometryFactory geometryFactory = new GeometryFactory();
   
        AttributeType at = new AttributeTypeImpl(new NameImpl("ID"), String.class,
                false, false, Collections.EMPTY_LIST, null, null);
        builder.add(new AttributeDescriptorImpl(at, new NameImpl("ID"), 0, 1,
                false, null));
   
        GeometryType gt = new GeometryTypeImpl(new NameImpl("GEOMETRY"),
                Geometry.class, crs, false, false, Collections.EMPTY_LIST, null,
                null);
   
        builder.add(new GeometryDescriptorImpl(gt, new NameImpl("GEOMETRY"), 0, 1,
                false, null));
   
        FeatureType fType = builder.buildFeatureType();
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(fType);
   
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("MixedGeometry.sld"));
   
        this.legendProducer.buildLegendGraphic(req);
   
View Full Code Here

    /**
     * Tests that symbols are not bigger than the requested icon size.
     */
    @org.junit.Test
    public void testSymbolContainedInIcon() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
   
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("BigSymbol.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

     * Tests that symbols are not bigger than the requested icon size, also
     * if an expression is used for the symbol Size.
     */
    @org.junit.Test
    public void testSymbolContainedInIconUsingExpression() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
   
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("SymbolExpression.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

    /**
     * Tests that symbols relative sizes are proportional.
     */
    @org.junit.Test
    public void testProportionalSymbolSize() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("ProportionalSymbols.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

    /**
     * Tests that symbols relative sizes are proportional also if using uoms.
     */
    @org.junit.Test
    public void testProportionalSymbolSizeUOM() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("ProportionalSymbolsUOM.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
               
View Full Code Here

     * Tests that symbols relative sizes are proportional also if using uoms
     * in some Symbolizer and not using them in others.
     */
    @org.junit.Test
    public void testProportionalSymbolSizePartialUOM() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        req.setScale(RendererUtilities.calculatePixelsPerMeterRatio(10, Collections.EMPTY_MAP));
       
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("ProportionalSymbolsPartialUOM.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

    /**
     * Tests that minSymbolSize legend option is respected.
     */
    @org.junit.Test
    public void testMinSymbolSize() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
        Map<String,String> options = new HashMap<String,String>();
        options.put("minSymbolSize", "10");
        req.setLegendOptions(options);
       
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("ProportionalSymbols.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
       
View Full Code Here

    /**
     * Tests that minSymbolSize legend option is respected.
     */
    @org.junit.Test
    public void testInternationalizedLabels() throws Exception {
        GetLegendGraphicRequest req = new GetLegendGraphicRequest();
       
        Map<String,String> options = new HashMap<String,String>();
        options.put("forceLabels", "on");
        req.setLegendOptions(options);
       
        FeatureTypeInfo ftInfo = getCatalog()
                .getFeatureTypeByName(MockData.MPOINTS.getNamespaceURI(),
                        MockData.MPOINTS.getLocalPart());
   
       
        List<FeatureType> layers = new ArrayList<FeatureType>();
        layers.add(ftInfo.getFeatureType());
        req.setLayers(layers);
   
        List<Style> styles = new ArrayList<Style>();
        req.setStyles(styles);
   
        styles.add(readSLD("Internationalized.sld"));
   
        BufferedImage image = this.legendProducer.buildLegendGraphic(req);
        int noLocalizedWidth = image.getWidth();       
       
       
        req.setLocale(Locale.ITALIAN);
        image = this.legendProducer.buildLegendGraphic(req);
        // test that using localized labels we get a different label than when not using it
        int itWidth = image.getWidth();
        assertTrue(itWidth != noLocalizedWidth);
       
        req.setLocale(Locale.ENGLISH);
        image = this.legendProducer.buildLegendGraphic(req);
        // test that using localized labels we get a different label than when not using it
        int enWidth = image.getWidth();
        assertTrue(enWidth != noLocalizedWidth);
        assertTrue(enWidth != itWidth);
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.