protected void runIndicesOfThenExtract(String inputStr, String subLineStr) // throws Exception { Geometry input = read(inputStr); Geometry subLine = read(subLineStr); Geometry result = indicesOfThenExtract(input, subLine); checkExpected(result, subLineStr); }
public void testIndexOfAfterSquare() { runIndexOfAfterTest("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)", "POINT (0 0)"); }
public void testLoopWithIdenticalSubLine() { runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)", "LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)"); }
protected void runIndexOfAfterTest(String inputStr, String testPtWKT) // throws Exception { Geometry input = read(inputStr); Geometry testPoint = read(testPtWKT); Coordinate testPt = testPoint.getCoordinate(); boolean resultOK = indexOfAfterCheck(input, testPt); assertTrue(resultOK); }
protected void runOffsetTest(String inputWKT, String testPtWKT, double offsetDistance, String expectedPtWKT) // throws Exception { Geometry input = read(inputWKT); Geometry testPoint = read(testPtWKT); Geometry expectedPoint = read(expectedPtWKT); Coordinate testPt = testPoint.getCoordinate(); Coordinate expectedPt = expectedPoint.getCoordinate(); Coordinate offsetPt = extractOffsetAt(input, testPt, offsetDistance); boolean isOk = offsetPt.distance(expectedPt) < TOLERANCE_DIST; if (! isOk) System.out.println("Expected = " + expectedPoint + " Actual = " + offsetPt); assertTrue(isOk); }
protected void checkExpected(Geometry result, String expected) { Geometry subLine = read(expected); boolean isEqual = result.equalsExact(subLine, 1.0e-5); if (! isEqual) { System.out.println("Computed result is: " + result); } assertTrue(isEqual); }
public void testOffsetEndPoint() { runOffsetTest("LINESTRING (0 0, 20 20)", "POINT(20 20)", 0.0, "POINT (20 20)"); runOffsetTest("LINESTRING (0 0, 13 13, 20 20)", "POINT(20 20)", 0.0, "POINT (20 20)"); runOffsetTest("LINESTRING (0 0, 10 0, 20 0)", "POINT(20 0)", 1.0, "POINT (20 1)"); runOffsetTest("LINESTRING (0 0, 20 0)", "POINT(10 0)", 1.0, "POINT (10 1)"); // point on last segment runOffsetTest("MULTILINESTRING ((0 0, 10 0), (10 0, 20 0))", "POINT(10 0)", -1.0, "POINT (10 -1)"); runOffsetTest("MULTILINESTRING ((0 0, 10 0), (10 0, 20 0))", "POINT(20 0)", 1.0, "POINT (20 1)"); }
protected void runIndexOfAfterTest(String inputStr, String testPtWKT, String afterPtWKT) // throws Exception { Geometry input = read(inputStr); Geometry testPoint = read(testPtWKT); Coordinate testPt = testPoint.getCoordinate(); Geometry afterPoint = read(afterPtWKT); Coordinate afterPt = afterPoint.getCoordinate(); boolean resultOK = indexOfAfterCheck(input, testPt, afterPt); assertTrue(resultOK); }
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)"); // These tests work for LengthIndexedLine, but not LocationIndexedLine //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)"); }
/** * Following tests check that correct portion of loop is identified. * This requires that the correct vertex for (0,0) is selected. */ public void testLoopWithStartSubLine() { runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)", "LINESTRING (0 0, 0 10, 10 10)"); }
public void testOffsetStartPoint() { runOffsetTest("LINESTRING (0 0, 10 10, 20 20)", "POINT(0 0)", 1.0, "POINT (-0.7071067811865475 0.7071067811865475)"); runOffsetTest("LINESTRING (0 0, 10 10, 20 20)", "POINT(0 0)", -1.0, "POINT (0.7071067811865475 -0.7071067811865475)"); runOffsetTest("LINESTRING (0 0, 10 10, 20 20)", "POINT(10 10)", 5.0, "POINT (6.464466094067262 13.535533905932738)"); runOffsetTest("LINESTRING (0 0, 10 10, 20 20)", "POINT(10 10)", -5.0, "POINT (13.535533905932738 6.464466094067262)"); }
public void testIndexOfAfterRibbon() { runIndexOfAfterTest("LINESTRING (0 0, 0 60, 50 60, 50 20, -20 20)", "POINT (0 20)"); runIndexOfAfterTest("LINESTRING (0 0, 0 60, 50 60, 50 20, -20 20)", "POINT (0 20)", "POINT (30 60)"); }
/** * Tests that duplicate coordinates are handled correctly. */ public void testPartOfSegmentContainingDuplicateCoords() { runIndicesOfThenExtract("LINESTRING (0 0, 10 10, 10 10, 20 20)", "LINESTRING (5 5, 10 10, 10 10, 15 15)"); }
public void testFirst() { runOffsetTest("LINESTRING (0 0, 20 20)", "POINT(20 20)", 0.0, "POINT (20 20)"); }
public void testIndexOfAfterBeyondEndRibbon() { runIndexOfAfterTest("LINESTRING (0 0, 0 60, 50 60, 50 20, -20 20)", "POINT (-30 20)", "POINT (-20 20)"); }
public void testZeroLenSubLineAtStart() { runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)", "LINESTRING (0 0, 0 0)"); }
public void testPartOfSegmentNoVertex() { runIndicesOfThenExtract("LINESTRING (0 0, 10 10, 20 20)", "LINESTRING (1 1, 9 9)"); }
public void testPartOfSegmentContainingVertex() { runIndicesOfThenExtract("LINESTRING (0 0, 10 10, 20 20)", "LINESTRING (5 5, 10 10, 15 15)"); }
public void testML() { runIndicesOfThenExtract("MULTILINESTRING ((0 0, 10 10), (20 20, 30 30))", "MULTILINESTRING ((1 1, 10 10), (20 20, 25 25))"); }
public void testLoopWithEndingSubLine() { runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)", "LINESTRING (10 10, 10 0, 0 0)"); }