2020-05-09
PolyLine Fix and Test
The main issue with PolyLine is that it may contain duplicate points during construction, leading to a series of segment-related geometric calculation problems:
- Vector calculation: Two duplicate points produce a zero vector.
- Length calculation: A segment length of 0 easily leads to
NaNissues.
Therefore, when constructing a PolyLine, we check the points and throw an exception if any duplicate points are found.
The following issues were identified:
getEndin JTS has problems.LinearLocationin JTS may have normalization issues.val loc1 = new LinearLocation(0, 1, 1.0) val loc2 = new LinearLocation(0, 2, 0.0) loc1 compareTo loc2 // the output is -1During interpolation, two points that are too close to each other may be selected.