Search in sources :

Example 16 with LineSegment

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

the class LineSegmentTest method testOrientationIndexSegment.

public void testOrientationIndexSegment() {
    final LineSegment seg = new LineSegmentDouble(2, 100, 100, 110, 110);
    checkOrientationIndex(seg, 100, 101, 105, 106, 1);
    checkOrientationIndex(seg, 100, 99, 105, 96, -1);
    checkOrientationIndex(seg, 200, 200, 210, 210, 0);
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 17 with LineSegment

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

the class LineSegmentTest method testProjectionFactor.

public void testProjectionFactor() {
    // zero-length line
    final LineSegment seg = new LineSegmentDouble(2, 10, 0, 10, 0);
    assertTrue(Double.isNaN(seg.projectionFactor(new PointDoubleXY(11.0, 0))));
    final LineSegment seg2 = new LineSegmentDouble(2, 10, 0, 20, 0);
    assertTrue(seg2.projectionFactor(new PointDoubleXY(11.0, 0)) == 0.1);
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 18 with LineSegment

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

the class SnapRoundingTest method isSnapped.

private boolean isSnapped(final Point v, final Point p0, final Point p1) {
    if (v.equals(2, p0)) {
        return true;
    }
    if (v.equals(2, p1)) {
        return true;
    }
    final LineSegment seg = new LineSegmentDouble(p0, p1);
    final double dist = seg.distancePoint(v);
    if (dist < SNAP_TOLERANCE / 2.05) {
        return false;
    }
    return true;
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 19 with LineSegment

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

the class LineMatchGraph method getMatchLength.

public double getMatchLength(final Node<LineSegmentMatch> node, final boolean direction, final int index1, final int index2) {
    List<Edge<LineSegmentMatch>> edges;
    if (direction) {
        edges = node.getOutEdges();
    } else {
        edges = node.getInEdges();
    }
    for (final Edge<LineSegmentMatch> edge : edges) {
        final LineSegmentMatch lineSegmentMatch = edge.getObject();
        if (lineSegmentMatch.hasMatches(index1, index2)) {
            final LineSegment segment = lineSegmentMatch.getSegment(index2);
            final double length = segment.getLength();
            final Node<LineSegmentMatch> nextNode = edge.getOppositeNode(node);
            return length + getMatchLength(nextNode, direction, index1, index2);
        }
    }
    return 0;
}
Also used : Edge(com.revolsys.geometry.graph.Edge) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 20 with LineSegment

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

the class LineMatchGraph method add.

private Edge<LineSegmentMatch> add(final LineSegmentMatch lineSegmentMatch, final Node<LineSegmentMatch> from, final Node<LineSegmentMatch> to) {
    final Edge<LineSegmentMatch> newEdge = add(from, to);
    final LineSegmentMatch newLineSegmentMatch = newEdge.getObject();
    for (int i = 0; i < lineSegmentMatch.getSegmentCount(); i++) {
        if (lineSegmentMatch.hasSegment(i)) {
            final LineSegment realSegment = lineSegmentMatch.getSegment(i);
            final Point coordinate0 = realSegment.project(from);
            final Point coordinate1 = realSegment.project(to);
            final LineSegment newSegment = new LineSegmentDoubleGF(this.geometryFactory, coordinate0, coordinate1);
            newLineSegmentMatch.addSegment(newSegment, i);
        }
    }
    return newEdge;
}
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)

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