[Utils] Discontinue usage of deprecated GDAL methods.
This commit is contained in:
parent
4fa0606498
commit
279868b782
1 changed files with 16 additions and 12 deletions
|
@ -459,10 +459,13 @@ void usage(const char* progname, const std::string& msg) {
|
|||
SG_LOG(SG_GENERAL, SG_INFO, "\t--format format");
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "\t\tSpecify the output format");
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "\t\tAvailable formats:");
|
||||
OGRSFDriverRegistrar* registrar=OGRSFDriverRegistrar::GetRegistrar();
|
||||
for (int i=0;i<registrar->GetDriverCount();i++) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "\t\t\t-f \"" << registrar->GetDriver(i)->GetDescription() << "\"");
|
||||
|
||||
auto driverManager = GetGDALDriverManager();
|
||||
for (int i = 0; i < driverManager->GetDriverCount(); ++i) {
|
||||
auto ogrDriver = driverManager->GetDriver(i);
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "\t\t\t-f \"" << ogrDriver->GetDescription() << "\"");
|
||||
}
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "\t\tDefault: ESRI Shapefile");
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "");
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "The polygons from the given paths are read and transferred");
|
||||
|
@ -483,7 +486,7 @@ struct option options[]={
|
|||
int main(int argc, char** argv) {
|
||||
sglog().setLogLevels( SG_ALL, SG_DEBUG );
|
||||
|
||||
OGRRegisterAll();
|
||||
GDALAllRegister();
|
||||
|
||||
int option;
|
||||
|
||||
|
@ -518,18 +521,18 @@ int main(int argc, char** argv) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
const char* dst_datasource=argv[optind++];
|
||||
OGRSFDriver *ogrdriver;
|
||||
auto driverManager = GetGDALDriverManager();
|
||||
|
||||
ogrdriver = (OGRSFDriver*) OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(format_name);
|
||||
if (!ogrdriver) {
|
||||
usage(argv[0],std::string("Unknown datasource format driver:")+format_name);
|
||||
auto gdalDriver = driverManager->GetDriverByName(format_name);
|
||||
if (!gdalDriver) {
|
||||
usage(argv[0], std::string("Unknown datasource format driver:") + format_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
datasource = ogrdriver->CreateDataSource(dst_datasource,NULL);
|
||||
const char* dst_datasource = argv[optind++];
|
||||
auto datasource = gdalDriver->Create(dst_datasource, 0, 0, 0, GDALDataType::GDT_Unknown, NULL);
|
||||
if (!datasource) {
|
||||
usage(argv[0],std::string("Unable to create datasource:")+dst_datasource);
|
||||
usage(argv[0],std::string("Unable to create datasource:") + dst_datasource);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -537,7 +540,8 @@ int main(int argc, char** argv) {
|
|||
process_file(SGPath(argv[i]));
|
||||
}
|
||||
|
||||
OGRDataSource::DestroyDataSource( datasource );
|
||||
GDALClose((GDALDatasetH) datasource );
|
||||
GDALDestroyDriverManager();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue