org.esa.beam.framework.datamodel.GeoCoding.getGeoPos()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.esa.beam.framework.datamodel.GeoCoding.getGeoPos()方法的一些代码示例,展示了GeoCoding.getGeoPos()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoCoding.getGeoPos()方法的具体详情如下:
包路径:org.esa.beam.framework.datamodel.GeoCoding
类名称:GeoCoding
方法名:getGeoPos

GeoCoding.getGeoPos介绍

[英]Returns the latitude and longitude value for a given pixel co-ordinate.
[中]返回给定像素坐标的纬度和经度值。

代码示例

代码示例来源:origin: bcdev/beam

protected GeoPos getGeoPos(PixelPos pixelPos) {
  final GeoPos geoPos = new GeoPos();
  gc.getGeoPos(pixelPos, geoPos);
  return geoPos;
}

代码示例来源:origin: bcdev/beam

@Override
  @Deprecated
  public GeoPos updateGeoPos(GeoCoding geoCoding, PixelPos pixelPos, GeoPos geoPos) {
    if (geoCoding == null || !geoCoding.canGetGeoPos()) {
      return geoPos;
    }
    return geoCoding.getGeoPos(pixelPos, geoPos);
  }
}

代码示例来源:origin: bcdev/beam

@Override
  @Deprecated
  public GeoPos updateGeoPos(GeoCoding geoCoding, PixelPos pixelPos, GeoPos geoPos) {
    if (geoCoding == null || !geoCoding.canGetGeoPos()) {
      return geoPos;
    }
    return geoCoding.getGeoPos(pixelPos, geoPos);
  }
}

代码示例来源:origin: bcdev/beam

@Override
  protected double computeSample(int sourceX, int sourceY) {
    GeoPos geoPos = geoCoding.getGeoPos(new PixelPos(sourceX + 0.5f, sourceY + 0.5f), null);
    try {
      return dem.getElevation(geoPos);
    } catch (Exception e) {
      return noDataValue;
    }
  }
}

代码示例来源:origin: bcdev/beam

private PixelPos getRrPixelPos(int x, int y) throws OperatorException {
  PixelPos frsPixelPos = new PixelPos(x, y);
  GeoPos geoPos = frsGeoCoding.getGeoPos(frsPixelPos, null);
  PixelPos rrPixelPos = rrGeoCoding.getPixelPos(geoPos, null);
  final int xrr = Math.round(rrPixelPos.x);
  final int yrr = Math.round(rrPixelPos.y);
  if (rrProduct.containsPixel(xrr, yrr)) {
    return rrPixelPos;
  } else {
    throw new OperatorException("RR product does not contain data for this coordinate: x=" + x + " y=" + y);
  }
}

代码示例来源:origin: bcdev/beam

private void exportLatLon(Band refBand, StringBuilder row, PixelPos pixelPos) {
  final GeoPos geoPos = new GeoPos();
  refBand.getGeoCoding().getGeoPos(pixelPos, geoPos);
  row.append(geoPos.getLon());
  row.append(getSeparator());
  row.append(geoPos.getLat());
  row.append(getSeparator());
}

代码示例来源:origin: bcdev/beam

private static GeoPos getGeoPos(final GeoCoding geoCoding, EvalEnv env, int width, int height) {
  RasterDataEvalEnv rasterEnv = (RasterDataEvalEnv) env;
  int pixelX = rasterEnv.getPixelX();
  int pixelY = rasterEnv.getPixelY();
  if (pixelX >= 0 && pixelX < width && pixelY >= 0 && pixelY < height) {
    return geoCoding.getGeoPos(new PixelPos(pixelX + 0.5f, pixelY + 0.5f), null);
  }
  return INVALID_GEO_POS;
}

代码示例来源:origin: bcdev/beam

private PixelPos getProductCenter(final Product product) {
  final GeoCoding geoCoding = product.getGeoCoding();
  PixelPos centerPos = null;
  if (geoCoding != null) {
    final float pixelX = (float) Math.floor(0.5f * product.getSceneRasterWidth()) + 0.5f;
    final float pixelY = (float) Math.floor(0.5f * product.getSceneRasterHeight()) + 0.5f;
    final GeoPos geoPos = geoCoding.getGeoPos(new PixelPos(pixelX, pixelY), null);
    final AffineTransform transform = layerCanvas.getViewport().getModelToViewTransform();
    final Point2D point2D = transform.transform(new Point2D.Double(geoPos.getLon(), geoPos.getLat()), null);
    centerPos = new PixelPos((float) point2D.getX(), (float) point2D.getY());
  }
  return centerPos;
}

代码示例来源:origin: bcdev/beam

@Override
public void pixelPosChanged(ImageLayer baseImageLayer, int pixelX, int pixelY, int currentLevel,
              boolean pixelPosValid, MouseEvent e) {
  PixelPos pixelPos = computeLevelZeroPixelPos(baseImageLayer, pixelX, pixelY, currentLevel);
  GeoPos geoPos = view.getRaster().getGeoCoding().getGeoPos(pixelPos, null);
  updateCursorOverlays(geoPos, view);
}

代码示例来源:origin: bcdev/beam

public static GeoPos getCenterGeoPos(final Product product) {
  final GeoCoding geoCoding = product.getGeoCoding();
  if (geoCoding != null) {
    final PixelPos centerPixelPos = new PixelPos(0.5f * product.getSceneRasterWidth() + 0.5f,
                           0.5f * product.getSceneRasterHeight() + 0.5f);
    return geoCoding.getGeoPos(centerPixelPos, null);
  }
  return null;
}

代码示例来源:origin: bcdev/beam

private void syncLatLonWithXYParams() {
  final PixelPos pixelPos1 = new PixelPos(((Number) paramX1.getValue()).intValue(),
                      ((Number) paramY1.getValue()).intValue());
  final PixelPos pixelPos2 = new PixelPos(((Number) paramX2.getValue()).intValue(),
                      ((Number) paramY2.getValue()).intValue());
  final GeoCoding geoCoding = product.getGeoCoding();
  final GeoPos geoPos1 = geoCoding.getGeoPos(pixelPos1, null);
  final GeoPos geoPos2 = geoCoding.getGeoPos(pixelPos2, null);
  paramNorthLat1.setValue(geoPos1.getLat(), null);
  paramWestLon1.setValue(geoPos1.getLon(), null);
  paramSouthLat2.setValue(geoPos2.getLat(), null);
  paramEastLon2.setValue(geoPos2.getLon(), null);
}

代码示例来源:origin: bcdev/beam

private void comparePixelPos(GeoCoding destGeoCoding, PixelPos pixelPos, PixelPos pixelPos1) {
  GeoPos srcPos = srcGeoCoding.getGeoPos(pixelPos, null);
  GeoPos destPos = destGeoCoding.getGeoPos(pixelPos1, null);
  assertEquals(srcPos, destPos);
}

代码示例来源:origin: bcdev/beam

@Test
public void testSpecifyingReferencing() throws IOException {
  parameterMap.put("crs", WGS84_CODE);
  parameterMap.put("referencePixelX", 0.5);
  parameterMap.put("referencePixelY", 0.5);
  parameterMap.put("easting", 9.0);   // just move it 3° degrees eastward
  parameterMap.put("northing", 52.0); // just move it 2° degrees up
  parameterMap.put("orientation", 0.0);
  final Product targetPoduct = createReprojectedProduct();
  assertNotNull(targetPoduct);
  final GeoPos geoPos = targetPoduct.getGeoCoding().getGeoPos(new PixelPos(0.5f, 0.5f), null);
  assertEquals(new GeoPos(52.0f, 9.0f), geoPos);
  assertPixelValue(targetPoduct.getBand(FLOAT_BAND_NAME), 23.5f, 13.5f, (double) 299, EPS);
}

代码示例来源:origin: bcdev/beam

protected void assertPixelValue(Band targetBand, float sourceX, float sourceY,
               double expectedPixelValue, double delta) throws IOException {
  final Band sourceBand = sourceProduct.getBand(targetBand.getName());
  final PixelPos sourcePP = new PixelPos(sourceX, sourceY);
  final GeoPos geoPos = sourceBand.getGeoCoding().getGeoPos(sourcePP, null);
  final PixelPos targetPP = targetBand.getGeoCoding().getPixelPos(geoPos, null);
  final double[] pixels = new double[1];
  targetBand.readPixels((int) Math.floor(targetPP.x), (int) Math.floor(targetPP.y), 1, 1, pixels);
  assertEquals(expectedPixelValue, pixels[0], delta);
}

代码示例来源:origin: bcdev/beam

protected void assertPixelValidState(Band targetBand, float sourceX, float sourceY,
                   boolean expectedValid) throws IOException {
  final Band sourceBand = sourceProduct.getBand(targetBand.getName());
  final PixelPos sourcePP = new PixelPos(sourceX, sourceY);
  final GeoPos geoPos = sourceBand.getGeoCoding().getGeoPos(sourcePP, null);
  final PixelPos targetPP = targetBand.getGeoCoding().getPixelPos(geoPos, null);
  boolean pixelValid = targetBand.isPixelValid((int) Math.floor(targetPP.x), (int) Math.floor(targetPP.y));
  assertEquals(expectedValid, pixelValid);
}

代码示例来源:origin: bcdev/beam

@Test
  public void testSmallImageNearGreenwichMeridian() throws Exception {
    final URL resource = getClass().getResource("nearGreenwichMeridian.tif");
    final String filePath = resource.getFile();
    final GeoTiffProductReader reader = new GeoTiffProductReader(new GeoTiffProductReaderPlugIn());
    final Product product = reader.readGeoTIFFProduct(new FileCacheImageInputStream(resource.openStream(), null), new File(filePath));

    final GeoCoding geoCoding = product.getGeoCoding();
    final GeoPos ul = geoCoding.getGeoPos(new PixelPos(0, 0), null);
    assertEquals(1.92584, ul.lon, 1.0e-5);
    assertEquals(48.28314, ul.lat, 1.0e-5);
    final GeoPos lr = geoCoding.getGeoPos(new PixelPos(49, 49), null);
    assertEquals(2.03596, lr.lon, 1.0e-5);
    assertEquals(48.17303, lr.lat, 1.0e-5);

  }
}

代码示例来源:origin: bcdev/beam

static DataPeriod.Membership[] analyseBasic(DataPeriod dataPeriod, Product product) {
  GeoCoding geoCoding = product.getGeoCoding();
  ProductData.UTC firstScanLineTime = ProductUtils.getScanLineTime(product, 0);
  float firstLon = geoCoding.getGeoPos(new PixelPos(0, 0), null).lon;
  DataPeriod.Membership fl = dataPeriod.getObservationMembership(firstLon, firstScanLineTime.getMJD());
  float lastLon = geoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, 0), null).lon;
  DataPeriod.Membership fr = dataPeriod.getObservationMembership(lastLon, firstScanLineTime.getMJD());
  ProductData.UTC lastScanLineTime = ProductUtils.getScanLineTime(product, product.getSceneRasterHeight() - 1);
  firstLon = geoCoding.getGeoPos(new PixelPos(0, product.getSceneRasterHeight() - 1), null).lon;
  DataPeriod.Membership ll = dataPeriod.getObservationMembership(firstLon, lastScanLineTime.getMJD());
  lastLon = geoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, product.getSceneRasterHeight() - 1), null).lon;
  DataPeriod.Membership lr = dataPeriod.getObservationMembership(lastLon, lastScanLineTime.getMJD());
  return new DataPeriod.Membership[]{fl, fr, ll, lr};
}

代码示例来源:origin: bcdev/beam

public void testTransferGeoCoding() {
  final Scene srcScene = SceneFactory.createScene(createProduct());
  final Scene destScene = SceneFactory.createScene(new Product("test2", "test2", PW, PH));
  final boolean transferred = srcScene.transferGeoCodingTo(destScene, null);
  assertTrue(transferred);
  final GeoCoding destGeoCoding = destScene.getGeoCoding();
  assertNotNull(destGeoCoding);
  assertTrue(destGeoCoding instanceof TiePointGeoCoding);
  final PixelPos pixelPos = new PixelPos(PW/2.0f, PH/2.0f);
  final GeoPos srcGeoPos = srcScene.getGeoCoding().getGeoPos(pixelPos, null);
  final GeoPos destGeoPos = destScene.getGeoCoding().getGeoPos(pixelPos, null);
  assertEquals(srcGeoPos, destGeoPos);
}

代码示例来源:origin: bcdev/beam

@Test
public void testThatPredictionCorrectionScopeIsAchieved() {
  final Orthorectifier o = createOrthorectifier();
  final PixelPos pixelPos = o.getPixelPos(new GeoPos(5.0f, 5.0f), null);
  assertEquals(50.0f, pixelPos.x, 1.0e-6);
  assertTrue(pixelPos.y > 50.0f);
  GeoPos geoPosFalse = o.getGeoCoding().getGeoPos(pixelPos, null);
  assertEquals(5.0f, geoPosFalse.lon, 1.0e-6);
  assertTrue(geoPosFalse.lat < 5.0f);
  GeoPos geoPosTrue = o.getGeoPos(pixelPos, null);
  assertEquals(5.0f, geoPosTrue.lon, 1.0e-6);
  assertTrue(geoPosTrue.lat > geoPosFalse.lat);
}

代码示例来源:origin: bcdev/beam

@Test
public void testTransferGeoCodingWithoutSubset() {
  final boolean returnValue = srcScene.transferGeoCodingTo(destScene, null);
  assertTrue(returnValue);
  final GeoCoding destGeoCoding = destScene.getGeoCoding();
  assertNotNull(destGeoCoding);
  assertNotSame(srcGeoCoding, destGeoCoding);
  assertEquals(srcGeoCoding.getDatum(), destGeoCoding.getDatum());
  assertEquals(srcGeoCoding.getMapCRS(), destGeoCoding.getMapCRS());
  assertEquals(srcGeoCoding.getGeoCRS(), destGeoCoding.getGeoCRS());
  assertEquals(srcGeoCoding.getGeoPos(new PixelPos(3.5f, 0.5f), null),
         destGeoCoding.getGeoPos(new PixelPos(3.5f, 0.5f), null));
}

相关文章