[gdal-dev] OGR_Dr_Open deprecated
Even Rouault
even.rouault at spatialys.com
Fri Nov 13 05:58:06 PST 2015
Le vendredi 13 novembre 2015 14:48:02, Ari Jolma a écrit :
> OGR_Dr_Open became deprecated in 2.0 but it is still the main method to
> open vector datasets in the bindings.
>
> I just realized that I would need one method to open all data sets.
> OpenEx seems to be it but I would still need to cast the object into a
> Dataset or a DataSource.
Just don't cast. You can use a Dataset for all purposes since the OGR_DS_XXXX
API has been transposed to GDALDatasetXXXX and is already available in
GDALDatasetShadow
> Maybe OpenEx should be the preferred way to
> open any data set also with the bindings.
>
> However, I don't seem to find good way to tell whether the data set
> object OpenEx gives me is a raster or a vector. Is there such?
If you open with OpenEx(filename, OF_VECTOR), so read-only + vector, then the
few drivers that support vector and raster will return NULL if the dataset has
no vector data and just raster. If you open with OpenEx(filename, OF_VECTOR |
OF_UPDATE) and they support update mode, then they will return non-NULL even
if the dataset has no vector data. A robust way of checking if there's vector
data is to check GetLayerCount() != 0.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list