final FXYSum ySum = FXYSum.createFXYSum(rlmOrder, yCoeffs); return new FXYGeoCoding(ulX, ulY, xDim, yDim, xSum, ySum, phiSum, lambdaSum, datum);
private void writeFXYGeoCoding(FXYGeoCoding fxyGeoCoding, String nodeType, StringBuffer sb) { sb.append("\n"); sb.append("\nThe ").append(nodeType).append(" uses a polynomial based geo-coding.\n"); sb.append("\n"); sb.append("Geographic coordinates (lat,lon) are computed from pixel coordinates (x,y)\n" + "by using following polynomial equations: \n\n"); sb.append(fxyGeoCoding.getLatFunction().createCFunctionCode("latitude", "x", "y")).append("\n"); sb.append(fxyGeoCoding.getLonFunction().createCFunctionCode("longitude", "x", "y")).append("\n"); sb.append("\n"); sb.append("Pixels (x,y) are computed from geographic coordinates (lat,lon)\n" + "by using the following polynomial equations: \n\n"); sb.append(fxyGeoCoding.getPixelXFunction().createCFunctionCode("x", "lat", "lon")).append("\n"); sb.append(fxyGeoCoding.getPixelYFunction().createCFunctionCode("y", "lat", "lon")).append("\n"); sb.append("\n"); }
public CombinedFXYGeoCoding(final CodingWrapper[] codingWrappers) { Guardian.assertNotNull("codingWrappers", codingWrappers); final ArrayList<CodingWrapper> wrappers = new ArrayList<CodingWrapper>(); for (int i = 0; i < codingWrappers.length; i++) { final CodingWrapper codingWrapper = codingWrappers[i]; if (codingWrapper != null) { wrappers.add(codingWrapper); } } Guardian.assertGreaterThan("number of coding wrappers", wrappers.size(), 0); _codingWrappers = wrappers.toArray(new CodingWrapper[wrappers.size()]); _datum = _codingWrappers[0].getGeoGoding().getDatum(); _lastIndex = 0; }
/** * Transfers the geo-coding of the {@link Scene srcScene} to the {@link Scene destScene} with respect to the given * {@link org.esa.beam.framework.dataio.ProductSubsetDef subsetDef}. * * @param srcScene the source scene * @param destScene the destination scene * @param subsetDef the definition of the subset, may be <code>null</code> * * @return true, if the geo-coding could be transferred. */ @Override public boolean transferGeoCoding(final Scene srcScene, final Scene destScene, final ProductSubsetDef subsetDef) { float pixelOffsetX = getPixelOffsetX(); float pixelOffsetY = getPixelOffsetY(); float pixelSizeX = getPixelSizeX(); float pixelSizeY = getPixelSizeY(); if (subsetDef != null) { if (subsetDef.getRegion() != null) { pixelOffsetX += subsetDef.getRegion().getX() * pixelSizeX; pixelOffsetY += subsetDef.getRegion().getY() * pixelSizeY; } pixelSizeX *= subsetDef.getSubSamplingX(); pixelSizeY *= subsetDef.getSubSamplingY(); } destScene.setGeoCoding(createCloneWithNewOffsetAndSize(pixelOffsetX, pixelOffsetY, pixelSizeX, pixelSizeY)); return true; }
printLine(indent, DimapProductConstants.TAG_ULX_MAP, fxyGeoCoding.getPixelOffsetX()); printLine(indent, DimapProductConstants.TAG_ULY_MAP, fxyGeoCoding.getPixelOffsetY()); printLine(indent, DimapProductConstants.TAG_X_DIM, fxyGeoCoding.getPixelSizeX()); printLine(indent, DimapProductConstants.TAG_Y_DIM, fxyGeoCoding.getPixelSizeY()); --indent; println(gpiTags[1]); println(slmTags[0]); final int directOrder = fxyGeoCoding.getLatFunction().getOrder(); final int reverseOrder = fxyGeoCoding.getPixelXFunction().getOrder(); final double[] lambdaCoeffs = fxyGeoCoding.getLonFunction().getCoefficients(); final double[] phiCoeffs = fxyGeoCoding.getLatFunction().getCoefficients(); final double[] xCoeffs = fxyGeoCoding.getPixelXFunction().getCoefficients(); final double[] yCoeffs = fxyGeoCoding.getPixelYFunction().getCoefficients(); indent++; writeDirectLocationModel(indent, directOrder, lambdaCoeffs, phiCoeffs);
final float pixelSizeY = 1; final Datum datum = Datum.WGS_84; final FXYGeoCoding geoCoding1 = new FXYGeoCoding(pixelOffsetX, pixelOffsetY, pixelSizeX, pixelSizeY, xFunction1, yFunction1, phiFunction1, lambdaFunction1, datum); final FXYGeoCoding geoCoding2 = new FXYGeoCoding(pixelOffsetX, pixelOffsetY, pixelSizeX, pixelSizeY, xFunction2, yFunction2, phiFunction2, lambdaFunction2, " </Geoposition_Insert>" + LS + " <Simplified_Location_Model>" + LS + " <Direct_Location_Model order=\"" + geoCoding1.getPixelXFunction().getOrder() + "\">" + LS + " <lc_List>" + LS + " <lc index=\"0\">" + lonCoefficients1[0] + "</lc>" + LS + " </pc_List>" + LS + " </Direct_Location_Model>" + LS + " <Reverse_Location_Model order=\"" + geoCoding1.getLatFunction().getOrder() + "\">" + LS + " <ic_List>" + LS + " <ic index=\"0\">" + xCoefficients1[0] + "</ic>" + LS + " </Geoposition_Insert>" + LS + " <Simplified_Location_Model>" + LS + " <Direct_Location_Model order=\"" + geoCoding2.getPixelXFunction().getOrder() + "\">" + LS + " <lc_List>" + LS + " <lc index=\"0\">" + lonCoefficients2[0] + "</lc>" + LS + " </pc_List>" + LS +
" </Geoposition_Insert>" + LS + " <Simplified_Location_Model>" + LS + " <Direct_Location_Model order=\"" + fxyGeoCoding.getPixelXFunction().getOrder() + "\">" + LS + " <lc_List>" + LS + " <lc index=\"0\">" + _lonCoefficients[0] + "</lc>" + LS + " </pc_List>" + LS + " </Direct_Location_Model>" + LS + " <Reverse_Location_Model order=\"" + fxyGeoCoding.getLatFunction().getOrder() + "\">" + LS + " <ic_List>" + LS + " <ic index=\"0\">" + _xCoefficients[0] + "</ic>" + LS +
public void testThatReverseIsInvOfForward() { final GeoPos geoPos = new GeoPos(); final PixelPos pixelPos = new PixelPos(12.5f, 349.1f); _geoCoding.getGeoPos(pixelPos, geoPos); final PixelPos pixelPosRev = new PixelPos(); _geoCoding.getPixelPos(geoPos, pixelPosRev); assertEquals(pixelPos.x, pixelPosRev.x, 1e-4); assertEquals(pixelPos.y, pixelPosRev.y, 1e-4); }
private PixelPos getPixelPos(final GeoPos geoPos, final PixelPos pixelPos) { final PixelPos pos = _geoGoding.getPixelPos(geoPos, pixelPos); pos.x += _location.x; pos.y += _location.y; return pos; }
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); }
assertEquals(_geoCoding.getPixelOffsetX() + subset.getRegion().getX(), subsetGeoCoding.getPixelOffsetX(), 1.e-6); assertEquals(_geoCoding.getPixelOffsetY() + subset.getRegion().getY(), subsetGeoCoding.getPixelOffsetY(), 1.e-6); assertEquals(_geoCoding.getPixelSizeX() * subset.getSubSamplingX(), subsetGeoCoding.getPixelSizeX(), 1.e-6); assertEquals(_geoCoding.getPixelSizeY() * subset.getSubSamplingY(), subsetGeoCoding.getPixelSizeY(), 1.e-6); assertTrue(_geoCoding.getPixelXFunction() != subsetGeoCoding.getPixelXFunction()); assertTrue(_geoCoding.getPixelYFunction() != subsetGeoCoding.getPixelYFunction()); assertTrue(_geoCoding.getLatFunction() != subsetGeoCoding.getLatFunction()); assertTrue(_geoCoding.getLonFunction() != subsetGeoCoding.getLonFunction()); assertTrue(_geoCoding.getPixelXFunction().getCoefficients() != subsetGeoCoding.getPixelXFunction().getCoefficients()); assertTrue(_geoCoding.getPixelYFunction().getCoefficients() != subsetGeoCoding.getPixelYFunction().getCoefficients()); assertTrue(_geoCoding.getLatFunction().getCoefficients() != subsetGeoCoding.getLatFunction().getCoefficients()); assertTrue(_geoCoding.getLonFunction().getCoefficients() != subsetGeoCoding.getLonFunction().getCoefficients()); assertTrue(Arrays.equals(_geoCoding.getPixelXFunction().getCoefficients(), subsetGeoCoding.getPixelXFunction().getCoefficients())); assertTrue(Arrays.equals(_geoCoding.getPixelYFunction().getCoefficients(), subsetGeoCoding.getPixelYFunction().getCoefficients())); assertTrue(Arrays.equals(_geoCoding.getLatFunction().getCoefficients(), subsetGeoCoding.getLatFunction().getCoefficients())); assertTrue(Arrays.equals(_geoCoding.getLonFunction().getCoefficients(), subsetGeoCoding.getLonFunction().getCoefficients()));
final FXYGeoCoding sourceGC = wrapper.getGeoGoding(); float gcPixelOffsetX = sourceGC.getPixelOffsetX(); float gcPixelOffsetY = sourceGC.getPixelOffsetY(); float gcPixelSizeX = sourceGC.getPixelSizeX(); float gcPixelSizeY = sourceGC.getPixelSizeY(); int gcwPosX = location.x; int gcwPosXSrc = 0; final FXYGeoCoding gc = sourceGC.createCloneWithNewOffsetAndSize(gcPixelOffsetX, gcPixelOffsetY, gcPixelSizeX,
private void assertEqual(final FXYGeoCoding expectedGeoCoding, final FXYGeoCoding actualGeoCoding) { assertEquals(expectedGeoCoding.getDatum().getName(), actualGeoCoding.getDatum().getName()); assertEquals(expectedGeoCoding.getDatum().getEllipsoid().getName(), actualGeoCoding.getDatum().getEllipsoid().getName()); assertEquals(expectedGeoCoding.getDatum().getEllipsoid().getSemiMajor(), actualGeoCoding.getDatum().getEllipsoid().getSemiMajor(), 1.0e-6); assertEquals(expectedGeoCoding.getDatum().getEllipsoid().getSemiMinor(), actualGeoCoding.getDatum().getEllipsoid().getSemiMinor(), 1.0e-6); assertEquals(expectedGeoCoding.getLatFunction().getOrder(), actualGeoCoding.getLatFunction().getOrder()); assertTrue(ArrayUtils.equalArrays(expectedGeoCoding.getLatFunction().getCoefficients(), actualGeoCoding.getLatFunction().getCoefficients(), 1.0e-6)); assertEquals(expectedGeoCoding.getLonFunction().getOrder(), actualGeoCoding.getLonFunction().getOrder()); assertTrue(ArrayUtils.equalArrays(expectedGeoCoding.getLonFunction().getCoefficients(), actualGeoCoding.getLonFunction().getCoefficients(), 1.0e-6)); assertEquals(expectedGeoCoding.getPixelXFunction().getOrder(), actualGeoCoding.getPixelXFunction().getOrder()); assertTrue(ArrayUtils.equalArrays(expectedGeoCoding.getPixelXFunction().getCoefficients(), actualGeoCoding.getPixelXFunction().getCoefficients(), 1.0e-6)); assertEquals(expectedGeoCoding.getPixelYFunction().getOrder(), actualGeoCoding.getPixelYFunction().getOrder()); assertTrue(ArrayUtils.equalArrays(expectedGeoCoding.getPixelYFunction().getCoefficients(), actualGeoCoding.getPixelYFunction().getCoefficients(), 1.0e-6)); assertEquals(expectedGeoCoding.getPixelOffsetX(), actualGeoCoding.getPixelOffsetX(), 1.0e-6); assertEquals(expectedGeoCoding.getPixelOffsetY(), actualGeoCoding.getPixelOffsetY(), 1.0e-6); assertEquals(expectedGeoCoding.getPixelSizeX(), actualGeoCoding.getPixelSizeX(), 1.0e-6); assertEquals(expectedGeoCoding.getPixelSizeY(), actualGeoCoding.getPixelSizeY(), 1.0e-6); }
private void writeCombinedFXYGeoCoding(CombinedFXYGeoCoding combinedGeoCoding, String nodeType, StringBuffer sb) { final CombinedFXYGeoCoding.CodingWrapper[] codingWrappers = combinedGeoCoding.getCodingWrappers(); sb.append("\n"); sb.append("\nThe ").append(nodeType).append( " uses a geo-coding which consists of multiple polynomial based geo-coding.\n"); sb.append("\n"); sb.append("The geo-coding uses ").append(codingWrappers.length).append(" polynomial based geo-codings\n"); for (int i = 0; i < codingWrappers.length; i++) { final CombinedFXYGeoCoding.CodingWrapper codingWrapper = codingWrappers[i]; final Rectangle region = codingWrapper.getRegion(); sb.append("\n==== Geo-coding[").append(i + 1).append("] ====\n"); sb.append("\nThe region in the scene which is covered by this geo-coding is defined by:\n"); sb.append("Location : X = ").append(region.x).append(" , Y = ").append(region.y).append("\n"); sb.append("Dimension : W = ").append(region.width).append(" , H = ").append(region.height).append("\n"); sb.append("\n"); final FXYGeoCoding fxyGeoCoding = codingWrapper.getGeoGoding(); sb.append("Geographic coordinates (lat,lon) are computed from pixel coordinates (x,y)\n" + "by using following polynomial equations: \n\n"); sb.append(fxyGeoCoding.getLatFunction().createCFunctionCode("latitude", "x", "y")).append("\n"); sb.append(fxyGeoCoding.getLonFunction().createCFunctionCode("longitude", "x", "y")).append("\n"); sb.append("\n"); sb.append("Pixels (x,y) are computed from geographic coordinates (lat,lon)\n" + "by using the following polynomial equations: \n\n"); sb.append(fxyGeoCoding.getPixelXFunction().createCFunctionCode("x", "lat", "lon")).append("\n"); sb.append(fxyGeoCoding.getPixelYFunction().createCFunctionCode("y", "lat", "lon")).append("\n"); sb.append("\n"); } }
public FXYGeoCoding createCloneWithNewOffsetAndSize(float pixelOffsetX, float pixelOffsetY, float pixelSizeX, float pixelSizeY) { final FXYSum pixelXFunction = FXYSum.createCopy(_pixelXFunction); final FXYSum pixelYFunction = FXYSum.createCopy(_pixelYFunction); final FXYSum latFunction = FXYSum.createCopy(_latFunction); final FXYSum lonFunction = FXYSum.createCopy(_lonFunction); return new FXYGeoCoding(pixelOffsetX, pixelOffsetY, pixelSizeX, pixelSizeY, pixelXFunction, pixelYFunction, latFunction, lonFunction, _datum); } }
private int writeFXYCoordRefSystem(final FXYGeoCoding fxyGeoCoding, int indent) { final String[] crsTags = createTags(indent, DimapProductConstants.TAG_COORDINATE_REFERENCE_SYSTEM); println(crsTags[0]); indent++; indent = writeDatum(fxyGeoCoding.getDatum(), indent); --indent; println(crsTags[1]); --indent; return indent; }
private void writeFXYGeoCoding(FXYGeoCoding fxyGeoCoding, String nodeType) { addEmptyRow(); addRow("The" + nodeType + " uses a polynomial based geo-coding."); addEmptyRow(); addRow("Geographic coordinates (lat,lon) are computed from pixel coordinates (x,y)\n" + "by using following polynomial equations"); addRow(fxyGeoCoding.getLatFunction().createCFunctionCode("latitude", "x", "y")); addRow(fxyGeoCoding.getLonFunction().createCFunctionCode("longitude", "x", "y")); addEmptyRow(); addRow("Pixels (x,y) are computed from geographic coordinates (lat,lon)\n" + "by using the following polynomial equations"); addRow(fxyGeoCoding.getPixelXFunction().createCFunctionCode("x", "lat", "lon")); addRow(fxyGeoCoding.getPixelYFunction().createCFunctionCode("y", "lat", "lon")); }
private AbstractGeoCoding createFXYSumGeoCoding() { final AbstractGeoCoding geoCoding; final FXYSum.Linear xFunc = new FXYSum.Linear(new double[]{0, 0, 1}); final FXYSum.Linear yFunc = new FXYSum.Linear(new double[]{0, 1, 0}); final FXYSum.Linear latFunc = new FXYSum.Linear(new double[]{0, 0, 1}); final FXYSum.Linear lonFunc = new FXYSum.Linear(new double[]{0, 1, 0}); geoCoding = new FXYGeoCoding(0, 0, 1, 1, xFunc, yFunc, latFunc, lonFunc, Datum.WGS_84); return geoCoding; }
private void writeCombinedFXYGeoCoding(CombinedFXYGeoCoding combinedGeoCoding, String nodeType) { final CombinedFXYGeoCoding.CodingWrapper[] codingWrappers = combinedGeoCoding.getCodingWrappers(); addEmptyRow(); addRow("The " + nodeType + " uses a geo-coding which consists of multiple polynomial based geo-coding."); addEmptyRow(); addRow("The geo-coding uses " + codingWrappers.length + " polynomial based geo-codings"); for (int i = 0; i < codingWrappers.length; i++) { final CombinedFXYGeoCoding.CodingWrapper codingWrapper = codingWrappers[i]; final Rectangle region = codingWrapper.getRegion(); addHeaderRow("Geo-coding[" + (i + 1) + "]"); addRow("The region in the scene which is covered by this geo-coding is defined by:"); addRow("Location: X = " + region.x + ", Y = " + region.y + "\n"); addRow("Dimension: W = " + region.width + ", H = " + region.height); addEmptyRow(); final FXYGeoCoding fxyGeoCoding = codingWrapper.getGeoGoding(); addRow("Geographic coordinates (lat,lon) are computed from pixel coordinates (x,y)\n" + "by using following polynomial equations"); addRow(fxyGeoCoding.getLatFunction().createCFunctionCode("latitude", "x", "y")); addRow(fxyGeoCoding.getLonFunction().createCFunctionCode("longitude", "x", "y")); addEmptyRow(); addRow("Pixels (x,y) are computed from geographic coordinates (lat,lon)\n" + "by using the following polynomial equations"); addRow(fxyGeoCoding.getPixelXFunction().createCFunctionCode("x", "lat", "lon")); addRow(fxyGeoCoding.getPixelYFunction().createCFunctionCode("y", "lat", "lon")); } }
@Override public void setUp() { final FXYSum.Linear xFunc = new FXYSum.Linear(new double[]{0, 0, 1}); final FXYSum.Linear yFunc = new FXYSum.Linear(new double[]{0, 1, 0}); final FXYSum.Linear latFunc = new FXYSum.Linear(new double[]{0, 0, 1}); final FXYSum.Linear lonFunc = new FXYSum.Linear(new double[]{0, 1, 0}); _geoCoding = new FXYGeoCoding(0, 0, 1, 1, xFunc, yFunc, latFunc, lonFunc, Datum.WGS_84); }