[GRASS-user] OpenFileGDB input error

Markus Metz markus.metz.giswork at gmail.com
Thu Sep 28 14:00:20 PDT 2017


On Thu, Sep 28, 2017 at 10:34 PM, Even Rouault <even.rouault at spatialys.com>
wrote:
>
>
>
> > By now, v.in.ogr is peppered with #if GDAL_VERSION_NUM >= X, looks like
at
>
> > some stage we should have two versions, one for GDAL 1.x, another one
for
>
> > GDAL 2.x...
>
>
>
> Seems to me that having 2 version of th code would be more difficult to
maintain.
>

True, but currently we are using the GDAL/OGR API version 1.x with some
#ifdefs for GDAL >= 2.0.

Regarding the new OGR API, it might be worth the effort to update
OGROpen() -> GDALOpenEx() (GDAL 2.0)
OGR_DS_GetLayer() -> GDALDatasetGetLayerByName() (GDAL 2.0)
OGR_L_GetNextFeature() -> GDALDatasetGetNextFeature() (GDAL 2.2)
OGR_L_ResetReading() -> GDALDatasetResetReading() (GDAL 2.2)
+ possibly more

Inserting #ifdefs for these makes the code of v.in.ogr even more unreadable
(v.in.ogr is already an example for code that's difficult to read).

v.in.ogr as it is now tries to work with all GDAL versions, but does not
make use of new features in GDAL 2.2. It might be worth to "freeze" this
code (keep it for backward compatibility for GDAL < 2.2), and create a
version of v.in.ogr for GDAL >= 2.2.

Markus M

>
> To avoid cluttering the code with condition related to
OGR_G_GetLinearGeometry() for older GDAL, you could create a dummy
implementation of OGR_G_GetLinearGeometry at the top of the file for GDAL <
2 that just does a OGR_G_Clone()
>
>
>
> #if GDAL_VERSION_NUM < 2000000
>
> static OGRGeometryH my_OGR_G_GetLinearGeometry(OGRGeometryH hGeom, double
unused1, char** unused2)
>
> {
>
> (void)unused1;
>
> (void)unused2;
>
> return OGR_G_Clone(hGeom);
>
> }
>
> #define OGR_G_GetLinearGeometry my_OGR_G_GetLinearGeometry
>
> #endif
>
>
>
> (untested)
>
>
>
> >
>
> > Markus M
>
> >
>
> > > --
>
> > >
>
> > > Spatialys - Geospatial professional services
>
> > >
>
> > > http://www.spatialys.com
>
>
>
>
>
> --
>
> Spatialys - Geospatial professional services
>
> http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20170928/c7d6937b/attachment.html>


More information about the grass-user mailing list