use of org.geotoolkit.display.SearchArea in project geotoolkit by Geomatys.
the class PortrayalServiceTest method testCoverageVisit0_360.
/**
* Test picking on a coverage in range 0-360.
* @throws PortrayalException
*/
@Test
public void testCoverageVisit0_360() throws PortrayalException {
// Create 0-360 coverage
final BufferedImage img = new BufferedImage(350, 180, BufferedImage.TYPE_INT_ARGB);
CoordinateReferenceSystem crs = CommonCRS.WGS84.normalizedGeographic();
crs = AbstractCRS.castOrCopy(crs).forConvention(AxesConvention.POSITIVE_RANGE);
final AffineTransform2D gridToCrs = new AffineTransform2D(1, 0, 0, -1, 0, 90);
final GridExtent extent = new GridExtent(350, 180);
final GridGeometry gg = new GridGeometry(extent, PixelInCell.CELL_CORNER, gridToCrs, crs);
final GridCoverageBuilder gcb = new GridCoverageBuilder();
gcb.setValues(img);
gcb.setDomain(gg);
final GridCoverage coverage = gcb.build();
final GridCoverageResource gcr = new InMemoryGridCoverageResource(coverage);
final MapLayer layer = MapBuilder.createCoverageLayer(gcr);
final MapLayers context = MapBuilder.createContext();
context.getComponents().add(layer);
final GeneralEnvelope viewEnv = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
viewEnv.setRange(0, -180, +180);
viewEnv.setRange(1, -90, +90);
final AtomicInteger count = new AtomicInteger();
GraphicVisitor gv = new GraphicVisitor() {
@Override
public void startVisit() {
}
@Override
public void endVisit() {
}
@Override
public void visit(Presentation graphic, RenderingContext context, SearchArea area) {
count.incrementAndGet();
}
@Override
public boolean isStopRequested() {
return false;
}
};
final SceneDef scene = new SceneDef(context);
final CanvasDef canvas = new CanvasDef(new Dimension(360, 180), viewEnv);
final VisitDef visit = new VisitDef(new Rectangle(10, 80, 2, 2), gv);
DefaultPortrayalService.visit(canvas, scene, visit);
assertEquals(1, count.get());
}
Aggregations