use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineSequencer method buildSequencedGeometry.
/**
* Builds a geometry ({@link Lineal} )
* representing the sequence.
*
* @param sequences a List of Lists of DirectedEdges with
* LineMergeEdges as their parent edges.
* @return the sequenced geometry, or <code>null</code> if no sequence exists
*/
private Geometry buildSequencedGeometry(final List sequences) {
final List lines = new ArrayList();
for (final Iterator i1 = sequences.iterator(); i1.hasNext(); ) {
final List seq = (List) i1.next();
for (final Iterator i2 = seq.iterator(); i2.hasNext(); ) {
final DirectedEdge de = (DirectedEdge) i2.next();
final LineMergeEdge e = (LineMergeEdge) de.getEdge();
final LineString line = e.getLine();
LineString lineToAdd = line;
if (!de.getEdgeDirection() && !line.isClosed()) {
lineToAdd = line.reverse();
}
lines.add(lineToAdd);
}
}
if (lines.size() == 0) {
return this.factory.lineString();
} else {
return this.factory.buildGeometry(lines);
}
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class LineBuilder method buildLines.
private void buildLines(final int opCode) {
for (final Edge e : this.lineEdgesList) {
final LineString line = this.geometryFactory.lineString(e.getLineString());
this.resultLineList.add(line);
e.setInResult(true);
}
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class BufferDistanceValidator method getPolygonLines.
private Geometry getPolygonLines(final Geometry geometry) {
final List<LineString> lines = new ArrayList<>();
for (final Polygon polygon : geometry.getGeometries(Polygon.class)) {
lines.addAll(polygon.getRings());
}
final GeometryFactory geometryFactory = geometry.getGeometryFactory();
return geometryFactory.geometry(lines);
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class DistanceToPointFinder method computeDistance.
public static void computeDistance(final Geometry geometry, final Point pt, final PointPairDistance ptDist) {
if (geometry instanceof LineString) {
computeDistance(geometry, pt, ptDist);
} else if (geometry instanceof Polygon) {
computeDistance(geometry, pt, ptDist);
} else if (geometry.isGeometryCollection()) {
for (int i = 0; i < geometry.getGeometryCount(); i++) {
final Geometry g = geometry.getGeometry(i);
computeDistance(g, pt, ptDist);
}
} else {
// assume geom is Point
ptDist.setMinimum(geometry.getPoint(), pt);
}
}
use of com.revolsys.geometry.model.LineString in project com.revolsys.open by revolsys.
the class PolygonizeGraph method addEdge.
/**
* Add a {@link LineString} forming an edge of the polygon graph.
* @param line the line to add
*/
public void addEdge(final LineString line) {
final LineString cleanLine = line.removeDuplicatePoints();
if (cleanLine.isEmpty()) {
return;
}
if (cleanLine.getVertexCount() < 2) {
return;
}
final Point startPt = cleanLine.getVertex(0).newPoint2D();
final Point endPt = cleanLine.getToVertex(0).newPoint2D();
final Node nStart = getNode(startPt);
final Node nEnd = getNode(endPt);
final DirectedEdge de0 = new PolygonizeDirectedEdge(nStart, nEnd, cleanLine.getVertex(1).newPoint2D(), true);
final DirectedEdge de1 = new PolygonizeDirectedEdge(nEnd, nStart, cleanLine.getVertex(-2).newPoint2D(), false);
final Edge edge = new PolygonizeEdge(line);
edge.setDirectedEdges(de0, de1);
add(edge);
}
Aggregations