@Override public void registerRelation(Placemark placemark, GeoPos insituGeopos) { pinRelationMap.put(placemark, insituGeopos); tsProduct.getPinGroup().add(placemark); }
@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); } } }
@Deprecated static void addGcps(Document dom, Product product) { Element groupElement = dom.getRootElement().getChild(DimapProductConstants.TAG_GCP_GROUP); List elements; if (groupElement != null) { elements = groupElement.getChildren(DimapProductConstants.TAG_PLACEMARK); } else { elements = Collections.EMPTY_LIST; } for (Object elementObj : elements) { final Element element = (Element) elementObj; final Placemark placemark = PlacemarkIO.createPlacemark(element, GcpDescriptor.getInstance(), product.getGeoCoding()); if (placemark != null) { product.getGcpGroup().add(placemark); } } }
private void generatePlacemarkForFeature(SimpleFeature feature) { final Placemark placemark = getPlacemarkGroup().getPlacemark(feature); if (placemark == null) { placemarkGroup.add(placemarkDescriptor.createPlacemark(feature)); } }
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]; final PixelPos pixelPos = new PixelPos(view.getCurrentPixelX() + 0.5f, view.getCurrentPixelY() + 0.5f); final Placemark newPlacemark = Placemark.createPointPlacemark(placemarkDescriptor, name, label, "", pixelPos, null, product.getGeoCoding()); getPlacemarkGroup(product).add(newPlacemark); }
@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 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 testChangingFeature() { placemarkGroup.add(createPlacemark("p1", new PixelPos(3, 1), new GeoPos(12, 34))); placemarkGroup.add(createPlacemark("p2", new PixelPos(5, 4), new GeoPos(16, 48))); placemarkGroup.add(createPlacemark("p3", new PixelPos(6, 2), new GeoPos(-45, 80))); assertAreEqual(placemarkGroup, pinFeatureCollection); final CoordinateArraySequence coordinates = new CoordinateArraySequence( new Coordinate[]{new Coordinate(-30, 70)}); final SimpleFeature changedFeature = placemarkGroup.get(2).getFeature(); changedFeature.setDefaultGeometry(new Point(coordinates, new GeometryFactory())); assertAreEqual(placemarkGroup, pinFeatureCollection); final SimpleFeature[] features = pinFeatureCollection.toArray(new SimpleFeature[pinFeatureCollection.size()]); assertEquals(changedFeature.getDefaultGeometry(), features[2].getDefaultGeometry()); }
@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")); }
@Test public void testMaskIsNotAddedWhenGcpIsAddedForTheSecondTime() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getGcpGroup().add(Placemark.createPointPlacemark(GcpDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); p.getGcpGroup().add(Placemark.createPointPlacemark(GcpDescriptor.getInstance(), "b", "b", "b", new PixelPos(), new GeoPos(), null)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("ground_control_points")); }
@Test public void testManipulatingPinGroup() { assertAreEqual(placemarkGroup, pinFeatureCollection); placemarkGroup.add(createPlacemark("p1", new PixelPos(3, 1), new GeoPos(12, 34))); assertAreEqual(placemarkGroup, pinFeatureCollection); final Placemark placemark2 = createPlacemark("p2", new PixelPos(5, 4), new GeoPos(16, 48)); placemarkGroup.add(placemark2); assertAreEqual(placemarkGroup, pinFeatureCollection); placemarkGroup.add(createPlacemark("p3", new PixelPos(6, 2), new GeoPos(-45, 80))); assertAreEqual(placemarkGroup, pinFeatureCollection); placemarkGroup.remove(placemark2); assertAreEqual(placemarkGroup, pinFeatureCollection); placemarkGroup.add(1, createPlacemark("p4", new PixelPos(6, 3), new GeoPos(-60, 47))); assertAreEqual(placemarkGroup, pinFeatureCollection); }
@Test public void testMaskIsAddedWhenPinIsAddedForTheFirstTime() 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)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("pins")); }
@Test public void testMaskIsAddedWhenGcpIsAddedForTheFirstTime() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getGcpGroup().add(Placemark.createPointPlacemark(GcpDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("ground_control_points")); }
@Test public void testMaskIsRemovedWhenAllGcpsAreRemoved() throws Exception { final Product p = new Product("P", "T", 1, 1); p.getGcpGroup().add(Placemark.createPointPlacemark(GcpDescriptor.getInstance(), "a", "a", "a", new PixelPos(), new GeoPos(), null)); p.getGcpGroup().removeAll(); assertEquals(0, p.getMaskGroup().getNodeCount()); }
@Test public void testMaskIsRemovedWhenAllPinsAreRemoved() 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().removeAll(); assertEquals(0, p.getMaskGroup().getNodeCount()); }
@Override public void computeTile(Band band, Tile targetTile, ProgressMonitor pm) { // Fill the tile with the constant sample value 12345 // for (Pos pos : targetTile) { targetTile.setSample(pos.x, pos.y, 12345); } // Set a pin, so that we can test that the header is rewritten after // a data model change. // final int minX = targetTile.getMinX(); final int minY = targetTile.getMinY(); Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), band.getName() + "-" + minX + "-" + minY, "label", "descr", new PixelPos(minX, minY), null, targetProduct.getGeoCoding()); targetProduct.getPinGroup().add(placemark); System.out.println("placemark = " + placemark.getName()); }
@Test public void testCopyPlacemarkGroups() throws IOException { final PlacemarkDescriptor pinDescriptor = PinDescriptor.getInstance(); final Placemark pin = Placemark.createPointPlacemark(pinDescriptor, "P1", "", "", new PixelPos(1.5f, 1.5f), null, sourceProduct.getGeoCoding()); final Placemark gcp = Placemark.createPointPlacemark(pinDescriptor, "G1", "", "", new PixelPos(2.5f, 2.5f), null, sourceProduct.getGeoCoding()); sourceProduct.getPinGroup().add(pin); sourceProduct.getGcpGroup().add(gcp); parameterMap.put("crs", WGS84_CODE); Product targetProduct = createReprojectedProduct(); assertEquals(1, targetProduct.getPinGroup().getNodeCount()); assertEquals(1, targetProduct.getGcpGroup().getNodeCount()); final Placemark pin2 = targetProduct.getPinGroup().get(0); final Placemark gcp2 = targetProduct.getGcpGroup().get(0); assertEquals("P1", pin2.getName()); assertEquals("G1", gcp2.getName()); assertEquals(pin.getGeoPos(), pin2.getGeoPos()); assertEquals(gcp.getGeoPos(), gcp2.getGeoPos()); assertNotNull(pin2.getPixelPos()); assertNotNull(gcp2.getPixelPos()); } }
if (!belongsToProduct) { placemarkDescriptor.getPlacemarkGroup(product).add(placemark);
@Test public void testAddingRemovingProductNodeGroups() { final Product product = createDummyProduct("x1"); productManager.addProduct(product); AbstractTN rootNode = treeModel.getRoot(); ProductTN productTN = (ProductTN) treeModel.getChild(rootNode, 0); assertEquals(0, treeModel.getChildCount(productTN)); // 1 node: "Bands" product.addBand("b1", ProductData.TYPE_INT8); assertEquals(1, treeModel.getChildCount(productTN)); product.addBand("b2", ProductData.TYPE_INT8); assertEquals(1, treeModel.getChildCount(productTN)); // 2 nodes now: "Bands" and "Vector Data" (with "Pins") final Placemark pin1 = createDummyPin("p1"); product.getPinGroup().add(pin1); assertEquals(2, treeModel.getChildCount(productTN)); // Still 2 nodes: "Bands" and "Vector Data" (with "Pins", but "v1" is empty) final VectorDataNode vec1 = new VectorDataNode("v1", PlainFeatureFactory.createDefaultFeatureType()); product.getVectorDataGroup().add(vec1); assertEquals(2, treeModel.getChildCount(productTN)); // When we remove "pin1", "Vector Data" stays away, because "Pins" is now empty but there is still "vec1" product.getPinGroup().remove(pin1); assertEquals(2, treeModel.getChildCount(productTN)); // Removing "vec1" should not change current state product.getVectorDataGroup().remove(vec1); assertEquals(1, treeModel.getChildCount(productTN)); }