@Override public PixelPos getPixelPos(GeoPos geoPos, PixelPos pixelPos) { if (pixelPos == null) { pixelPos = new PixelPos(); } final float x = OrthorectifierTest.SCENE_WIDTH * (geoPos.lon / 10.0f); final float y = OrthorectifierTest.SCENE_HEIGHT * (1.0f - geoPos.lat / 10.0f); pixelPos.setLocation(x, y); return pixelPos; }
@Override public PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos) { if (pixelPos == null) { pixelPos = new PixelPos(); } pixelPos.setLocation(_width / 360.0f * (geoPos.getLon() + 180.0f), _height - (_height / 180.0f * (geoPos.getLat() + 90.0f))); return pixelPos; }
/** * {@inheritDoc} */ public PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos) { final Point2D.Double point = new Point2D.Double(geoPos.lon, geoPos.lat); rotator.transform(point); if (pixelPos == null) { pixelPos = new PixelPos(); } pixelPos.setLocation(inverseMap.getValue(point)); if (!pixelPos.isValid() || pixelPos.x < 0 || pixelPos.x >= sceneWidth || pixelPos.y < 0 || pixelPos.y >= sceneHeight) { pixelPos.x = -1; pixelPos.y = -1; } return pixelPos; }
final float lon0 = geoPos.lon; pixelPos.setLocation(x0, y0); int y1; int x1; x1, y1, pixelPos)); if (Math.sqrt(minDelta) < deltaThreshold) { pixelPos.setLocation(pixelPos.x + 0.5f, pixelPos.y + 0.5f); } else { pixelPos.setInvalid();
/** * Returns the pixel co-ordinates as x/y for a given geographical position given as lat/lon. * This algorithm * * @param geoPos the geographical position as lat/lon. * @param pixelPos the return value */ public void getPixelPosUsingQuadTreeSearch(final GeoPos geoPos, PixelPos pixelPos) { final Result result = new Result(); boolean pixelFound = quadTreeSearch(0, geoPos.lat, geoPos.lon, 0, 0, width, height, result); if (pixelFound) { pixelPos.setLocation(result.x + 0.5f, result.y + 0.5f); } else { pixelPos.setInvalid(); } }
private GeoPos getGeoPos(final PixelPos pixelPos, final GeoPos geoPos) { final PixelPos localPixelPos = new PixelPos(); localPixelPos.setLocation(pixelPos.getX() - _location.x, pixelPos.getY() - _location.y); return _geoGoding.getGeoPos(localPixelPos, geoPos); }
private void updateXYParams(GeoPos geoPos1, GeoPos geoPos2) { final GeoCoding geoCoding = product.getGeoCoding(); final PixelPos pixelPos1 = geoCoding.getPixelPos(geoPos1, null); if (!pixelPos1.isValid()) { pixelPos1.setLocation(0, 0); } final PixelPos pixelPos2 = geoCoding.getPixelPos(geoPos2, null); if (!pixelPos2.isValid()) { pixelPos2.setLocation(product.getSceneRasterWidth(), product.getSceneRasterHeight()); } final Rectangle.Float region = new Rectangle.Float(); region.setFrameFromDiagonal(pixelPos1.x, pixelPos1.y, pixelPos2.x, pixelPos2.y); final Rectangle.Float productBounds = new Rectangle.Float(0, 0, product.getSceneRasterWidth(), product.getSceneRasterHeight()); Rectangle2D finalRegion = productBounds.createIntersection(region); paramX1.setValue((int) finalRegion.getMinX(), null); paramY1.setValue((int) finalRegion.getMinY(), null); paramX2.setValue((int) finalRegion.getMaxX() - 1, null); paramY2.setValue((int) finalRegion.getMaxY() - 1, null); }
private boolean correctPrediction(final PixelPos pixelPos, double factor, final PixelPos correctedPixelPos) { final PixelPos pp = new PixelPos(); final GeoPos gp = new GeoPos(); float dx; float dy; float r; correctedPixelPos.setLocation(pixelPos); for (int i = 0; i < maxIterationCount; i++) { performDirectLocationModel(correctedPixelPos, factor, gp); performReverseLocationModel(gp, pp); // Refinement of pixel position dx = pixelPos.x - pp.x; dy = pixelPos.y - pp.y; correctedPixelPos.x += dx; correctedPixelPos.y += dy; r = dx * dx + dy * dy; if (r < PIXEL_EPS_SQR) { return true; } } return false; }
/** * Returns the pixel co-ordinates as x/y for a given geographical position given as lat/lon. * This algorithm * * @param geoPos the geographical position as lat/lon. * @param pixelPos the return value */ public void getPixelPosUsingQuadTreeSearch(final GeoPos geoPos, PixelPos pixelPos) { initialize(); final Result result = new Result(); boolean pixelFound = quadTreeSearch(0, geoPos.lat, geoPos.lon, 0, 0, rasterWidth, rasterHeight, result); if (pixelFound) { pixelPos.setLocation(result.x + 0.5f, result.y + 0.5f); } else { pixelPos.setInvalid(); } }
/** * Returns the source pixel coordinate for a <i>true (corrected)</i> geographical coordinate. * <p/> * Implements the prediction/correction algorithm from the MERIS Geometry Handbook, VT-P194-DOC-001-E, iss 1, rev 4, * page 29, figure 23. * <p/> * Scope of the prediction/correction algorithm is to retrieve the pixel x,y * that matches the <i>true</i> lat,lon by the direct location model f(x,y) = lat,lon. * * @param geoPos the <i>true (corrected)</i> geographical coordinate as lat/lon. * @param pixelPos an instance of <code>Point</code> to be used as return value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * * @return the source pixel coordinate */ @Override public PixelPos getPixelPos(GeoPos geoPos, PixelPos pixelPos) { pixelPos = performReverseLocationModel(geoPos, pixelPos); if (!isPixelPosValid(pixelPos)) { return pixelPos; } if (!mustCorrect(geoPos, pixelPos)) { return pixelPos; } final PixelPos correctedPixelPos = performPredictionCorrection(pixelPos); if (correctedPixelPos != null) { pixelPos.setLocation(correctedPixelPos); } return pixelPos; }
pixelPos.setLocation(result.getX() + 0.5f, result.getY() + 0.5f); } else { pixelPos.setInvalid();
@Override public PixelPos getPixelPos(GeoPos geoPos, PixelPos pixelPos) { if (pixelPos == null) { pixelPos = new PixelPos(); } try { DirectPosition directGeoPos = new DirectPosition2D(geoPos.getLon(), geoPos.getLat()); DirectPosition directPixelPos = geoToImage.transform(directGeoPos, null); pixelPos.setLocation((float) directPixelPos.getOrdinate(0), (float) directPixelPos.getOrdinate(1)); } catch (Exception ignored) { pixelPos.setInvalid(); } return pixelPos; }
public void testTransferGeoCodingWithSubSampling() { final Scene srcScene = SceneFactory.createScene(new Band("srcTest", ProductData.TYPE_UINT8, 10, 10)); final Scene destScene = SceneFactory.createScene(new Band("destTest", ProductData.TYPE_UINT8, 4, 4)); final ProductSubsetDef subsetDef = new ProductSubsetDef("testSubset"); subsetDef.setSubSampling(3, 3); _srcGeoCoding.transferGeoCoding(srcScene, destScene, subsetDef); final GeoCoding actGeoCoding = destScene.getGeoCoding(); assertNotNull(actGeoCoding); final PixelPos srcPixelPos = new PixelPos(); final PixelPos destPixelPos = new PixelPos(); srcPixelPos.setLocation(0, 0); destPixelPos.setLocation(0, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(3, 0); destPixelPos.setLocation(1, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(6, 0); destPixelPos.setLocation(2, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(9, 0); destPixelPos.setLocation(3, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); }
for (int y = 0; y < numVer; y++) { for (int x = 0; x < numHor; x++) { pixelPos.setLocation(((width - 1) * (double) x / (numHor - 1.0f)) + 0.5, ((height - 1) * (double) y / (numVer - 1.0f)) + 0.5); geoCoding.getGeoPos(pixelPos, geoPos);
public void testTransferGeoCodingWithRegion() { final Scene srcScene = SceneFactory.createScene(new Band("srcTest", ProductData.TYPE_UINT8, 10, 10)); final Scene destScene = SceneFactory.createScene(new Band("destTest", ProductData.TYPE_UINT8, 4, 3)); final ProductSubsetDef subsetDef = new ProductSubsetDef("testSubset"); subsetDef.setRegion(3, 1, 4, 3); _srcGeoCoding.transferGeoCoding(srcScene, destScene, subsetDef); final GeoCoding actGeoCoding = destScene.getGeoCoding(); assertNotNull(actGeoCoding); final PixelPos srcPixelPos = new PixelPos(); final PixelPos destPixelPos = new PixelPos(); srcPixelPos.setLocation(3, 1); destPixelPos.setLocation(0, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(5, 1); destPixelPos.setLocation(2, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(6, 2); destPixelPos.setLocation(3, 1); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(4, 3); destPixelPos.setLocation(1, 2); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); }
public void testTransferGeoCodingWithRegionAndSubsampling() { final Scene srcScene = SceneFactory.createScene(new Band("srcTest", ProductData.TYPE_UINT8, 10, 10)); final Scene destScene = SceneFactory.createScene(new Band("destTest", ProductData.TYPE_UINT8, 2, 2)); final ProductSubsetDef subsetDef = new ProductSubsetDef("testSubset"); subsetDef.setRegion(3, 1, 4, 3); subsetDef.setSubSampling(2, 2); _srcGeoCoding.transferGeoCoding(srcScene, destScene, subsetDef); final GeoCoding actGeoCoding = destScene.getGeoCoding(); assertNotNull(actGeoCoding); final PixelPos srcPixelPos = new PixelPos(); final PixelPos destPixelPos = new PixelPos(); srcPixelPos.setLocation(3, 1); destPixelPos.setLocation(0, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(5, 1); destPixelPos.setLocation(1, 0); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(3, 3); destPixelPos.setLocation(0, 1); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); srcPixelPos.setLocation(5, 3); destPixelPos.setLocation(1, 1); assertEquals(_srcGeoCoding.getGeoPos(srcPixelPos, null), actGeoCoding.getGeoPos(destPixelPos, null)); }
/** * Returns the pixel co-ordinates as x/y for a given geographical position given as lat/lon. * * @param geoPos the geographical position as lat/lon. * @param pixelPos an instance of <code>Point</code> to be used as retun value. If this parameter is * <code>null</code>, the method creates a new instance which it then returns. * * @return the pixel co-ordinates as x/y */ @Override public PixelPos getPixelPos(final GeoPos geoPos, PixelPos pixelPos) { if (pixelPos == null) { pixelPos = new PixelPos(); } pixelPos.setInvalid(); final double x = _pixelXFunction.computeZ(geoPos.getLat(), geoPos.getLon()); final double y = _pixelYFunction.computeZ(geoPos.getLat(), geoPos.getLon()); pixelPos.setLocation((x - _pixelOffsetX) / _pixelSizeX, (y - _pixelOffsetY) / _pixelSizeY); return pixelPos; }
approximation = GeoApproximation.findMostSuitable(approximations, lat, lon); if (approximation != null) { p.setLocation(lon, lat); approximation.g2p(p); final double x = p.getX();
final float fy = (float) (mY.get(0, 0) + mY.get(1, 0) * lat + mY.get(2, 0) * lon); pixelPos.setLocation(fx, fy); return true;
static int[] analysePrecise(DataPeriod dataPeriod, Product product) { int width = product.getSceneRasterWidth(); int height = product.getSceneRasterHeight(); GeoCoding geoCoding = product.getGeoCoding(); PixelPos pixelPos = new PixelPos(); GeoPos geoPos = new GeoPos(); int[] distribution = new int[DataPeriod.Membership.values().length]; for (int y = 0; y < height; y++) { ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, y); double mjd = scanLineTime.getMJD(); for (int x = 0; x < width; x++) { pixelPos.setLocation(x, y); geoCoding.getGeoPos(pixelPos, geoPos); DataPeriod.Membership membership = dataPeriod.getObservationMembership(geoPos.lon, mjd); distribution[membership.ordinal()]++; } } return distribution; }