/** * Computes the {@link LinearLocation} for a * given length along a linear {@link Geometry}. * * @param linearGeom the linear geometry to use * @param length the length index of the location * @return the {@link LinearLocation} for the length */ public static LinearLocation getLocation(Geometry linearGeom, double length) { LengthLocationMap locater = new LengthLocationMap(linearGeom); return locater.getLocation(length); }
/** * Computes the length for a given {@link LinearLocation} * on a linear {@link Geometry}. * * @param linearGeom the linear geometry to use * @param loc the {@link LinearLocation} index of the location * @return the length for the {@link LinearLocation} */ public static double getLength(Geometry linearGeom, LinearLocation loc) { LengthLocationMap locater = new LengthLocationMap(linearGeom); return locater.getLength(loc); }
/** * Compute the {@link LinearLocation} corresponding to a length. * Negative lengths are measured in reverse from end of the linear geometry. * Out-of-range values are clamped. * Ambiguous indexes are resolved to the lowest or highest possible location value, * depending on the value of <tt>resolveLower</tt> * * @param length the length index * @return the corresponding LinearLocation */ public LinearLocation getLocation(double length, boolean resolveLower) { double forwardLength = length; // negative values are measured from end of geometry if (length < 0.0) { double lineLen = linearGeom.getLength(); forwardLength = lineLen + length; } LinearLocation loc = getLocationForward(forwardLength); if (resolveLower) { return loc; } return resolveHigher(loc); }
private LinearLocation locationOf(double index) { return LengthLocationMap.getLocation(linearGeom, index); }
/** * Computes the indices for a subline of the line. * (The subline must <b>conform</b> to the line; that is, * all vertices in the subline (except possibly the first and last) * must be vertices of the line and occur in the same order). * * @param subLine a subLine of the line * @return a pair of indices for the start and end of the subline. */ public double[] indicesOf(Geometry subLine) { LinearLocation[] locIndex = LocationIndexOfLine.indicesOf(linearGeom, subLine); double[] index = new double[] { LengthLocationMap.getLength(linearGeom, locIndex[0]), LengthLocationMap.getLength(linearGeom, locIndex[1]) }; return index; }
/** * Compute the {@link LinearLocation} corresponding to a length. * Negative lengths are measured in reverse from end of the linear geometry. * Out-of-range values are clamped. * Ambiguous indexes are resolved to the lowest possible location value. * * @param length the length index * @return the corresponding LinearLocation */ public LinearLocation getLocation(double length) { return getLocation(length, true); }
/** * Computes the {@link LinearLocation} for a * given length along a linear {@link Geometry}, * with control over how the location * is resolved at component endpoints. * * @param linearGeom the linear geometry to use * @param length the length index of the location * @param resolveLower if true lengths are resolved to the lowest possible index * @return the {@link LinearLocation} for the length */ public static LinearLocation getLocation(Geometry linearGeom, double length, boolean resolveLower) { LengthLocationMap locater = new LengthLocationMap(linearGeom); return locater.getLocation(length, resolveLower); }
private LinearLocation locationOf(double index, boolean resolveLower) { return LengthLocationMap.getLocation(linearGeom, index, resolveLower); }
/** * Computes the {@link Coordinate} for the point * on the line at the given index. * If the index is out of range the first or last point on the * line will be returned. * The Z-ordinate of the computed point will be interpolated from * the Z-ordinates of the line segment containing it, if they exist. * * @param index the index of the desired point * @return the Coordinate at the given index */ public Coordinate extractPoint(double index) { LinearLocation loc = LengthLocationMap.getLocation(linearGeom, index); return loc.getCoordinate(linearGeom); }
/** * Computes the {@link Coordinate} for the point * on the line at the given index, offset by the given distance. * If the index is out of range the first or last point on the * line will be returned. * The computed point is offset to the left of the line if the offset distance is * positive, to the right if negative. * * The Z-ordinate of the computed point will be interpolated from * the Z-ordinates of the line segment containing it, if they exist. * * @param index the index of the desired point * @param offsetDistance the distance the point is offset from the segment * (positive is to the left, negative is to the right) * @return the Coordinate at the given index */ public Coordinate extractPoint(double index, double offsetDistance) { LinearLocation loc = LengthLocationMap.getLocation(linearGeom, index); LinearLocation locLow = loc.toLowest(linearGeom); return locLow.getSegment(linearGeom).pointAlongOffset(locLow.getSegmentFraction(), offsetDistance); }