/** * Extracts a subline of the input. * If <code>end < start</code> the linear geometry computed will be reversed. * * @param start the start location * @param end the end location * @return a linear geometry */ public Geometry extract(LinearLocation start, LinearLocation end) { if (end.compareTo(start) < 0) { return reverse(computeLinear(end, start)); } return computeLinear(start, end); }
protected boolean indexOfAfterCheck(Geometry linearGeom, Coordinate testPt, Coordinate afterPt) { LocationIndexedLine indexedLine = new LocationIndexedLine(linearGeom); // check that computed location is after check location LinearLocation afterLoc = indexedLine.indexOf(afterPt); LinearLocation testLoc = indexedLine.indexOfAfter(testPt, afterLoc); if (testLoc.compareTo(afterLoc) < 0 ) return false; return true; }
public void testZeroLengthLineString() throws Exception { Geometry line = reader.read("LINESTRING (10 0, 10 0)"); LocationIndexedLine indexedLine = new LocationIndexedLine(line); LinearLocation loc0 = indexedLine.indexOf(new Coordinate(11, 0)); assertTrue(loc0.compareTo(new LinearLocation(1, 0.0)) == 0); }
public void testRepeatedCoordsLineString() throws Exception { Geometry line = reader.read("LINESTRING (10 0, 10 0, 20 0)"); LocationIndexedLine indexedLine = new LocationIndexedLine(line); LinearLocation loc0 = indexedLine.indexOf(new Coordinate(11, 0)); assertTrue(loc0.compareTo(new LinearLocation(1, 0.1)) == 0); }
protected boolean indexOfAfterCheck(Geometry linearGeom, Coordinate testPt) { LocationIndexedLine indexedLine = new LocationIndexedLine(linearGeom); // check locations are consecutive LinearLocation loc1 = indexedLine.indexOf(testPt); LinearLocation loc2 = indexedLine.indexOfAfter(testPt, loc1); if (loc2.compareTo(loc1) <= 0 ) return false; // check extracted points are the same as the input Coordinate pt1 = indexedLine.extractPoint(loc1); Coordinate pt2 = indexedLine.extractPoint(loc2); if (! pt1.equals2D(testPt)) return false; if (! pt2.equals2D(testPt)) return false; return true; }