@Override public void actionPerformed(ActionEvent e) { final Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "Coord_" + tableModel.getRowCount(), "", "", new PixelPos(), new GeoPos(0, 0), null); tableModel.addPlacemark(placemark); } }
private static void addGCPGrid(final int width, final int height, final int numPins, final ProductNodeGroup<Placemark> group, final GeoCoding targetGeoCoding) { final double ratio = width / (double) height; final double n = Math.sqrt(numPins / ratio); final double m = ratio * n; final double spacingX = width / m; final double spacingY = height / n; final GcpDescriptor gcpDescriptor = GcpDescriptor.getInstance(); group.removeAll(); int pinNumber = group.getNodeCount() + 1; for (double y = spacingY / 2f; y < height; y += spacingY) { for (double x = spacingX / 2f; x < width; x += spacingX) { final String name = PlacemarkNameFactory.createName(gcpDescriptor, pinNumber); final String label = PlacemarkNameFactory.createLabel(gcpDescriptor, pinNumber, true); final Placemark newPin = Placemark.createPointPlacemark(gcpDescriptor, name, label, "", new PixelPos((int) x, (int) y), null, targetGeoCoding); group.add(newPin); ++pinNumber; } } }
@Override public void run() { //System.out.println("Running "+mPin.getName()); boolean getSlaveGCP = getCoarseSlaveGCPPosition(slaveBand1, slaveBand2, mGCPPixelPos, sGCPPixelPos); if (getSlaveGCP && complexCoregistration && applyFineRegistration) { if (inSAROptimized) { getSlaveGCP = getFineOffsets(slaveBand1, slaveBand2, mGCPPixelPos, sGCPPixelPos); } else { getSlaveGCP = getFineSlaveGCPPosition(slaveBand1, slaveBand2, mGCPPixelPos, sGCPPixelPos); } } if (getSlaveGCP) { final Placemark sPin = Placemark.createPointPlacemark( GcpDescriptor.getInstance(), mPin.getName(), mPin.getLabel(), mPin.getDescription(), sGCPPixelPos, mGCPGeoPos, tgtGeoCoding); addPlacemark(sPin); //System.out.println("final "+mPin.getName()+" = " + "(" + sGCPPixelPos.x + "," + sGCPPixelPos.y + ")"); //System.out.println(); } //else { //System.out.println("GCP(" + mPin.getName() + ") is invalid."); //} }
@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); }
@Test public void testWritingShapeFile_Pins() throws Exception { Placemark pin = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "name1", "label1", "", new PixelPos(0, 0), new GeoPos(52.0, 10.0), null); ArrayList<SimpleFeature> features = new ArrayList<>(); features.add(pin.getFeature()); Class<Point> geomType = Point.class; doExportImport(features, geomType); }
UndoablePlacemarkEditingStrategy(Product product, Placemark oldPlacemark, Placemark newPlacemark, PlacemarkDescriptor placemarkDescriptor) { this.product = product; this.oldPlacemark = oldPlacemark; this.newPlacemark = Placemark.createPointPlacemark(newPlacemark.getDescriptor(), newPlacemark.getName(), newPlacemark.getLabel(), newPlacemark.getDescription(), newPlacemark.getPixelPos(), newPlacemark.getGeoPos(), newPlacemark.getProduct().getSceneGeoCoding()); placemarkInView = newPlacemark; this.placemarkDescriptor = placemarkDescriptor; }
private Placemark createTransferrablePlacemark(Placemark placemark, Product product) { Placemark newPlacemark = Placemark.createPointPlacemark(placemark.getDescriptor(), placemark.getName(), placemark.getLabel(), placemark.getDescription(), placemark.getPixelPos(), placemark.getGeoPos(), product.getSceneGeoCoding()); newPlacemark.setStyleCss(placemark.getStyleCss()); return newPlacemark; }
void newPin() { Guardian.assertNotNull("product", product); String[] uniquePinNameAndLabel = PlacemarkNameFactory.createUniqueNameAndLabel(placemarkDescriptor, product); Placemark newPlacemark = Placemark.createPointPlacemark(placemarkDescriptor, uniquePinNameAndLabel[0], uniquePinNameAndLabel[1], "", new PixelPos(0, 0), null, product.getSceneGeoCoding()); if (PlacemarkDialog.showEditPlacemarkDialog( SwingUtilities.getWindowAncestor(this), product, newPlacemark, placemarkDescriptor)) { makePlacemarkNameUnique(newPlacemark); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkInsertion(product, newPlacemark, placemarkDescriptor)); } updateUIState(); } }
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); } }
private void insertPlacemark(ProductSceneView view) { Product product = view.getProduct(); final String[] uniqueNameAndLabel = PlacemarkNameFactory.createUniqueNameAndLabel(placemarkDescriptor, product); final String name = uniqueNameAndLabel[0]; final String label = uniqueNameAndLabel[1]; PixelPos rasterPos = new PixelPos(view.getCurrentPixelX() + 0.5f, view.getCurrentPixelY() + 0.5f); Point2D modelPos = view.getRaster().getImageToModelTransform().transform(rasterPos, new Point2D.Double()); Point2D scenePos = new Point2D.Double(); try { view.getRaster().getModelToSceneTransform().transform(modelPos, scenePos); final AffineTransform sceneToImage = Product.findImageToModelTransform(product.getSceneGeoCoding()).createInverse(); rasterPos = (PixelPos) sceneToImage.transform(modelPos, new PixelPos()); } catch (TransformException | NoninvertibleTransformException e) { Dialogs.showError("Could not place pin in image due to transformation exception: " + e.getMessage()); return; } final Placemark newPlacemark = Placemark.createPointPlacemark(placemarkDescriptor, name, label, "", rasterPos, null, product.getSceneGeoCoding()); PlacemarkGroup placemarkGroup = placemarkDescriptor.getPlacemarkGroup(product); String defaultStyleCss = placemarkGroup.getVectorDataNode().getDefaultStyleCss(); if(newPlacemark.getStyleCss().isEmpty()) { newPlacemark.setStyleCss(defaultStyleCss); } placemarkGroup.add(newPlacemark); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkInsertion(product, newPlacemark, placemarkDescriptor)); } }
void editActivePin() { Guardian.assertNotNull("product", product); Placemark activePlacemark = getSelectedPlacemark(); Placemark originalPlacemark = Placemark.createPointPlacemark(activePlacemark.getDescriptor(), activePlacemark.getName(), activePlacemark.getLabel(), activePlacemark.getDescription(), activePlacemark.getPixelPos(), activePlacemark.getGeoPos(), activePlacemark.getProduct().getSceneGeoCoding()); Guardian.assertNotNull("activePlacemark", activePlacemark); if (PlacemarkDialog.showEditPlacemarkDialog(SwingUtilities.getWindowAncestor(this), product, activePlacemark, placemarkDescriptor)) { makePlacemarkNameUnique(activePlacemark); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkEditing(product, originalPlacemark, activePlacemark, placemarkDescriptor)); } updateUIState(); } }
private void addSlaveGCPs(final PolynomialModel warpData, final String bandName) { final GeoCoding targetGeoCoding = targetProduct.getSceneGeoCoding(); final String newName = excludeMaster ? StackUtils.getBandNameWithoutDate(bandName) : bandName; final ProductNodeGroup<Placemark> targetGCPGroup = GCPManager.instance().getGcpGroup(targetProduct.getBand(newName)); targetGCPGroup.removeAll(); final List<Placemark> slaveGCPList = warpData.getSlaveGCPList(); for (final Placemark sPin : slaveGCPList) { final Placemark tPin = Placemark.createPointPlacemark(GcpDescriptor.getInstance(), sPin.getName(), sPin.getLabel(), sPin.getDescription(), sPin.getPixelPos(), sPin.getGeoPos(), targetGeoCoding); targetGCPGroup.add(tPin); } }
void copyActivePlacemark() { Guardian.assertNotNull("product", product); Placemark activePlacemark = getSelectedPlacemark(); Guardian.assertNotNull("activePlacemark", activePlacemark); Placemark newPlacemark = Placemark.createPointPlacemark(activePlacemark.getDescriptor(), "copy_of_" + activePlacemark.getName(), activePlacemark.getLabel(), activePlacemark.getDescription(), activePlacemark.getPixelPos(), activePlacemark.getGeoPos(), activePlacemark.getProduct().getSceneGeoCoding()); newPlacemark.setStyleCss(activePlacemark.getStyleCss()); if (PlacemarkDialog.showEditPlacemarkDialog( SwingUtilities.getWindowAncestor(this), product, newPlacemark, placemarkDescriptor)) { makePlacemarkNameUnique(newPlacemark); UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product); if (undoManager != null) { undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkCopying(product, newPlacemark, placemarkDescriptor)); } updateUIState(); } }