Package org.geotools.styling

Examples of org.geotools.styling.StyledLayerDescriptor


        if ( styleResource.getType() == Type.UNDEFINED ){
            throw new IOException( "No such resource: " + s.getFilename());
        }
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        locator.setSourceUrl(resourceToUrl(styleResource));
        StyledLayerDescriptor sld =
            Styles.handler(s.getFormat()).parse(styleResource, s.getFormatVersion(), locator, null);
        final Style style = Styles.style(sld);
        assert style!=null;
        return style;
    }
View Full Code Here


                }
            }
           
        };
        locator.setSourceUrl(resourceToUrl(styleResource));
        final StyledLayerDescriptor sld =
            Styles.handler(s.getFormat()).parse(input, s.getFormatVersion(), locator, null);
        final Style style = Styles.style(sld);
       
        assert style!=null;
        return style;
View Full Code Here

      dom = db.parse(source);
      // for our next trick do something with the dom.

      // NodeList nodes = findElements(dom, "StyledLayerDescriptor");

      StyledLayerDescriptor sld = parseDescriptor(dom
          .getDocumentElement());// should only be
                      // one per file
      return sld;

    } catch (javax.xml.parsers.ParserConfigurationException pce) {
View Full Code Here

      throw new RuntimeException(ie);
    }
  }

  public StyledLayerDescriptor parseDescriptor(Node root) {
    StyledLayerDescriptor sld = factory.createStyledLayerDescriptor();
    // StyledLayer layer = null;
    // LineSymbolizer symbol = factory.createLineSymbolizer();

    NodeList children = root.getChildNodes();
    final int length = children.getLength();

    for (int i = 0; i < length; i++) {
      Node child = children.item(i);
      if ((child == null) || (child.getNodeType() != Node.ELEMENT_NODE)) {
        continue;
      }
      String childName = child.getLocalName();
      if (childName == null) {
        childName = child.getNodeName();
      }

      if (childName.equalsIgnoreCase("Name")) {
        sld.setName(getFirstChildValue(child));
      } else if (childName.equalsIgnoreCase("Title")) {
        sld.setTitle(getFirstChildValue(child));
      } else if (childName.equalsIgnoreCase("Abstract")) {
        sld.setAbstract(getFirstChildValue(child));
      } else if (childName.equalsIgnoreCase("NamedLayer")) {
        NamedLayer layer = parseNamedLayer(child);
        sld.addStyledLayer(layer);
      } else if (childName.equalsIgnoreCase("UserLayer")) {
        StyledLayer layer = parseUserLayer(child);
        sld.addStyledLayer(layer);
      }
    }

    return sld;
  }
View Full Code Here

    @Override
    public Object decode(InputStream input) throws Exception {
        Parser p = new Parser(sldConfiguration);

        // extract the first style in the first sld
        StyledLayerDescriptor sld = (StyledLayerDescriptor) p.parse(input);
        NamedLayer styledLayer = (NamedLayer) sld.getStyledLayers()[0];
        return styledLayer.getStyles()[0];
    }
View Full Code Here

    }

    @Override
    public void encode(Object obj, ContentHandler handler) throws Exception {
        StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        NamedLayer nl = sf.createNamedLayer();
        nl.setName("");
        nl.styles().add((Style) obj);
        sld.setStyledLayers(new StyledLayer[] { nl });

        Encoder e = new Encoder(sldConfiguration);
        e.encode(sld, element, handler);
    }
View Full Code Here

    @Override
    public Object decode(Object input) throws Exception {
        Parser p = new Parser(sldConfiguration);

        // extract the first style in the first sld
        StyledLayerDescriptor sld = (StyledLayerDescriptor) p.parse(new StringReader((String) input));
        NamedLayer styledLayer = (NamedLayer) sld.getStyledLayers()[0];
        return styledLayer.getStyles()[0];
    }
View Full Code Here

    }

    private Style parseStyle(String styleName) throws IOException {
        SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory());
        parser.setInput(RasterSymbolizerVisitorTest.class.getResource(styleName));
        StyledLayerDescriptor sld = parser.parseSLD();
        NamedLayer ul = (NamedLayer) sld.getStyledLayers()[0];
        return ul.getStyles()[0];
    }
View Full Code Here

        if ( request == null ) {
            throw new IllegalArgumentException( "request must be not null" );
        }
       
        GetMapRequest getMap = (GetMapRequest) request;
        StyledLayerDescriptor sld =
            Styles.handler(getMap.getStyleFormat()).parse(reader, getMap.styleVersion(), null, null);

        //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.