Search in sources :

Example 1 with RasterGrayStyle

use of org.polymap.core.style.model.raster.RasterGrayStyle in project polymap4-core by Polymap4.

the class SLDSerializer2 method serialize.

@Override
public org.geotools.styling.Style serialize(Context context) {
    FeatureStyle featureStyle = context.featureStyle.get();
    List<Style> sorted = featureStyle.members().stream().sorted((s1, s2) -> s1.zPriority.get().compareTo(s2.zPriority.get())).collect(Collectors.toList());
    org.geotools.styling.Style result = sf.createStyle();
    for (Style style : sorted) {
        if (style.active.get()) {
            StyleSerializer serializer = null;
            if (style instanceof PointStyle) {
                serializer = new PointStyleSerializer(context);
            } else if (style instanceof PolygonStyle) {
                serializer = new PolygonStyleSerializer(context);
            } else if (style instanceof TextStyle) {
                serializer = new TextStyleSerializer(context);
            } else if (style instanceof LineStyle) {
                serializer = new LineStyleSerializer(context);
            } else if (style instanceof RasterGrayStyle) {
                serializer = new RasterSerializer.GraySerializer(context);
            } else if (style instanceof RasterRGBStyle) {
                serializer = new RasterSerializer.RGBSerializer(context);
            } else if (style instanceof RasterColorMapStyle) {
                serializer = new RasterSerializer.ColorMapSerializer(context);
            } else {
                throw new RuntimeException("Unhandled Style type: " + style.getClass().getName());
            }
            serializer.serialize(style, result);
        }
    }
    return result;
}
Also used : PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle) TextStyle(org.polymap.core.style.model.feature.TextStyle) RasterColorMapStyle(org.polymap.core.style.model.raster.RasterColorMapStyle) Cloner(com.rits.cloning.Cloner) SLD(org.geotools.styling.SLD) FeatureStyleSerializer(org.polymap.core.style.serialize.FeatureStyleSerializer) CommonFactoryFinder(org.geotools.factory.CommonFactoryFinder) Collectors(java.util.stream.Collectors) StyleFactory(org.geotools.styling.StyleFactory) StringUtils(org.apache.commons.lang3.StringUtils) SLDTransformer(org.geotools.styling.SLDTransformer) Style(org.polymap.core.style.model.Style) RasterRGBStyle(org.polymap.core.style.model.raster.RasterRGBStyle) List(java.util.List) PointStyle(org.polymap.core.style.model.feature.PointStyle) LineStyle(org.polymap.core.style.model.feature.LineStyle) FilterFactory2(org.opengis.filter.FilterFactory2) Log(org.apache.commons.logging.Log) FeatureStyle(org.polymap.core.style.model.FeatureStyle) LogFactory(org.apache.commons.logging.LogFactory) RasterGrayStyle(org.polymap.core.style.model.raster.RasterGrayStyle) DataPlugin(org.polymap.core.data.DataPlugin) PointStyle(org.polymap.core.style.model.feature.PointStyle) LineStyle(org.polymap.core.style.model.feature.LineStyle) FeatureStyleSerializer(org.polymap.core.style.serialize.FeatureStyleSerializer) RasterColorMapStyle(org.polymap.core.style.model.raster.RasterColorMapStyle) RasterGrayStyle(org.polymap.core.style.model.raster.RasterGrayStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) TextStyle(org.polymap.core.style.model.feature.TextStyle) RasterRGBStyle(org.polymap.core.style.model.raster.RasterRGBStyle) PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle) TextStyle(org.polymap.core.style.model.feature.TextStyle) RasterColorMapStyle(org.polymap.core.style.model.raster.RasterColorMapStyle) Style(org.polymap.core.style.model.Style) RasterRGBStyle(org.polymap.core.style.model.raster.RasterRGBStyle) PointStyle(org.polymap.core.style.model.feature.PointStyle) LineStyle(org.polymap.core.style.model.feature.LineStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) RasterGrayStyle(org.polymap.core.style.model.raster.RasterGrayStyle) PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle)

Example 2 with RasterGrayStyle

use of org.polymap.core.style.model.raster.RasterGrayStyle in project polymap4-core by Polymap4.

the class DefaultStyle method fillGrayscaleStyle.

public static RasterStyle fillGrayscaleStyle(FeatureStyle fs, GridCoverage2D gridCoverage) {
    RasterGrayStyle gray = fs.members().createElement(RasterGrayStyle.defaults);
    gray.opacity.createValue(ConstantNumber.defaults(1.0));
    gray.grayBand.createValue(ConstantRasterBand.defaults(0));
    return gray;
}
Also used : RasterGrayStyle(org.polymap.core.style.model.raster.RasterGrayStyle)

Aggregations

RasterGrayStyle (org.polymap.core.style.model.raster.RasterGrayStyle)2 Cloner (com.rits.cloning.Cloner)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 CommonFactoryFinder (org.geotools.factory.CommonFactoryFinder)1 SLD (org.geotools.styling.SLD)1 SLDTransformer (org.geotools.styling.SLDTransformer)1 StyleFactory (org.geotools.styling.StyleFactory)1 FilterFactory2 (org.opengis.filter.FilterFactory2)1 DataPlugin (org.polymap.core.data.DataPlugin)1 FeatureStyle (org.polymap.core.style.model.FeatureStyle)1 Style (org.polymap.core.style.model.Style)1 LineStyle (org.polymap.core.style.model.feature.LineStyle)1 PointStyle (org.polymap.core.style.model.feature.PointStyle)1 PolygonStyle (org.polymap.core.style.model.feature.PolygonStyle)1 TextStyle (org.polymap.core.style.model.feature.TextStyle)1 RasterColorMapStyle (org.polymap.core.style.model.raster.RasterColorMapStyle)1