Search in sources :

Example 1 with SegmentString

use of com.revolsys.geometry.noding.SegmentString in project com.revolsys.open by revolsys.

the class BufferFunctions method buildCurveSet.

private static Geometry buildCurveSet(final Geometry geometry, final double dist, final BufferParameters bufParams) {
    // --- now construct curve
    final GeometryFactory precisionModel = geometry.getGeometryFactory();
    final OffsetCurveSetBuilder curveBuilder = new OffsetCurveSetBuilder(geometry, dist, precisionModel, bufParams);
    final List curves = curveBuilder.getCurves();
    final List<LineString> lines = new ArrayList<>();
    for (final Iterator i = curves.iterator(); i.hasNext(); ) {
        final SegmentString ss = (SegmentString) i.next();
        final LineString points = ss.getLineString();
        lines.add(geometry.getGeometryFactory().lineString(points));
    }
    final Geometry curve = geometry.getGeometryFactory().geometry(lines);
    return curve;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SegmentString(com.revolsys.geometry.noding.SegmentString) OffsetCurveSetBuilder(com.revolsys.geometry.operation.buffer.OffsetCurveSetBuilder)

Example 2 with SegmentString

use of com.revolsys.geometry.noding.SegmentString in project com.revolsys.open by revolsys.

the class NodingFunctions method newSegmentStrings.

private static List<SegmentString> newSegmentStrings(final Geometry geom) {
    final List<SegmentString> segs = new ArrayList<>();
    final List<LineString> lines = geom.getGeometries(LineString.class);
    for (final LineString line : lines) {
        segs.add(new BasicSegmentString(line, null));
    }
    return segs;
}
Also used : LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList) BasicSegmentString(com.revolsys.geometry.noding.BasicSegmentString) SegmentString(com.revolsys.geometry.noding.SegmentString) BasicSegmentString(com.revolsys.geometry.noding.BasicSegmentString) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString)

Example 3 with SegmentString

use of com.revolsys.geometry.noding.SegmentString in project com.revolsys.open by revolsys.

the class NodingFunctions method fromSegmentStrings.

private static Geometry fromSegmentStrings(final Collection segStrings) {
    final LineString[] lines = new LineString[segStrings.size()];
    int index = 0;
    for (final Iterator i = segStrings.iterator(); i.hasNext(); ) {
        final SegmentString ss = (SegmentString) i.next();
        final LineString line = FunctionsUtil.getFactoryOrDefault(null).lineString(ss.getLineString());
        lines[index++] = line;
    }
    return FunctionsUtil.getFactoryOrDefault(null).lineal(lines);
}
Also used : LineString(com.revolsys.geometry.model.LineString) Iterator(java.util.Iterator) SegmentString(com.revolsys.geometry.noding.SegmentString) BasicSegmentString(com.revolsys.geometry.noding.BasicSegmentString) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) Point(com.revolsys.geometry.model.Point)

Example 4 with SegmentString

use of com.revolsys.geometry.noding.SegmentString in project com.revolsys.open by revolsys.

the class Buffer method computeNodedEdges.

private static void computeNodedEdges(final Noder noder, final EdgeList edges, final List<NodedSegmentString> segments) {
    noder.computeNodes(segments);
    final Collection<NodedSegmentString> nodedSegments = noder.getNodedSubstrings();
    for (final SegmentString segment : nodedSegments) {
        final int vertexCount = segment.size();
        if (vertexCount > 2 || vertexCount == 2 && !segment.equalsVertex2d(0, 1)) {
            final Label oldLabel = (Label) segment.getData();
            final Label label = new Label(oldLabel);
            final LineString points = segment.getLineString();
            final Edge edge = new Edge(points, label);
            insertUniqueEdge(edges, edge);
        }
    }
}
Also used : NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) LineString(com.revolsys.geometry.model.LineString) Label(com.revolsys.geometry.geomgraph.Label) SegmentString(com.revolsys.geometry.noding.SegmentString) NodedSegmentString(com.revolsys.geometry.noding.NodedSegmentString) Edge(com.revolsys.geometry.geomgraph.Edge) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Point(com.revolsys.geometry.model.Point)

Example 5 with SegmentString

use of com.revolsys.geometry.noding.SegmentString in project com.revolsys.open by revolsys.

the class MCIndexedPointInAreaLocator method addLine.

private void addLine(final LineString points) {
    final SegmentString segStr = new BasicSegmentString(points, null);
    final List<MonotoneChain> chains = MonotoneChainBuilder.getChains(segStr.getLineString(), segStr);
    for (final MonotoneChain chain : chains) {
        this.index.insertItem(chain);
    }
}
Also used : MonotoneChain(com.revolsys.geometry.index.chain.MonotoneChain) BasicSegmentString(com.revolsys.geometry.noding.BasicSegmentString) SegmentString(com.revolsys.geometry.noding.SegmentString) BasicSegmentString(com.revolsys.geometry.noding.BasicSegmentString)

Aggregations

SegmentString (com.revolsys.geometry.noding.SegmentString)5 LineString (com.revolsys.geometry.model.LineString)4 BasicSegmentString (com.revolsys.geometry.noding.BasicSegmentString)3 NodedSegmentString (com.revolsys.geometry.noding.NodedSegmentString)3 Point (com.revolsys.geometry.model.Point)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)1 Edge (com.revolsys.geometry.geomgraph.Edge)1 Label (com.revolsys.geometry.geomgraph.Label)1 MonotoneChain (com.revolsys.geometry.index.chain.MonotoneChain)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 OffsetCurveSetBuilder (com.revolsys.geometry.operation.buffer.OffsetCurveSetBuilder)1 List (java.util.List)1