Search in sources :

Example 1 with MutableNamedLayer

use of org.geotoolkit.sld.MutableNamedLayer in project geotoolkit by Geomatys.

the class Tester method createSLD.

private static StyledLayerDescriptor createSLD() {
    MutableStyledLayerDescriptor geoSLD = SLD_FACTORY.createSLD();
    geoSLD.setVersion("1.1.0");
    geoSLD.setName("the sld name");
    geoSLD.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the title"), new SimpleInternationalString("the abstract")));
    // Libraries-------------------------------------------------------------
    OnlineResource online = null;
    try {
        online = STYLE_FACTORY.onlineResource(new URI("http://geomayts.fr/anSLDFile.xml"));
    } catch (URISyntaxException ex) {
        Logger.getLogger("org.geotoolkit.style").log(Level.WARNING, null, ex);
    }
    SLDLibrary lib = SLD_FACTORY.createSLDLibrary(online);
    geoSLD.libraries().add(lib);
    // named layer-----------------------------------------------------------
    MutableNamedLayer named = SLD_FACTORY.createNamedLayer();
    named.setName("A named layer");
    named.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the named layer title"), new SimpleInternationalString("the named layer description")));
    MutableNamedStyle mns = SLD_FACTORY.createNamedStyle();
    mns.setName("named style name");
    mns.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the named style title"), new SimpleInternationalString("the named style description")));
    named.styles().add(mns);
    geoSLD.layers().add(named);
    // user layer------------------------------------------------------------
    MutableUserLayer user = SLD_FACTORY.createUserLayer();
    user.setName("A user layer");
    user.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the user layer title"), new SimpleInternationalString("the user layer description")));
    MutableStyle style = createSEStyle();
    user.styles().add(style);
    geoSLD.layers().add(user);
    return geoSLD;
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) SLDLibrary(org.opengis.sld.SLDLibrary) MutableNamedStyle(org.geotoolkit.sld.MutableNamedStyle) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) URISyntaxException(java.net.URISyntaxException) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) URI(java.net.URI) MutableUserLayer(org.geotoolkit.sld.MutableUserLayer) MutableStyledLayerDescriptor(org.geotoolkit.sld.MutableStyledLayerDescriptor)

Example 2 with MutableNamedLayer

use of org.geotoolkit.sld.MutableNamedLayer in project geotoolkit by Geomatys.

the class SLD100toGTTransformer method visitLayers.

/**
 * Transform a jaxb v1.0.0 layers in a GT Layer objects.
 */
public Collection<? extends MutableLayer> visitLayers(final List<Object> layers) {
    if (layers == null || layers.isEmpty()) {
        return Collections.emptyList();
    } else {
        final Collection<MutableLayer> sldLayers = new ArrayList<MutableLayer>();
        for (final Object obj : layers) {
            if (obj instanceof NamedLayer) {
                final NamedLayer nl = (NamedLayer) obj;
                final MutableNamedLayer mnl = sldFactory.createNamedLayer();
                mnl.setName(nl.getName());
                mnl.getConstraints().constraints().addAll(visitFeatureConstraints(nl.getLayerFeatureConstraints()));
                mnl.styles().addAll(visitStyles(nl.getNamedStyleOrUserStyle()));
                sldLayers.add(mnl);
            } else if (obj instanceof UserLayer) {
                final UserLayer ul = (UserLayer) obj;
                final MutableUserLayer mul = sldFactory.createUserLayer();
                mul.setName(ul.getName());
                mul.styles().addAll(visitUserStyles(ul.getUserStyle()));
                if (ul.getLayerFeatureConstraints() != null) {
                    final MutableLayerFeatureConstraints consts = sldFactory.createLayerFeatureConstraints();
                    consts.constraints().addAll(visitFeatureConstraints(ul.getLayerFeatureConstraints()));
                    mul.setConstraints(consts);
                }
                if (ul.getRemoteOWS() != null) {
                    mul.setSource(visiteRemoteOWS(ul.getRemoteOWS()));
                }
                sldLayers.add(mul);
            }
        }
        return sldLayers;
    }
}
Also used : ArrayList(java.util.ArrayList) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) UserLayer(org.geotoolkit.sld.xml.v100.UserLayer) MutableUserLayer(org.geotoolkit.sld.MutableUserLayer) NamedLayer(org.geotoolkit.sld.xml.v100.NamedLayer) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) MutableUserLayer(org.geotoolkit.sld.MutableUserLayer) MutableLayerFeatureConstraints(org.geotoolkit.sld.MutableLayerFeatureConstraints) MutableLayer(org.geotoolkit.sld.MutableLayer)

Example 3 with MutableNamedLayer

use of org.geotoolkit.sld.MutableNamedLayer in project geotoolkit by Geomatys.

the class SLD110toGTTransformer method visitLayers.

/**
 * Transform a jaxb v1.1.0 SLD layers in a GT layers Objects
 */
public Collection<? extends MutableLayer> visitLayers(final List<Object> layers) throws FactoryException {
    if (layers == null || layers.isEmpty()) {
        return Collections.emptyList();
    } else {
        final Collection<MutableLayer> sldLayers = new ArrayList<MutableLayer>();
        for (final Object obj : layers) {
            if (obj instanceof NamedLayer) {
                final NamedLayer nl = (NamedLayer) obj;
                final MutableNamedLayer mnl = sldFactory.createNamedLayer();
                mnl.setName(nl.getName());
                mnl.setDescription(visitDescription(nl.getDescription()));
                mnl.getConstraints().constraints().addAll(visitFeatureConstraints(nl.getLayerFeatureConstraints()));
                mnl.styles().addAll(visitStyles(nl.getNamedStyleOrUserStyle()));
                sldLayers.add(mnl);
            } else if (obj instanceof UserLayer) {
                final UserLayer ul = (UserLayer) obj;
                final MutableUserLayer mul = sldFactory.createUserLayer();
                mul.setName(ul.getName());
                mul.setDescription(visitDescription(ul.getDescription()));
                mul.styles().addAll(visitUserStyles(ul.getUserStyle()));
                if (ul.getLayerCoverageConstraints() != null) {
                    final MutableLayerCoverageConstraints consts = sldFactory.createLayerCoverageConstraints();
                    consts.constraints().addAll(visitCoverageConstraints(ul.getLayerCoverageConstraints()));
                    mul.setConstraints(consts);
                } else if (ul.getLayerFeatureConstraints() != null) {
                    final MutableLayerFeatureConstraints consts = sldFactory.createLayerFeatureConstraints();
                    consts.constraints().addAll(visitFeatureConstraints(ul.getLayerFeatureConstraints()));
                    mul.setConstraints(consts);
                }
                if (ul.getInlineFeature() != null) {
                    mul.setSource(visitInlineFeature(ul.getInlineFeature()));
                } else if (ul.getRemoteOWS() != null) {
                    mul.setSource(visiteRemoteOWS(ul.getRemoteOWS()));
                }
                sldLayers.add(mul);
            }
        }
        return sldLayers;
    }
}
Also used : MutableLayerCoverageConstraints(org.geotoolkit.sld.MutableLayerCoverageConstraints) ArrayList(java.util.ArrayList) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) UserLayer(org.geotoolkit.sld.xml.v110.UserLayer) MutableUserLayer(org.geotoolkit.sld.MutableUserLayer) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) NamedLayer(org.geotoolkit.sld.xml.v110.NamedLayer) MutableUserLayer(org.geotoolkit.sld.MutableUserLayer) MutableLayerFeatureConstraints(org.geotoolkit.sld.MutableLayerFeatureConstraints) MutableLayer(org.geotoolkit.sld.MutableLayer)

Example 4 with MutableNamedLayer

use of org.geotoolkit.sld.MutableNamedLayer in project geotoolkit by Geomatys.

the class XMLUtilitiesTest method createSLD.

// -------------for tests----------------------------------------------------
private static MutableStyledLayerDescriptor createSLD() {
    MutableStyledLayerDescriptor geoSLD = SLD_FACTORY.createSLD();
    geoSLD.setVersion("1.1.0");
    geoSLD.setName("the sld name");
    geoSLD.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the title"), new SimpleInternationalString("the abstract")));
    // Libraries-------------------------------------------------------------
    OnlineResource online = null;
    try {
        online = STYLE_FACTORY.onlineResource(new URI("http://geomayts.fr/anSLDFile.xml"));
    } catch (URISyntaxException ex) {
        Logger.getLogger("org.geotoolkit.style").log(Level.WARNING, null, ex);
    }
    SLDLibrary lib = SLD_FACTORY.createSLDLibrary(online);
    geoSLD.libraries().add(lib);
    // named layer-----------------------------------------------------------
    MutableNamedLayer named = SLD_FACTORY.createNamedLayer();
    named.setName("A named layer");
    named.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the named layer title"), new SimpleInternationalString("the named layer description")));
    MutableNamedStyle mns = SLD_FACTORY.createNamedStyle();
    mns.setName("named style name");
    mns.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the named style title"), new SimpleInternationalString("the named style description")));
    named.styles().add(mns);
    geoSLD.layers().add(named);
    // user layer------------------------------------------------------------
    MutableUserLayer user = SLD_FACTORY.createUserLayer();
    user.setName("A user layer");
    user.setDescription(STYLE_FACTORY.description(new SimpleInternationalString("the user layer title"), new SimpleInternationalString("the user layer description")));
    MutableStyle style = createSEStyle();
    user.styles().add(style);
    geoSLD.layers().add(user);
    return geoSLD;
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) SLDLibrary(org.opengis.sld.SLDLibrary) MutableNamedStyle(org.geotoolkit.sld.MutableNamedStyle) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) URISyntaxException(java.net.URISyntaxException) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) URI(java.net.URI) MutableUserLayer(org.geotoolkit.sld.MutableUserLayer) MutableStyledLayerDescriptor(org.geotoolkit.sld.MutableStyledLayerDescriptor)

Example 5 with MutableNamedLayer

use of org.geotoolkit.sld.MutableNamedLayer in project geotoolkit by Geomatys.

the class MapfileToSLDProcess method convert.

private void convert(final MutableStyledLayerDescriptor sld, final Feature feature) throws ProcessException {
    final Collection<Feature> layers = (Collection<Feature>) feature.getPropertyValue(MAP_LAYER.toString());
    for (final Feature mflayer : layers) {
        // create an sld layer
        final MutableNamedLayer sldLayer = SLDF.createNamedLayer();
        sld.layers().add(sldLayer);
        final String name = String.valueOf(mflayer.getPropertyValue(LAYER_NAME.toString()));
        sldLayer.setName(name);
        sldLayer.setDescription(SF.description(name, name));
        // create the style
        final MutableStyle sldStyle = SF.style();
        sldLayer.styles().add(sldStyle);
        final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
        sldStyle.featureTypeStyles().add(fts);
        final Double minscale = (Double) mflayer.getPropertyValue(LAYER_MINSCALEDENOM.toString());
        final Double maxscale = (Double) mflayer.getPropertyValue(LAYER_MAXSCALEDENOM.toString());
        final Collection<Feature> classes = (Collection<Feature>) mflayer.getPropertyValue(LAYER_CLASS.toString());
        for (final Feature clazz : classes) {
            final MutableRule rule = createRule(mflayer, minscale, maxscale, clazz);
            fts.rules().add(rule);
        }
    }
}
Also used : MutableRule(org.geotoolkit.style.MutableRule) MutableStyle(org.geotoolkit.style.MutableStyle) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) Collection(java.util.Collection) MutableNamedLayer(org.geotoolkit.sld.MutableNamedLayer) Feature(org.opengis.feature.Feature)

Aggregations

MutableNamedLayer (org.geotoolkit.sld.MutableNamedLayer)5 MutableUserLayer (org.geotoolkit.sld.MutableUserLayer)4 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)2 MutableLayer (org.geotoolkit.sld.MutableLayer)2 MutableLayerFeatureConstraints (org.geotoolkit.sld.MutableLayerFeatureConstraints)2 MutableNamedStyle (org.geotoolkit.sld.MutableNamedStyle)2 MutableStyledLayerDescriptor (org.geotoolkit.sld.MutableStyledLayerDescriptor)2 OnlineResource (org.opengis.metadata.citation.OnlineResource)2 SLDLibrary (org.opengis.sld.SLDLibrary)2 Collection (java.util.Collection)1 MutableLayerCoverageConstraints (org.geotoolkit.sld.MutableLayerCoverageConstraints)1 NamedLayer (org.geotoolkit.sld.xml.v100.NamedLayer)1 UserLayer (org.geotoolkit.sld.xml.v100.UserLayer)1 NamedLayer (org.geotoolkit.sld.xml.v110.NamedLayer)1 UserLayer (org.geotoolkit.sld.xml.v110.UserLayer)1 MutableFeatureTypeStyle (org.geotoolkit.style.MutableFeatureTypeStyle)1 MutableRule (org.geotoolkit.style.MutableRule)1