Search in sources :

Example 6 with RasterSymbolizer

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);
}
Also used : RasterSymbolizer(org.opengis.style.RasterSymbolizer) Marshaller(javax.xml.bind.Marshaller) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 7 with RasterSymbolizer

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);
}
Also used : Marshaller(javax.xml.bind.Marshaller) JAXBElement(javax.xml.bind.JAXBElement) RasterSymbolizer(org.opengis.style.RasterSymbolizer) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 8 with RasterSymbolizer

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);
}
Also used : Description(org.opengis.style.Description) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) ColorMap(org.opengis.style.ColorMap) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 9 with RasterSymbolizer

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);
}
Also used : Description(org.opengis.style.Description) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) ColorMap(org.opengis.style.ColorMap) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 10 with RasterSymbolizer

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);
}
Also used : Description(org.opengis.style.Description) HashMap(java.util.HashMap) ColorMap(org.opengis.style.ColorMap) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) Literal(org.opengis.filter.Literal) OverlapBehavior(org.opengis.style.OverlapBehavior)

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