NetTopologySuite / NetTopologySuite.IO.ShapeFile

The ShapeFile IO module for NTS.
33 stars 25 forks source link

MultiLineHandler.GeometryInstantiationErrorHandling is broken #44

Closed stijnherreman closed 2 years ago

stijnherreman commented 4 years ago

https://github.com/NetTopologySuite/NetTopologySuite.IO.ShapeFile/blob/bef5ec80cc5b1b5a95f4df3bfc5a61ab837525a1/src/NetTopologySuite.IO.ShapeFile/Handlers/MultiLineHandler.cs#L86-L103

The default is ThrowException, this works. Null also works, it ends up creating an empty multilinestring. Empty and TryFix don't work, they modify sequences[s] but this modified data is not used in the later code. factory.CreateLineString(points) throws because there is still only one point in points.

I assume this wasn't fully tested when introduced in https://github.com/NetTopologySuite/NetTopologySuite/commit/99423319ed4ef21f35e48a2e145a8431cf372227 Replacing sequences[s] with points makes Empty return an empty linestring, and makes TryFix return a linestring with two coordinates at the same position. This was probably the intent of the original code.