use of org.opengis.style.RasterSymbolizer in project geotoolkit by Geomatys.
the class SEforSLD100Test method testRasterSymbolizer.
@Test
public void testRasterSymbolizer() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_SYMBOL_RASTER);
assertNotNull(obj);
JAXBElement<org.geotoolkit.sld.xml.v100.RasterSymbolizer> jax = (JAXBElement<org.geotoolkit.sld.xml.v100.RasterSymbolizer>) obj;
RasterSymbolizer rasterSymbol = TRANSFORMER_GT.visit(jax.getValue());
assertNotNull(rasterSymbol);
assertEquals(rasterSymbol.getGeometryPropertyName(), valueGeom);
assertEquals(Units.POINT, rasterSymbol.getUnitOfMeasure());
assertNotNull(rasterSymbol.getChannelSelection());
assertEquals(rasterSymbol.getChannelSelection().getRGBChannels()[0].getChannelName(), "band_1");
assertEquals(rasterSymbol.getChannelSelection().getRGBChannels()[1].getChannelName(), "band_2");
assertEquals(rasterSymbol.getChannelSelection().getRGBChannels()[2].getChannelName(), "band_3");
assertNotNull(rasterSymbol.getColorMap());
// assertNotNull( rasterSymbol.getColorMap().getFunction() );
assertNotNull(rasterSymbol.getContrastEnhancement());
assertEquals(rasterSymbol.getContrastEnhancement().getMethod(), ContrastMethod.NORMALIZE);
assertEquals(floatValue(rasterSymbol.getContrastEnhancement().getGammaValue()), 3f, DELTA);
assertNotNull(rasterSymbol.getImageOutline());
assertNotNull(rasterSymbol.getOpacity());
assertEquals(floatValue(rasterSymbol.getOpacity()), 0.32f, DELTA);
assertNotNull(rasterSymbol.getOverlapBehavior());
assertEquals(rasterSymbol.getOverlapBehavior(), OverlapBehavior.EARLIEST_ON_TOP);
assertNotNull(rasterSymbol.getShadedRelief());
assertEquals(rasterSymbol.getShadedRelief().isBrightnessOnly(), true);
assertEquals(floatValue(rasterSymbol.getShadedRelief().getReliefFactor()), 5f, DELTA);
// Write test
JAXBElement<org.geotoolkit.sld.xml.v100.RasterSymbolizer> pvt = TRANSFORMER_OGC.visit(rasterSymbol, null);
assertNotNull(pvt);
org.geotoolkit.sld.xml.v100.RasterSymbolizer rs = pvt.getValue();
assertEquals(rs.getGeometry().getPropertyName().getContent(), "");
assertNotNull(rs.getChannelSelection());
assertEquals(rs.getChannelSelection().getRedChannel().getSourceChannelName(), "band_1");
assertEquals(rs.getChannelSelection().getGreenChannel().getSourceChannelName(), "band_2");
assertEquals(rs.getChannelSelection().getBlueChannel().getSourceChannelName(), "band_3");
assertNotNull(rs.getColorMap());
// TODO test colormap content
assertNotNull(rs.getContrastEnhancement());
assertNotNull(rs.getContrastEnhancement().getNormalize());
assertNull(rs.getContrastEnhancement().getHistogram());
assertEquals(rs.getContrastEnhancement().getGammaValue().doubleValue(), 3d, DELTA);
assertNotNull(rs.getImageOutline());
assertNotNull(rs.getOpacity());
assertEquals(rs.getContrastEnhancement().getGammaValue().doubleValue(), 3d, DELTA);
assertNotNull(rs.getOverlapBehavior());
assertNotNull(rs.getOverlapBehavior().getEARLIESTONTOP());
assertNull(rs.getOverlapBehavior().getAVERAGE());
assertNull(rs.getOverlapBehavior().getLATESTONTOP());
assertNull(rs.getOverlapBehavior().getRANDOM());
assertNotNull(rs.getShadedRelief());
assertEquals(rs.getShadedRelief().isBrightnessOnly().booleanValue(), true);
assertEquals(rs.getShadedRelief().getReliefFactor().doubleValue(), 5d, DELTA);
MARSHALLER.marshal(pvt, TEST_FILE_SE_SYMBOL_RASTER);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.opengis.style.RasterSymbolizer in project geotoolkit by Geomatys.
the class SEforSLD110Test method testRasterSymbolizer.
@Test
public void testRasterSymbolizer() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_SE_SYMBOL_RASTER);
assertNotNull(obj);
JAXBElement<org.geotoolkit.se.xml.v110.RasterSymbolizerType> jax = (JAXBElement<org.geotoolkit.se.xml.v110.RasterSymbolizerType>) obj;
RasterSymbolizer rasterSymbol = TRANSFORMER_GT.visit(jax.getValue());
assertNotNull(rasterSymbol);
assertEquals(rasterSymbol.getGeometryPropertyName(), valueGeom);
assertEquals(Units.METRE, rasterSymbol.getUnitOfMeasure());
assertNotNull(rasterSymbol.getChannelSelection());
assertEquals(rasterSymbol.getChannelSelection().getRGBChannels()[0].getChannelName(), "band_1");
assertEquals(rasterSymbol.getChannelSelection().getRGBChannels()[1].getChannelName(), "band_2");
assertEquals(rasterSymbol.getChannelSelection().getRGBChannels()[2].getChannelName(), "band_3");
// assertNotNull(rasterSymbol.getColorMap());
// assertNotNull( rasterSymbol.getColorMap().getFunction() );
assertNotNull(rasterSymbol.getContrastEnhancement());
assertEquals(rasterSymbol.getContrastEnhancement().getMethod(), ContrastMethod.NORMALIZE);
assertEquals(floatValue(rasterSymbol.getContrastEnhancement().getGammaValue()), 3f, DELTA);
assertNotNull(rasterSymbol.getImageOutline());
assertNotNull(rasterSymbol.getOpacity());
assertEquals(floatValue(rasterSymbol.getOpacity()), 0.32f, DELTA);
assertNotNull(rasterSymbol.getOverlapBehavior());
assertEquals(rasterSymbol.getOverlapBehavior(), OverlapBehavior.EARLIEST_ON_TOP);
assertNotNull(rasterSymbol.getShadedRelief());
assertEquals(rasterSymbol.getShadedRelief().isBrightnessOnly(), true);
assertEquals(floatValue(rasterSymbol.getShadedRelief().getReliefFactor()), 5f, DELTA);
// Write test
JAXBElement<org.geotoolkit.se.xml.v110.RasterSymbolizerType> pvt = TRANSFORMER_OGC.visit(rasterSymbol, null);
assertNotNull(pvt);
org.geotoolkit.se.xml.v110.RasterSymbolizerType rs = pvt.getValue();
assertEquals(rs.getGeometry(), null);
assertNotNull(rs.getChannelSelection());
assertEquals(rs.getChannelSelection().getRedChannel().getSourceChannelName(), "band_1");
assertEquals(rs.getChannelSelection().getGreenChannel().getSourceChannelName(), "band_2");
assertEquals(rs.getChannelSelection().getBlueChannel().getSourceChannelName(), "band_3");
// assertNotNull(rs.getColorMap());
// TODO test colormap content
assertNotNull(rs.getContrastEnhancement());
assertNotNull(rs.getContrastEnhancement().getNormalize());
assertNull(rs.getContrastEnhancement().getHistogram());
assertEquals(rs.getContrastEnhancement().getGammaValue().doubleValue(), 3d, DELTA);
assertNotNull(rs.getImageOutline());
assertNotNull(rs.getOpacity());
assertEquals(rs.getContrastEnhancement().getGammaValue().doubleValue(), 3d, DELTA);
assertNotNull(rs.getOverlapBehavior());
// assertNotNull(rs.getOverlapBehavior().getEARLIESTONTOP());
// assertNull(rs.getOverlapBehavior().getAVERAGE());
// assertNull(rs.getOverlapBehavior().getLATESTONTOP());
// assertNull(rs.getOverlapBehavior().getRANDOM());
assertNotNull(rs.getShadedRelief());
assertEquals(rs.getShadedRelief().isBrightnessOnly().booleanValue(), true);
assertEquals(rs.getShadedRelief().getReliefFactor().doubleValue(), 5d, DELTA);
MARSHALLER.marshal(pvt, TEST_FILE_SE_SYMBOL_RASTER);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.opengis.style.RasterSymbolizer 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.RasterSymbolizer 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.RasterSymbolizer 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);
}
Aggregations