Search in sources :

Example 11 with FeatureTypeStyle

use of org.opengis.style.FeatureTypeStyle in project geotoolkit by Geomatys.

the class GTtoSE100Transformer method visit.

/**
 * Transform a GT Style in Jaxb UserStyle
 */
@Override
public org.geotoolkit.sld.xml.v100.UserStyle visit(final Style style, final Object data) {
    final org.geotoolkit.sld.xml.v100.UserStyle userStyle = sld_factory_v100.createUserStyle();
    userStyle.setName(style.getName());
    if (style.getDescription() != null) {
        if (style.getDescription().getAbstract() != null)
            userStyle.setAbstract(style.getDescription().getAbstract().toString());
        if (style.getDescription().getTitle() != null)
            userStyle.setTitle(style.getDescription().getTitle().toString());
    }
    userStyle.setIsDefault(style.isDefault());
    for (final FeatureTypeStyle fts : style.featureTypeStyles()) {
        userStyle.getFeatureTypeStyle().add(visit(fts, null));
    }
    return userStyle;
}
Also used : FeatureTypeStyle(org.opengis.style.FeatureTypeStyle)

Example 12 with FeatureTypeStyle

use of org.opengis.style.FeatureTypeStyle in project geotoolkit by Geomatys.

the class GTtoSE110Transformer method visit.

/**
 * Transform a GT Style in Jaxb UserStyle
 */
@Override
public org.geotoolkit.sld.xml.v110.UserStyle visit(final Style style, final Object data) {
    final org.geotoolkit.sld.xml.v110.UserStyle userStyle = sld_factory_v110.createUserStyle();
    userStyle.setName(style.getName());
    userStyle.setDescription(visit(style.getDescription(), null));
    userStyle.setIsDefault(style.isDefault());
    for (final FeatureTypeStyle fts : style.featureTypeStyles()) {
        userStyle.getFeatureTypeStyleOrCoverageStyleOrOnlineResource().add(visit(fts, null));
    }
    return userStyle;
}
Also used : FeatureTypeStyle(org.opengis.style.FeatureTypeStyle)

Example 13 with FeatureTypeStyle

use of org.opengis.style.FeatureTypeStyle 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");
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) MutableFeatureTypeStyle(org.geotoolkit.style.MutableFeatureTypeStyle) FeatureTypeStyle(org.opengis.style.FeatureTypeStyle) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

FeatureTypeStyle (org.opengis.style.FeatureTypeStyle)13 Rule (org.opengis.style.Rule)6 Symbolizer (org.opengis.style.Symbolizer)5 DataStoreException (org.apache.sis.storage.DataStoreException)4 MutableFeatureTypeStyle (org.geotoolkit.style.MutableFeatureTypeStyle)4 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)4 Style (org.opengis.style.Style)4 MapLayer (org.apache.sis.portrayal.MapLayer)3 MapLayers (org.apache.sis.portrayal.MapLayers)3 LineSymbolizer (org.opengis.style.LineSymbolizer)3 PointSymbolizer (org.opengis.style.PointSymbolizer)3 Dimension (java.awt.Dimension)2 FontMetrics (java.awt.FontMetrics)2 MapItem (org.apache.sis.portrayal.MapItem)2 FeatureSet (org.apache.sis.storage.FeatureSet)2 GridCoverageResource (org.apache.sis.storage.GridCoverageResource)2 Resource (org.apache.sis.storage.Resource)2 PortrayalException (org.geotoolkit.display.PortrayalException)2 Expression (org.opengis.filter.Expression)2 Filter (org.opengis.filter.Filter)2