protected void setPixelPosX(Object value, Placemark placemark) { double pixelY = placemark.getPixelPos() == null ? -1 : placemark.getPixelPos().y; placemark.setPixelPos(new PixelPos((Double) value, pixelY)); }
protected void setPixelPosY(Object value, Placemark placemark) { double pixelX = placemark.getPixelPos() == null ? -1 : placemark.getPixelPos().x; placemark.setPixelPos(new PixelPos(pixelX, (Double) value)); }
/** * Get GCP coordinates for master and slave bands. * * @param masterGCPGroup The master GCPs. */ private void getMasterAndSlaveGCPCoordinates(final ProductNodeGroup<Placemark> masterGCPGroup) { masterGCPCoords = new float[2 * numValidGCPs]; slaveGCPCoords = new float[2 * numValidGCPs]; for (int i = 0; i < numValidGCPs; ++i) { final Placemark sPin = slaveGCPList.get(i); final PixelPos sGCPPos = sPin.getPixelPos(); //System.out.println("WARP: slave gcp[" + i + "] = " + "(" + sGCPPos.x + "," + sGCPPos.y + ")"); final Placemark mPin = masterGCPGroup.get(sPin.getName()); final PixelPos mGCPPos = mPin.getPixelPos(); //System.out.println("WARP: master gcp[" + i + "] = " + "(" + mGCPPos.x + "," + mGCPPos.y + ")"); final int j = 2 * i; masterGCPCoords[j] = (float) mGCPPos.x; masterGCPCoords[j + 1] = (float) mGCPPos.y; slaveGCPCoords[j] = (float) sGCPPos.x; slaveGCPCoords[j + 1] = (float) sGCPPos.y; } }
private static Placemark[] getValidGcps(ProductNodeGroup<Placemark> gcpGroup) { final List<Placemark> gcpList = new ArrayList<Placemark>(gcpGroup.getNodeCount()); for (int i = 0; i < gcpGroup.getNodeCount(); i++) { final Placemark p = gcpGroup.get(i); final PixelPos pixelPos = p.getPixelPos(); final GeoPos geoPos = p.getGeoPos(); if (pixelPos != null && pixelPos.isValid() && geoPos != null && geoPos.isValid()) { gcpList.add(p); } } return gcpList.toArray(new Placemark[gcpList.size()]); }
private static boolean isValid(Placemark p) { final PixelPos pixelPos = p.getPixelPos(); final GeoPos geoPos = p.getGeoPos(); return pixelPos != null && pixelPos.isValid() && geoPos != null && geoPos.isValid(); }
public void readValues() { Debug.assertNotNull(bands); for (int i = 0; i < bands.length; i++) { final Band band = bands[i]; if (placemark != null) { // position of placemark is given in image (L0) coordinates // we have to transform them to the current level final MultiLevelModel multiLevelModel = band.getMultiLevelModel(); final AffineTransform i2mTransform = multiLevelModel.getImageToModelTransform(0); final AffineTransform m2iTransform = multiLevelModel.getModelToImageTransform(0); final Point2D modelPixel = i2mTransform.transform(placemark.getPixelPos(), null); final Point2D imagePixel = m2iTransform.transform(modelPixel, null); int pixelX = (int) Math.floor(imagePixel.getX()); int pixelY = (int) Math.floor(imagePixel.getY()); energies[i] = getSample(band, pixelX, pixelY, 0); } } IndexValidator validator = new IndexValidator() { @Override public boolean validateIndex(int index) { return energies[index] != bands[index].getGeophysicalNoDataValue(); } }; Range.computeRangeDouble(energies, validator, energyRange, ProgressMonitor.NULL); // no invalidate() call here, SpectrumDiagram does this }
/** * Check if a given master GCP is within the given tile and the GCP imagette is within the image. * * @param mPin The GCP position. * @return flag Return true if the GCP is within the given tile and the GCP imagette is within the image, * false otherwise. */ private boolean checkMasterGCPValidity(final Placemark mPin) throws Exception { final PixelPos pixelPos = mPin.getPixelPos(); if (onlyGCPsOnLand) { double alt = dem.getElevation(mPin.getGeoPos()); if (alt == dem.getDescriptor().getNoDataValue()) return false; } return (pixelPos.x - cHalfWindowWidth + 1 >= 0 && pixelPos.x + cHalfWindowWidth <= sourceImageWidth - 1) && (pixelPos.y - cHalfWindowHeight + 1 >= 0 && pixelPos.y + cHalfWindowHeight <= sourceImageHeight - 1); }
final PixelPos sGCPPos = sPin.getPixelPos(); final PixelPos mGCPPos = mPin.getPixelPos();
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 void writeGcpGeoCoding(GcpGeoCoding gcpGeoCoding, String nodeType) { addEmptyRow(); addRow("The " + nodeType + " uses a geo-coding which is based on ground control points (GCPs)."); addEmptyRow(); ProductNodeGroup<Placemark> gcpGroup = getProduct().getGcpGroup(); addRow("Number Of GCPs", String.valueOf(gcpGroup.getNodeCount())); addRow("Function", String.valueOf(gcpGeoCoding.getMethod())); addRow("Datum", String.valueOf(gcpGeoCoding.getDatum().getName())); addRow("Latitude RMSE", String.valueOf(gcpGeoCoding.getRmseLat())); addRow("Longitude RMSE", String.valueOf(gcpGeoCoding.getRmseLon())); addEmptyRow(); addRow("Table of used GCPs"); Placemark[] gcps = gcpGroup.toArray(new Placemark[0]); addRow("Number", "Label", "X", "Y", "Latitude", "Longitude"); for (int i = 0; i < gcps.length; i++) { Placemark gcp = gcps[i]; PixelPos pixelPos = gcp.getPixelPos(); GeoPos geoPos = gcp.getGeoPos(); addRow(String.valueOf(i), gcp.getLabel(), String.valueOf(pixelPos.getX()), String.valueOf(pixelPos.getY()), geoPos.getLatString(), geoPos.getLonString()); } // setFirstColumnWidth(40); }
private void snapToSelectedPin() { final Placemark pin = currentView != null ? currentView.getSelectedPin() : null; if (pin != null) { //todo [multisize_products] replace this very ugly code by using the scene raster transformer - tf 20151113 PixelPos rasterPos = new PixelPos(); final Point pinSceneCoords = (Point) pin.getFeature().getDefaultGeometry(); final Point2D.Double pinSceneCoordsDouble = new Point2D.Double(pinSceneCoords.getX(), pinSceneCoords.getY()); try { currentView.getRaster().getImageToModelTransform().createInverse().transform(pinSceneCoordsDouble, rasterPos); } catch (NoninvertibleTransformException e) { rasterPos = pin.getPixelPos(); } final int x = MathUtils.floorInt(rasterPos.x); final int y = MathUtils.floorInt(rasterPos.y); pixelInfoView.updatePixelValues(currentView, x, y, 0, true); } else { pixelInfoView.updatePixelValues(currentView, -1, -1, 0, false); } }
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; }
double y = Double.NaN; final PixelPos pixelPos = placemark.getPixelPos(); if (pixelPos != null) { x = pixelPos.x;
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(); } }
@Test public void initialState() { final double x = placemark.getPixelPos().getX(); final double y = placemark.getPixelPos().getY(); assertEquals(1.0, x, 0.0); assertEquals(1.0, y, 0.0); final Point point = (Point) placemark.getFeature().getDefaultGeometry(); assertEquals(2.0, point.getX(), 0.0); assertEquals(2.0, point.getY(), 0.0); final double lon = placemark.getGeoPos().getLon(); final double lat = placemark.getGeoPos().getLat(); assertEquals(2.0, lon, 0.0); assertEquals(2.0, lat, 0.0); }
@Test public void movePinByPixelPosition() { placemark.setPixelPos(new PixelPos(2.0f, 1.0f)); final double x = placemark.getPixelPos().getX(); final double y = placemark.getPixelPos().getY(); assertEquals(2.0, x, 0.0); assertEquals(1.0, y, 0.0); // todo: rq/?? - make asserts successful final Point point = (Point) placemark.getFeature().getDefaultGeometry(); assertEquals(4.0, point.getX(), 0.0); assertEquals(2.0, point.getY(), 0.0); // todo: rq/?? - make asserts successful final double lon = placemark.getGeoPos().getLon(); final double lat = placemark.getGeoPos().getLat(); assertEquals(4.0, lon, 0.0); assertEquals(2.0, lat, 0.0); }
@Test public void movePinByGeometry() { placemark.getFeature().setDefaultGeometry(newPoint(4.0, 2.0)); placemark.getProduct().getVectorDataGroup().get("pins").fireFeaturesChanged(placemark.getFeature()); final Point point = (Point) placemark.getFeature().getDefaultGeometry(); assertEquals(4.0, point.getX(), 0.0); assertEquals(2.0, point.getY(), 0.0); // todo: rq/?? - make asserts successful final double x = placemark.getPixelPos().getX(); final double y = placemark.getPixelPos().getY(); assertEquals(2.0, x, 0.0); assertEquals(1.0, y, 0.0); // todo: rq/?? - make asserts successful final double lon = placemark.getGeoPos().getLon(); final double lat = placemark.getGeoPos().getLat(); assertEquals(4.0, lon, 0.0); assertEquals(2.0, lat, 0.0); }
dialog.setPixelPos(placemark.getPixelPos()); GeoPos geoPos = placemark.getGeoPos(); dialog.setGeoPos(geoPos != null ? geoPos : new GeoPos(Float.NaN, Float.NaN));