Search in sources :

Example 86 with GeometryFactory

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

the class AbstractGeometryCollectionEditor method appendVertex.

@SuppressWarnings("unchecked")
@Override
public GeometryEditor<?> appendVertex(final int[] geometryId, final GeometryDataType<?, ?> partDataType, final Point point) {
    if (geometryId == null || geometryId.length < 1) {
    } else {
        final int partIndex = geometryId[0];
        GE editor = getEditor(partIndex);
        if (editor == null && partIndex == this.editors.size()) {
            final GeometryDataType<?, ?> thisPartDataType = getPartDataType();
            if (thisPartDataType == null || thisPartDataType.equals(partDataType)) {
                editor = (GE) partDataType.newGeometryEditor(getGeometryFactory());
                addEditor(editor);
            }
        }
        if (editor != null) {
            final int[] childGeometryId = Arrays.copyOfRange(geometryId, 1, geometryId.length);
            final GeometryEditor<?> newEditor = editor.appendVertex(childGeometryId, point);
            if (newEditor != editor) {
                final List<GeometryEditor<?>> editors = new ArrayList<>(this.editors);
                editors.set(partIndex, newEditor);
                final GeometryFactory geometryFactory = getGeometryFactory();
                return new GeometryCollectionImplEditor(geometryFactory, editors);
            }
        }
    }
    return this;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point)

Example 87 with GeometryFactory

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

the class AbstractGeometryCollectionEditor method getCurrentGeometry.

@Override
public Geometry getCurrentGeometry() {
    final List<Geometry> geometries = new ArrayList<>();
    for (final GE editor : this.editors) {
        final Geometry currentGeometry = editor.getCurrentGeometry();
        geometries.add(currentGeometry);
    }
    final GeometryFactory geometryFactory = getGeometryFactory();
    return geometryFactory.geometry(geometries);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ArrayList(java.util.ArrayList)

Example 88 with GeometryFactory

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

the class LineStringEditor method newPolygon.

public Polygon newPolygon() {
    final LinearRing ring = newLinearRing();
    final GeometryFactory geometryFactory = getGeometryFactory();
    return geometryFactory.polygon(ring);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LinearRing(com.revolsys.geometry.model.LinearRing)

Example 89 with GeometryFactory

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

the class LinearRingEditor method getCurrentGeometry.

@Override
public Geometry getCurrentGeometry() {
    final GeometryFactory geometryFactory = getGeometryFactory();
    final int vertexCount = getVertexCount();
    if (vertexCount == 0) {
        return newLineStringEmpty();
    } else if (vertexCount == 1) {
        return newPoint();
    } else if (vertexCount == 2 || !isClosed()) {
        return newLineString(geometryFactory, this.axisCount, vertexCount, this.coordinates);
    } else {
        return this;
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 90 with GeometryFactory

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

the class MultiPointEditor method appendVertex.

public void appendVertex(final Point point) {
    if (point != null && !point.isEmpty()) {
        final GeometryFactory geometryFactory = getGeometryFactory();
        final Point newPoint = point.convertGeometry(geometryFactory);
        final PointEditor pointEditor = newPoint.newGeometryEditor(this);
        addEditor(pointEditor);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MultiPoint(com.revolsys.geometry.model.MultiPoint) Point(com.revolsys.geometry.model.Point)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)360 Point (com.revolsys.geometry.model.Point)142 Geometry (com.revolsys.geometry.model.Geometry)72 BoundingBox (com.revolsys.geometry.model.BoundingBox)70 LineString (com.revolsys.geometry.model.LineString)61 ArrayList (java.util.ArrayList)45 DataType (com.revolsys.datatype.DataType)25 FieldDefinition (com.revolsys.record.schema.FieldDefinition)24 Polygon (com.revolsys.geometry.model.Polygon)22 List (java.util.List)18 RecordDefinition (com.revolsys.record.schema.RecordDefinition)17 Test (org.junit.Test)16 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)14 Record (com.revolsys.record.Record)14 IOException (java.io.IOException)13 PathName (com.revolsys.io.PathName)12 LinearRing (com.revolsys.geometry.model.LinearRing)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)10 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)8