NetTopologySuite / NetTopologySuite.IO.SpatiaLite

SpatialLite IO module for NTS.
BSD 3-Clause "New" or "Revised" License
7 stars 9 forks source link

GaiaGeoReader.Read(byte[] blob) throws an exception in case the envelope Coordinates read from the blob contain double.NaN #9

Open UliEgger opened 1 year ago

UliEgger commented 1 year ago

Dear developers,

It seems to be normal, that a Coordinate can contain an Ordinate double.NaN as defined in NetTopologySuite.Geometries.Coordinate.NullOrdinate

public const double NullOrdinate = NaN

https://nettopologysuite.github.io/NetTopologySuite/api/NetTopologySuite.Geometries.Coordinate.html

A point that contains such a Coordinate can be stored to a database as a blob unsing GaiaGeoWriter.Write(Geometry geom)

However when using GaiaGeoReader.Read to get back the Geometry from the blob value (when reading from database), an exception is thrown at this location:

Evenlope.Init

grafik

Further down in the call stack, we see that an Envelope is created but not used in GaiaGeoReader.Read:

grafik

Would it be possible that this is removed and a new version of the nuget-Package can be provided ?

Thank you very much, best regards, Ulrich Egger

UliEgger commented 1 year ago

I guess gaiaImport.GetDouble has still to be called four times at that place, but without creating the evelope.

UliEgger commented 1 year ago

If I use the current version of GaiaGeoWriter to write the geometry, the problem does not occur. It occurs in case of the blob has been wirtten by an earlier version.

It looks like current version created a null envelope for a Point with X = 550123 and Y = double.NaN

grafik

and this envelope is valid.

UliEgger commented 1 year ago

Currently used version is 2.0.0 Previously used version, where the bug did not occur when reading but wirtes blobs that cannot be read with the current version was 1.14.4

UliEgger commented 1 year ago

In the earlier used version of NetTopologySuite the constructor of envelope / Init method did not throw an exception when using double.NaN.

UliEgger commented 1 year ago

I have created a pull request