@Override public void redo() throws CannotRedoException { super.redo(); product.setSceneGeoCoding(pixelGeoCoding); }
@Override public void undo() throws CannotUndoException { super.undo(); product.setSceneGeoCoding(pixelGeoCoding); }
@Override protected void addGeoCoding(final Product product) { try { Product imageProduct = ProductIO.readProduct(imageFile); if (imageProduct != null) { product.setSceneGeoCoding(imageProduct.getSceneGeoCoding()); } } catch (IOException e) { //e.printStackTrace(); } }
@Override public void redo() throws CannotRedoException { super.redo(); if (product.getSceneGeoCoding() == pixelGeoCoding) { product.setSceneGeoCoding(pixelGeoCoding.getPixelPosEstimator()); } }
@Override public void undo() throws CannotUndoException { super.undo(); if (product.getSceneGeoCoding() == pixelGeoCoding) { product.setSceneGeoCoding(pixelGeoCoding.getPixelPosEstimator()); } }
@Override protected void done() { final GcpGeoCoding gcpGeoCoding; try { gcpGeoCoding = get(); product.setSceneGeoCoding(gcpGeoCoding); updateUIState(); } catch (InterruptedException e) { Debug.trace(e); } catch (ExecutionException e) { Debug.trace(e.getCause()); } } };
public static void setTiePointGeoCoding(final Product product) { TiePointGrid lonGrid = null, latGrid = null; for (String lonStr : NetcdfConstants.LON_VAR_NAMES) { lonGrid = product.getTiePointGrid(lonStr); if (lonGrid != null) break; } for (String latStr : NetcdfConstants.LAT_VAR_NAMES) { latGrid = product.getTiePointGrid(latStr); if (latGrid != null) break; } if (latGrid != null && lonGrid != null) { final TiePointGeoCoding tpGeoCoding = new TiePointGeoCoding(latGrid, lonGrid); product.setSceneGeoCoding(tpGeoCoding); } }
private void detachGeoCoding(Product product) { if (product.getSceneGeoCoding() instanceof GcpGeoCoding) { GeoCoding gc = ((GcpGeoCoding) product.getSceneGeoCoding()).getOriginalGeoCoding(); product.setSceneGeoCoding(gc); } updateUIState(); }
@BeforeClass public static void setUpTestClass() throws Exception { product = new Product("world", "myWorld", 20, 10); product.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 20, 10, -180, 90, 18, 18, 0.0, 0.0)); File tempTempFile = File.createTempFile("temp", null); tempDir = new File(tempTempFile.getParentFile(), "ExportGeometryActionTest"); tempDir.mkdir(); tempTempFile.delete(); }
@Override protected Void doInBackground(ProgressMonitor pm) throws Exception { final BasicPixelGeoCoding pixelGeoCoding = GeoCodingFactory.createPixelGeoCoding(latBand, lonBand, validMask, searchRadius, pm); product.setSceneGeoCoding(pixelGeoCoding); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(new UndoableAttachGeoCoding<>(product, pixelGeoCoding)); } return null; }
public static Product createProduct4() { Product product = new Product("Test_Product_4", "Test_Type_4", 512, 512); product.getMetadataRoot().addElement(new MetadataElement("Global_Attributes")); product.getMetadataRoot().addElement(new MetadataElement("Local_Attributes")); product.setModified(false); double sx = 10.0 / product.getSceneRasterWidth(); VirtualBand band4 = new VirtualBand("Band_4", ProductData.TYPE_FLOAT64, 512, 512, "cos(ampl((X-256)/100, (Y-256)/100))"); product.addBand(band4); AffineTransform at4 = new AffineTransform(); at4.scale(0.5 * sx, 0.5 * sx); at4.rotate(-0.2, 5.0, 5.0); at4.translate(256, 256); product.setSceneGeoCoding(new ATGeoCoding(at4)); return product; }
@Override protected Throwable doInBackground() throws Exception { try { GeoCoding geoCoding = product.getSceneGeoCoding(); if (geoCoding instanceof BasicPixelGeoCoding) { final BasicPixelGeoCoding pixelGeoCoding = (BasicPixelGeoCoding) geoCoding; final GeoCoding delegate = pixelGeoCoding.getPixelPosEstimator(); product.setSceneGeoCoding(delegate); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(new UndoableDetachGeoCoding<>(product, pixelGeoCoding)); } } } catch (Throwable e) { return e; } return null; }
private void initProductTiePointGeoCoding(ImageMetadata imageMetadata, Product product) { float[][] cornerLonsLats = imageMetadata.getCornerLonsLats(); int sceneWidth = product.getSceneRasterWidth(); int sceneHeight = product.getSceneRasterHeight(); TiePointGrid latGrid = createTiePointGrid("latitude", 2, 2, 0, 0, sceneWidth , sceneHeight, cornerLonsLats[1]); product.addTiePointGrid(latGrid); TiePointGrid lonGrid = createTiePointGrid("longitude", 2, 2, 0, 0, sceneWidth, sceneHeight, cornerLonsLats[0]); product.addTiePointGrid(lonGrid); product.setSceneGeoCoding(new TiePointGeoCoding(latGrid, lonGrid)); }
private void initProductTiePointGeoCoding(ImageMetadata imageMetadata, Product product) { float[][] cornerLonsLats = imageMetadata.getCornerLonsLats(); int sceneWidth = product.getSceneRasterWidth(); int sceneHeight = product.getSceneRasterHeight(); TiePointGrid latGrid = createTiePointGrid("latitude", 2, 2, 0, 0, sceneWidth , sceneHeight, cornerLonsLats[1]); product.addTiePointGrid(latGrid); TiePointGrid lonGrid = createTiePointGrid("longitude", 2, 2, 0, 0, sceneWidth, sceneHeight, cornerLonsLats[0]); product.addTiePointGrid(lonGrid); product.setSceneGeoCoding(new TiePointGeoCoding(latGrid, lonGrid)); }
@Before public void setup() throws TransformException, FactoryException { final AffineTransform i2m = new AffineTransform(); i2m.scale(2.0, 2.0); final GeoCoding geoCoding = new CrsGeoCoding(DefaultGeographicCRS.WGS84, new Rectangle(0, 0, 10, 10), i2m); final Product product = new Product("P", "T", 10, 10); product.setSceneGeoCoding(geoCoding); placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "P1", "L", "", new PixelPos(1.0f, 1.0f), null, product.getSceneGeoCoding()); product.getPinGroup().add(placemark); }
private void initGeoCoding(Product product) { TiePointGrid latGrid = addTiePointGrid(product.getSceneRasterWidth(), product.getSceneRasterHeight(), product, "latitude", metadata.getCornersLatitudes()); TiePointGrid lonGrid = addTiePointGrid(product.getSceneRasterWidth(), product.getSceneRasterHeight(), product, "longitude", metadata.getCornersLongitudes()); GeoCoding geoCoding = new TiePointGeoCoding(latGrid, lonGrid); product.setSceneGeoCoding(geoCoding); }
public static void main(String[] args) throws TransformException, FactoryException { Product product1 = new Product("A", "B", 360, 180); product1.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 360, 180, -180.0, 90.0, 1.0, 1.0, 0.0, 0.0)); PinDescriptor descriptor = PinDescriptor.getInstance(); Placemark pin1 = Placemark.createPointPlacemark(descriptor, "pin_1", "Pin 1", "Schnatter!", new PixelPos(0, 0), new GeoPos(), product1.getSceneGeoCoding()); product1.getPinGroup().add(pin1); showEditPlacemarkDialog(null, product1, pin1, descriptor); } }
/** * Creates geo-coding based on latitude/longitude {@code TiePointGrid}s</li> * * @param k2Metadata Kompsat2Metadata parameter * @param product Product to add TiePointGrid and TiePointGridGeoCoding */ private void initProductTiePointGeoCoding(Kompsat2Metadata k2Metadata, Product product) { float[][] cornerLonsLats = k2Metadata.getMetadataComponent().getTiePointGridPoints(); int sceneWidth = product.getSceneRasterWidth(); int sceneHeight = product.getSceneRasterHeight(); TiePointGrid latGrid = createTiePointGrid(Kompsat2Constants.LAT_DS_NAME, 2, 2, 0, 0, sceneWidth , sceneHeight, cornerLonsLats[0]); product.addTiePointGrid(latGrid); TiePointGrid lonGrid = createTiePointGrid(Kompsat2Constants.LON_DS_NAME, 2, 2, 0, 0, sceneWidth, sceneHeight, cornerLonsLats[1]); product.addTiePointGrid(lonGrid); if (latGrid != null && lonGrid != null) { product.setSceneGeoCoding(new TiePointGeoCoding(latGrid, lonGrid)); } }
private void initTiePointGeoCoding(Product product) { TiePoint[] tiePoints = imageMetadata.getTiePoints(); if (tiePoints != null && tiePoints.length == 4) { float[] latPoints = new float[tiePoints.length]; float[] lonPoints = new float[tiePoints.length]; for (int i = 0; i < tiePoints.length; i++) { latPoints[(i != 2 ? (i != 3 ? i : 2) : 3)] = (float) tiePoints[i].getValueAt(4); lonPoints[(i != 2 ? (i != 3 ? i : 2) : 3)] = (float) tiePoints[i].getValueAt(3); } TiePointGrid latGrid = createTiePointGrid("latitude", 2, 2, 0, 0, metadata.getRasterWidth(), metadata.getRasterHeight(), latPoints); product.addTiePointGrid(latGrid); TiePointGrid lonGrid = createTiePointGrid("longitude", 2, 2, 0, 0, metadata.getRasterWidth(), metadata.getRasterHeight(), lonPoints); product.addTiePointGrid(lonGrid); GeoCoding geoCoding = new TiePointGeoCoding(latGrid, lonGrid); product.setSceneGeoCoding(geoCoding); } }
public static Product createProduct5() { try { Product product = new Product("Test_Product_5_CRS", "Test_Type_5_CRS", 512, 512); product.getMetadataRoot().addElement(new MetadataElement("Global_Attributes")); product.getMetadataRoot().addElement(new MetadataElement("Local_Attributes")); product.setModified(false); product.addBand("Band_A", "sin(4 * PI * sqrt( sq(X/1000.0 - 1) + sq(Y/500.0 - 1) ))"); product.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 512, 512, 0, 10, 1, 1)); final String b_expression = "sin(4 * PI * sqrt( 2.0 * abs(X/1000.0 * Y/500.0) ))"; final VirtualBand band_b = new VirtualBand("Band_B", ProductData.TYPE_FLOAT32, 1024, 256, b_expression); band_b.setGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 1024, 256, 0, 10, 0.5, 2.0)); band_b.setNoDataValueUsed(true); product.addBand(band_b); return product; } catch (FactoryException | TransformException e) { return null; } }