1
0
Fork 0

Merge branch 'gdal-fixes' into next

This commit is contained in:
James.Hester 2019-01-04 20:10:13 +11:00
commit eb4f8ac710

View file

@ -9,25 +9,25 @@ bool tgShapefile::initialized = false;
void* tgShapefile::OpenDatasource( const char* datasource_name ) void* tgShapefile::OpenDatasource( const char* datasource_name )
{ {
OGRDataSource* datasource; GDALDataset* datasource;
OGRSFDriver* ogrdriver; GDALDriver* ogrdriver;
const char* format_name = "ESRI Shapefile"; GDALDriverManager* drivermanager;
const std::string format_name = "ESRI Shapefile";
if (!tgShapefile::initialized) { if (!tgShapefile::initialized) {
OGRRegisterAll(); GDALAllRegister();
tgShapefile::initialized = true; tgShapefile::initialized = true;
} }
ogrdriver = (OGRSFDriver*) OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName( format_name ); datasource = (GDALDataset *) GDALOpenEx(datasource_name,GDAL_OF_VECTOR|GDAL_OF_UPDATE, NULL ,NULL,NULL);
if ( !ogrdriver ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Unknown datasource format driver: " << format_name );
exit(1);
}
datasource = ogrdriver->Open( datasource_name, TRUE );
if ( !datasource ) { if ( !datasource ) {
datasource = ogrdriver->CreateDataSource( datasource_name, NULL ); drivermanager = GetGDALDriverManager();
ogrdriver = drivermanager->GetDriverByName( format_name.c_str() );
if ( !ogrdriver ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Unknown datasource format driver: " << format_name );
exit(1);
}
datasource = ogrdriver->Create(datasource_name,0,0,0,GDT_Unknown,NULL);
} }
if ( !datasource ) { if ( !datasource ) {
@ -39,7 +39,7 @@ void* tgShapefile::OpenDatasource( const char* datasource_name )
} }
void* tgShapefile::OpenLayer( void* ds_id, const char* layer_name ) { void* tgShapefile::OpenLayer( void* ds_id, const char* layer_name ) {
OGRDataSource* datasource = ( OGRDataSource * )ds_id; GDALDataset* datasource = ( GDALDataset * )ds_id;
OGRLayer* layer; OGRLayer* layer;
OGRSpatialReference srs; OGRSpatialReference srs;
@ -67,7 +67,7 @@ void* tgShapefile::OpenLayer( void* ds_id, const char* layer_name ) {
} }
void* tgShapefile::OpenLineLayer( void* ds_id, const char* layer_name ) { void* tgShapefile::OpenLineLayer( void* ds_id, const char* layer_name ) {
OGRDataSource* datasource = ( OGRDataSource * )ds_id; GDALDataset* datasource = ( GDALDataset * )ds_id;
OGRLayer* layer; OGRLayer* layer;
OGRSpatialReference srs; OGRSpatialReference srs;
@ -96,9 +96,8 @@ void* tgShapefile::OpenLineLayer( void* ds_id, const char* layer_name ) {
void* tgShapefile::CloseDatasource( void* ds_id ) void* tgShapefile::CloseDatasource( void* ds_id )
{ {
OGRDataSource* datasource = ( OGRDataSource * )ds_id; GDALDataset* datasource = ( GDALDataset * )ds_id;
OGRDataSource::DestroyDataSource( datasource ); GDALClose((GDALDatasetH) datasource );
return (void *)-1; return (void *)-1;
} }