public void testExtractLineIndexAtEndpoint() { checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))", 10, -1, "LINESTRING (20 0, 25 0, 29 0)"); }
/** * These tests work for LengthIndexedLine, but not LocationIndexedLine * */ public void testOffsetStartPointRepeatedPoint() { runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(0 0)", 1.0, "POINT (-0.7071067811865475 0.7071067811865475)"); runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(0 0)", -1.0, "POINT (0.7071067811865475 -0.7071067811865475)"); runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(10 10)", 5.0, "POINT (6.464466094067262 13.535533905932738)"); runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(10 10)", -5.0, "POINT (13.535533905932738 6.464466094067262)"); }
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); }
private void checkExtractLine(String wkt, double start, double end, String expected) { Geometry linearGeom = read(wkt); LengthIndexedLine indexedLine = new LengthIndexedLine(linearGeom); Geometry result = indexedLine.extractLine(start, end); checkExpected(result, expected); }
/** * 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() )); }
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 testExtractLineBothIndicesAtEndpoint() { checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))", 10, 10, "LINESTRING (10 0, 10 0)"); }
/** * 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))); }
public void testExtractLineBothIndicesAtEndpointXXX() { checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))", -10, 10, "LINESTRING (10 0, 10 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))); }
public void testExtractLineReverseMulti() { checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))", 19, 1, "MULTILINESTRING ((29 0, 25 0, 20 0), (10 0, 1 0))"); }
public void testExtractLineBothIndicesAtEndpointNegative() { checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))", -10, 10, "LINESTRING (10 0, 10 0)"); }
public void testExtractLineNegative() { checkExtractLine("LINESTRING (0 0, 10 0)", -9, -1, "LINESTRING (1 0, 9 0)"); }
public void testExtractLineNegativeReverse() { checkExtractLine("LINESTRING (0 0, 10 0)", -1, -9, "LINESTRING (9 0, 1 0)"); }
public void testExtractLineReverse() { checkExtractLine("LINESTRING (0 0, 10 0)", 9, 1, "LINESTRING (9 0, 1 0)"); }
public void testExtractLineBeyondRange() { checkExtractLine("LINESTRING (0 0, 10 10)", -100, 100, "LINESTRING (0 0, 10 10)"); }
/** * Tests that leading and trailing zero-length sublines are trimmed in the computed result, * and that zero-length extracts return the lowest extracted zero-length line */ public void testExtractLineIndexAtEndpointWithZeroLenComponents() { checkExtractLine("MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))", 10, -1, "LINESTRING (20 0, 25 0, 29 0)"); checkExtractLine("MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))", 5, 10, "LINESTRING (5 0, 10 0)"); checkExtractLine("MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))", 10, 10, "LINESTRING (10 0, 10 0)"); checkExtractLine("MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (10 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))", 10, -10, "LINESTRING (10 0, 10 0)"); }