use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.
the class SE110toGTTransformer method visitFTS.
/**
* Transform a SLD v1.1 FeatureTypeStyle or CoverageStyle in GT FTS.
*/
public MutableFeatureTypeStyle visitFTS(final Object obj) throws FactoryException {
if (obj == null)
return null;
if (obj instanceof OnlineResourceType) {
final OnlineResourceType ort = (OnlineResourceType) obj;
final OnlineResource or = visitOnlineResource(ort);
if (or != null) {
try {
return xmlUtilities.readFeatureTypeStyle(or, Specification.SymbologyEncoding.V_1_1_0);
} catch (JAXBException ex) {
Logger.getLogger("org.geotoolkit.sld.xml").log(Level.WARNING, null, ex);
}
return null;
}
} else if (obj instanceof CoverageStyleType) {
final MutableFeatureTypeStyle fts = styleFactory.featureTypeStyle();
final CoverageStyleType cst = (CoverageStyleType) obj;
fts.setName(cst.getName());
fts.setDescription(visitDescription(cst.getDescription()));
fts.semanticTypeIdentifiers().addAll(visitSemantics(cst.getSemanticTypeIdentifier()));
if (cst.getCoverageName() != null) {
fts.featureTypeNames().add(NamesExt.create(cst.getCoverageName()));
}
if (cst.getRuleOrOnlineResource() == null || cst.getRuleOrOnlineResource().isEmpty()) {
} else {
for (Object objRule : cst.getRuleOrOnlineResource()) {
fts.rules().add(visitRule(objRule));
}
}
return fts;
} else if (obj instanceof FeatureTypeStyleType) {
final MutableFeatureTypeStyle fts = styleFactory.featureTypeStyle();
final FeatureTypeStyleType ftst = (FeatureTypeStyleType) obj;
fts.setName(ftst.getName());
fts.setDescription(visitDescription(ftst.getDescription()));
fts.semanticTypeIdentifiers().addAll(visitSemantics(ftst.getSemanticTypeIdentifier()));
if (ftst.getFeatureTypeName() != null) {
fts.featureTypeNames().add(NamesExt.create(ftst.getFeatureTypeName()));
}
if (ftst.getRuleOrOnlineResource() == null || ftst.getRuleOrOnlineResource().isEmpty()) {
} else {
for (final Object objRule : ftst.getRuleOrOnlineResource()) {
fts.rules().add(visitRule(objRule));
}
}
return fts;
}
return null;
}
use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.
the class StyleXmlIO method readFeatureTypeStyle.
/**
* Read a SE FeatureTypeStyle source and parse it in GT FTS object.
* Source can be : File, InputSource, InputStream, Node, Reader, Source, URL,
* XMLEventReader, XMLStreamReader or OnlineResource
*/
public MutableFeatureTypeStyle readFeatureTypeStyle(final Object source, final Specification.SymbologyEncoding version) throws JAXBException, FactoryException {
ensureNonNull("source", source);
ensureNonNull("version", version);
final Object obj;
switch(version) {
case SLD_1_0_0:
obj = unmarshallV100(source);
if (obj instanceof org.geotoolkit.sld.xml.v100.FeatureTypeStyle) {
return getTransformer100().visitFTS((org.geotoolkit.sld.xml.v100.FeatureTypeStyle) obj);
} else {
throw new JAXBException("Source is not a valid OGC SLD FeatureTypeStyle v1.0.0");
}
case V_1_1_0:
obj = unmarshallV110(source);
if (obj instanceof org.geotoolkit.se.xml.v110.FeatureTypeStyleType) {
return getTransformer110().visitFTS(obj);
} else if (obj instanceof JAXBElement<?> && (((JAXBElement<?>) obj).getValue() instanceof org.geotoolkit.se.xml.v110.OnlineResourceType || ((JAXBElement<?>) obj).getValue() instanceof org.geotoolkit.se.xml.v110.FeatureTypeStyleType)) {
return getTransformer110().visitFTS(((JAXBElement<?>) obj).getValue());
} else {
throw new JAXBException("Source is not a valid OGC SE FeatureTypeStyle v1.1.0");
}
default:
throw new IllegalArgumentException("Unable to read source, specified version is not supported");
}
}
use of org.geotoolkit.style.MutableFeatureTypeStyle 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);
}
}
}
use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.
the class Styles method scaleRule.
// ////////////////////////////////////////////////////////////////////
// RULES /////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle scaleRule() {
final MutableRule over = SF.rule();
over.setMinScaleDenominator(1000000);
over.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.RED), null));
final MutableRule under = SF.rule();
under.setMaxScaleDenominator(1000000);
under.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.GREEN), null));
final MutableStyle style = SF.style();
final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
fts.rules().add(over);
fts.rules().add(under);
style.featureTypeStyles().add(fts);
return style;
}
use of org.geotoolkit.style.MutableFeatureTypeStyle in project geotoolkit by Geomatys.
the class Styles method filterRule.
public static MutableStyle filterRule() {
final MutableRule over = SF.rule();
over.setFilter(FF.greaterOrEqual(FF.property("POP_CNTRY"), FF.literal(5000000)));
over.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.RED), null));
final MutableRule under = SF.rule();
under.setFilter(FF.less(FF.property("POP_CNTRY"), FF.literal(5000000)));
under.symbolizers().add(SF.polygonSymbolizer(DEFAULT_STROKE, SF.fill(Color.GREEN), null));
final MutableStyle style = SF.style();
final MutableFeatureTypeStyle fts = SF.featureTypeStyle();
fts.rules().add(over);
fts.rules().add(under);
style.featureTypeStyles().add(fts);
return style;
}
Aggregations