use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method propertyChange.
@Override
public void propertyChange(final PropertyChangeEvent event) {
super.propertyChange(event);
final String propertyName = event.getPropertyName();
if ("hasChanges".equals(propertyName)) {
final GeoreferencedImage image = getImage();
if (event.getSource() == image) {
image.saveChanges();
}
}
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method zoomToLayer.
@Override
public void zoomToLayer() {
final Project project = getProject();
final GeometryFactory geometryFactory = project.getGeometryFactory();
final BoundingBox layerBoundingBox = getBoundingBox();
BoundingBox boundingBox = layerBoundingBox;
final AffineTransform transform = this.image.getAffineTransformation(layerBoundingBox);
if (!transform.isIdentity()) {
final GeoreferencedImage image = getImage();
final double width = image.getImageWidth() - 1;
final double height = image.getImageHeight() - 1;
final double[] targetCoordinates = MappedLocation.toModelCoordinates(image, layerBoundingBox, true, 0, height, width, height, width, 0, 0, 0, 0, height);
final LineString line = layerBoundingBox.getGeometryFactory().lineString(2, targetCoordinates);
boundingBox = boundingBox.expandToInclude(line);
}
boundingBox = boundingBox.convert(geometryFactory).expandPercent(0.1).clipToCoordinateSystem();
project.setViewBoundingBox(boundingBox);
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method targetPointToSourcePixel.
public Point targetPointToSourcePixel(Point targetPoint) {
final GeoreferencedImage image = getImage();
final BoundingBox boundingBox = getBoundingBox();
targetPoint = targetPoint.convertPoint2d(boundingBox.getGeometryFactory());
final double modelX = targetPoint.getX();
final double modelY = targetPoint.getY();
final double modelDeltaX = modelX - boundingBox.getMinX();
final double modelDeltaY = modelY - boundingBox.getMinY();
final double modelWidth = boundingBox.getWidth();
final double modelHeight = boundingBox.getHeight();
final double xRatio = modelDeltaX / modelWidth;
final double yRatio = modelDeltaY / modelHeight;
final double imageX = image.getImageWidth() * xRatio;
final double imageY = image.getImageHeight() * yRatio;
final double[] coordinates = new double[] { imageX, imageY };
if (!isShowOriginalImage()) {
try {
final AffineTransform transform = image.getAffineTransformation(boundingBox).createInverse();
transform.transform(coordinates, 0, coordinates, 0, 1);
} catch (final NoninvertibleTransformException e) {
}
}
return new PointDoubleXY(Doubles.makePrecise(1, coordinates[0]), Doubles.makePrecise(1, coordinates[1]));
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageMapTile method loadData.
protected GeoreferencedImage loadData(final CoordinateSystem coordinateSystem) {
synchronized (this.projectedImages) {
GeoreferencedImage projectedImage = this.projectedImages.get(coordinateSystem);
if (projectedImage == null) {
final GeometryFactory geometryFactory = getGeometryFactory();
GeoreferencedImage image = getData();
if (image == null) {
image = loadData();
this.projectedImages.put(geometryFactory.getCoordinateSystem(), image);
}
if (image != null) {
projectedImage = image.getImage(coordinateSystem, getResolution());
this.projectedImages.put(coordinateSystem, projectedImage);
}
}
return projectedImage;
}
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method moveTiePointStart.
private boolean moveTiePointStart(final MouseEvent event) {
if (this.moveTiePointIndex > -1) {
if (SwingUtilities.isLeftMouseButton(event)) {
final MappedLocation tiePoint = getMoveTiePoint();
String action;
if (this.moveTiePointSource) {
action = ACTION_TIE_POINT_MOVE_SOURCE;
this.moveTiePointOpposite = tiePoint.getTargetPoint();
} else {
action = ACTION_TIE_POINT_MOVE_TARGET;
final GeoreferencedImage image = this.image;
final boolean showOriginalImage = this.layer.isShowOriginalImage();
final BoundingBox boundingBox = getImageBoundingBox();
this.moveTiePointOpposite = tiePoint.getSourcePoint(image, boundingBox, !showOriginalImage);
}
if (setOverlayAction(action)) {
this.moveTiePointStarted = true;
setMapCursor(CURSOR_NODE_ADD);
getMap().clearToolTipText();
event.consume();
repaint();
return true;
}
}
}
return false;
}
Aggregations