@Override public void exitImagePos(ImagePosContext ctx) { BandSpecifierContext bandCtx = ctx.bandSpecifier(); Band band = bandCtx == null ? Band.DEFAULT : getAsType(bandCtx, Band.class); PixelSpecifierContext pixelCtx = ctx.pixelSpecifier(); Pixel pixel = pixelCtx == null ? Pixel.DEFAULT : getAsType(pixelCtx, Pixel.class); set(ctx, new ImagePos(band, pixel)); }
@Override public void exitImagePos(ImagePosContext ctx) { BandSpecifierContext bandCtx = ctx.bandSpecifier(); Band band = bandCtx == null ? Band.DEFAULT : getAsType(bandCtx, Band.class); PixelSpecifierContext pixelCtx = ctx.pixelSpecifier(); Pixel pixel = pixelCtx == null ? Pixel.DEFAULT : getAsType(pixelCtx, Pixel.class); set(ctx, new ImagePos(band, pixel)); }
@Test public void flow() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("flow.jfl", "dtm"); GetSourceValue offset = new GetSourceValue( "dtm", new ImagePos( Band.DEFAULT, new Pixel(offsetVariable("x", "dx"), offsetVariable("y", "dy")))); assertThat(sourcePositions, hasSize(1)); assertThat(sourcePositions, hasItems(offset)); }
@Test public void lifeEdges() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("life-edges.jfl", "world"); GetSourceValue offset = new GetSourceValue( "world", new ImagePos( Band.DEFAULT, new Pixel(offsetVariable("x", "ix"), offsetVariable("y", "iy")))); GetSourceValue original = new GetSourceValue("world", ImagePos.DEFAULT); assertThat(sourcePositions, hasItems(offset, original)); }
@Test public void ndvi_s2() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("ndvi_s2.jfl", "src"); assertThat(sourcePositions, hasSize(2)); assertThat( sourcePositions, hasItems( new GetSourceValue( "src", new ImagePos(new Band(new IntLiteral("7")), Pixel.DEFAULT)))); assertThat( sourcePositions, hasItems( new GetSourceValue( "src", new ImagePos(new Band(new IntLiteral("3")), Pixel.DEFAULT)))); }
@Test public void aspect() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("aspect.jfl", "dtm"); assertThat(sourcePositions, hasSize(5)); assertThat(sourcePositions, hasItems(new GetSourceValue("dtm", ImagePos.DEFAULT))); for (int[] offsets : new int[][] {{0, -1}, {0, 1}, {-1, 0}, {1, 0}}) { assertThat( sourcePositions, hasItems( new GetSourceValue( "dtm", new ImagePos( Band.DEFAULT, new Pixel( offsetLiteral("x", offsets[0]), offsetLiteral("y", offsets[1])))))); } }
@Test public void lifeToroid() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("life-toroid.jfl", "world"); GetSourceValue absolute = new GetSourceValue( "world", new ImagePos( Band.DEFAULT, new Pixel( new Variable("xx", JiffleType.D), new Variable("yy", JiffleType.D)))); GetSourceValue original = new GetSourceValue("world", ImagePos.DEFAULT); assertThat(sourcePositions, hasItems(absolute, original)); }