Search in sources :

Example 21 with LineSegment

use of com.revolsys.geometry.model.segment.LineSegment in project com.revolsys.open by revolsys.

the class LineMatchGraph method add.

private void add(final LineString line, final int index) {
    if (line.getLength() > 0) {
        final LineString coords = line;
        final Point coordinate0 = coords.getPoint(0);
        final Node<LineSegmentMatch> node = getNode(coordinate0);
        final Set<Node<LineSegmentMatch>> indexStartNodes = getStartNodes(index);
        indexStartNodes.add(node);
        Point previousCoordinate = coordinate0;
        for (int i = 1; i < coords.getVertexCount(); i++) {
            final Point coordinate = coords.getPoint(i);
            final LineSegment segment = new LineSegmentDoubleGF(this.geometryFactory, previousCoordinate, coordinate);
            if (segment.getLength() > 0) {
                add(previousCoordinate, coordinate, segment, index);
            }
            previousCoordinate = coordinate;
        }
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) Node(com.revolsys.geometry.graph.Node) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) LineSegmentDoubleGF(com.revolsys.geometry.model.segment.LineSegmentDoubleGF) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 22 with LineSegment

use of com.revolsys.geometry.model.segment.LineSegment in project com.revolsys.open by revolsys.

the class LineMatchGraph method splitEdge.

@Override
public List<Edge<LineSegmentMatch>> splitEdge(final Edge<LineSegmentMatch> edge, final Point point) {
    final LineSegmentMatch lineSegmentMatch = edge.getObject();
    final LineSegment segment = lineSegmentMatch.getSegment();
    final Edge<LineSegmentMatch> edge1 = add(segment.getPoint(0), point);
    final LineSegmentMatch lineSegmentMatch1 = edge1.getObject();
    final Edge<LineSegmentMatch> edge2 = add(point, segment.getPoint(1));
    final LineSegmentMatch lineSegmentMatch2 = edge2.getObject();
    for (int i = 0; i < lineSegmentMatch.getSegmentCount(); i++) {
        if (lineSegmentMatch.hasSegment(i)) {
            final LineSegment realSegment = lineSegmentMatch.getSegment(i);
            final Point projectedCoordinate = realSegment.project(point);
            final Point startCoordinate = realSegment.getPoint(0);
            final LineSegment segment1 = new LineSegmentDoubleGF(this.geometryFactory, startCoordinate, projectedCoordinate);
            lineSegmentMatch1.addSegment(segment1, i);
            final Point endCoordinate = realSegment.getPoint(1);
            final LineSegment segment2 = new LineSegmentDoubleGF(this.geometryFactory, projectedCoordinate, endCoordinate);
            lineSegmentMatch2.addSegment(segment2, i);
        }
    }
    remove(edge);
    return Arrays.asList(edge1, edge2);
}
Also used : Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) LineSegmentDoubleGF(com.revolsys.geometry.model.segment.LineSegmentDoubleGF) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 23 with LineSegment

use of com.revolsys.geometry.model.segment.LineSegment in project com.revolsys.open by revolsys.

the class LineSegmentIndex method isWithinDistance.

public boolean isWithinDistance(final Point point) {
    BoundingBox envelope = point.getBoundingBox();
    envelope = envelope.expand(1);
    final List<LineSegment> lines = getItems(envelope);
    for (final LineSegment line : lines) {
        if (line.distancePoint(point) <= 1) {
            return true;
        }
    }
    return false;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 24 with LineSegment

use of com.revolsys.geometry.model.segment.LineSegment in project com.revolsys.open by revolsys.

the class MonotoneChainOverlapAction method overlap.

/**
 * This function can be overridden if the original chains are needed
 *
 * @param start1 the index of the start of the overlapping segment from mc1
 * @param start2 the index of the start of the overlapping segment from mc2
 */
public void overlap(final MonotoneChain mc1, final int start1, final MonotoneChain mc2, final int start2) {
    final LineSegment overlapSeg1 = mc1.getLineSegment(start1);
    final LineSegment overlapSeg2 = mc2.getLineSegment(start2);
    overlap(overlapSeg1, overlapSeg2);
}
Also used : LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 25 with LineSegment

use of com.revolsys.geometry.model.segment.LineSegment in project com.revolsys.open by revolsys.

the class MonotoneChainSelectAction method select.

/**
 * This method is overridden
 * to process a segment
 * in the context of the parent chain.
 *
 * @param mc the parent chain
 * @param startIndex the index of the start vertex of the segment being processed
 */
public void select(final MonotoneChain mc, final int startIndex) {
    final LineSegment selectedSegment = mc.getLineSegment(startIndex);
    // call this routine in case select(segmenet) was overridden
    select(selectedSegment);
}
Also used : LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Aggregations

LineSegment (com.revolsys.geometry.model.segment.LineSegment)61 Point (com.revolsys.geometry.model.Point)34 Edge (com.revolsys.geometry.graph.Edge)19 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)14 LineSegmentDoubleGF (com.revolsys.geometry.model.segment.LineSegmentDoubleGF)13 Geometry (com.revolsys.geometry.model.Geometry)12 PointOnLineSegment (com.revolsys.geometry.model.coordinates.filter.PointOnLineSegment)11 ArrayList (java.util.ArrayList)10 LineString (com.revolsys.geometry.model.LineString)9 Node (com.revolsys.geometry.graph.Node)7 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)6 EdgeAttributeValueComparator (com.revolsys.geometry.graph.comparator.EdgeAttributeValueComparator)5 BoundingBox (com.revolsys.geometry.model.BoundingBox)4 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)4 List (java.util.List)4 EdgeObjectFilter (com.revolsys.geometry.graph.filter.EdgeObjectFilter)2 LineStringGraph (com.revolsys.geometry.graph.linestring.LineStringGraph)2 Polygon (com.revolsys.geometry.model.Polygon)2 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 Shape (java.awt.Shape)2