<div dir="ltr"><div><div><br><br>On Thu, Sep 28, 2017 at 10:34 PM, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br>><br>>  <br>><br>> > By now, v.in.ogr is peppered with #if GDAL_VERSION_NUM >= X, looks like at<br>><br>> > some stage we should have two versions, one for GDAL 1.x, another one for<br>><br>> > GDAL 2.x...<br>><br>>  <br>><br>> Seems to me that having 2 version of th code would be more difficult to maintain.<br>><br><br></div>True, but currently we are using the GDAL/OGR API version 1.x with some #ifdefs for GDAL >= 2.0.<br><br></div>Regarding the new OGR API, it might be worth the effort to update<br>OGROpen() -> GDALOpenEx() (GDAL 2.0)<div><div>OGR_DS_GetLayer() -> GDALDatasetGetLayerByName() (GDAL 2.0)</div><div>OGR_L_GetNextFeature() -> GDALDatasetGetNextFeature() (GDAL 2.2)</div><div>OGR_L_ResetReading() -> GDALDatasetResetReading() (GDAL 2.2)</div><div>+ possibly more</div><div><br></div><div>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).</div><div><br></div><div>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.<br></div><div><br></div><div>Markus M<br></div><div><br></div><div>><br>> 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()<br>><br>>  <br>><br>> #if GDAL_VERSION_NUM < 2000000<br>><br>> static OGRGeometryH my_OGR_G_GetLinearGeometry(OGRGeometryH hGeom, double unused1, char** unused2)<br>><br>> {<br>><br>> (void)unused1;<br>><br>> (void)unused2;<br>><br>> return OGR_G_Clone(hGeom);<br>><br>> }<br>><br>> #define OGR_G_GetLinearGeometry my_OGR_G_GetLinearGeometry<br>><br>> #endif<br>><br>>  <br>><br>> (untested)<br>><br>>  <br>><br>> ><br>><br>> > Markus M<br>><br>> ><br>><br>> > > --<br>><br>> > ><br>><br>> > > Spatialys - Geospatial professional services<br>><br>> > ><br>><br>> > > <a href="http://www.spatialys.com">http://www.spatialys.com</a><br>><br>>  <br>><br>>  <br>><br>> --<br>><br>> Spatialys - Geospatial professional services<br>><br>> <a href="http://www.spatialys.com">http://www.spatialys.com</a><br><br></div></div></div>