Search in sources :

Example 36 with LineString

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);
    }
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 37 with LineString

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);
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Edge(com.revolsys.geometry.geomgraph.Edge)

Example 38 with LineString

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);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) Polygon(com.revolsys.geometry.model.Polygon)

Example 39 with LineString

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);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineString(com.revolsys.geometry.model.LineString) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point)

Example 40 with LineString

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);
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) LineString(com.revolsys.geometry.model.LineString) Node(com.revolsys.geometry.planargraph.Node) Point(com.revolsys.geometry.model.Point) Edge(com.revolsys.geometry.planargraph.Edge) DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge)

Aggregations

LineString (com.revolsys.geometry.model.LineString)380 Point (com.revolsys.geometry.model.Point)184 Geometry (com.revolsys.geometry.model.Geometry)65 ArrayList (java.util.ArrayList)62 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)51 Polygon (com.revolsys.geometry.model.Polygon)37 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)24 Edge (com.revolsys.geometry.graph.Edge)22 List (java.util.List)22 BoundingBox (com.revolsys.geometry.model.BoundingBox)20 Lineal (com.revolsys.geometry.model.Lineal)20 Test (org.junit.Test)20 LinearRing (com.revolsys.geometry.model.LinearRing)19 Record (com.revolsys.record.Record)17 Iterator (java.util.Iterator)14 LineStringEditor (com.revolsys.geometry.model.editor.LineStringEditor)13 Punctual (com.revolsys.geometry.model.Punctual)12 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)12 LineSegment (com.revolsys.geometry.model.segment.LineSegment)10 Polygonal (com.revolsys.geometry.model.Polygonal)9