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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations