org.esa.beam.framework.datamodel.GeoCoding类的使用及代码示例

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

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

GeoCoding介绍

[英]The GeoCoding interface provides geo-spatial latitude and longitude information for a given X/Y position of any (two-dimensional) raster.

Note: New geo-coding implementations shall implement the abstract class AbstractGeoCoding, instead of implementing this interface.

All GeoCoding implementations should override the Object#equals(Object) and Object#hashCode() methods.
[中]GeoCoding界面为任何(二维)光栅的给定X/Y位置提供地理空间纬度和经度信息。
注:新的地理编码实现应实现抽象类AbstractGeoCoding,而不是实现此接口。
所有GeoCoding实现都应该重写Object#equals(Object)和Object#hashCode()方法。

代码示例

代码示例来源: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

@Override
public CoordinateReferenceSystem getMapCRS() {
  return geoCoding.getMapCRS();
}

代码示例来源: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 PixelPos updatePixelPos(GeoCoding geoCoding, GeoPos geoPos, PixelPos pixelPos) {
  if (geoCoding == null || !geoCoding.canGetPixelPos() || geoPos == null) {
    return pixelPos;
  }
  return geoCoding.getPixelPos(geoPos, pixelPos);
}

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

/**
 * Gets the coordinate reference system used for the model space. The model space is coordinate system
 * that is used to render images for display.
 *
 * @param geoCoding A geo-coding, may be {@code null}.
 * @return The coordinate reference system used for the model space. If {@code geoCoding} is {@code null},
 *         it will be a default image coordinate reference system (an instance of {@code org.opengis.referencing.crs.ImageCRS}).
 */
public static CoordinateReferenceSystem getModelCrs(GeoCoding geoCoding) {
  if (geoCoding != null) {
    final MathTransform image2Map = geoCoding.getImageToMapTransform();
    if (image2Map instanceof AffineTransform) {
      return geoCoding.getMapCRS();
    }
    return geoCoding.getImageCRS();
  } else {
    return DEFAULT_IMAGE_CRS;
  }
}

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

final Rectangle destArea) {
Guardian.assertNotNull("sourceGeoCoding", sourceGeoCoding);
Guardian.assertEquals("sourceGeoCoding.canGetPixelPos()", sourceGeoCoding.canGetPixelPos(), true);
Guardian.assertNotNull("destGeoCoding", destGeoCoding);
Guardian.assertEquals("destGeoCoding.canGetGeoPos()", destGeoCoding.canGetGeoPos(), true);
Guardian.assertNotNull("destArea", destArea);
    pixelPos.x = x + 0.5f;
    pixelPos.y = y + 0.5f;
    destGeoCoding.getGeoPos(pixelPos, geoPos);
    sourceGeoCoding.getPixelPos(geoPos, pixelPos);
    if (pixelPos.x >= 0.0f && pixelPos.x < sourceWidth
      && pixelPos.y >= 0.0f && pixelPos.y < sourceHeight) {

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

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

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

private PixelPos performReverseLocationModel(GeoPos geoPos, PixelPos pixelPos) {
  return geoCoding.getPixelPos(geoPos, pixelPos);
}

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

private void assertEquality(final GeoCoding gc1, final GeoCoding gc2, float accuracy) {
  assertNotNull(gc2);
  assertEquals(gc1.canGetGeoPos(), gc2.canGetGeoPos());
  assertEquals(gc1.canGetPixelPos(), gc2.canGetPixelPos());
  assertEquals(gc1.isCrossingMeridianAt180(), gc2.isCrossingMeridianAt180());
  if (gc1 instanceof CrsGeoCoding) {
    assertEquals(CrsGeoCoding.class, gc2.getClass());
    CRS.equalsIgnoreMetadata(gc1, gc2);
  } else if (gc1 instanceof TiePointGeoCoding) {
    assertEquals(TiePointGeoCoding.class, gc2.getClass());
  }
  final int width = outProduct.getSceneRasterWidth();
  final int height = outProduct.getSceneRasterHeight();
  GeoPos geoPos1 = null;
  GeoPos geoPos2 = null;
  final String msgPattern = "%s at [%d,%d] is not equal:";
  for (int i = 0; i < width; i++) {
    for (int j = 0; j < height; j++) {
      final PixelPos pixelPos = new PixelPos(i, j);
      geoPos1 = gc1.getGeoPos(pixelPos, geoPos1);
      geoPos2 = gc2.getGeoPos(pixelPos, geoPos2);
      assertEquals(String.format(msgPattern, "Latitude", i, j), geoPos1.lat, geoPos2.lat, accuracy);
      assertEquals(String.format(msgPattern, "Longitude", i, j), geoPos1.lon, geoPos2.lon, accuracy);
    }
  }
}

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

throw new IllegalArgumentException("searchRadius < 2");
crossingMeridianAt180 = pixelPosEstimator.isCrossingMeridianAt180();
GeoPos p0 = pixelPosEstimator.getGeoPos(new PixelPos(0.5f, 0.5f), null);
GeoPos p1 = pixelPosEstimator.getGeoPos(new PixelPos(1.5f, 0.5f), null);

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

@Override
  public boolean accept(Product product) {
    final GeoCoding geoCoding = product.getGeoCoding();
    return geoCoding != null && geoCoding.canGetGeoPos() && geoCoding.canGetPixelPos();
  }
}

代码示例来源: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));
}

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

@Test
public void testTransferGeoCodingWithSubset_Subsampling() {
  final ProductSubsetDef subsetDef = new ProductSubsetDef("subset");
  subsetDef.setSubSampling(2, 4);
  final boolean transfered = srcScene.transferGeoCodingTo(destScene, subsetDef);
  assertTrue(transfered);
  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());
  comparePixelPos(destGeoCoding, new PixelPos(0, 0), new PixelPos(0, 0));
  comparePixelPos(destGeoCoding, new PixelPos(8, 0), new PixelPos(4, 0));
  comparePixelPos(destGeoCoding, new PixelPos(8, 16), new PixelPos(4, 4));
  comparePixelPos(destGeoCoding, new PixelPos(0, 16), new PixelPos(0, 4));
}

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

/**
 * Checks whether or not this geo-coding can determine the pixel position from a geodetic position.
 *
 * @return <code>true</code>, if so
 */
@Override
public boolean canGetPixelPos() {
  return getGeoCoding().canGetPixelPos();
}

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

public static GeoTIFFMetadata createGeoTIFFMetadata(GeoCoding geoCoding, int width, int height) {
  GeoTIFFMetadata metadata = null;
  if (geoCoding instanceof CrsGeoCoding || geoCoding instanceof MapGeoCoding) {
    metadata = createProjectedGeoTIFFMetadata(geoCoding.getMapCRS(), geoCoding.getImageToMapTransform());
  } else if (geoCoding != null) {
    metadata = createFallbackGeoTIFFMetada(geoCoding, width, height);
  }
  return metadata;
}

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

/**
 * Checks whether or not this geo-coding can determine the geodetic position from a pixel position.
 *
 * @return <code>true</code>, if so
 */
@Override
public boolean canGetGeoPos() {
  return getGeoCoding().canGetGeoPos();
}

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

@Test
public void testTransferGeoCodingWithSubset_Region() {
  final ProductSubsetDef subsetDef = new ProductSubsetDef("subset");
  subsetDef.setRegion(2, 2, 4, 4);
  final boolean transfered = srcScene.transferGeoCodingTo(destScene, subsetDef);
  assertTrue(transfered);
  final GeoCoding destGeoCoding = destScene.getGeoCoding();
  assertNotNull(destGeoCoding);
  assertNotSame(srcGeoCoding, destGeoCoding);
  assertEquals(srcGeoCoding.getDatum(), destGeoCoding.getDatum());
  assertEquals(srcGeoCoding.getMapCRS(), destGeoCoding.getMapCRS());
  // position (3,3) in source equals (1,1) in dest
  comparePixelPos(destGeoCoding, new PixelPos(3, 3), new PixelPos(1, 1));
}

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

/**
 * Releases all of the resources used by this object instance and all of its owned children. Its primary use is to
 * allow the garbage collector to perform a vanilla job.
 * <p/>
 * <p>This method should be called only if it is for sure that this object instance will never be used again. The
 * results of referencing an instance of this class after a call to <code>dispose()</code> are undefined.
 */
@Override
public void dispose() {
  for (GeoCoding gc : _gcList) {
    if (gc != null) {
      gc.dispose();
    }
  }
  _gcList.clear();
}

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

private static Rectangle2D createMapBoundary(final Product product, CoordinateReferenceSystem targetCrs) {
  try {
    final CoordinateReferenceSystem sourceCrs = product.getGeoCoding().getImageCRS();
    final int sourceW = product.getSceneRasterWidth();
    final int sourceH = product.getSceneRasterHeight();
    final Rectangle2D rect = XRectangle2D.createFromExtremums(0.5, 0.5, sourceW - 0.5, sourceH - 0.5);
    int pointsPerSide = Math.max(sourceH, sourceW) / 10;
    pointsPerSide = Math.max(9, pointsPerSide);
    final ReferencedEnvelope sourceEnvelope = new ReferencedEnvelope(rect, sourceCrs);
    final ReferencedEnvelope targetEnvelope = sourceEnvelope.transform(targetCrs, true, pointsPerSide);
    double minX = targetEnvelope.getMinX();
    double width = targetEnvelope.getWidth();
    if (product.getGeoCoding().isCrossingMeridianAt180()) {
      minX = -180.0;
      width = 360;
    }
    return new Rectangle2D.Double(minX, targetEnvelope.getMinY(), width, targetEnvelope.getHeight());
  } catch (Exception e) {
    throw new IllegalStateException(e);
  }
}

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

/**
 * Checks whether or not the longitudes of this geo-coding cross the +/- 180 degree meridian.
 *
 * @return <code>true</code>, if so
 */
@Override
public boolean isCrossingMeridianAt180() {
  return getGeoCoding().isCrossingMeridianAt180();
}

相关文章