Search in sources :

Example 26 with Vertex

use of com.revolsys.geometry.model.vertex.Vertex in project com.revolsys.open by revolsys.

the class GeometryCoordinatesTableModel method getIndexOfVertices.

public static Map<int[], Vertex> getIndexOfVertices(final Geometry geometry) {
    final Map<int[], Vertex> pointIndexes = new LinkedHashMap<>();
    if (geometry == null || geometry.isEmpty()) {
    } else {
        for (final Vertex vertex : geometry.vertices()) {
            final int[] vertexId = vertex.getVertexId();
            final Vertex clone = vertex.clone();
            pointIndexes.put(vertexId, clone);
        }
    }
    return pointIndexes;
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) LinkedHashMap(java.util.LinkedHashMap)

Example 27 with Vertex

use of com.revolsys.geometry.model.vertex.Vertex in project com.revolsys.open by revolsys.

the class GriddedElevationModel method setGeometryElevations.

@SuppressWarnings("unchecked")
default <G extends Geometry> G setGeometryElevations(final G geometry) {
    final GeometryEditor<?> editor = geometry.newGeometryEditor();
    editor.setAxisCount(3);
    for (final Vertex vertex : geometry.vertices()) {
        final double x = vertex.getX();
        final double y = vertex.getY();
        final double elevation = getElevation(x, y);
        if (Double.isFinite(elevation)) {
            final int[] vertexId = vertex.getVertexId();
            editor.setZ(vertexId, elevation);
        }
    }
    return (G) editor.newGeometry();
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex)

Example 28 with Vertex

use of com.revolsys.geometry.model.vertex.Vertex in project com.revolsys.open by revolsys.

the class QuadEdgeDelaunayTinBuilder method insertVertices.

/**
 * Sets the sites (vertices) which will be triangulated.
 * All vertices of the given geometry will be used as sites.
 *
 * @param geometry the geometry from which the sites will be extracted.
 */
public void insertVertices(final Geometry geometry) {
    for (final Vertex point : geometry.vertices()) {
        final double x = point.getX();
        final double y = point.getY();
        final double z = point.getZ();
        insertVertex(x, y, z);
    }
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex)

Example 29 with Vertex

use of com.revolsys.geometry.model.vertex.Vertex in project com.revolsys.open by revolsys.

the class ConvexHull method convexHull.

public static Geometry convexHull(final Geometry geometry) {
    final Vertex vertices = geometry.vertices();
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    return convexHull(geometryFactory, vertices);
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 30 with Vertex

use of com.revolsys.geometry.model.vertex.Vertex in project com.revolsys.open by revolsys.

the class LineString method split.

default List<LineString> split(Point point) {
    final GeometryFactory geometryFactory = getGeometryFactory();
    point = point.convertGeometry(geometryFactory);
    final double x = point.getX();
    final double y = point.getY();
    final Pair<GeometryComponent, Double> result = findClosestGeometryComponent(x, y);
    if (result.isEmpty()) {
        return Collections.<LineString>singletonList(this);
    } else {
        final int vertexCount = getVertexCount();
        final GeometryComponent geometryComponent = result.getValue1();
        final double distance = result.getValue2();
        if (geometryComponent instanceof Vertex) {
            final Vertex vertex = (Vertex) geometryComponent;
            final int vertexIndex = vertex.getVertexIndex();
            if (distance == 0) {
                if (vertexIndex <= 0 || vertexIndex >= vertexCount - 1) {
                    return Collections.<LineString>singletonList(this);
                } else {
                    final LineString line1 = subLine(vertexIndex + 1);
                    final LineString line2 = subLine(vertexIndex, vertexCount - vertexIndex);
                    return Arrays.asList(line1, line2);
                }
            } else {
                final LineString line1 = subLine(vertexIndex + 1, point);
                final LineString line2 = subLine(point, vertexIndex, vertexCount - vertexIndex, null);
                return Arrays.asList(line1, line2);
            }
        } else if (geometryComponent instanceof Segment) {
            final Segment segment = (Segment) geometryComponent;
            final int segmentIndex = segment.getSegmentIndex();
            final LineString line1 = subLine(segmentIndex + 1, point);
            final LineString line2 = subLine(point, segmentIndex + 1, vertexCount - segmentIndex - 1, null);
            return Arrays.asList(line1, line2);
        } else {
            return Collections.<LineString>singletonList(this);
        }
    }
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) LineStringVertex(com.revolsys.geometry.model.vertex.LineStringVertex) AbstractVertex(com.revolsys.geometry.model.vertex.AbstractVertex) PreparedLineString(com.revolsys.geometry.model.prep.PreparedLineString) LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) BiConsumerDouble(com.revolsys.util.function.BiConsumerDouble) Consumer3Double(com.revolsys.util.function.Consumer3Double) Consumer4Double(com.revolsys.util.function.Consumer4Double) LineStringSegment(com.revolsys.geometry.model.segment.LineStringSegment) Segment(com.revolsys.geometry.model.segment.Segment)

Aggregations

Vertex (com.revolsys.geometry.model.vertex.Vertex)42 Point (com.revolsys.geometry.model.Point)18 Geometry (com.revolsys.geometry.model.Geometry)16 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 LineString (com.revolsys.geometry.model.LineString)10 Polygon (com.revolsys.geometry.model.Polygon)6 Segment (com.revolsys.geometry.model.segment.Segment)6 ArrayList (java.util.ArrayList)6 GeometryEditor (com.revolsys.geometry.model.editor.GeometryEditor)4 AbstractVertex (com.revolsys.geometry.model.vertex.AbstractVertex)4 LineStringVertex (com.revolsys.geometry.model.vertex.LineStringVertex)4 BaseCloseable (com.revolsys.io.BaseCloseable)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 DataType (com.revolsys.datatype.DataType)3 LinearRing (com.revolsys.geometry.model.LinearRing)3 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)3 LineSegment (com.revolsys.geometry.model.segment.LineSegment)3 MapPanel (com.revolsys.swing.map.MapPanel)3 WebColors (com.revolsys.awt.WebColors)2 Maps (com.revolsys.collection.map.Maps)2