@Test public void imageRead() throws Exception { Expression e = new GetSourceValue("src", ImagePos.DEFAULT); assertThat(e.toString(), is("readFromImage(src,_x(),_y(),0)")); }
@Override public void exitImageCall(ImageCallContext ctx) { String name = ctx.ID().getText(); ImagePos pos = getAsType(ctx.imagePos(), ImagePos.class); set(ctx, new GetSourceValue(name, pos)); }
@Override public void exitImageCall(ImageCallContext ctx) { String name = ctx.ID().getText(); ImagePos pos = getAsType(ctx.imagePos(), ImagePos.class); set(ctx, new GetSourceValue(name, pos)); }
@Test public void ndvi() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("ndvi.jfl", "nir", "red"); assertThat(sourcePositions, hasSize(2)); assertThat(sourcePositions, hasItems(new GetSourceValue("nir", ImagePos.DEFAULT))); assertThat(sourcePositions, hasItems(new GetSourceValue("red", ImagePos.DEFAULT))); }
case SOURCE_IMAGE: set(ctx, new GetSourceValue(name, ImagePos.DEFAULT)); break;
case SOURCE_IMAGE: set(ctx, new GetSourceValue(name, ImagePos.DEFAULT)); break;
@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 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 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 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)); }
@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)))); }