Lines 134-144
Link Here
|
134 |
|
134 |
|
135 |
virtual ReadResult readFile(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const |
135 |
virtual ReadResult readFile(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const |
136 |
{ |
136 |
{ |
|
|
137 |
#if GDAL_VERSION_MAJOR < 2 |
137 |
if (OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount() == 0) |
138 |
if (OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount() == 0) |
138 |
OGRRegisterAll(); |
139 |
OGRRegisterAll(); |
|
|
140 |
#else |
141 |
if (GDALGetDriverCount() == 0) |
142 |
GDALAllRegister(); |
143 |
#endif |
139 |
|
144 |
|
140 |
// Try to open data source |
145 |
// Try to open data source |
|
|
146 |
#if GDAL_VERSION_MAJOR < 2 |
141 |
OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str()); |
147 |
OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str()); |
|
|
148 |
#else |
149 |
GDALDataset *file; |
150 |
file = (GDALDataset*) GDALOpenEx( fileName.c_str(), GDAL_OF_VECTOR, NULL, NULL, NULL ); |
151 |
#endif |
142 |
if (!file) |
152 |
if (!file) |
143 |
return 0; |
153 |
return 0; |
144 |
|
154 |
|
Lines 156-161
Link Here
|
156 |
|
166 |
|
157 |
osg::Group* group = new osg::Group; |
167 |
osg::Group* group = new osg::Group; |
158 |
|
168 |
|
|
|
169 |
#if GDAL_VERSION_MAJOR < 2 |
159 |
for (int i = 0; i < file->GetLayerCount(); i++) |
170 |
for (int i = 0; i < file->GetLayerCount(); i++) |
160 |
{ |
171 |
{ |
161 |
osg::Group* node = readLayer(file->GetLayer(i), file->GetName(), useRandomColorByFeature, addGroupPerFeature); |
172 |
osg::Group* node = readLayer(file->GetLayer(i), file->GetName(), useRandomColorByFeature, addGroupPerFeature); |
Lines 163-168
Link Here
|
163 |
group->addChild( node ); |
174 |
group->addChild( node ); |
164 |
} |
175 |
} |
165 |
OGRDataSource::DestroyDataSource( file ); |
176 |
OGRDataSource::DestroyDataSource( file ); |
|
|
177 |
#else |
178 |
for (int i = 0; i < file->GetLayerCount(); i++) |
179 |
{ |
180 |
OGRLayer* layer = (OGRLayer *)GDALDatasetGetLayer(file, i); |
181 |
osg::Group* node = readLayer(layer, layer->GetName(), useRandomColorByFeature, addGroupPerFeature); |
182 |
if (node) |
183 |
group->addChild( node ); |
184 |
} |
185 |
GDALClose( file ); |
186 |
#endif |
166 |
return group; |
187 |
return group; |
167 |
} |
188 |
} |
168 |
|
189 |
|