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:

  1. Vector calculation: Two duplicate points produce a zero vector.
  2. Length calculation: A segment length of 0 easily leads to NaN issues.

Therefore, when constructing a PolyLine, we check the points and throw an exception if any duplicate points are found.

The following issues were identified:

  • getEnd in JTS has problems.

  • LinearLocation in 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 -1
    
  • During interpolation, two points that are too close to each other may be selected.