Saving geometries with Z=NaN
Closed this issue · 3 comments
We're in process of migrating to IO.ESRI
from IO.ShapeFile
& we have noticed a change in behavior when saving PointZM geometries where Z=NaN
The old version was exporting these NaN
values, while the new version converts them to 0
.
Checking the code it mentions spec conformance. On the other hand, according to the spec:
Positive infinity, negative infinity, and Not-a-Number (NaN) values are not allowed in shapefiles.
& the library saves X & Y coordinates without any conversion. (Sure, the code mentions "// Avoid performance costs (if you trying to pas NaN as X,Y then you're wrong).")
Unfortunately our software is relying on the behavior of the old version: we need to round-trip coordinates with NaN
values.
Before sending a PR I'd be interested in your opinion & if this is something you consider supporting at all.
I was thinking of introducing some kind of "Legacy" or "Loose" behavior switch for exports, similar to the GeometryBuilderMode
when importing, but open to other ideas.
Another option would be making the Shapefile
static class a bit more extensible & reusable, so I can reproduce the WriteAllFeatures
without copying half of the class, by injecting a custom ShapefilePointWriter
. This way I could write out-of-spec files without making the library to support out-of-spec files. This would be a bigger refactoring, however. (Esp. that the other writers need to be split, too, e.g. ShpMultiPartBuilder
)
The old version was exporting these NaN values, while the new version converts them to 0.
Hi @enyim , as you can see in the code conversion from NaN
to 0.0
is already commented out (in order to avoid performance costs). This means NaN
values should be exported as NaN
. I think the conversion NaN -> 0.0
is done somewhere else. Can you provide code sample that illustrates the issue?
Before sending a PR I'd be interested in your opinion & if this is something you consider supporting at all.
I can't judge this until I see the code. I would go with a new property in ShapefileReaderOptions
and ShapefileWriterOptions
, similar to GeometryBuilderMode
.
See also #29.
We have requested more information regarding this issue, but have not received a response or additional information regarding this issue. Therefore, we are closing this issue. Please feel free to reopen it if you are able to provide the necessary details.