private File getImageFile(TiePointGrid tiePointGrid) { return new File(new File(dataOutputDir, DimapProductConstants.TIE_POINT_GRID_DIR_NAME), tiePointGrid.getName() + DimapProductConstants.IMAGE_FILE_EXTENSION); }
private File getEnviHeaderFile(TiePointGrid tiePointGrid) { return new File(new File(dataOutputDir, DimapProductConstants.TIE_POINT_GRID_DIR_NAME), tiePointGrid.getName() + EnviHeader.FILE_EXTENSION); }
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); if (value instanceof CompatibleNodeList) { label.setText(MessageFormat.format("<html><b>{0}</b></html>", ((CompatibleNodeList) value).name)); } else if (value instanceof Band) { label.setText(MessageFormat.format("<html><b>{0}</b></html>", ((Band) value).getName())); } else if (value instanceof TiePointGrid) { label.setText(MessageFormat.format("<html><b>{0}</b> (Tie-point grid)</html>", ((TiePointGrid) value).getName())); } return label; } }
/** * Adds the given tie-point grid to this product. * * @param tiePointGrid the tie-point grid to added, ignored if <code>null</code> */ public void addTiePointGrid(final TiePointGrid tiePointGrid) { if (containsRasterDataNode(tiePointGrid.getName())) { throw new IllegalArgumentException("The Product '" + getName() + "' already contains " + "a tie-point grid with the name '" + tiePointGrid.getName() + "'."); } tiePointGridGroup.add(tiePointGrid); }
@Override public Element createXmlFromObject(Object object) { PodGeoCoding podGeoCoding = (PodGeoCoding) object; final Element podGeoCodingElement = new Element(POD_GEO_CODING_TAG); final Element tpgLatElement = new Element(DimapProductConstants.TAG_TIE_POINT_GRID_NAME_LAT); tpgLatElement.setText(podGeoCoding.getLatGrid().getName()); podGeoCodingElement.addContent(tpgLatElement); final Element tpgLonElement = new Element(DimapProductConstants.TAG_TIE_POINT_GRID_NAME_LON); tpgLonElement.setText(podGeoCoding.getLonGrid().getName()); podGeoCodingElement.addContent(tpgLonElement); return podGeoCodingElement; } }
private static void addGridNameRefs(Product product, String namePrefix, List<String> list) { for (int j = 0; j < product.getNumTiePointGrids(); j++) { TiePointGrid grid = product.getTiePointGridAt(j); list.add(namePrefix + grid.getName()); } }
@Override public void visit(TiePointGrid grid) { visitedList.add(grid.getName()); }
ExpectedTiePointGrid(TiePointGrid tiePointGrid, Random random) { this(); this.name = tiePointGrid.getName(); this.description = tiePointGrid.getDescription(); this.offsetX = String.valueOf(tiePointGrid.getOffsetX()); this.offsetY = String.valueOf(tiePointGrid.getOffsetY()); this.subSamplingX = String.valueOf(tiePointGrid.getSubSamplingX()); this.subSamplingY = String.valueOf(tiePointGrid.getSubSamplingY()); expectedPixels = createExpectedPixels(tiePointGrid, random); }
private void writeGeoCoding(final TiePointGeoCoding geoCoding) throws IOException { final int groupID = createH5G(_fileID, "geo_coding"); try { createScalarAttribute(groupID, "java_class_name", TiePointGeoCoding.class.getName()); createScalarAttribute(groupID, "lat_grid", geoCoding.getLatGrid().getName()); createScalarAttribute(groupID, "lon_grid", geoCoding.getLonGrid().getName()); } finally { closeH5G(groupID); } }
@Override public String[] getRasterDataNodeNamesToWrite() { Band[] selectedBands = strategy.getSelectedBands(); TiePointGrid[] selectedTiePointGrids = strategy.getSelectedTiePointGrids(); String[] nodeNames = new String[selectedBands.length + selectedTiePointGrids.length]; for (int i = 0; i < selectedBands.length; i++) { nodeNames[i] = selectedBands[i].getName(); } for (int i = 0; i < selectedTiePointGrids.length; i++) { nodeNames[selectedBands.length + i] = selectedTiePointGrids[i].getName(); } return nodeNames; } }
private boolean createGeocoding(Scene destScene) { final String latGridName = latgrid.getName(); final String lonGridName = lonGrid.getName(); final TiePointGrid latGrid = destScene.getProduct().getTiePointGrid(latGridName); final TiePointGrid lonGrid = destScene.getProduct().getTiePointGrid(lonGridName); if (latGrid != null && lonGrid != null) { destScene.setGeoCoding(new ModisTiePointGeoCoding(latGrid, lonGrid, getDatum())); return true; } return false; }
private static void registerTiePointGridSymbols(WritableNamespace namespace, Product product, String namePrefix) { for (int i = 0; i < product.getNumTiePointGrids(); i++) { final TiePointGrid grid = product.getTiePointGridAt(i); final String symbolName = namePrefix + grid.getName(); namespace.registerSymbol(new RasterDataSymbol(symbolName, grid, RasterDataSymbol.GEOPHYSICAL)); } }
private void resetTiePointGridTableModel() { tiePointModel.clear(); if (currentRaster != null) { final int numTiePointGrids = currentProduct.getNumTiePointGrids(); for (int i = 0; i < numTiePointGrids; i++) { final TiePointGrid tiePointGrid = currentProduct.getTiePointGridAt(i); tiePointModel.addRow(tiePointGrid.getName(), "", tiePointGrid.getUnit()); } } }
@Override public void preEncode(ProfileWriteContext ctx, Product p) throws IOException { super.preEncode(ctx, p); final GeoCoding geoCoding = p.getGeoCoding(); if (geoCoding instanceof TiePointGeoCoding) { final TiePointGeoCoding tpGC = (TiePointGeoCoding) geoCoding; final String[] names = new String[2]; names[LON_INDEX] = tpGC.getLonGrid().getName(); names[LAT_INDEX] = tpGC.getLatGrid().getName(); final String value = StringUtils.arrayToString(names, " "); ctx.getNetcdfFileWriteable().addGlobalAttribute(TIEPOINT_COORDINATES, value); } else { if (geoCoding instanceof CrsGeoCoding) { addWktAsVariable(ctx.getNetcdfFileWriteable(), geoCoding); } } }
private FileImageInputStream createInputStream(TiePointGrid grid) { File tiePointGridDir = new File(createDataDir(), DimapProductConstants.TIE_POINT_GRID_DIR_NAME); File file = new File(tiePointGridDir, grid.getName() + DimapProductConstants.IMAGE_FILE_EXTENSION); assertEquals(true, file.exists()); FileImageInputStream inputStream = null; try { inputStream = new FileImageInputStream(file); } catch (FileNotFoundException e) { fail("FileNotFoundException not expected"); } catch (IOException e) { fail("IOException not expected"); } return inputStream; }
@Override public String getColumnName(int columnIndex) { if (columnIndex < getStandardColumnNames().length) { return getStandardColumnNames()[columnIndex]; } int newIndex = columnIndex - getStandardColumnNames().length; if (newIndex < getNumSelectedBands()) { return selectedBands[newIndex].getName(); } newIndex -= getNumSelectedBands(); if (selectedGrids != null && newIndex < selectedGrids.length) { return selectedGrids[newIndex].getName(); } return "?"; }
private void checkGeoCoding(final GeoCoding geoCoding) { if (geoCoding instanceof TiePointGeoCoding) { final TiePointGeoCoding gc = (TiePointGeoCoding) geoCoding; Guardian.assertSame("gc.getLatGrid()", gc.getLatGrid(), getTiePointGrid(gc.getLatGrid().getName())); Guardian.assertSame("gc.getLonGrid()", gc.getLonGrid(), getTiePointGrid(gc.getLonGrid().getName())); } else if (geoCoding instanceof MapGeoCoding) { final MapGeoCoding gc = (MapGeoCoding) geoCoding; final MapInfo mapInfo = gc.getMapInfo(); Guardian.assertNotNull("mapInfo", mapInfo); Guardian.assertEquals("mapInfo.getSceneWidth()", mapInfo.getSceneWidth(), getSceneRasterWidth()); Guardian.assertEquals("mapInfo.getSceneHeight()", mapInfo.getSceneHeight(), getSceneRasterHeight()); } }
public static TiePointGrid createZenithFromElevationAngleTiePointGrid(TiePointGrid elevationAngleGrid) { final float[] elevationAngles = elevationAngleGrid.getTiePoints(); final float[] zenithAngles = new float[elevationAngles.length]; for (int i = 0; i < zenithAngles.length; i++) { zenithAngles[i] = 90.0f - elevationAngles[i]; } return new TiePointGrid(elevationAngleGrid.getName(), elevationAngleGrid.getRasterWidth(), elevationAngleGrid.getRasterHeight(), elevationAngleGrid.getOffsetX(), elevationAngleGrid.getOffsetY(), elevationAngleGrid.getSubSamplingX(), elevationAngleGrid.getSubSamplingY(), zenithAngles); }
public TiePointGrid cloneTiePointGrid() { final float[] srcTiePoints = this.getTiePoints(); final float[] destTiePoints = new float[srcTiePoints.length]; System.arraycopy(srcTiePoints, 0, destTiePoints, 0, srcTiePoints.length); TiePointGrid clone = new TiePointGrid(this.getName(), this.getRasterWidth(), this.getRasterHeight(), this.getOffsetX(), this.getOffsetY(), this.getSubSamplingX(), this.getSubSamplingY(), destTiePoints, this.getDiscontinuity()); clone.setUnit(getUnit()); clone.setDescription(getDescription()); return clone; }