NetTopologySuite / NetTopologySuite.IO.Esri

BSD 3-Clause "New" or "Revised" License
35 stars 18 forks source link

Treat `*` character as null indicator of numeric field #13

Closed KubaSzostak closed 1 year ago

KubaSzostak commented 1 year ago

QGIS reads numeric fields filled with * character. Esri also does not complain. Now NetTopologySuite.IO.Esri will also support it. Fix #11.

FObermaier commented 1 year ago

Here is how GDAL/OGR evaluates a dbase field for NULL: https://github.com/OSGeo/gdal/blob/master/ogr/ogrsf_frmts/shape/dbfopen.c#L1102-L1143

Is that conformant to how we do it here?

DGuidi commented 1 year ago

Is that conformant to how we do it here?

looks the same handling implemented here to me

KubaSzostak commented 1 year ago

Is that conformant to how we do it here?

  1. It's pretty much the same for numeric and character fields .
  2. Additionally I will add missing "00000000" check fot Date fields.
  3. For Logical fields they check only for '?'. In our code everything but TtYy and FfNn is treated as NULL. Should I make it conformant with GDAL?
FObermaier commented 1 year ago
  1. Additionally I will add missing "00000000" check for Date fields.

That is good.

  1. For Logical fields they check only for '?'. In our code everything but TtYy and FfNn is treated as NULL. Should I make it conformant with GDAL?

I'd say so, this way we reduce the chance of having to fix it later on. I assume that everything else beside "TtYy" and "?" is treated as false in GDAL/OGR.

KubaSzostak commented 1 year ago

I assume that everything else beside "TtYy" and "?" is treated as false in GDAL/OGR.

I don't know how it's treated in GDAL. The TtYy and FfNn is my ideat to get logical value from character not always within DBASE specification. I don't know how GDAL is dealing with this. I will check it and make it conformant with GDAL.

FObermaier commented 1 year ago

It seems like GDAL/OGR Shapefile driver does not do any explicit conversion to bool and just passes a pointer ot the character. In QGIS you can't create a Dbase field of type logical/bool. So we are a bit on our own.

I'd say we can safely convert TtYy1 to true and any other value to false. ? is null. Maybe instead of just 1 we can treat any number character != 0 as true.

According to https://www.clicketyclick.dk/databases/xbase/format/data_types.html#DATA_TYPES