Package org.geotools.styling

Examples of org.geotools.styling.SLDParser


    }
   
    public void testGroup() throws Exception {
        InputStream stream = get("wms?service=WMS&version=1.1.1&request=GetStyles&layers=lakesGroup&sldver=1.0.0");
       
        SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(null));
        parser.setInput(stream);
       
        StyledLayerDescriptor sld = parser.parseSLD();
        assertEquals(1, sld.getStyledLayers().length);
       
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals("lakesGroup", layer.getName());
       
View Full Code Here


   
    public void testMultiStyle() throws Exception {
        InputStream stream = get("wms?service=WMS&version=1.1.1&request=GetStyles&layers="
                + getLayerId(MockData.LAKES) + "&sldver=1.0.0");
       
        SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(null));
        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());
View Full Code Here

            Object obj = layer.getStyle();
            if(obj instanceof Style) {
              result = (Style)result;
            } else if (obj instanceof File || obj instanceof String) {
              StyleFactory styleFactory = new StyleFactoryImpl();
              SLDParser parser = new SLDParser(styleFactory);
              try {
                if(obj instanceof File) {
                  parser.setInput(new FileReader((File)obj));
                }else{
                  parser.setInput(new StringReader(obj.toString()));
                }
                  Style[] styles = parser.readXML();
          result = styles[0];
              }
              catch (Exception e) {
                  System.err.println("Error loading style '"+obj+"': "+e.getMessage());
                  e.printStackTrace(System.err);
View Full Code Here

  /**
     * Create a Style object from a definition in a SLD document
     */
    private Style createStyleFromSLD(String sldFile) {
        try {
            SLDParser stylereader = new SLDParser(styleFactory, new File(sldFile).toURI().toURL());
            Style[] style = stylereader.readXML();
            return style[0];
        } catch (Exception e) {
      System.err.println("Failed to read style from '" + sldFile + "': " + e.getMessage());
        }
        return null;
View Full Code Here

    return baos.toByteArray();
  }

  private static Rule[] decodeRules(
      final byte[] rulesBinary ) {
    final SLDParser parser = new SLDParser(
        CommonFactoryFinder.getStyleFactory(null),
        new ByteArrayInputStream(
            rulesBinary));
    final StyledLayerDescriptor sld = parser.parseSLD();
    final List<StyledLayer> layers = sld.layers();
    if ((layers != null) && !layers.isEmpty()) {
      // drill down to eventually get the rules from the sld
      for (final StyledLayer l : layers) {
        if (l instanceof NamedLayer) {
View Full Code Here

        assertNotNull(tx);
        assertEquals("vec:Heatmap", tx.getName());
    }

    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

     *
     * @throws WmsException
     *             if a parsing error occurs
     */
    private Style[] parseSld(Reader xmlIn) throws ServiceException {
        SLDParser parser = new SLDParser(styleFactory, xmlIn);
        Style[] styles = null;

        try {
            styles = parser.readXML();
        } catch (RuntimeException e) {
            throw new ServiceException(e);
        }

        if ((styles == null) || (styles.length == 0)) {
View Full Code Here

     * @return
     * @throws IOException
     */
    private Style readSLD(String sldName) throws IOException {
        StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
        SLDParser stylereader = new SLDParser(styleFactory, getClass().getResource(
                sldName));
        Style[] readStyles = stylereader.readXML();
   
        Style style = readStyles[0];
        return style;
    }
View Full Code Here

    @Test
    public void testSimple() throws Exception {
        InputStream stream = get("wms?service=WMS&version=1.1.1&&request=GetStyles&layers="
                + getLayerId(MockData.BASIC_POLYGONS) + "&sldver=1.0.0");
       
        SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(null));
        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());
View Full Code Here

   
    @Test
    public void testGroup() throws Exception {
        InputStream stream = get("wms?service=WMS&version=1.1.1&request=GetStyles&layers=lakesGroup&sldver=1.0.0");
       
        SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory(null));
        parser.setInput(stream);
       
        StyledLayerDescriptor sld = parser.parseSLD();
        assertEquals(1, sld.getStyledLayers().length);
       
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals("lakesGroup", layer.getName());
       
View Full Code Here

TOP

Related Classes of org.geotools.styling.SLDParser

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.