public void testExtractPointBeyondRange() { Geometry linearGeom = read("LINESTRING (0 0, 10 10)"); LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom); Coordinate pt = indexedLine.extractPoint(100); assertTrue(pt.equals(new Coordinate(10, 10))); Coordinate pt2 = indexedLine.extractPoint(0); assertTrue(pt2.equals(new Coordinate(0, 0))); }
public void testProjectPointWithDuplicateCoords() { Geometry linearGeom = read("LINESTRING (0 0, 10 0, 10 0, 20 0)"); LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom); double projIndex = indexedLine.project(new Coordinate(10, 1)); assertTrue(projIndex == 10.0); }
/** * Tests that if the input does not have Z ordinates, neither does the output. * */ public void testComputeZNaN() { Geometry linearGeom = read("LINESTRING (0 0, 10 10 10)"); LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom); double projIndex = indexedLine.project(new Coordinate(5, 5)); Coordinate projPt = indexedLine.extractPoint(projIndex); assertTrue(Double.isNaN(projPt.getZ() )); }
/** * From GEOS Ticket #323 */ public void testProjectExtractPoint() { Geometry linearGeom = read("MULTILINESTRING ((0 2, 0 0), (-1 1, 1 1))"); LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom); double index = indexedLine.project(new Coordinate(1, 0)); Coordinate pt = indexedLine.extractPoint(index); assertTrue(pt.equals(new Coordinate(0, 0))); }
/** * Tests that z values are interpolated * */ public void testComputeZ() { Geometry linearGeom = read("LINESTRING (0 0 0, 10 10 10)"); LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom); double projIndex = indexedLine.project(new Coordinate(5, 5)); Coordinate projPt = indexedLine.extractPoint(projIndex); // System.out.println(projPt); assertTrue(projPt.equals3D(new Coordinate(5, 5, 5))); }