use of org.opengis.style.ChannelSelection in project geotoolkit by Geomatys.
the class RasterSymbolizerRenderer method channelSelection.
private int[] channelSelection(RasterSymbolizer sourceSymbol, GridCoverageResource ref) throws PortrayalException, DataStoreException {
final ChannelSelection selections = sourceSymbol.getChannelSelection();
final int[] channelSelection;
// we can change sample dimension only if we have more then one available.
if (selections != null) {
// delay sample dimension reading until we really need it, it may be expensive
final List<SampleDimension> sampleDimensions = ref.getSampleDimensions();
if (sampleDimensions == null || sampleDimensions.size() > 1) {
final SelectedChannelType channel = selections.getGrayChannel();
final SelectedChannelType[] channels = channel != null ? new SelectedChannelType[] { channel } : selections.getRGBChannels();
if (channels != null && channels.length > 0) {
channelSelection = new int[channels.length];
for (int i = 0; i < channels.length; i++) {
channelSelection[i] = getBandIndice(channels[i].getChannelName(), sampleDimensions);
}
} else {
channelSelection = null;
}
} else {
channelSelection = null;
}
} else {
channelSelection = null;
}
return channelSelection;
}
use of org.opengis.style.ChannelSelection in project geotoolkit by Geomatys.
the class Tester method createRasterSymbolizer.
private static RasterSymbolizer createRasterSymbolizer() {
String name = "Raster symbolizer name";
Description desc = STYLE_FACTORY.description("Raster symbolizer title", "Raster symbolizer description");
Unit uom = Units.METRE;
String geom = "geom";
Expression opacity = FILTER_FACTORY.literal(0.5);
ChannelSelection selection = STYLE_FACTORY.channelSelection(STYLE_FACTORY.selectedChannelType("chanel2", FILTER_FACTORY.literal(1)));
OverlapBehavior overlap = OverlapBehavior.RANDOM;
ColorMap colorMap = STYLE_FACTORY.colorMap();
ContrastEnhancement enchance = STYLE_FACTORY.contrastEnhancement();
ShadedRelief relief = STYLE_FACTORY.shadedRelief(FILTER_FACTORY.literal(3), true);
Symbolizer outline = createLineSymbolizer();
return STYLE_FACTORY.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
}
use of org.opengis.style.ChannelSelection in project geotoolkit by Geomatys.
the class XMLUtilitiesTest method createRasterSymbolizer.
private static RasterSymbolizer createRasterSymbolizer() {
String name = "Raster symbolizer name";
Description desc = STYLE_FACTORY.description("Raster symbolizer title", "Raster symbolizer description");
Unit uom = Units.METRE;
String geom = "geom";
Expression opacity = FILTER_FACTORY.literal(0.5);
ChannelSelection selection = STYLE_FACTORY.channelSelection(STYLE_FACTORY.selectedChannelType("chanel2", FILTER_FACTORY.literal(1)));
OverlapBehavior overlap = OverlapBehavior.RANDOM;
ColorMap colorMap = STYLE_FACTORY.colorMap();
ContrastEnhancement enchance = STYLE_FACTORY.contrastEnhancement();
ShadedRelief relief = STYLE_FACTORY.shadedRelief(FILTER_FACTORY.literal(3), true);
Symbolizer outline = createLineSymbolizer();
return STYLE_FACTORY.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
}
use of org.opengis.style.ChannelSelection in project geotoolkit by Geomatys.
the class Styles method colorCategorizeRaster.
public static MutableStyle colorCategorizeRaster() {
final Map<Expression, Expression> values = new HashMap<>();
values.put(StyleConstants.CATEGORIZE_LESS_INFINITY, SF.literal(new Color(46, 154, 88)));
values.put(FF.literal(1003), SF.literal(new Color(46, 154, 88)));
values.put(FF.literal(1800), SF.literal(new Color(251, 255, 128)));
values.put(FF.literal(2800), SF.literal(new Color(224, 108, 31)));
values.put(FF.literal(3500), SF.literal(new Color(200, 55, 55)));
values.put(FF.literal(4397), SF.literal(new Color(215, 244, 244)));
final Expression lookup = DEFAULT_CATEGORIZE_LOOKUP;
final Literal fallback = DEFAULT_FALLBACK;
final Expression function = SF.categorizeFunction(lookup, values, ThreshholdsBelongTo.SUCCEEDING, fallback);
final ChannelSelection selection = null;
final Expression opacity = LITERAL_ONE_FLOAT;
final OverlapBehavior overlap = OverlapBehavior.LATEST_ON_TOP;
final ColorMap colorMap = SF.colorMap(function);
final ContrastEnhancement enchance = SF.contrastEnhancement(LITERAL_ONE_FLOAT, ContrastMethod.NONE);
final ShadedRelief relief = SF.shadedRelief(LITERAL_ONE_FLOAT);
final Symbolizer outline = null;
final Unit uom = Units.POINT;
final String geom = DEFAULT_GEOM;
final String name = "raster symbol name";
final Description desc = DEFAULT_DESCRIPTION;
final RasterSymbolizer symbol = SF.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
return SF.style(symbol);
}
use of org.opengis.style.ChannelSelection in project geotoolkit by Geomatys.
the class Styles method colorInterpolationRaster.
public static MutableStyle colorInterpolationRaster() {
final List<InterpolationPoint> values = new ArrayList<>();
values.add(SF.interpolationPoint(1003, SF.literal(new Color(46, 154, 88))));
values.add(SF.interpolationPoint(1800, SF.literal(new Color(251, 255, 128))));
values.add(SF.interpolationPoint(2800, SF.literal(new Color(224, 108, 31))));
values.add(SF.interpolationPoint(3500, SF.literal(new Color(200, 55, 55))));
values.add(SF.interpolationPoint(4397, SF.literal(new Color(215, 244, 244))));
final Expression lookup = DEFAULT_CATEGORIZE_LOOKUP;
final Literal fallback = DEFAULT_FALLBACK;
final Expression function = SF.interpolateFunction(lookup, values, Method.COLOR, Mode.LINEAR, fallback);
final ChannelSelection selection = null;
final Expression opacity = LITERAL_ONE_FLOAT;
final OverlapBehavior overlap = OverlapBehavior.LATEST_ON_TOP;
final ColorMap colorMap = SF.colorMap(function);
final ContrastEnhancement enchance = SF.contrastEnhancement(LITERAL_ONE_FLOAT, ContrastMethod.NONE);
final ShadedRelief relief = SF.shadedRelief(LITERAL_ONE_FLOAT);
final Symbolizer outline = null;
final Unit uom = Units.POINT;
final String geom = DEFAULT_GEOM;
final String name = "raster symbol name";
final Description desc = DEFAULT_DESCRIPTION;
final RasterSymbolizer symbol = SF.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
return SF.style(symbol);
}
Aggregations