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