Search in sources :

Example 21 with RasterSymbolizer

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

the class GTtoSE110Transformer method visit.

/**
 * Transform a GT FTS in Jaxb FeatureTypeStyle or CoveragaStyle or
 * OnlineResource.
 */
@Override
public Object visit(final FeatureTypeStyle fts, final Object data) {
    if (fts.getOnlineResource() != null) {
        // we store only the online resource
        return visit(fts.getOnlineResource(), null);
    } else {
        // try to figure out if we have here a coverage FTS or not
        boolean isCoverage = false;
        if (fts.semanticTypeIdentifiers().contains(SemanticType.RASTER)) {
            isCoverage = true;
        } else if (fts.semanticTypeIdentifiers().contains(SemanticType.ANY) || fts.semanticTypeIdentifiers().isEmpty()) {
            if (fts.getFeatureInstanceIDs() == null) {
                // try to find a coverage style
                ruleLoop: for (final Rule r : fts.rules()) {
                    for (final Symbolizer s : r.symbolizers()) {
                        if (s instanceof RasterSymbolizer) {
                            isCoverage = true;
                            break ruleLoop;
                        }
                    }
                }
            } else {
                isCoverage = false;
            }
        } else {
            isCoverage = false;
        }
        final Object obj;
        // create the sld FTS
        if (isCoverage) {
            // coverage type
            final CoverageStyleType cst = se_factory.createCoverageStyleType();
            if (!fts.featureTypeNames().isEmpty()) {
                cst.setCoverageName(fts.featureTypeNames().iterator().next().toString());
            }
            cst.setDescription(visit(fts.getDescription(), null));
            cst.setName(fts.getName());
            for (final SemanticType semantic : fts.semanticTypeIdentifiers()) {
                if (SemanticType.ANY.equals(semantic)) {
                    cst.getSemanticTypeIdentifier().add(GENERIC_ANY);
                } else if (SemanticType.POINT.equals(semantic)) {
                    cst.getSemanticTypeIdentifier().add(GENERIC_POINT);
                } else if (SemanticType.LINE.equals(semantic)) {
                    cst.getSemanticTypeIdentifier().add(GENERIC_LINE);
                } else if (SemanticType.POLYGON.equals(semantic)) {
                    cst.getSemanticTypeIdentifier().add(GENERIC_POLYGON);
                } else if (SemanticType.TEXT.equals(semantic)) {
                    cst.getSemanticTypeIdentifier().add(GENERIC_TEXT);
                } else if (SemanticType.RASTER.equals(semantic)) {
                    cst.getSemanticTypeIdentifier().add(GENERIC_RASTER);
                } else {
                    cst.getSemanticTypeIdentifier().add(semantic.identifier());
                }
            }
            for (final Rule rule : fts.rules()) {
                cst.getRuleOrOnlineResource().add(visit(rule, null));
            }
            obj = cst;
        } else {
            // feature type
            final FeatureTypeStyleType ftst = se_factory.createFeatureTypeStyleType();
            if (!fts.featureTypeNames().isEmpty()) {
                final GenericName name = fts.featureTypeNames().iterator().next();
                final String pre = name.scope().isGlobal() ? null : name.scope().name().toString();
                final String local = name.toString();
                ftst.setFeatureTypeName(new QName(pre + ':', local));
            }
            ftst.setDescription(visit(fts.getDescription(), null));
            ftst.setName(fts.getName());
            for (final SemanticType semantic : fts.semanticTypeIdentifiers()) {
                if (SemanticType.ANY.equals(semantic)) {
                    ftst.getSemanticTypeIdentifier().add(GENERIC_ANY);
                } else if (SemanticType.POINT.equals(semantic)) {
                    ftst.getSemanticTypeIdentifier().add(GENERIC_POINT);
                } else if (SemanticType.LINE.equals(semantic)) {
                    ftst.getSemanticTypeIdentifier().add(GENERIC_LINE);
                } else if (SemanticType.POLYGON.equals(semantic)) {
                    ftst.getSemanticTypeIdentifier().add(GENERIC_POLYGON);
                } else if (SemanticType.TEXT.equals(semantic)) {
                    ftst.getSemanticTypeIdentifier().add(GENERIC_TEXT);
                } else if (SemanticType.RASTER.equals(semantic)) {
                    ftst.getSemanticTypeIdentifier().add(GENERIC_RASTER);
                } else {
                    ftst.getSemanticTypeIdentifier().add(semantic.identifier());
                }
            }
            for (final Rule rule : fts.rules()) {
                ftst.getRuleOrOnlineResource().add(visit(rule, null));
            }
            obj = ftst;
        }
        return obj;
    }
}
Also used : RasterSymbolizer(org.opengis.style.RasterSymbolizer) SemanticType(org.opengis.style.SemanticType) GenericName(org.opengis.util.GenericName) QName(javax.xml.namespace.QName) CoverageStyleType(org.geotoolkit.se.xml.v110.CoverageStyleType) FeatureTypeStyleType(org.geotoolkit.se.xml.v110.FeatureTypeStyleType) Rule(org.opengis.style.Rule) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) ExtensionSymbolizer(org.opengis.style.ExtensionSymbolizer) PointSymbolizer(org.opengis.style.PointSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) Symbolizer(org.opengis.style.Symbolizer)

Example 22 with RasterSymbolizer

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

the class Styles method defaultRaster.

// ////////////////////////////////////////////////////////////////////
// RASTER SYMBOLIZER /////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////
public static MutableStyle defaultRaster() {
    final RasterSymbolizer symbol = DEFAULT_RASTER_SYMBOLIZER;
    final MutableStyle style = SF.style(symbol);
    return style;
}
Also used : RasterSymbolizer(org.opengis.style.RasterSymbolizer) MutableStyle(org.geotoolkit.style.MutableStyle)

Aggregations

RasterSymbolizer (org.opengis.style.RasterSymbolizer)22 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)15 LineSymbolizer (org.opengis.style.LineSymbolizer)14 PointSymbolizer (org.opengis.style.PointSymbolizer)14 TextSymbolizer (org.opengis.style.TextSymbolizer)14 Symbolizer (org.opengis.style.Symbolizer)13 Expression (org.opengis.filter.Expression)10 ColorMap (org.opengis.style.ColorMap)10 ChannelSelection (org.opengis.style.ChannelSelection)9 ContrastEnhancement (org.opengis.style.ContrastEnhancement)9 ShadedRelief (org.opengis.style.ShadedRelief)9 Unit (javax.measure.Unit)7 Description (org.opengis.style.Description)7 OverlapBehavior (org.opengis.style.OverlapBehavior)7 GridCoverage (org.apache.sis.coverage.grid.GridCoverage)4 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)4 ExtensionSymbolizer (org.opengis.style.ExtensionSymbolizer)4 IOException (java.io.IOException)3 GridCoverage2D (org.apache.sis.coverage.grid.GridCoverage2D)3 MapLayer (org.apache.sis.portrayal.MapLayer)3