Search in sources :

Example 1 with LengthIndexedLine

use of com.revolsys.geometry.linearref.LengthIndexedLine in project com.revolsys.open by revolsys.

the class LinearReferencingFunctions method extractPoint.

public static Geometry extractPoint(final Geometry g, final double index) {
    final LengthIndexedLine ll = new LengthIndexedLine(g);
    final Point p = ll.extractPoint(index);
    return g.getGeometryFactory().point(p);
}
Also used : LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) Point(com.revolsys.geometry.model.Point)

Example 2 with LengthIndexedLine

use of com.revolsys.geometry.linearref.LengthIndexedLine in project com.revolsys.open by revolsys.

the class LengthIndexedLineTest method indexOfAfterCheck.

@Override
protected boolean indexOfAfterCheck(final Geometry linearGeom, final Point testPt, final Point checkPt) {
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    // check that computed location is after check location
    final double checkLoc = indexedLine.indexOf(checkPt);
    final double testLoc = indexedLine.indexOfAfter(testPt, checkLoc);
    if (testLoc < checkLoc) {
        return false;
    }
    return true;
}
Also used : LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine)

Example 3 with LengthIndexedLine

use of com.revolsys.geometry.linearref.LengthIndexedLine in project com.revolsys.open by revolsys.

the class LengthIndexedLineTest method testProjectExtractPoint.

/**
 * From GEOS Ticket #323
 */
public void testProjectExtractPoint() {
    final Geometry linearGeom = read("MULTILINESTRING ((0 2, 0 0), (-1 1, 1 1))");
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    final double index = indexedLine.project(new PointDoubleXY(1, 0));
    final Point pt = indexedLine.extractPoint(index);
    assertTrue(pt.equals(new PointDoubleXY(0, 0)));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 4 with LengthIndexedLine

use of com.revolsys.geometry.linearref.LengthIndexedLine in project com.revolsys.open by revolsys.

the class LengthIndexedLineTest method testComputeZ.

/**
 * Tests that z values are interpolated
 */
public void testComputeZ() {
    final Geometry linearGeom = read("LINESTRINGZ(0 0 0, 10 10 10)");
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    final double projIndex = indexedLine.project(new PointDoubleXY(5, 5));
    final Point projPt = indexedLine.extractPoint(projIndex);
    // System.out.println(projPt);
    assertTrue(projPt.equals(3, new PointDoubleXYZ(5.0, 5, 5)));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 5 with LengthIndexedLine

use of com.revolsys.geometry.linearref.LengthIndexedLine in project com.revolsys.open by revolsys.

the class LengthIndexedLineTest method testExtractPointBeyondRange.

public void testExtractPointBeyondRange() {
    final Geometry linearGeom = read("LINESTRING (0 0, 10 10)");
    final LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom);
    final Point pt = indexedLine.extractPoint(100);
    assertTrue(pt.equals(new PointDoubleXY(10, 10)));
    final Point pt2 = indexedLine.extractPoint(0);
    assertTrue(pt2.equals(new PointDoubleXY(0, 0)));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LengthIndexedLine(com.revolsys.geometry.linearref.LengthIndexedLine) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Aggregations

LengthIndexedLine (com.revolsys.geometry.linearref.LengthIndexedLine)11 Geometry (com.revolsys.geometry.model.Geometry)7 Point (com.revolsys.geometry.model.Point)6 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)5 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)1