/** * Copies this location * * @return a copy of this location */ public LinearLocation copy() { return new LinearLocation(componentIndex, segmentIndex, segmentFraction); }
/** * Returns the index of the start of the line * @return the location index */ public LinearLocation getStartIndex() { return new LinearLocation(); }
/** * Gets a location which refers to the end of a linear {@link Geometry}. * @param linear the linear geometry * @return a new <tt>LinearLocation</tt> */ public static LinearLocation getEndLocation(Geometry linear) { // assert: linear is LineString or MultiLineString LinearLocation loc = new LinearLocation(); loc.setToEnd(linear); return loc; }
public void testMultiLineString2() throws Exception { runExtractLine("MULTILINESTRING ((0 0, 10 10), (20 20, 30 30))", new LinearLocation(0, 0, 1.0), new LinearLocation(1, 0, .5), "MULTILINESTRING ((10 10, 10 10), (20 20, 25 25))"); }
public void testMultiLineStringSimple() throws Exception { runExtractLine("MULTILINESTRING ((0 0, 10 10), (20 20, 30 30))", new LinearLocation(0, 0, .5), new LinearLocation(1, 0, .5), "MULTILINESTRING ((5 5, 10 10), (20 20, 25 25))"); }
/** * Converts a linear location to the lowest equivalent location index. * The lowest index has the lowest possible component and segment indices. * <p> * Specifically: * <ul> * <li>if the location point is an endpoint, a location value is returned as (nseg-1, 1.0) * <li>if the location point is ambiguous (i.e. an endpoint and a startpoint), the lowest endpoint location is returned * </ul> * If the location index is already the lowest possible value, the original location is returned. * * @param linearGeom the linear geometry referenced by this location * @return the lowest equivalent location */ public LinearLocation toLowest(Geometry linearGeom) { // TODO: compute lowest component index LineString lineComp = (LineString) linearGeom.getGeometryN(componentIndex); int nseg = lineComp.getNumPoints() - 1; // if not an endpoint can be returned directly if (segmentIndex < nseg) return this; return new LinearLocation(componentIndex, nseg, 1.0, false); }
private LinearLocation resolveHigher(LinearLocation loc) { if (! loc.isEndpoint(linearGeom)) return loc; int compIndex = loc.getComponentIndex(); // if last component can't resolve any higher if (compIndex >= linearGeom.getNumGeometries() - 1) return loc; do { compIndex++; } while (compIndex < linearGeom.getNumGeometries() - 1 && linearGeom.getGeometryN(compIndex).getLength() == 0); // resolve to next higher location return new LinearLocation(compIndex, 0, 0.0); }
private LinearLocation getLocationForward(double length) return new LinearLocation(); int compIndex = it.getComponentIndex(); int segIndex = it.getVertexIndex(); return new LinearLocation(compIndex, segIndex, 0.0); int compIndex = it.getComponentIndex(); int segIndex = it.getVertexIndex(); return new LinearLocation(compIndex, segIndex, frac);
return new LinearLocation(minIndex); LinearLocation loc = new LinearLocation(minComponentIndex, minSegmentIndex, minFrac); return loc;
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); }
public void testGetSegmentMultiLineString() throws Exception { Geometry line = reader.read("MULTILINESTRING ((0 0, 10 0, 20 0), (20 0, 30 0))"); LocationIndexedLine indexedLine = new LocationIndexedLine(line); LinearLocation loc0 = indexedLine.indexOf(new Coordinate(0, 0)); LinearLocation loc0_5 = indexedLine.indexOf(new Coordinate(5, 0)); LinearLocation loc1 = indexedLine.indexOf(new Coordinate (10, 0)); LinearLocation loc2 = indexedLine.indexOf(new Coordinate (20, 0)); LinearLocation loc2B = new LinearLocation(1, 0, 0.0); LinearLocation loc2_5 = indexedLine.indexOf(new Coordinate (25, 0)); LinearLocation loc3 = indexedLine.indexOf(new Coordinate (30, 0)); LineSegment seg0 = new LineSegment(new Coordinate(0,0), new Coordinate(10, 0)); LineSegment seg1 = new LineSegment(new Coordinate(10,0), new Coordinate(20, 0)); LineSegment seg2 = new LineSegment(new Coordinate(20,0), new Coordinate(30, 0)); assertTrue(loc0.getSegment(line).equals(seg0)); assertTrue(loc0_5.getSegment(line).equals(seg0)); assertTrue(loc1.getSegment(line).equals(seg1)); assertTrue(loc2.getSegment(line).equals(seg1)); assertTrue(loc2_5.getSegment(line).equals(seg2)); assertTrue(loc3.getSegment(line).equals(seg2)); }
LinearLocation loc1 = indexedLine.indexOf(new Coordinate (10, 0)); LinearLocation loc2 = indexedLine.indexOf(new Coordinate (20, 0)); LinearLocation loc2B = new LinearLocation(1, 0, 0.0);