Package org.geotools.styling

Examples of org.geotools.styling.NamedLayer


       
        try {
            StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
            List<StyledLayer> layers = new ArrayList<StyledLayer>();
            for(String layerName : request.getLayers()) {
                NamedLayer namedLayer = factory.createNamedLayer();
                layers.add(namedLayer);
                namedLayer.setName(layerName);
                LayerGroupInfo group = wms.getLayerGroupByName(layerName);
                LayerInfo layer = wms.getLayerByName(layerName);
                if(group != null) {
                    // nothing to do, groups have no style
                } else if(layer != null) {
                    Style style = layer.getDefaultStyle().getStyle();
                    // add the default style first
                    style = cloneStyle(style);
                    style.setDefault(true);
                    style.setName(layer.getDefaultStyle().getName());
                    namedLayer.styles().add(style);
                    // add alternate styles
                    for(StyleInfo si : layer.getStyles()) {
                        style = cloneStyle(si.getStyle());
                        style.setName(si.getName());
                        namedLayer.styles().add(style);
                    }
                } else {
                    // we should really add a code and a locator...
                    throw new WmsException("Unknown layer " + layerName);
                }
View Full Code Here


        parser.setInput(stream);
       
        StyledLayerDescriptor sld = parser.parseSLD();
        assertEquals(1, sld.getStyledLayers().length);
       
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals(getLayerId(MockData.BASIC_POLYGONS), layer.getName());
        assertEquals(1, layer.styles().size());
       
        Style style = layer.styles().get(0);
        assertTrue(style.isDefault());
        assertEquals("BasicPolygons", style.getName());
    }
View Full Code Here

        parser.setInput(stream);
       
        StyledLayerDescriptor sld = parser.parseSLD();
        assertEquals(1, sld.getStyledLayers().length);
       
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals("lakesGroup", layer.getName());
       
        // groups have no style
        assertEquals(0, layer.styles().size());
    }
View Full Code Here

        parser.setInput(stream);
       
        StyledLayerDescriptor sld = parser.parseSLD();
        assertEquals(1, sld.getStyledLayers().length);
       
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals(getLayerId(MockData.LAKES), layer.getName());
        assertEquals(2, layer.styles().size());
       
        Style style = layer.styles().get(0);
        assertTrue(style.isDefault());
        assertEquals("Lakes", style.getName());
       
        style = layer.styles().get(1);
        assertFalse(style.isDefault());
        assertEquals("Forests", style.getName());
    }
View Full Code Here

    protected void write(Object object, OutputStream out) throws IOException {
        Style style = (Style) object;
       
        //wrap in a StyledLayerDescriptor
        StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
        NamedLayer nl = sf.createNamedLayer();
        nl.setName( style.getName() );
        nl.addStyle( style );
       
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        sld.setStyledLayers( new StyledLayer[]{ nl });
       
        SLDTransformer writer = new SLDTransformer();
View Full Code Here

            Object o = requestedLayers.get(i);
            if(o instanceof LayerInfo){
                currLayer = new MapLayerInfo((LayerInfo)o);
               
                if (styledLayers[i] instanceof NamedLayer) {
                    NamedLayer namedLayer = ((NamedLayer) styledLayers[i]);
                    currLayer.setLayerFeatureConstraints(namedLayer.getLayerFeatureConstraints());
                }
               
                layers.add(currLayer);
                Style style = findStyleOf(request, currLayer, styleName, styledLayers);
                styles.add(style);
View Full Code Here

                        if(layerInfo == null)
                            throw new WmsException("Unknown layer: " + layerName);
                       
                        currLayer = new MapLayerInfo(layerInfo);
                        if (sl instanceof NamedLayer) {
                            NamedLayer namedLayer = ((NamedLayer) sl);
                            currLayer.setLayerFeatureConstraints(namedLayer.getLayerFeatureConstraints());
                        }
                    }
                }

                if (currLayer.getType() == MapLayerInfo.TYPE_RASTER) {
View Full Code Here

           
            for (int i = 0; i < sld.getStyledLayers().length; i++) {
                Style[] styles = null;
               
                if (sld.getStyledLayers()[i] instanceof NamedLayer) {
                    NamedLayer layer = (NamedLayer) sld.getStyledLayers()[i];
                    styles = layer.getStyles();
                }
                else if(sld.getStyledLayers()[i] instanceof UserLayer) {
                    UserLayer layer = (UserLayer) sld.getStyledLayers()[i];
                    styles = layer.getUserStyles();
                }
               
                if (styles != null) {
                    for (int j = 0; j < styles.length; i++) {
                        if (!(styles[j] instanceof NamedStyle)) {
View Full Code Here

    @SuppressWarnings("unchecked")
    public NamedLayer build() {
        if (unset) {
            return null;
        }
        NamedLayer layer = sf.createNamedLayer();
        layer.setName(name);
        List<FeatureTypeConstraint> list = new ArrayList<FeatureTypeConstraint>();
        for (FeatureTypeConstraintBuilder constraint : featureTypeConstraint) {
            list.add(constraint.build());
        }
        layer.layerFeatureConstraints().addAll(list);
        for (StyleBuilder sb : styles) {
            layer.addStyle(sb.build());
        }

        if (parent == null) {
            reset();
        }
View Full Code Here

        StyleCollector collector = new StyleCollector();
        sld.accept(collector);
        assertSimpleStyle(collector);

        NamedLayer layer = (NamedLayer) collector.layers.get(0);
        assertEquals("states", layer.getName());
        assertTrue(collector.symbolizers.get(0) instanceof PointSymbolizer);
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.NamedLayer

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.