/** * 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(LinearLocation index, double offsetDistance) { return index.getSegment(linearGeom).pointAlongOffset(index.getSegmentFraction(), offsetDistance); }
/** * 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); return loc.getSegment(linearGeom).pointAlongOffset(loc.getSegmentFraction(), offsetDistance); }
Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen); Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
// create LineSegment LineSegment ls = new LineSegment(p1.getX(), p1.getY(), p2.getX(), p2.getY()); // perpendicular distance to line double offsetDistance = 10; // calculate Point right to start point Coordinate startRight = ls.pointAlongOffset(0, offsetDistance); // calculate Point left to start point Coordinate startLeft = ls.pointAlongOffset(0, -offsetDistance); // calculate Point right to end point Coordinate endRight = ls.pointAlongOffset(1, offsetDistance); // calculate Point left to end point Coordinate endLeft = ls.pointAlongOffset(1, -offsetDistance);
private static Set<Coordinate> computePoints(Coordinate[] coords, double segmentLengthFraction, double offsetDistance) { Set<Coordinate> pointsToAdd = new HashSet<Coordinate>(); for (int j = 0; j < coords.length - 1; j++) { LineSegment segment = new LineSegment(coords[j], coords[j + 1]); pointsToAdd.add(segment.pointAlongOffset(segmentLengthFraction, offsetDistance)); } return pointsToAdd; } }
private static Set<Coordinate> computePoints(Coordinate[] coords, double segmentLengthFraction, double offsetDistance) { Set<Coordinate> pointsToAdd = new HashSet<Coordinate>(); for (int j = 0; j < coords.length - 1; j++) { LineSegment segment = new LineSegment(coords[j], coords[j + 1]); pointsToAdd.add(segment.pointAlongOffset(segmentLengthFraction, offsetDistance)); } return pointsToAdd; } }
/** * 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(LinearLocation index, double offsetDistance) { LinearLocation indexLow = index.toLowest(linearGeom); return indexLow.getSegment(linearGeom).pointAlongOffset(indexLow.getSegmentFraction(), offsetDistance); }
/** * 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); }
Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen); Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);