@Override public void visit(ChannelSelection cs) { if (cs.getGrayChannel() != null) { cs.getGrayChannel().accept(this); } final SelectedChannelType[] rgbChannels = cs.getRGBChannels(); for (SelectedChannelType ch : rgbChannels) { if (ch != null) ch.accept(this); } } });
@Override public void visit(ChannelSelection cs) { if (cs.getGrayChannel() != null) { cs.getGrayChannel().accept(this); } for (SelectedChannelType ch : cs.getRGBChannels()) { if (ch != null) { ch.accept(this); } } }
public ChannelSelectionBuilder reset(ChannelSelection original) { if (original == null) { return unset(); } if (original.getGrayChannel() != null) { gray.reset(original.getGrayChannel()); } else { red.reset(original.getRGBChannels()[0]); green.reset(original.getRGBChannels()[1]); blue.reset(original.getRGBChannels()[2]); } unset = false; return this; }
protected ChannelSelection copy(ChannelSelection channelSelection) { if (channelSelection == null) return null; SelectedChannelType[] channels = copy(channelSelection.getSelectedChannels()); ChannelSelection copy = sf.createChannelSelection(channels); copy.setGrayChannel(copy(channelSelection.getGrayChannel())); copy.setRGBChannels(copy(channelSelection.getRGBChannels())); return copy; }
final SelectedChannelType gray = cs.getGrayChannel();
@Override protected ContrastEnhancement getContrastEnhancement( GroupIdEnum id, ChannelSelection channelSelection) { if (id == GroupIdEnum.RASTER_GREY_CHANNEL_OPTION) { return channelSelection.getGrayChannel().getContrastEnhancement(); } return null; }
@Override public void visit(ChannelSelection cs) { if (cs.getGrayChannel() != null) { cs.getGrayChannel().accept(this); } for (SelectedChannelType ch : cs.getRGBChannels()) { ch.accept(this); } }
@Override protected ContrastEnhancement getContrastEnhancement(RasterSymbolizer rasterSymbolizer) { if (rasterSymbolizer != null) { ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection(); if (channelSelection != null) { SelectedChannelType greyChannel = channelSelection.getGrayChannel(); if (greyChannel != null) { return greyChannel.getContrastEnhancement(); } } } return null; }
if (cs.getGrayChannel() != null) { start("ChannelSelection"); SelectedChannelType gray = cs.getGrayChannel();
public void setEdited(ChannelSelection channel) { this.channel = channel; if (channel != null) { guiGray.setEdited(channel.getGrayChannel()); SelectedChannelType[] sct = channel.getRGBChannels(); if(sct!= null && sct.length==3){ guiRed.setEdited(sct[0]); guiGreen.setEdited(sct[1]); guiBlue.setEdited(sct[2]); } } lock(); }
/** * Test to ensure that updating the channels duplicates the raster sybmolizer with the new rgb * channels */ public void testSetRasterRGBChannels() { RasterSymbolizer rs = sb.createRasterSymbolizer(); Style s = sb.createStyle(rs); SelectedChannelType red = sf.createSelectedChannelType("red", sf.createContrastEnhancement(ff.literal(0.2))); SelectedChannelType green = sf.createSelectedChannelType( "green", sf.createContrastEnhancement(ff.literal(0.4))); SelectedChannelType blue = sf.createSelectedChannelType("blue", sf.createContrastEnhancement(ff.literal(0.7))); SLD.setChannelSelection(s, new SelectedChannelType[] {red, green, blue}, null); assertNull(SLD.rasterSymbolizer(s).getChannelSelection().getGrayChannel()); assertNotNull(SLD.rasterSymbolizer(s).getChannelSelection().getRGBChannels()); SelectedChannelType[] selectedChannels = SLD.rasterSymbolizer(s).getChannelSelection().getRGBChannels(); assertEquals("red", selectedChannels[0].getChannelName().evaluate(null, String.class)); assertEquals("green", selectedChannels[1].getChannelName().evaluate(null, String.class)); assertEquals("blue", selectedChannels[2].getChannelName().evaluate(null, String.class)); assertNotSame(SLD.rasterSymbolizer(s), rs); } }
protected ChannelSelection copy(ChannelSelection channelSelection) { if( channelSelection == null ) return null; SelectedChannelType[] channels = copy( channelSelection.getSelectedChannels() ); ChannelSelection copy = sf.createChannelSelection( channels); copy.setGrayChannel( copy( channelSelection.getGrayChannel() )); copy.setRGBChannels( copy( channelSelection.getRGBChannels() )); return copy; }
((channelSelection.getGrayChannel() != null) || (rgbChannels[0] != null) || (rgbChannels[1] != null) SelectedChannelType greyChannel = channelSelection.getGrayChannel(); if (greyChannel != null) { channelSelectionGroup.setOption(GroupIdEnum.RASTER_GREY_CHANNEL_OPTION);
final SelectedChannelType gray=cs.getGrayChannel();
@Test public void testCreateCollectionSimpleLayerWithCustomStyle() throws Exception { // setup the granules setupLayer( "/test123-product-granules-rgb.json", "/test123-layer-simple-graystyle.json", "gs", Boolean.FALSE); LayerInfo layer = validateBasicLayerStructure( "gs", "gs:test123", new String[] {"RED_BAND", "GREEN_BAND", "BLUE_BAND"}); // ... its style is a gray one based on the RED band assertThat(layer.getDefaultStyle().prefixedName(), equalTo("gs:test123")); ChannelSelection cs = getChannelSelection(layer); assertNull(cs.getRGBChannels()[0]); assertNull(cs.getRGBChannels()[1]); assertNull(cs.getRGBChannels()[2]); assertEquals("1", cs.getGrayChannel().getChannelName().evaluate(null, String.class)); BufferedImage image = getAsImage("wms/reflect?layers=gs:test123&format=image/png&width=200", "image/png"); File expected = new File("src/test/resources/test123-simple-gray.png"); ImageAssert.assertEquals(expected, image, 1000); }
@Test public void testBandsFlagsGrayFlag() throws Exception { setupLayer( "/test123-product-granules-bands-flags.json", "/test123-layer-bands-flags-grayFlag.json", "gs", Boolean.TRUE); // check the configuration elements are there too LayerInfo layer = validateBasicLayerStructure( "gs", "gs:test123", new String[] { "VNIR_0", "VNIR_1", "VNIR_2", "QUALITY", "CLOUDSHADOW", "HAZE", "SNOW" }); // ... its style has been generated assertThat(layer.getDefaultStyle().prefixedName(), equalTo("gs:test123")); // ... and it uses only a gray band, the snow flag ChannelSelection cs = getChannelSelection(layer); assertNull(cs.getRGBChannels()[0]); assertNull(cs.getRGBChannels()[1]); assertNull(cs.getRGBChannels()[2]); assertEquals("7", cs.getGrayChannel().getChannelName().evaluate(null, String.class)); // the image is almost black, but not fully BufferedImage image = getAsImage("wms/reflect?layers=gs:test123&format=image/png&width=200", "image/png"); File expected = new File("src/test/resources/test123-gray-snow.png"); ImageAssert.assertEquals(expected, image, 1000); }
if (cs.getGrayChannel() != null) { start("ChannelSelection"); SelectedChannelType gray = cs.getGrayChannel();
@Test public void testCreateCollectionMultiband() throws Exception { // setup the granules setupLayer( "/test123-product-granules-multiband.json", "/test123-layer-multiband.json", "gs", Boolean.TRUE); // check the configuration elements are there too LayerInfo layer = validateBasicLayerStructure( "gs", "gs:test123", new String[] {"B02", "B03", "B04", "B08"}); // ... its style is a RGB one based on the B2, B3, B4 assertThat(layer.getDefaultStyle().prefixedName(), equalTo("gs:test123")); ChannelSelection cs = getChannelSelection(layer); assertEquals("4", cs.getRGBChannels()[0].getChannelName().evaluate(null, String.class)); assertEquals("2", cs.getRGBChannels()[1].getChannelName().evaluate(null, String.class)); assertEquals("1", cs.getRGBChannels()[2].getChannelName().evaluate(null, String.class)); assertNull(cs.getGrayChannel()); BufferedImage image = getAsImage("wms/reflect?layers=gs:test123&format=image/png&width=200", "image/png"); File expected = new File("src/test/resources/test123-multiband.png"); ImageAssert.assertEquals(expected, image, 1000); }
@Test public void testBandsFlagsMix() throws Exception { setupLayer( "/test123-product-granules-bands-flags.json", "/test123-layer-bands-flags-browseMix.json", "gs", Boolean.TRUE); // check the configuration elements are there too LayerInfo layer = validateBasicLayerStructure( "gs", "gs:test123", new String[] { "VNIR_0", "VNIR_1", "VNIR_2", "QUALITY", "CLOUDSHADOW", "HAZE", "SNOW" }); // ... its style has been generated assertThat(layer.getDefaultStyle().prefixedName(), equalTo("gs:test123")); // ... and it uses all two vnir bands and a flag ChannelSelection cs = getChannelSelection(layer); assertEquals("1", cs.getRGBChannels()[0].getChannelName().evaluate(null, String.class)); assertEquals("2", cs.getRGBChannels()[1].getChannelName().evaluate(null, String.class)); assertEquals("7", cs.getRGBChannels()[2].getChannelName().evaluate(null, String.class)); assertNull(cs.getGrayChannel()); BufferedImage image = getAsImage("wms/reflect?layers=gs:test123&format=image/png&width=200", "image/png"); File expected = new File("src/test/resources/test123-vnir-snow.png"); ImageAssert.assertEquals(expected, image, 1000); }
@Test public void testBandsFlagsAll() throws Exception { setupLayer( "/test123-product-granules-bands-flags.json", "/test123-layer-bands-flags-all.json", "gs", Boolean.TRUE); // check the configuration elements are there too LayerInfo layer = validateBasicLayerStructure( "gs", "gs:test123", new String[] { "VNIR_0", "VNIR_1", "VNIR_2", "QUALITY", "CLOUDSHADOW", "HAZE", "SNOW" }); // ... its style has been generated assertThat(layer.getDefaultStyle().prefixedName(), equalTo("gs:test123")); // ... and it uses all VNIR bands ChannelSelection cs = getChannelSelection(layer); assertEquals("1", cs.getRGBChannels()[0].getChannelName().evaluate(null, String.class)); assertEquals("2", cs.getRGBChannels()[1].getChannelName().evaluate(null, String.class)); assertEquals("3", cs.getRGBChannels()[2].getChannelName().evaluate(null, String.class)); assertNull(cs.getGrayChannel()); BufferedImage image = getAsImage("wms/reflect?layers=gs:test123&format=image/png&width=200", "image/png"); File expected = new File("src/test/resources/test123-vnir.png"); ImageAssert.assertEquals(expected, image, 1000); }