final Point geometry = geometryFactory.createPoint(toCoordinate(i2m.transform(imagePos, null))); final SimpleFeature feature = PlainFeatureFactory.createPlainFeature(descriptor.getBaseFeatureType(), name, null); feature.setAttribute(Placemark.PROPERTY_NAME_PIXELPOS, geometryFactory.createPoint(toCoordinate(imagePos))); feature.setAttribute(Placemark.PROPERTY_NAME_GEOPOS, geometryFactory.createPoint(toCoordinate(geoPos)));
private void updateDefaultGeometryAttribute(PixelPos pixelPos) { final Product product = getProduct(); final Point2D.Float geometryPoint = new Point2D.Float(pixelPos.x, pixelPos.y); if (product != null) { final AffineTransform i2m = ImageManager.getImageToModelTransform(product.getGeoCoding()); i2m.transform(pixelPos, geometryPoint); } final Point point = (Point) feature.getDefaultGeometry(); point.getCoordinate().setCoordinate(toCoordinate(geometryPoint)); point.geometryChanged(); }
private void setGeoPosAttribute(GeoPos geoPos, boolean updatePixelPos) { final Coordinate newCoordinate = toCoordinate(geoPos); final Coordinate oldCoordinate = getGeoPosAttribute(); if (!ObjectUtils.equalObjects(oldCoordinate, newCoordinate)) { if (oldCoordinate == null) { final GeometryFactory geometryFactory = new GeometryFactory(); setAttributeValue(PROPERTY_NAME_GEOPOS, geometryFactory.createPoint(newCoordinate)); } else if (newCoordinate != null) { final Point point = (Point) getAttributeValue(PROPERTY_NAME_GEOPOS); point.getCoordinate().setCoordinate(newCoordinate); point.geometryChanged(); } if (updatePixelPos && getProduct() != null) { final PixelPos pixelPos = getPixelPos(); descriptor.updatePixelPos(getProduct().getGeoCoding(), geoPos, pixelPos); setPixelPosAttribute(pixelPos, false, true); } fireProductNodeChanged(PROPERTY_NAME_GEOPOS); } }
private void setPixelPosAttribute(PixelPos pixelPos, boolean updateGeoPos, boolean updateDefaultGeometry) { final Coordinate newCoordinate = toCoordinate(pixelPos); final Coordinate oldCoordinate = getPixelPosAttribute(); if (!ObjectUtils.equalObjects(oldCoordinate, newCoordinate)) { if (oldCoordinate == null) { final GeometryFactory geometryFactory = new GeometryFactory(); setAttributeValue(PROPERTY_NAME_PIXELPOS, geometryFactory.createPoint(newCoordinate)); } else { final Point point = (Point) getAttributeValue(PROPERTY_NAME_PIXELPOS); point.getCoordinate().setCoordinate(newCoordinate); point.geometryChanged(); } // Make sure, object is in a consistent state if (updateDefaultGeometry) { updateDefaultGeometryAttribute(pixelPos); } if (updateGeoPos && getProduct() != null) { final GeoPos geoPos = getGeoPos(); descriptor.updateGeoPos(getProduct().getGeoCoding(), pixelPos, geoPos); setGeoPosAttribute(geoPos, false); } fireProductNodeChanged(PROPERTY_NAME_PIXELPOS); } }