Examples of SLDParser


Examples of org.geotools.styling.SLDParser

    // pipe to geotools parser
    StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pii = new PipedInputStream(pos);

    final SLDParser parser = new SLDParser(factory, pii);

    IMarshallingContext mctx = bfact.createMarshallingContext();
    mctx.setOutput(new PrintWriter(pos));

    CountDownLatch countDown = new CountDownLatch(2);
View Full Code Here

Examples of org.geotools.styling.SLDParser

    NamedStyleInfo namedStyle = vectorLayerRasterizingInfo.getStyle();
    String location = namedStyle.getSldLocation();
    Style[] styles = styleMap.get(location);
    if (styles == null) {
      Resource sld = applicationContext.getResource(location);
      SLDParser parser = new SLDParser(styleFactory);
      // external graphics will be resolved with respect to the SLD URL !
      try {
        parser.setInput(sld.getURL());
        styles = parser.readXML();
        // apply missing titles (needed for legend)
        String styleName = (namedStyle.getSldStyleName() != null ?
            namedStyle.getSldStyleName() : layer.getId());
        for (Style style : styles) {
          if (style.getDescription().getTitle() == null) {
View Full Code Here

Examples of org.geotools.styling.SLDParser

  public void testLabels() throws IOException {
    VectorLayerRasterizingInfo vectorLayerRasterizingInfo = new VectorLayerRasterizingInfo();
    vectorLayerRasterizingInfo.setPaintGeometries(false);
    vectorLayerRasterizingInfo.setPaintLabels(true);
    RasterizingStyleVisitor visitor = new RasterizingStyleVisitor(vectorLayerRasterizingInfo);
    SLDParser parser = new SLDParser(styleFactory);
    parser.setInput(getClass().getResource("point_pointwithdefaultlabel.sld"));
    Style[] styles = parser.readXML();
    Assert.assertEquals(1, styles.length);
    visitor.visit(styles[0]);
    Style copy = (Style) visitor.getCopy();
    FeatureTypeStyle featureTypeStyle = copy.featureTypeStyles().iterator().next();
    Rule rule = featureTypeStyle.rules().iterator().next();
View Full Code Here

Examples of org.geotools.styling.SLDParser

  public void testGeometries() throws IOException{
    VectorLayerRasterizingInfo vectorLayerRasterizingInfo = new VectorLayerRasterizingInfo();
    vectorLayerRasterizingInfo.setPaintGeometries(true);
    vectorLayerRasterizingInfo.setPaintLabels(false);
    RasterizingStyleVisitor visitor = new RasterizingStyleVisitor(vectorLayerRasterizingInfo);
    SLDParser parser = new SLDParser(styleFactory);
    parser.setInput(getClass().getResource("point_pointwithdefaultlabel.sld"));
    Style[] styles = parser.readXML();
    Assert.assertEquals(1, styles.length);
    visitor.visit(styles[0]);
    Style copy = (Style) visitor.getCopy();
    FeatureTypeStyle featureTypeStyle = copy.featureTypeStyles().iterator().next();
    Rule rule = featureTypeStyle.rules().iterator().next();
View Full Code Here

Examples of org.geotools.styling.SLDParser

  public void testLabelsAndGeometries() throws IOException{
    VectorLayerRasterizingInfo vectorLayerRasterizingInfo = new VectorLayerRasterizingInfo();
    vectorLayerRasterizingInfo.setPaintGeometries(true);
    vectorLayerRasterizingInfo.setPaintLabels(true);
    RasterizingStyleVisitor visitor = new RasterizingStyleVisitor(vectorLayerRasterizingInfo);
    SLDParser parser = new SLDParser(styleFactory);
    parser.setInput(getClass().getResource("point_pointwithdefaultlabel.sld"));
    Style[] styles = parser.readXML();
    Assert.assertEquals(1, styles.length);
    visitor.visit(styles[0]);
    Style copy = (Style) visitor.getCopy();
    FeatureTypeStyle featureTypeStyle = copy.featureTypeStyles().iterator().next();
    Rule rule = featureTypeStyle.rules().iterator().next();
View Full Code Here

Examples of org.geotools.styling.SLDParser

            if( reader != null){
                reader.close();
            }
        }
        // parse it up
        SLDParser parser = new SLDParser(styleFactory);
        try {
            parser.setInput(file);
            StyledLayerDescriptor sld = parser.parseSLD();
            return sld;
        } catch (FileNotFoundException e) {
            return null; // well that is unexpected since f.exists()
        }
    }
View Full Code Here

Examples of org.geotools.styling.SLDParser

                input.close();
            }
        }
        // The SLD 1.0 parser is far more forgiving
        StyleFactory factory = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
        SLDParser styleReader = new SLDParser(factory, url);
        Style style = styleReader.readXML()[0];
        return style;
    }
View Full Code Here

Examples of org.geotools.styling.SLDParser

                reader.close();
            }
        }
       
        // parse it up
        SLDParser parser = new SLDParser(styleFactory);
        try {
            parser.setInput(file);
            Style[] array = parser.readXML();
            if( array != null && array.length > 0 ){
                return array[0];
            }
        } catch (FileNotFoundException e) {
            return null; // well that is unexpected since f.exists()
View Full Code Here

Examples of org.geotools.styling.SLDParser

     * @param file the sld file to parse.
     * @return the styled layer descriptor.
     * @throws IOException
     */
    public static StyledLayerDescriptor readStyle( File file ) throws IOException {
        SLDParser stylereader = new SLDParser(sf, file);
        StyledLayerDescriptor sld = stylereader.parseSLD();
        return sld;
    }
View Full Code Here

Examples of org.geotools.styling.SLDParser

    public Object load( IMemento momento ) {
        // parse the sld object
        if( momento.getTextData()==null )
            return null;
        StringReader reader = new StringReader(momento.getTextData());
        SLDParser sldParser = new SLDParser(getStyleFactory(), reader);

        Style[] parsed = sldParser.readXML();
        if (parsed != null && parsed.length > 0)
            return parsed[0];

        return null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.