Search in sources :

Example 21 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class TiePointsPanel method zoomToTiePoint.

public void zoomToTiePoint() {
    final MappedLocation object = getEventRowObject();
    final GeoreferencedImage image = this.layer.getImage();
    final Geometry geometry = object.getSourceToTargetLine(image, this.layer.getBoundingBox(), !this.layer.isShowOriginalImage());
    if (geometry != null) {
        final Project project = Project.get();
        final GeometryFactory geometryFactory = project.getGeometryFactory();
        final BoundingBox boundingBox = geometry.getBoundingBox().convert(geometryFactory).expand(200);
        project.setViewBoundingBox(boundingBox);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Project(com.revolsys.swing.map.layer.Project) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) MappedLocation(com.revolsys.raster.MappedLocation) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage)

Example 22 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class MapGuideWebServer method actionAddLayer.

private static void actionAddLayer(final FeatureLayer layerDescription) {
    final Project project = Project.get();
    if (project != null) {
        LayerGroup layerGroup = project;
        final PathName layerPath = layerDescription.getPathName();
        for (final String groupName : layerPath.getParent().getElements()) {
            layerGroup = layerGroup.addLayerGroup(groupName);
        }
        final MapGuideWebServerRecordLayer layer = new MapGuideWebServerRecordLayer(layerDescription);
        layerGroup.addLayer(layer);
        if (AbstractLayer.isShowNewLayerTableView()) {
            layer.showTableView();
        }
    }
}
Also used : Project(com.revolsys.swing.map.layer.Project) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) PathName(com.revolsys.io.PathName)

Example 23 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class GeoreferencedImageLayer method fitToViewport.

public synchronized BoundingBox fitToViewport() {
    final Project project = getProject();
    if (project == null || this.image == null || !isInitialized()) {
        return BoundingBox.empty();
    } else {
        final BoundingBox oldValue = this.image.getBoundingBox();
        final BoundingBox viewBoundingBox = project.getViewBoundingBox();
        if (viewBoundingBox.isEmpty()) {
            return viewBoundingBox;
        } else {
            final double viewRatio = viewBoundingBox.getAspectRatio();
            final double imageRatio = this.image.getImageAspectRatio();
            BoundingBox boundingBox;
            if (viewRatio > imageRatio) {
                boundingBox = viewBoundingBox.expandPercent(-1 + imageRatio / viewRatio, 0.0);
            } else if (viewRatio < imageRatio) {
                boundingBox = viewBoundingBox.expandPercent(0.0, -1 + viewRatio / imageRatio);
            } else {
                boundingBox = viewBoundingBox;
            }
            this.image.setBoundingBox(boundingBox);
            firePropertyChange("boundingBox", oldValue, boundingBox);
            return boundingBox;
        }
    }
}
Also used : Project(com.revolsys.swing.map.layer.Project) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 24 with Project

use of com.revolsys.swing.map.layer.Project 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 25 with Project

use of com.revolsys.swing.map.layer.Project in project com.revolsys.open by revolsys.

the class RecordLayerTableModel method getFilterQuery.

protected Query getFilterQuery() {
    final Query query = this.layer.getQuery();
    final Condition filter = getFilter();
    query.and(filter);
    query.setOrderBy(this.orderBy);
    if (this.filterByBoundingBox) {
        final Project project = this.layer.getProject();
        final BoundingBox viewBoundingBox = project.getViewBoundingBox();
        final RecordDefinition recordDefinition = this.layer.getRecordDefinition();
        final FieldDefinition geometryField = recordDefinition.getGeometryField();
        if (geometryField != null) {
            query.and(F.envelopeIntersects(geometryField, viewBoundingBox));
        }
    }
    return query;
}
Also used : Condition(com.revolsys.record.query.Condition) Project(com.revolsys.swing.map.layer.Project) Query(com.revolsys.record.query.Query) BoundingBox(com.revolsys.geometry.model.BoundingBox) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

Project (com.revolsys.swing.map.layer.Project)28 BoundingBox (com.revolsys.geometry.model.BoundingBox)14 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)6 Viewport2D (com.revolsys.swing.map.Viewport2D)4 MapPanel (com.revolsys.swing.map.MapPanel)3 Point (com.revolsys.geometry.model.Point)2 GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)2 ImageViewport (com.revolsys.swing.map.ImageViewport)2 Layer (com.revolsys.swing.map.layer.Layer)2 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)2 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)2 PageFormat (java.awt.print.PageFormat)2 PrinterException (java.awt.print.PrinterException)2 PrinterJob (java.awt.print.PrinterJob)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Geometry (com.revolsys.geometry.model.Geometry)1 LineString (com.revolsys.geometry.model.LineString)1 RectangularMapGrid (com.revolsys.gis.grid.RectangularMapGrid)1 RectangularMapTile (com.revolsys.gis.grid.RectangularMapTile)1