Package org.geotools.styling

Examples of org.geotools.styling.StyledLayerDescriptor


       
        PolygonSymbolizer sym = (PolygonSymbolizer) r.symbolizers().get(0);
    }
   
    public void testParseGraphicFill() throws Exception {
        StyledLayerDescriptor sld = (StyledLayerDescriptor) parse("../graphicFill.xml");
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        PolygonSymbolizer ps = (PolygonSymbolizer) layer.getStyles()[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
        Graphic graphicFill = ps.getFill().getGraphicFill();
        assertNotNull(graphicFill);
        ExternalGraphic eg = (ExternalGraphic) graphicFill.graphicalSymbols().get(0);
        assertEquals(new URI("http://maps.google.com/mapfiles/kml/pal2/icon4.png"), eg.getOnlineResource().getLinkage());
View Full Code Here


        }       
    }
   
    public void testParseValidateVendorOptions() throws Exception {
        String file = "example-sld-vendor-option.xml";
        StyledLayerDescriptor sld = (StyledLayerDescriptor) parse(file);
       
        // basic drill down
        assertEquals(1, sld.getStyledLayers().length);
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals(1, layer.getStyles().length);
        Style style = layer.getStyles()[0];
        assertEquals(1, style.featureTypeStyles().size());
        FeatureTypeStyle fts = style.featureTypeStyles().get(0);
        assertEquals(1, fts.rules().size());
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {

        StyledLayerDescriptor sld =  (StyledLayerDescriptor) super.parse(instance, node, value);
        if (node.hasChild("Description")) {
            Description desc = (Description) node.getChildValue("Description");
            if (desc.getAbstract() != null) {
                sld.setAbstract(desc.getAbstract().toString());
            }
            if (desc.getTitle() != null) {
                sld.setTitle(desc.getTitle().toString());
            }
        }
        return sld;
    }
View Full Code Here

     * @return
     * @throws TransformerException
     */
    private String styleToXML(final Style style) throws TransformerException
    {
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer styleTransform = new SLDTransformer();
        String xml = styleTransform.transform(sld);

View Full Code Here

         * @param hints
         * @throws OperationNotSupportedException
         */
        public Object getValue( Element element, ElementValue[] value, Attributes attrs1, Map hints )
                throws OperationNotSupportedException, SAXException {
            StyledLayerDescriptor sld = StyleFactoryFinder.createStyleFactory().createStyledLayerDescriptor();
   
                for (int i = 0; i < value.length; i++) {
                    if ((value[i] == null) || value[i].getElement() == null) {
                        continue;
                    }
   
                    Element e = value[i].getElement();
                    if(elems[NAME].getName().equals(e.getName()))
                        sld.setName((String)value[i].getValue());
   
                    if(elems[TITLE].getName().equals(e.getName()))
                        sld.setTitle((String)value[i].getValue());
                   
                    if(elems[ABSTRACT].getName().equals(e.getName()))
                        sld.setAbstract((String)value[i].getValue());
                   
                    if(elems[NAMEDLAYER].getName().equals(e.getName()))
                        sld.addStyledLayer((StyledLayerImpl)value[i].getValue());
                   
                    if(elems[USERLAYER].getName().equals(e.getName()))
                        sld.addStyledLayer((StyledLayerImpl)value[i].getValue());
                }
               
                return sld;
        }
View Full Code Here

            try {
                parser.setInput(getClass().getResource(styleName));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            StyledLayerDescriptor sld = parser.parseSLD();
            UserLayer layer = (UserLayer) sld.getStyledLayers()[0];
            style = layer.getUserStyles()[0];
            STYLES.put(styleName, style);
        }
        return style;
    }
View Full Code Here

                            new ByteArrayInputStream(getMap.getSldBody().getBytes()), errors));
                }
            }

            InputStream input = new ByteArrayInputStream(getMap.getSldBody().getBytes());
            StyledLayerDescriptor sld = parseSld(getMap, input);
            processSld(getMap, requestedLayerInfos, sld, styleNameList);

            // set filter in, we'll check consistency later
            getMap.setFilter(filters);
        } else if (getMap.getSld() != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Getting layers and styles from reomte SLD");
            }

            URL sldUrl = getMap.getSld();

            if (getMap.getValidateSchema().booleanValue()) {
                InputStream input = Requests.getInputStream(sldUrl);
                List errors = null;

                try {
                    errors = validateSld(input, getMap);
                } finally {
                    input.close();
                }

                if ((errors != null) && (errors.size() != 0)) {
                    input = Requests.getInputStream(sldUrl);

                    try {
                        throw new ServiceException(SLDValidator.getErrorMessage(input, errors));
                    } finally {
                        input.close();
                    }
                }
            }

            // JD: GEOS-420, Wrap the sldUrl in getINputStream method in order
            // to do compression
            InputStream input = Requests.getInputStream(sldUrl);

            try {
                StyledLayerDescriptor sld = parseSld(getMap, input);
                processSld(getMap, requestedLayerInfos, sld, styleNameList);
            } finally {
                input.close();
            }
View Full Code Here

    /**
     * Parses an sld document.
     */
    private StyledLayerDescriptor parseSld(GetMapRequest getMap, InputStream stream) {
      
        StyledLayerDescriptor sld;
        try {
            if (getMap.getSldVersion() != null) {
                sld = Styles.parse(stream, new Version(getMap.getSldVersion()));
            }
            else {
View Full Code Here

        if ( request == null ) {
            throw new IllegalArgumentException( "request must be not null" );
        }
       
        GetMapRequest getMap = (GetMapRequest) request;
        StyledLayerDescriptor sld =
            new SLDParser( styleFactory, reader ).parseSLD();
       
        //process the sld
        GetMapKvpRequestReader.processStandaloneSld(wms, getMap, sld);
   
View Full Code Here

                    // we should really add a code and a locator...
                    throw new ServiceException("Unknown layer " + layerName);
                }
            }

            StyledLayerDescriptor sld = factory.createStyledLayerDescriptor();
            sld.setStyledLayers((StyledLayer[]) layers.toArray(new StyledLayer[layers.size()]));

            return sld;
        } catch (IOException e) {
            throw new ServiceException(e);
        }
View Full Code Here

TOP

Related Classes of org.geotools.styling.StyledLayerDescriptor

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.