Package org.geotools.styling

Examples of org.geotools.styling.SLDParser


    {
        final Style style;
        if ( sld != null )
        {
            final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory( null );
            final SLDParser stylereader = new SLDParser( styleFactory, sld );
            final Style[] styles = stylereader.readXML();

            style = styles[ 0 ];
        }
        else
        {
View Full Code Here


        FeatureSource fs = ds.getFeatureSource();
        com.vividsolutions.jts.geom.Envelope env = fs.getBounds();
        myMapPane.setMapArea( env );
        StyleFactory factory = CommonFactoryFinder.getStyleFactory( null );

        SLDParser stylereader = new SLDParser( factory, sld );
        org.geotools.styling.Style[] style = stylereader.readXML();

        CoordinateReferenceSystem crs = fs.getSchema().getDefaultGeometry().getCoordinateSystem();
        if ( crs == null )
        {
            crs = DefaultGeographicCRS.WGS84;
View Full Code Here

        FeatureSource fs = ds.getFeatureSource();
        com.vividsolutions.jts.geom.Envelope env = fs.getBounds();
        myMapPane.setMapArea( env );
        StyleFactory factory = CommonFactoryFinder.getStyleFactory( null );

        SLDParser stylereader = new SLDParser( factory, sld );
        org.geotools.styling.Style[] style = stylereader.readXML();

        CoordinateReferenceSystem crs = fs.getSchema().getDefaultGeometry().getCoordinateSystem();
        if ( crs == null )
        {
            crs = DefaultGeographicCRS.WGS84;
View Full Code Here

  protected void importSLD() {
    File file = importStyleWizard("Select style layer descriptor 1.0 document","sld","style layer descriptor");
    if( file == null ) return; // cancel
   
    StyleFactory factory = CommonFactoryFinder.getStyleFactory();
    SLDParser sldParser = new SLDParser(factory);

  }
View Full Code Here

  private void readSLD_1_0() {
    StyleFactory factory = CommonFactoryFinder.getStyleFactory();

    StringReader reader = new StringReader(text.getText());
    SLDParser sldParser = new SLDParser(factory, reader);

    Style[] parsed = sldParser.readXML();
    if (parsed != null && parsed.length > 0) {
      style = parsed[0];
    }
  }
View Full Code Here

     * @param sld the sld file.
     * @return the created {@link Style} or <code>null</code>.
     */
    public static Style createFromSLD( File sld ) {
        try {
            SLDParser stylereader = new SLDParser(styleFactory, sld.toURI().toURL());
            Style[] style = stylereader.readXML();
            return style[0];

        } catch (Exception e) {
            ExceptionMonitor.show(null, e, "Problem creating style");
        }
View Full Code Here

    private Style getStyle(final String styleName) {
        Style style = STYLES.get(styleName);
        if (style == null) {
            StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(GeoTools
                    .getDefaultHints());
            SLDParser parser = new SLDParser(styleFactory);
            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

     *
     * @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

            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);
   
        return getMap;
View Full Code Here

   
    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

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.