Search in sources :

Example 6 with LineSegmentDouble

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);
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 7 with LineSegmentDouble

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);
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 8 with LineSegmentDouble

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;
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 9 with LineSegmentDouble

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;
    }
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble)

Example 10 with LineSegmentDouble

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);
}
Also used : LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point)

Aggregations

LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)20 LineSegment (com.revolsys.geometry.model.segment.LineSegment)14 Point (com.revolsys.geometry.model.Point)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)5 LineString (com.revolsys.geometry.model.LineString)2 DirectedEdge (com.revolsys.geometry.geomgraph.DirectedEdge)1 Edge (com.revolsys.geometry.geomgraph.Edge)1 LinearLocation (com.revolsys.geometry.linearref.LinearLocation)1 LocationIndexedLine (com.revolsys.geometry.linearref.LocationIndexedLine)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1