[gdal-dev] ShapeLib/GDAL support for Dates and Booleans

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] ShapeLib/GDAL support for Dates and Booleans

Jerry Faust

Hello.

My name is Jerry Faust, and I'm a recent contributor to MapWinGIS.  We provide GDAL/OGR layer support, and we use the embedded ShapeLib calls to work with Shapefiles as our primary data source.  Specifically, we make direct DBF calls into dbfopen.c through gdal2xx.dll, bypassing the OGRDatasource/OGRLayer wrappers.

We are looking to add support for Date and Boolean field types, and while I had thought that perhaps I could add support without having to change anything within ShapeLib or OGR, alas, I could not.  Inevitably, since the dates are stored as Integers, having the 'N' field descriptor rather than the 'D' field descriptor, our code had no way to determine that the field was a Date as opposed to an Integer.

 

I believe that the OGR constructs handle these issues through the OGR Field Definition, but since we bypass those constructs, we get the data back in a more 'raw' form.  There are similar issues with the Logical field type (not with ShapeLib, but with OGR).

Interestingly, is appears that ShapeLib is very close to supporting Dates altogether, with various 'if' and 'switch' statements checking for the 'D' descriptor.  I presume this is because you have to be able to read Shapefiles created externally, which would have the 'D' descriptor, but you don't save them that way.

I have made minimal changes to ShapeLib files (Shapefil.h and dbfopen.c) in an effort to add raw Date and Logical support, and had to make a couple small changes to the OGR code as well (making sure that Shapefiles saved through the modified ShapeLib are still readable with OGR).

I would like to submit these changes for review, in hopes that something along these lines could be integrated into the official release.  I acknowledge that there may be things I don't yet understand, and that perhaps there are better ways to do what I have done, but it's a starting point.

How would I go about submitting these changes for consideration?

Thank you.


Kind Regards.
Jerry Faust.



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ShapeLib/GDAL support for Dates and Booleans

Even Rouault-2

Jerry,

>

> My name is Jerry Faust, and I'm a recent contributor to MapWinGIS. We

> provide GDAL/OGR layer support, and we use the embedded ShapeLib calls to

> work with Shapefiles as our primary data source. Specifically, we make

> direct DBF calls into dbfopen.c through gdal2xx.dll, bypassing the

> OGRDatasource/OGRLayer wrappers.

 

Note that this shapelib integrated in GDAL is considered as an internal detail of GDAL and that some builds might have the shapelib symbols hidden (will be the case in GDAL 2.3 on Unix builds)

 

>

> We are looking to add support for Date and Boolean field types, and while I

> had thought that perhaps I could add support without having to change

> anything within ShapeLib or OGR, alas, I could not. Inevitably, since the

> dates are stored as Integers, having the 'N' field descriptor rather than

> the 'D' field descriptor, our code had no way to determine that the field

> was a Date as opposed to an Integer.

 

Where do you find that dates are stored with N field descriptor ? OGR writes and read them with D descriptor, 8 characters width and store values as decimal numbers of value YY * 10000 + MM * 100 + DD.

 

>

> I believe that the OGR constructs handle these issues through the OGR Field

> Definition, but since we bypass those constructs, we get the data back in a

> more 'raw' form. There are similar issues with the Logical field type (not

> with ShapeLib, but with OGR).

 

Yes I realized that we haven't upgraded the OGR side to convert DBF Logical field type to (OFTInteger, OFSTBoolean). But I failed to find DBF files in the wild with logical field types.

 

> I have made minimal changes to ShapeLib files (Shapefil.h and dbfopen.c) in

> an effort to add raw Date and Logical support, and had to make a couple

> small changes to the OGR code as well (making sure that Shapefiles saved

> through the modified ShapeLib are still readable with OGR).

>

> I would like to submit these changes for review, in hopes that something

> along these lines could be integrated into the official release. I

> acknowledge that there may be things I don't yet understand, and that

> perhaps there are better ways to do what I have done, but it's a starting

> point.

>

> How would I go about submitting these changes for consideration?

 

I'd suggest a pull request against the github mirror at

https://github.com/OSGeo/gdal

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev