private boolean placemarkHasGeoPos(int rowIndex) { return getPlacemarkAt(rowIndex).getGeoPos() != null; } }
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(); }
@Override public void mouseMoved(MouseEvent e) { int rowIndex = placemarkTable.rowAtPoint(e.getPoint()); if (rowIndex != _rowIndex) { _rowIndex = rowIndex; if (_rowIndex >= 0 && _rowIndex < placemarkTable.getRowCount()) { GeoPos geoPos = getPlacemarkAt(placemarkTable.convertRowIndexToModel(_rowIndex)).getGeoPos(); if (geoPos != null) { placemarkTable.setToolTipText(geoPos.getLonString() + " / " + geoPos.getLatString()); } } } }
/** * 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); }
public Coordinate[] getCoordinates() { Coordinate[] coordinates = new Coordinate[coordinateTableModel.getRowCount()]; for (int i = 0; i < coordinateTableModel.getRowCount(); i++) { final Placemark placemark = coordinateTableModel.getPlacemarkAt(i); SimpleFeature feature = placemark.getFeature(); final Date dateTime = (Date) feature.getAttribute(Placemark.PROPERTY_NAME_DATETIME); final Coordinate.OriginalValue[] originalValues = PixExOp.getOriginalValues(feature); if (placemark.getGeoPos() == null) { final Point point = (Point) feature.getDefaultGeometry(); coordinates[i] = new Coordinate(placemark.getName(), point.getY(), point.getX(), dateTime, originalValues); } else { coordinates[i] = new Coordinate(placemark.getName(), placemark.getGeoPos().getLat(), placemark.getGeoPos().getLon(), dateTime, originalValues); } } return coordinates; }
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; }
@Override protected Object getStandardColumnValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: return getPlacemarkAt(rowIndex).getName(); case 1: if (placemarkHasGeoPos(rowIndex)) { return getPlacemarkAt(rowIndex).getGeoPos().getLat(); } return ((Point) getPlacemarkAt(rowIndex).getFeature().getDefaultGeometry()).getY(); case 2: if (placemarkHasGeoPos(rowIndex)) { return getPlacemarkAt(rowIndex).getGeoPos().getLon(); } return ((Point) getPlacemarkAt(rowIndex).getFeature().getDefaultGeometry()).getX(); case 3: return getPlacemarkAt(rowIndex).getFeature().getAttribute(Placemark.PROPERTY_NAME_DATETIME); default: throw new IllegalArgumentException(String.format("Invalid columnIndex = %d", columnIndex)); } }
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; }
@Override public void redo() { placemarkInView.setName(newPlacemark.getName()); placemarkInView.setLabel(newPlacemark.getLabel()); placemarkInView.setDescription(newPlacemark.getDescription()); placemarkInView.setGeoPos(newPlacemark.getGeoPos()); placemarkInView.setStyleCss(newPlacemark.getStyleCss()); }
@Override public void undo() { placemarkInView.setName(oldPlacemark.getName()); placemarkInView.setLabel(oldPlacemark.getLabel()); placemarkInView.setDescription(oldPlacemark.getDescription()); placemarkInView.setGeoPos(oldPlacemark.getGeoPos()); placemarkInView.setStyleCss(oldPlacemark.getStyleCss()); }
@Override public void readValues(final ImageLayer imageLayer, final GeoPos geoPos, final int level) { resetData(); if (placemark != null) { for (Band band : selectedBands) { final int index = getTimeIndex(band); if (index >= 0) { final PixelPos pix = band.getGeoCoding().getPixelPos(placemark.getGeoPos(), null); /*final MultiLevelModel multiLevelModel = ImageManager.getMultiLevelModel(band); final AffineTransform i2mTransform = multiLevelModel.getImageToModelTransform(0); final AffineTransform m2iTransform = multiLevelModel.getModelToImageTransform(level); final Point2D modelPixel = i2mTransform.transform(placemark.getPixelPos(), null); final Point2D imagePixel = m2iTransform.transform(modelPixel, null); final int pixX = (int) Math.floor(imagePixel.getX()); final int pixY = (int) Math.floor(imagePixel.getY()); */ dataPoints[index] = ProductUtils.getGeophysicalSampleAsLong(band, (int) pix.getX(), (int) pix.getY(), level); if (dataPoints[index] == band.getNoDataValue()) { dataPoints[index] = Double.NaN; } } } } Range.computeRangeDouble(dataPoints, IndexValidator.TRUE, dataPointRange, ProgressMonitor.NULL); // no invalidate() call here, SpectrumDiagram does this }
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); }