use of com.revolsys.geometry.model.segment.LineSegmentDouble 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.LineSegmentDouble 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.LineSegmentDouble 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.LineSegmentDouble in project com.revolsys.open by revolsys.
the class LineString method isLeft.
default boolean isLeft(final Point point) {
final double x = point.getX();
final double y = point.getY();
final int vertexCount = getVertexCount();
if (vertexCount > 1) {
double x1 = getX(0);
double y1 = getY(0);
for (int vertexIndex = 1; vertexIndex < vertexCount; vertexIndex++) {
final double x2 = getX(vertexIndex);
final double y2 = getY(vertexIndex);
if (!crosses(new LineSegmentDouble(2, x1, y1, x, y)) && !crosses(new LineSegmentDouble(2, x2, y2, x, y))) {
final int orientation = LineSegmentUtil.orientationIndex(x1, y1, x2, y2, x, y);
if (orientation == 1) {
return true;
} else {
return false;
}
}
x1 = x2;
y1 = y2;
}
return true;
} else {
return false;
}
}
use of com.revolsys.geometry.model.segment.LineSegmentDouble in project com.revolsys.open by revolsys.
the class LinearLocation method getSegment.
/**
* Gets a {@link LineSegmentDouble} representing the segment of the
* given linear {@link Geometry} which contains this location.
*
* @param linearGeom a linear geometry
* @return the <tt>LineSegmentDouble</tt> containing the location
*/
public LineSegment getSegment(final Geometry linearGeom) {
final LineString lineComp = (LineString) linearGeom.getGeometry(this.componentIndex);
final Point p0 = lineComp.getPoint(this.segmentIndex);
// check for endpoint - return last segment of the line if so
if (this.segmentIndex >= lineComp.getVertexCount() - 1) {
final Point prev = lineComp.getPoint(lineComp.getVertexCount() - 2);
return new LineSegmentDouble(prev, p0);
}
final Point p1 = lineComp.getPoint(this.segmentIndex + 1);
return new LineSegmentDouble(p0, p1);
}
Aggregations