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();
}
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);
}
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;
}
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();
}
}
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);
}
}
}
}
}
}
}
Aggregations