Search in sources :

Example 1 with SearchArea

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());
}
Also used : GridGeometry(org.apache.sis.coverage.grid.GridGeometry) RenderingContext(org.geotoolkit.display.canvas.RenderingContext) GridExtent(org.apache.sis.coverage.grid.GridExtent) InMemoryGridCoverageResource(org.geotoolkit.storage.memory.InMemoryGridCoverageResource) SearchArea(org.geotoolkit.display.SearchArea) GraphicVisitor(org.geotoolkit.display2d.GraphicVisitor) MapLayer(org.apache.sis.portrayal.MapLayer) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) SampleDimension(org.apache.sis.coverage.SampleDimension) Presentation(org.apache.sis.internal.map.Presentation) BufferedImage(java.awt.image.BufferedImage) GridCoverage(org.apache.sis.coverage.grid.GridCoverage) GridCoverageBuilder(org.apache.sis.coverage.grid.GridCoverageBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InMemoryGridCoverageResource(org.geotoolkit.storage.memory.InMemoryGridCoverageResource) GridCoverageResource(org.apache.sis.storage.GridCoverageResource) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope) AffineTransform2D(org.apache.sis.internal.referencing.j2d.AffineTransform2D) MapLayers(org.apache.sis.portrayal.MapLayers) Test(org.junit.Test)

Aggregations

Dimension (java.awt.Dimension)1 Rectangle (java.awt.Rectangle)1 BufferedImage (java.awt.image.BufferedImage)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 SampleDimension (org.apache.sis.coverage.SampleDimension)1 GridCoverage (org.apache.sis.coverage.grid.GridCoverage)1 GridCoverageBuilder (org.apache.sis.coverage.grid.GridCoverageBuilder)1 GridExtent (org.apache.sis.coverage.grid.GridExtent)1 GridGeometry (org.apache.sis.coverage.grid.GridGeometry)1 GeneralEnvelope (org.apache.sis.geometry.GeneralEnvelope)1 Presentation (org.apache.sis.internal.map.Presentation)1 AffineTransform2D (org.apache.sis.internal.referencing.j2d.AffineTransform2D)1 MapLayer (org.apache.sis.portrayal.MapLayer)1 MapLayers (org.apache.sis.portrayal.MapLayers)1 GridCoverageResource (org.apache.sis.storage.GridCoverageResource)1 SearchArea (org.geotoolkit.display.SearchArea)1 RenderingContext (org.geotoolkit.display.canvas.RenderingContext)1 GraphicVisitor (org.geotoolkit.display2d.GraphicVisitor)1 InMemoryGridCoverageResource (org.geotoolkit.storage.memory.InMemoryGridCoverageResource)1 Test (org.junit.Test)1