Search in sources :

Example 46 with LayerRecord

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

the class OsmOverpassLayer method getRecords.

@Override
public List<LayerRecord> getRecords(BoundingBox boundingBox) {
    if (hasGeometryField()) {
        boundingBox = convertBoundingBox(boundingBox);
        if (Property.hasValue(boundingBox)) {
            final Map<Identifier, LayerRecord> recordMap = new HashMap<>();
            final List<BoundingBox> boundingBoxes = getTileBoundingBoxes(boundingBox);
            for (final BoundingBox tileBoundingBox : boundingBoxes) {
                final OsmDocument document = getTile(tileBoundingBox);
                for (final OsmElement record : document.getRecords()) {
                    final Geometry geometry = record.getGeometry();
                    if (geometry != null && !geometry.isEmpty()) {
                        if (boundingBox.intersects(geometry.getBoundingBox())) {
                            final Identifier identifier = record.getIdentifier();
                        // final OsmProxyLayerRecord layerRecord = new
                        // OsmProxyLayerRecord(
                        // this, document, identifier);
                        // recordMap.put(identifier, layerRecord);
                        }
                    }
                }
            }
            this.boundingBoxTileMap.keySet().retainAll(boundingBoxes);
            return new ArrayList<>(recordMap.values());
        }
    }
    return Collections.emptyList();
}
Also used : OsmElement(com.revolsys.record.io.format.openstreetmap.model.OsmElement) Geometry(com.revolsys.geometry.model.Geometry) Identifier(com.revolsys.identifier.Identifier) HashMap(java.util.HashMap) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) OsmDocument(com.revolsys.record.io.format.openstreetmap.model.OsmDocument)

Example 47 with LayerRecord

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

the class SelectRecordsOverlay method paintComponent.

@Override
public void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
    final GeoreferencedImage imageSelected = this.imageSelected.getResource();
    if (imageSelected != null) {
        GeoreferencedImageLayerRenderer.render(viewport, graphics, imageSelected, false);
    }
    final GeometryFactory viewportGeometryFactory = getViewportGeometryFactory2d();
    final MapPanel map = getMap();
    final List<LayerRecord> closeSelectedRecords = map.getCloseSelectedRecords();
    if (!closeSelectedRecords.isEmpty()) {
        try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
            for (final LayerRecord record : closeSelectedRecords) {
                final Geometry geometry = record.getGeometry();
                if (record.isHighlighted()) {
                    this.highlightVertexRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
                } else {
                    this.selectVertexRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
                }
            }
        }
    }
    final List<CloseLocation> closeSelectedLocations = map.getCloseSelectedLocations();
    if (Property.hasValue(closeSelectedLocations)) {
        for (final CloseLocation location : closeSelectedLocations) {
            final Vertex vertex = location.getVertex();
            CLOSE_VERTEX_STYLE_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, vertex);
        }
    }
    paintSelectBox(graphics);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Vertex(com.revolsys.geometry.model.vertex.Vertex) MapPanel(com.revolsys.swing.map.MapPanel) BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 48 with LayerRecord

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

the class CloseLocation method equals.

@Override
public boolean equals(final Object other) {
    if (other instanceof CloseLocation) {
        final CloseLocation location = (CloseLocation) other;
        final LayerRecord record1 = getRecord();
        final LayerRecord record2 = location.getRecord();
        if (record1 == null) {
            if (record2 != null) {
                return false;
            }
        } else if (record2 == null) {
            return false;
        } else if (!record2.isSame(record1)) {
            return false;
        }
        if (!DataType.equal(getVertex(), location.getVertex())) {
            return false;
        } else if (!DataType.equal(getSegment(), location.getSegment())) {
            return false;
        } else if (location.getViewportPoint().equals(getViewportPoint())) {
            return true;
        } else {
            return false;
        }
    }
    return false;
}
Also used : LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 49 with LayerRecord

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

the class GeometryCoordinatesTableModel method setGeometry.

public void setGeometry(final Geometry geometry) {
    final LayerRecordForm form = this.geometryCoordinatesPanel.getForm();
    final LayerRecord record = form.getRecord();
    final Geometry oldGeometry = record.getGeometry();
    if (oldGeometry != geometry) {
        final AbstractRecordLayer layer = record.getLayer();
        final String geometryFieldName = record.getGeometryFieldName();
        final UndoableEdit setGeometryUndo = layer.newSetFieldUndo(record, geometryFieldName, oldGeometry, geometry);
        final UndoManager undoManager = form.getUndoManager();
        undoManager.addEdit(setGeometryUndo);
    }
    if (this.geometry != geometry) {
        this.geometry = geometry;
        if (geometry == null) {
            this.geometryFactory = GeometryFactory.DEFAULT_3D;
            this.vertexIndexMap = Collections.emptyMap();
            this.vertexIndices = Collections.emptyList();
        } else {
            this.geometryFactory = geometry.getGeometryFactory();
            this.vertexIndexMap = getIndexOfVertices(geometry);
            this.vertexIndices = new ArrayList<>(this.vertexIndexMap.keySet());
        }
        this.axisCount = this.geometryFactory.getAxisCount();
        this.axisNames = new ArrayList<>();
        if (geometry.isGeometryCollection()) {
            this.axisNames.add("P");
        }
        if (geometry instanceof Polygonal) {
            this.axisNames.add("R");
        }
        this.vertexIndexColumn = this.axisNames.size();
        this.axisNames.add("#");
        this.segmentIndexColumn = this.axisNames.size();
        this.axisNames.add("S #");
        this.numIndexItems = this.axisNames.size();
        this.axisNames.add("X");
        this.axisNames.add("Y");
        if (this.axisCount > 2) {
            this.axisNames.add("Z");
        }
        if (this.axisCount > 3) {
            this.axisNames.add("M");
        }
        this.columnCount = this.axisNames.size();
        fireTableStructureChanged();
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) UndoManager(com.revolsys.swing.undo.UndoManager) UndoableEdit(javax.swing.undo.UndoableEdit) Polygonal(com.revolsys.geometry.model.Polygonal) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 50 with LayerRecord

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

the class SelectRecordsOverlay method refreshImageRenderer.

private void refreshImageRenderer(final ImageViewport viewport, final LayerGroup layerGroup) {
    for (final Layer layer : layerGroup.getLayers()) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            refreshImageRenderer(viewport, childGroup);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            final AbstractRecordLayerRenderer layerRenderer = layer.getRenderer();
            if (recordLayer.isSelectable()) {
                final List<LayerRecord> selectedRecords = recordLayer.getSelectedRecords();
                for (final LayerRecord record : selectedRecords) {
                    if (record != null && recordLayer.isVisible(record)) {
                        if (!recordLayer.isDeleted(record)) {
                            layerRenderer.renderSelectedRecord(viewport, recordLayer, record);
                        }
                    }
                }
            }
        }
    }
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) List(java.util.List) ArrayList(java.util.ArrayList) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Aggregations

LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)79 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)34 Geometry (com.revolsys.geometry.model.Geometry)15 IdentifierProxyLayerRecord (com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord)15 NewProxyLayerRecord (com.revolsys.swing.map.layer.record.NewProxyLayerRecord)15 BoundingBox (com.revolsys.geometry.model.BoundingBox)11 Record (com.revolsys.record.Record)11 ArrayList (java.util.ArrayList)11 List (java.util.List)10 Test (org.junit.Test)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Point (com.revolsys.geometry.model.Point)6 Condition (com.revolsys.record.query.Condition)4 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)4 LineString (com.revolsys.geometry.model.LineString)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)3 Layer (com.revolsys.swing.map.layer.Layer)3