Opened 10 years ago
Closed 9 years ago
#5699 closed defect (wontfix)
Docs: not clear that tutorials on default pages are GDAL 2.0 only
Reported by: | nadams | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Docs | Version: | 1.11.1 |
Severity: | normal | Keywords: | |
Cc: |
Description (last modified by )
After building from source on Windows 7 with MS Visual Studio 2008, no drivers are found by GDAL.
In the following application, all of the cerr statements get hit:
#include <iostream> #include "gdal.h" #include "gdal_priv.h" #include "ogr_api.h" int main(int argc, char *argv[]) { GDALAllRegister(); GDALDriverManager dm; dm.AutoLoadDrivers(); int count = dm.GetDriverCount(); if( count == 0 ) std::cerr << "Exactly " << count << " drivers found by GDALDriverManager.\n" << std::endl; GDALDriver *poDriver = (GDALDriver*) GDALGetDriverByName("ESRI Shapefile"); if( poDriver == NULL ) std::cerr << "ESRI Shapefile driver not available.\n" << std::endl; GDALDataset* poDS = (GDALDataset*) GDALOpen( "Political_VotingPrecincts.shp", GA_ReadOnly ); if( poDS == NULL ) std::cerr << "Open failed.\n" << std::endl; return 0; }
Attachments (1)
Change History (8)
by , 10 years ago
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
comment:2 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Version: | 1.11.1 → unspecified |
Kyle is right.
To be more precise, actually with GDAL 2.0, you would need to use GDALOpenEx() and specify GDAL_OF_VECTOR as open flag (or use OGROpen() )
comment:3 by , 10 years ago
Version: | unspecified → 1.11.1 |
---|
Thank you for the feedback.
But to clarify, I am indeed using version 1.11.1.
I downloaded it via the "Building GDAL from Source" page linked from the homepage: http://trac.osgeo.org/gdal/wiki/BuildHints
That page links to here for the actual download: http://trac.osgeo.org/gdal/wiki/DownloadSource
And I initially tried used the tutorial that is also linked from the homepage: http://www.gdal.org/ogr_apitut.html
That tutorial differentiates between "C++" and "C" examples, not particular versions of GDAL.
But the GDALOpenEx() method did not exist in 1.11.1, so I switched to the GDALOpen() method.
Failing that I went looking for a way to have the API tell me things like how many drivers were being loaded and whether the shapefile in particular was being loaded. That is what led to the GDALDriverManager and GDALGetDriverByName() code snippets.
Perhaps the tutorials linked from the homepage could use some clarifying text with regard to the particular versions of GDAL at play, especially since the homepage leads to version 1.11.1 for developers wanting to build from source.
comment:4 by , 10 years ago
Component: | default → Docs |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
comment:5 by , 10 years ago
The home page at gdal.org mentions "Traditionnaly GDAL used to design the raster part of the library, and OGR the vector part for Simple Features. Starting with GDAL 2.0, both sides have been more tightly integrated. You can still refer to the documentation of GDAL 1.X if needed." and that points to http://gdal.org/1.11/index.html
comment:6 by , 10 years ago
Summary: | No drivers found → Docs: not clear that tutorials on default pages are GDAL 2.0 only |
---|
comment:7 by , 9 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
I don't think any further action is needed. Closing
nadams,
You don't need to instantiate a driver manager. Also you are using the 2.0 unified driver model for GDAL and OGR, but you stated verson 1.11.1 in the ticket.
See the docs here for 1.x:
http://gdal.org/1.11/index.html
If you are using the trunk (2.0dev), then this should work:
If you are using 1.x, you need to use the OGR API for vector datasources (cut from the ogr tutorial):