locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.97k stars 442 forks source link

RobustLineIntersector defensive copyWithZ check to avoid exception with CoordinateXY or CoordinateXYM #1071

Closed jodygarnett closed 2 months ago

jodygarnett commented 2 months ago

Defensive check prevents copyWithZ, copyWithZInterpolate methods from throwing an exception when the target coordinate is CoordinateXY or CoordinateXYM.

This is in addition to the existing defensive check to avoid doing anything if the z vale was Double.NaN.

This mitigates but does not solve https://github.com/locationtech/jts/issues/375 which is due to the intermixing of Coordinate and CoordinateXY values in GeoTools clipping code.

jodygarnett commented 2 months ago

This is minimal change to avoid exception.

I looked at "casting" coordinates to solve https://github.com/locationtech/jts/issues/375 but am uncomfortable doing so in performance sensitive code.

dr-jts commented 2 months ago

Looks good to me.