本文整理了Java中org.esa.beam.framework.datamodel.GeoCoding.getPixelPos()
方法的一些代码示例,展示了GeoCoding.getPixelPos()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoCoding.getPixelPos()
方法的具体详情如下:
包路径:org.esa.beam.framework.datamodel.GeoCoding
类名称:GeoCoding
方法名:getPixelPos
[英]Returns the pixel co-ordinates as x/y for a given geographical position given as lat/lon.
[中]返回给定地理位置(lat/lon)的像素坐标(x/y)。
代码示例来源:origin: bcdev/beam
private PixelPos performReverseLocationModel(GeoPos geoPos, PixelPos pixelPos) {
return geoCoding.getPixelPos(geoPos, pixelPos);
}
代码示例来源: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
@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
@Override
public void filter(Coordinate coordinate) {
final GeoPos geoPos = new GeoPos((float) coordinate.y, (float) coordinate.x);
final PixelPos pixelPos = geoCoding.getPixelPos(geoPos, null);
if (pixelPos.isValid()) {
x1 = min(x1, (int) floor(pixelPos.x));
x2 = max(x2, (int) ceil(pixelPos.x));
y1 = min(y1, (int) floor(pixelPos.y));
y2 = max(y2, (int) ceil(pixelPos.y));
}
}
代码示例来源:origin: bcdev/beam
@Override
public void filter(CoordinateSequence seq, int i) {
Coordinate coord = seq.getCoordinate(i);
PixelPos pixelPos = geoCoding.getPixelPos(new GeoPos((float) coord.y, (float) coord.x), null);
// rounding needed because closed geometries yield errors if their first and last coordinate
// do not exactly match
double x = Math.round(pixelPos.x * 10000) / 10000;
double y = Math.round(pixelPos.y * 10000) / 10000;
coord.setCoordinate(new Coordinate(x, y));
count++;
}
代码示例来源: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
ExpectedGeoCoding(Product product, Random random) {
this();
final ArrayList<Point2D> pointList = ExpectedPixel.createPointList(product, random);
final GeoCoding geoCoding = product.getGeoCoding();
coordinates = new ExpectedGeoCoordinate[pointList.size()];
for (int i = 0; i < pointList.size(); i++) {
Point2D point = pointList.get(i);
final float x = (float) point.getX();
final float y = (float) point.getY();
final GeoPos geoPos = geoCoding.getGeoPos(new PixelPos(x, y), null);
final PixelPos pixelPos = geoCoding.getPixelPos(geoPos, null);
float xAccuracy = Math.abs(x - pixelPos.x);
float yAccuracy = Math.abs(y - pixelPos.y);
float accuracy = Math.max(xAccuracy, yAccuracy);
reverseAccuracy = Math.max(reverseAccuracy, accuracy);
coordinates[i] = new ExpectedGeoCoordinate(x, y, geoPos.getLat(), geoPos.getLon());
}
}
代码示例来源:origin: bcdev/beam
private static SimpleFeature createFeature(SimpleFeatureType type, GeoCoding geoCoding, int pointIndex, float lat, float lon, double data) {
PixelPos pixelPos = geoCoding.getPixelPos(new GeoPos(lat, lon), null);
if (!pixelPos.isValid()) {
return null;
}
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
GeometryFactory gf = new GeometryFactory();
/*0*/
fb.add(gf.createPoint(new Coordinate(pixelPos.x, pixelPos.y)));
/*1*/
fb.add(gf.createPoint(new Coordinate(lon, lat)));
/*2*/
fb.add(data);
return fb.buildFeature(String.format("ID%08d", pointIndex));
}
代码示例来源:origin: bcdev/beam
@Override
public TimeSeriesGraphUpdater.Position transformGeoPos(GeoPos geoPos) {
geoCoding.getPixelPos(geoPos, pixelPos);
return new TimeSeriesGraphUpdater.Position((int) pixelPos.getX(), (int) pixelPos.getY(), 0);
}
};
代码示例来源:origin: bcdev/beam
private Rectangle findL3Rectangle(Rectangle l1Rectangle, Band srcBand) {
PixelPos bottomLeft = new PixelPos(l1Rectangle.x, l1Rectangle.y);
PixelPos l3PixelPos = l3GeoCoding.getPixelPos(l1GeoCoding.getGeoPos(bottomLeft, null), null);
Rectangle l3Rectangle = new Rectangle(Math.round(l3PixelPos.x), Math.round(l3PixelPos.y), 1, 1);
PixelPos bottomRight = new PixelPos(l1Rectangle.x + l1Rectangle.width, l1Rectangle.y);
l3PixelPos = l3GeoCoding.getPixelPos(l1GeoCoding.getGeoPos(bottomRight, null), l3PixelPos);
l3Rectangle.add(l3PixelPos.x, l3PixelPos.y);
PixelPos topRight = new PixelPos(l1Rectangle.x + l1Rectangle.width, l1Rectangle.y + l1Rectangle.height);
l3PixelPos = l3GeoCoding.getPixelPos(l1GeoCoding.getGeoPos(topRight, null), l3PixelPos);
l3Rectangle.add(l3PixelPos.x, l3PixelPos.y);
PixelPos topLeft = new PixelPos(l1Rectangle.x, l1Rectangle.y + l1Rectangle.height);
l3PixelPos = l3GeoCoding.getPixelPos(l1GeoCoding.getGeoPos(topLeft, null), l3PixelPos);
l3Rectangle.add(l3PixelPos.x, l3PixelPos.y);
l3Rectangle.grow(2, 2);
Rectangle sceneRectangle = new Rectangle(srcBand.getSceneRasterWidth(), srcBand.getSceneRasterHeight());
return l3Rectangle.intersection(sceneRectangle);
}
代码示例来源:origin: bcdev/beam
private PixelPos getPixelPosition(Product product, Coordinate coordinate) {
return product.getGeoCoding().getPixelPos(new GeoPos(coordinate.getLat(), coordinate.getLon()), null);
}
代码示例来源:origin: bcdev/beam
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);
}
代码示例来源:origin: bcdev/beam
protected final float getElevation(GeoPos geoPos, PixelPos pixelPos) {
float h = 0.0f;
if (elevationModel != null) {
try {
h = elevationModel.getElevation(geoPos);
} catch (Exception ignored) {
// ignored
}
if (h == elevationModel.getDescriptor().getNoDataValue()) {
h = 0.0f;
}
} else if (pointing.canGetElevation()) {
if (pixelPos == null) {
pixelPos = geoCoding.getPixelPos(geoPos, null);
}
h = pointing.getElevation(pixelPos);
}
return h;
}
代码示例来源: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
private void assertSampleValuesFloat(Band b1Band, GeoPos[] geoPositions, float[] expectedValues) {
GeoCoding geoCoding = b1Band.getGeoCoding();
final Raster b1Raster = b1Band.getSourceImage().getData();
for (int i = 0; i < geoPositions.length; i++) {
PixelPos pp = geoCoding.getPixelPos(geoPositions[i], null);
final float expectedValue = expectedValues[i];
final float actualValue = b1Raster.getSampleFloat((int) pp.x, (int) pp.y, 0);
final String message = String.format("At <%d>:", i);
assertEquals(message, expectedValue, actualValue, 1.0e-6);
}
}
代码示例来源:origin: bcdev/beam
private void assertSampleValuesInt(Band b1Band, GeoPos[] geoPositions, int[] expectedValues) {
GeoCoding geoCoding = b1Band.getGeoCoding();
final Raster b1Raster = b1Band.getSourceImage().getData();
for (int i = 0; i < geoPositions.length; i++) {
PixelPos pp = geoCoding.getPixelPos(geoPositions[i], null);
final int expectedValue = expectedValues[i];
final int actualValue = b1Raster.getSample((int) pp.x, (int) pp.y, 0);
final String message = String.format("At <%d>:", i);
assertEquals(message, expectedValue, actualValue);
}
}
代码示例来源:origin: bcdev/beam
@Override
public void paintOverlay(LayerCanvas canvas, Rendering rendering) {
if (geoPosition == null || !geoPosition.isValid()) {
return;
}
final GeoCoding geoCoding = sceneView.getRaster().getGeoCoding();
if (!geoCoding.canGetPixelPos()) {
return;
}
final Product product = sceneView.getRaster().getProduct();
final PixelPos pixelPos = geoCoding.getPixelPos(geoPosition, null);
if (!pixelPos.isValid() || !product.containsPixel(pixelPos)) {
return;
}
final Viewport viewport = canvas.getViewport();
drawCursor(rendering.getGraphics(), viewport, pixelPos);
}
代码示例来源:origin: bcdev/beam
@Test
public void testGetPixelPos() throws IOException {
Product product = createProduct();
TiePointGeoCoding tiePointGeoCoding = (TiePointGeoCoding) product.getGeoCoding();
GeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(product.getBand("latBand"),
product.getBand("lonBand"),
null,
2,
ProgressMonitor.NULL);
product.setGeoCoding(pixelGeoCoding);
TiePointGrid latGrid = tiePointGeoCoding.getLatGrid();
TiePointGrid lonGrid = tiePointGeoCoding.getLonGrid();
GeoPos gp = new GeoPos(latGrid.getTiePoints()[0], lonGrid.getTiePoints()[0]);
PixelPos pixelPos = pixelGeoCoding.getPixelPos(gp, null);
assertEquals(new PixelPos(0.5f, 0.5f), pixelPos);
System.out.println("----");
gp = new GeoPos((latGrid.getTiePoints()[0] + latGrid.getTiePoints()[1]) / 2,
(lonGrid.getTiePoints()[0] + lonGrid.getTiePoints()[1]) / 2);
pixelPos = pixelGeoCoding.getPixelPos(gp, null);
assertEquals(new PixelPos(2.5f, 0.5f), pixelPos);
}
代码示例来源:origin: bcdev/beam
public void testTransferGeoCoding_WithSpatialSubset() throws IOException {
final Scene srcScene = SceneFactory.createScene(createProduct());
final ProductSubsetDef subsetDef = new ProductSubsetDef();
subsetDef.setRegion(2, 2, PW - 4, PH - 4);
subsetDef.setSubSampling(1,2);
final Product destProduct = ProductSubsetBuilder.createProductSubset(new Product("test2", "test2", PW, PH),
subsetDef, "test2", "");
final Scene destScene = SceneFactory.createScene(destProduct);
final boolean transferred = srcScene.transferGeoCodingTo(destScene, subsetDef);
assertTrue(transferred);
final GeoCoding destGeoCoding = destScene.getGeoCoding();
assertTrue(destGeoCoding instanceof TiePointGeoCoding);
final GeoPos srcGeoPos = srcScene.getGeoCoding().getGeoPos(new PixelPos(4.5f, 6.5f), null);
final PixelPos destPixelPos = destScene.getGeoCoding().getPixelPos(srcGeoPos, null);
assertEquals(2.5, destPixelPos.getX(), 1.0e-1);
assertEquals(1.5, destPixelPos.getY(), 1.0e-1);
}
内容来源于网络,如有侵权,请联系作者删除!