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;
}
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;
}
}
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;
}
}
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;
}
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);
}
}
}
Aggregations