PixelGeoCoding extends AbstractGeoCoding implements BasicPixelGeoCoding { @Override public GeoPos getGeoPos(final PixelPos pixelPos, GeoPos geoPos) { initialize(); if (geoPos == null) { geoPos = new GeoPos(); } geoPos.setInvalid(); if (pixelPos.isValid()) { int x0 = (int) Math.floor(pixelPos.getX()); int y0 = (int) Math.floor(pixelPos.getY()); if (x0 >= 0 && x0 < rasterWidth && y0 >= 0 && y0 < rasterHeight) { if (fractionAccuracy) { if (x0 > 0 && pixelPos.x - x0 < 0.5f || x0 == rasterWidth - 1) { x0 -= 1; } if (y0 > 0 && pixelPos.y - y0 < 0.5f || y0 == rasterHeight - 1) { y0 -= 1; } final float wx = pixelPos.x - (x0 + 0.5f); final float wy = pixelPos.y - (y0 + 0.5f); final Raster latLonData = latLonImage.getData(new Rectangle(x0, y0, 2, 2)); final float lat = interpolate(wx, wy, latLonData, 0); final float lon = interpolate(wx, wy, latLonData, 1); geoPos.setLocation(lat, lon); } else { getGeoPosInternal(x0, y0, geoPos); } } else { if (pixelPosEstimator != null) { return pixelPosEstimator.getGeoPos(pixelPos, geoPos); } } } return geoPos; } PixelGeoCoding(final Band latBand, final Band lonBand, final String validMask, final int searchRadius);  PixelGeoCoding(final Band latBand, final Band lonBand, final String validMask, final int searchRadius,
                          ProgressMonitor pm); static long getRequiredMemory(Product product, boolean usesValidMask); @Override Band getLatBand(); @Override Band getLonBand(); @Override String getValidMask(); @Override GeoCoding getPixelPosEstimator(); @Override int getSearchRadius(); @Override boolean isCrossingMeridianAt180(); @Override boolean canGetPixelPos(); @Override boolean canGetGeoPos(); @Override PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos); void getPixelPosUsingEstimator(final GeoPos geoPos, PixelPos pixelPos); void getPixelPosUsingQuadTreeSearch(final GeoPos geoPos, PixelPos pixelPos); @Override GeoPos getGeoPos(final PixelPos pixelPos, GeoPos geoPos); @Override boolean equals(Object o); @Override int hashCode(); @Override synchronized void dispose(); @Override boolean transferGeoCoding(final Scene srcScene, final Scene destScene, final ProductSubsetDef subsetDef); @Override Datum getDatum();  }
@Test public void testGetGeoPos() throws IOException { doTestGetGeoPos(); }
@Test public void testGetGeoPos_withFractionAccuracy() throws IOException { Product product = createProduct(); TiePointGeoCoding tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding(); GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"), product.getBand("lonBand"), null, 5, ProgressMonitor.NULL); product.setGeoCoding(pixelGeoCoding); String gp = tiePointGeoCoding.getGeoPos(new PixelPos(0.5f, 0.5f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.25f, 0.25f), null).toString()); try { System.setProperty("beam.pixelGeoCoding.fractionAccuracy", "true"); System.setProperty("beam.pixelGeoCoding.useTiling", "true"); product = createProduct(); tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding(); pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"), product.getBand("lonBand"), null, 5, ProgressMonitor.NULL); gp = tiePointGeoCoding.getGeoPos(new PixelPos(0.5f, 0.5f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.5f, 0.5f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(0.25f, 0.25f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.25f, 0.25f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(0.75f, 0.75f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.75f, 0.75f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(0.25f, 0.75f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.25f, 0.75f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(0.75f, 0.25f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(0.75f, 0.25f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(1.5f, 1.5f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(1.5f, 1.5f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(1.25f, 1.25f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(1.25f, 1.25f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(1.75f, 1.75f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(1.75f, 1.75f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(1.25f, 1.75f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(1.25f, 1.75f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(1.75f, 1.25f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(1.75f, 1.25f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(2.5f, 2.5f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(2.5f, 2.5f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(2.25f, 2.25f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(2.25f, 2.25f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(2.75f, 2.75f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(2.75f, 2.75f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(2.25f, 2.75f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(2.25f, 2.75f), null).toString()); gp = tiePointGeoCoding.getGeoPos(new PixelPos(2.75f, 2.25f), null).toString(); assertEquals(gp, pixelGeoCoding.getGeoPos(new PixelPos(2.75f, 2.25f), null).toString()); } finally { System.clearProperty("beam.pixelGeoCoding.fractionAccuracy"); System.clearProperty("beam.pixelGeoCoding.useTiling"); } }