public PinManagerToolView() { super(PinDescriptor.getInstance(), new TableModelFactory() { @Override public PinTableModel createTableModel(PlacemarkDescriptor placemarkDescriptor, Product product, Band[] selectedBands, TiePointGrid[] selectedGrids) { return new PinTableModel(placemarkDescriptor, product, selectedBands, selectedGrids); } }); } }
@Test public void testReadPlacemarkTextFileWithDateTime() throws Exception { StringWriter writer = new StringWriter(WRITER_INITIAL_SIZE); PinDescriptor pinDescriptor = PinDescriptor.getInstance(); List<Placemark> expectedPlacemarks = createPlacemarks(pinDescriptor, GEO_CODING, DATA_BOUNDS); String[] stdColumnName = {"X", "Y", "Lon", "Lat", "Label"}; PlacemarkIO.writePlacemarksWithAdditionalData(writer, pinDescriptor.getRoleLabel(), "ProductName", expectedPlacemarks, valuesList, stdColumnName, addColumnName); String output = writer.toString();
@Test public void testSetUserData() throws Exception { testSetUserDataOf(new PinDescriptor(), "org.esa.beam.framework.datamodel.PinDescriptor"); testSetUserDataOf(new GcpDescriptor(), "org.esa.beam.framework.datamodel.GcpDescriptor"); testSetUserDataOf(new TrackPointDescriptor(), "org.esa.beam.framework.datamodel.TrackPointDescriptor"); testSetUserDataOf(new GeometryDescriptor(), "org.esa.beam.framework.datamodel.GeometryDescriptor"); SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("Horst"); builder.setDefaultGeometry("the_geom"); builder.add("the_geom", Point.class); SimpleFeatureType featureType = builder.buildFeatureType(); testSetUserDataOf(new GenericPlacemarkDescriptor(featureType), "org.esa.beam.framework.datamodel.GenericPlacemarkDescriptor"); }
@Test public void testReadWritePlacemarksTextFileWithAdditionalData() throws Exception { StringWriter writer = new StringWriter(WRITER_INITIAL_SIZE); PinDescriptor pinDescriptor = PinDescriptor.getInstance(); List<Placemark> expectedPlacemarks = createPlacemarks(pinDescriptor, GEO_CODING, DATA_BOUNDS); String[] stdColumnName = {"X", "Y", "Lon", "Lat", "Label"}; PlacemarkIO.writePlacemarksWithAdditionalData(writer, pinDescriptor.getRoleLabel(), "ProductName", expectedPlacemarks, valuesList, stdColumnName, addColumnName); String output = writer.toString();
public InsertPinInteractor() { super(PinDescriptor.getInstance()); } }
CoordinateTableModel() { super(PinDescriptor.getInstance(), null, null, null); }
@Deprecated static void addPins(Document dom, Product product) { Element groupElement = dom.getRootElement().getChild(DimapProductConstants.TAG_PIN_GROUP); List elements; if (groupElement != null) { elements = groupElement.getChildren(DimapProductConstants.TAG_PLACEMARK); } else { // get pins of old DIMAP files prior version 2.3 elements = dom.getRootElement().getChildren(DimapProductConstants.TAG_PIN); } for (Object elementObj : elements) { final Element element = (Element) elementObj; final Placemark placemark = PlacemarkIO.createPlacemark(element, PinDescriptor.getInstance(), product.getGeoCoding()); if (placemark != null) { product.getPinGroup().add(placemark); } } }
private Placemark createPlacemark(String name, PixelPos pixelPos, GeoPos geoPos) { return Placemark.createPointPlacemark(PinDescriptor.getInstance(), name, "", "", pixelPos, geoPos, null); } }
@Test public void testPinDescriptorIsRegistered() throws Exception { assertNotNull(PinDescriptor.getInstance()); assertEquals(PinDescriptor.class, PinDescriptor.getInstance().getClass()); }
try { reader = new FileReader(selectedFile); final List<Placemark> placemarks = PlacemarkIO.readPlacemarks(reader, null, PinDescriptor.getInstance()); for (Placemark placemark : placemarks) { tableModel.addPlacemark(placemark);
private List<Coordinate> extractCoordinates(File coordinatesFile) { final List<Coordinate> extractedCoordinates = new ArrayList<>(); FileReader fileReader = null; try { fileReader = new FileReader(coordinatesFile); final List<Placemark> pins = PlacemarkIO.readPlacemarks(fileReader, null, // no GeoCoding needed PinDescriptor.getInstance()); for (Placemark pin : pins) { final GeoPos geoPos = pin.getGeoPos(); if (geoPos != null) { final Date dateTimeValue = (Date) pin.getFeature().getAttribute(Placemark.PROPERTY_NAME_DATETIME); final Coordinate coordinate = new Coordinate(pin.getName(), geoPos.lat, geoPos.lon, dateTimeValue); extractedCoordinates.add(coordinate); } } } catch (IOException cause) { throw new OperatorException(cause); } finally { if (fileReader != null) { try { fileReader.close(); } catch (IOException ignored) { } } } return extractedCoordinates; }
private Placemark createDummyPin(String name) { return Placemark.createPointPlacemark(PinDescriptor.getInstance(), name, "", "", new PixelPos(0.5f, 0.5f), null, null); }
@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); } }
@Test public void testReadWritePinXmlFile() throws Exception { testReadWritePlacemarkXmlFile(PinDescriptor.getInstance()); }
@Test public void testGetInstance() throws Exception { assertNotNull(instance); assertSame(instance, PinDescriptor.getInstance()); assertSame(PinDescriptor.class, instance.getClass()); }
@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.setGeoCoding(geoCoding); placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "P1", "L", "", new PixelPos(1.0f, 1.0f), null, product.getGeoCoding()); product.getPinGroup().add(placemark); }
public void testWriteXML_IndentIsSmallerThanZero() { Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "pinName", "pinLabel", "", null, new GeoPos(), product.getGeoCoding()); try { int indent = -1; PlacemarkIO.writeXML(placemark, new XmlWriter(new StringWriter(), false), indent); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected IllegalArgumentException } catch (Exception e) { fail("IllegalArgumentException expected"); } }
@Test public void testReadMinimalPlacemarkTextFile() throws Exception { testReadMinimalPlacemarkTextFile(GcpDescriptor.getInstance()); testReadMinimalPlacemarkTextFile(PinDescriptor.getInstance()); }
public static void main(String[] args) throws TransformException, FactoryException { Product product1 = new Product("A", "B", 360, 180); product1.setGeoCoding(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.getGeoCoding()); product1.getPinGroup().add(pin1); showEditPlacemarkDialog(null, product1, pin1, descriptor); } }
@Test public void testMaskIsNotAddedWhenPinIsAddedForTheSecondTime() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getPinGroup().add(Placemark.createPointPlacemark(PinDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); p.getPinGroup().add(Placemark.createPointPlacemark(PinDescriptor.getInstance(), "b", "b", "b", new PixelPos(), new GeoPos(), null)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("pins")); }