PixelPosEstimator { public GeoApproximation getPixelPos(GeoPos g, PixelPos p) { GeoApproximation approximation = null; if (approximations != null) { if (g.isValid()) { final double lat = g.getLat(); final double lon = g.getLon(); approximation = GeoApproximation.findMostSuitable(approximations, lat, lon); if (approximation != null) { p.setLocation(lon, lat); approximation.g2p(p); final double x = p.getX(); final double y = p.getY(); if (!EXTRAPOLATE && (x < bounds.getMinX() || x > bounds.getMaxX() || y < bounds.getMinY() || y > bounds.getMaxY())) { p.setInvalid(); } } else { p.setInvalid(); } } else { p.setInvalid(); } } return approximation; } PixelPosEstimator(GeoApproximation[] approximations, Rectangle bounds);   PixelPosEstimator(PlanarImage lonImage, PlanarImage latImage, PlanarImage maskImage, double accuracy); private  PixelPosEstimator(PlanarImage lonImage, PlanarImage latImage, PlanarImage maskImage, double accuracy,
                              SteppingFactory steppingFactory); final boolean canGetPixelPos(); GeoApproximation getPixelPos(GeoPos g, PixelPos p);  }
@Test @Ignore public void testGetPixelPosForSimulatedSwath() { final int nx = 512; final int ny = 36000; final PlanarImage[] images = generateSwathCoordinates(nx, ny, 0.009, 0.009, new Rotator(0.0, -5.0, 269.0)); final PlanarImage lonImage = images[0]; final PlanarImage latImage = images[1]; final PlanarImage maskImage = images[2]; final PixelPosEstimator estimator = new PixelPosEstimator(lonImage, latImage, maskImage, 0.5); final GeoPos g = new GeoPos(); final PixelPos p = new PixelPos(); for (int y = 0; y < ny; y++) { final Rectangle region = new Rectangle(0, y, nx, 1); final Raster lonData = lonImage.getData(region); final Raster latData = latImage.getData(region); for (int x = 0; x < nx; x++) { final float lon = lonData.getSampleFloat(x, y, 0); final float lat = latData.getSampleFloat(x, y, 0); g.setLocation(lat, lon); estimator.getPixelPos(g, p); assertTrue(p.isValid()); assertEquals(x + 0.5, p.getX(), 0.5); assertEquals(y + 0.5, p.getY(), 0.5); } } }