jts
jts copied to clipboard
FacetSequenceTreeBuilder - issue with odd CoordinateSequences
FacetSequenceTreeBuilder for odd CoordinateSequences produces last FacetSequence with size=1. And last Coordinate is duplicated in previous FacetSequence (that is extended). I think there was intention to avoid having one point FacetSequences. I attached proposed patch. Not very elegant but should be correct. Issue is reproducible in JTS 1.14 - current master.
Code from following lines: https://github.com/locationtech/jts/blob/b236fb62db6bd61ab54e3f086cf9875b1ce5a56b/modules/core/src/main/java/org/locationtech/jts/operation/distance/FacetSequenceTreeBuilder.java#L78-L81
Should be replaced to:
if (end >= size - 1) {
end = size;
FacetSequence sect = new FacetSequence(geom, pts, i, end);
sections.add(sect);
break;
}
FacetSequence sect = new FacetSequence(geom, pts, i, end);
sections.add(sect);