Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jts-dev] LinearLocation

Dear,
I was having precision issues when generating a Coordinate over a LineString (coord1, coord2). In particular, I would do a convex combination of p1 and p2 to get the Coordinate, but it would not always be covered by the LineString due to numerical precision. After I changed to pointAlongSegmentByFraction, then it seems to be solved, but does anyone know whether there is any guarantee the generated point will always lie over the line?

Thanks in advance,
Afonso

public static Coordinate pointAlongSegmentByFraction(Coordinate p0, Coordinate p1, double frac)
Computes the Coordinate of a point a given fraction along the line segment (p0, p1). If the fraction is greater than 1.0 the last point of the segment is returned. If the fraction is less than or equal to 0.0 the first point of the segment is returned. The Z ordinate is interpolated from the Z-ordinates of the given points, if they are specified.

Back to the top