Search in sources :

Example 1 with GeometryDataType

use of com.revolsys.geometry.model.GeometryDataType in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method getVertexGeometry.

protected Geometry getVertexGeometry(final MouseEvent event, final CloseLocation location) {
    final Geometry geometry = location.getGeometry();
    final DataType geometryDataType = DataTypes.getDataType(geometry);
    final DataType geometryPartDataType = getGeometryPartDataType(geometryDataType);
    int previousPointOffset;
    int[] vertexId = location.getVertexId();
    if (vertexId == null) {
        previousPointOffset = 0;
        vertexId = location.getSegmentId();
    } else {
        previousPointOffset = -1;
    }
    final GeometryFactory geometryFactory = location.getGeometryFactory();
    if (DataTypes.GEOMETRY.equals(geometryPartDataType)) {
    } else if (DataTypes.POINT.equals(geometryPartDataType)) {
    } else {
        final Point point = getPoint(geometryFactory, event);
        final Vertex vertex = geometry.getVertex(vertexId);
        Point previousPoint = null;
        Point nextPoint = null;
        if (DataTypes.LINE_STRING.equals(geometryPartDataType) || DataTypes.POLYGON.equals(geometryPartDataType)) {
            if (previousPointOffset == 0) {
                previousPoint = vertex;
            } else {
                previousPoint = vertex.getLinePrevious();
            }
            nextPoint = vertex.getLineNext();
        }
        final List<LineString> lines = new ArrayList<>();
        if (previousPoint != null && !previousPoint.isEmpty()) {
            lines.add(newXorLine(geometryFactory, previousPoint, point));
        }
        if (nextPoint != null && !nextPoint.isEmpty()) {
            lines.add(newXorLine(geometryFactory, nextPoint, point));
        }
        if (!lines.isEmpty()) {
            return geometryFactory.lineal(lines);
        }
    }
    return null;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Vertex(com.revolsys.geometry.model.vertex.Vertex) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeometryDataType(com.revolsys.geometry.model.GeometryDataType) DataType(com.revolsys.datatype.DataType) List(java.util.List) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 2 with GeometryDataType

use of com.revolsys.geometry.model.GeometryDataType in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method addRecord.

/**
 * Set the addLayer that a new feature is to be added to.
 *
 * @param addLayer
 */
@SuppressWarnings("unchecked")
public void addRecord(final AbstractRecordLayer layer, final AddGeometryCompleteAction addCompleteAction) {
    if (layer != null) {
        final RecordDefinition recordDefinition = layer.getRecordDefinition();
        final FieldDefinition geometryField = recordDefinition.getGeometryField();
        if (geometryField != null) {
            this.addLayer = layer;
            this.addCompleteAction = addCompleteAction;
            final GeometryFactory geometryFactory = recordDefinition.getGeometryFactory();
            this.setGeometryFactory(geometryFactory);
            clearUndoHistory();
            setOverlayAction(ACTION_ADD_GEOMETRY);
            final GeometryDataType<Geometry, GeometryEditor<?>> geometryDataType = (GeometryDataType<Geometry, GeometryEditor<?>>) geometryField.getDataType();
            setAddGeometryDataType(geometryDataType, geometryFactory);
            setMapCursor(CURSOR_NODE_ADD);
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) FieldDefinition(com.revolsys.record.schema.FieldDefinition) GeometryDataType(com.revolsys.geometry.model.GeometryDataType) RecordDefinition(com.revolsys.record.schema.RecordDefinition) GeometryEditor(com.revolsys.geometry.model.editor.GeometryEditor)

Aggregations

Geometry (com.revolsys.geometry.model.Geometry)2 GeometryDataType (com.revolsys.geometry.model.GeometryDataType)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)2 DataType (com.revolsys.datatype.DataType)1 Point (com.revolsys.geometry.model.Point)1 GeometryEditor (com.revolsys.geometry.model.editor.GeometryEditor)1 Vertex (com.revolsys.geometry.model.vertex.Vertex)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1