Search in sources :

Example 11 with GeoreferencedImage

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();
        }
    }
}
Also used : GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) LineString(com.revolsys.geometry.model.LineString)

Example 12 with GeoreferencedImage

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);
}
Also used : Project(com.revolsys.swing.map.layer.Project) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) AffineTransform(java.awt.geom.AffineTransform)

Example 13 with GeoreferencedImage

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]));
}
Also used : NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) BoundingBox(com.revolsys.geometry.model.BoundingBox) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) AffineTransform(java.awt.geom.AffineTransform) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 14 with GeoreferencedImage

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;
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage)

Example 15 with GeoreferencedImage

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;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) MappedLocation(com.revolsys.raster.MappedLocation) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) LineString(com.revolsys.geometry.model.LineString)

Aggregations

GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)15 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 LineString (com.revolsys.geometry.model.LineString)4 BufferedGeoreferencedImage (com.revolsys.raster.BufferedGeoreferencedImage)4 MappedLocation (com.revolsys.raster.MappedLocation)3 AffineTransform (java.awt.geom.AffineTransform)3 Geometry (com.revolsys.geometry.model.Geometry)2 Point (com.revolsys.geometry.model.Point)2 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 BaseCloseable (com.revolsys.io.BaseCloseable)2 Project (com.revolsys.swing.map.layer.Project)2 Graphics2D (java.awt.Graphics2D)2 Polygon (com.revolsys.geometry.model.Polygon)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 Resource (com.revolsys.spring.resource.Resource)1 MapPanel (com.revolsys.swing.map.MapPanel)1 NullLayer (com.revolsys.swing.map.layer.NullLayer)1 GeoreferencedImageLayer (com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer)1 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)1