MCPcopy Create free account
hub / github.com/OSGeo/gdal / LoadIMDWktFile

Method LoadIMDWktFile

gcore/mdreader/reader_geo_eye.cpp:227–354  ·  view source on GitHub ↗

* LoadWKTIMDFile() */

Source from the content-addressed store, hash-verified

225 * LoadWKTIMDFile()
226 */
227char **GDALMDReaderGeoEye::LoadIMDWktFile() const
228{
229 char **papszResultList = nullptr;
230 char **papszLines = CSLLoad(m_osIMDSourceFilename);
231 bool bBeginSection = false;
232 CPLString osSection;
233 CPLString osKeyLevel1;
234 CPLString osKeyLevel2;
235 CPLString osKeyLevel3;
236 int nLevel = 0;
237 int nSpaceCount;
238
239 if (papszLines == nullptr)
240 return nullptr;
241
242 for (int i = 0; papszLines[i] != nullptr; i++)
243 {
244 // skip section (=== or ---) lines
245
246 if (STARTS_WITH_CI(papszLines[i], "==="))
247 {
248 bBeginSection = true;
249 continue;
250 }
251
252 if (STARTS_WITH_CI(papszLines[i], "---") ||
253 CPLStrnlen(papszLines[i], 512) == 0)
254 continue;
255
256 // check the metadata level
257 nSpaceCount = 0;
258 for (int j = 0; j < 11; j++)
259 {
260 if (papszLines[i][j] != ' ')
261 break;
262 nSpaceCount++;
263 }
264
265 if (nSpaceCount % 3 != 0)
266 continue; // not a metadata item
267 nLevel = nSpaceCount / 3;
268
269 const char *pszValue;
270 char *pszKey = nullptr;
271 pszValue = CPLParseNameValue(papszLines[i], &pszKey);
272
273 if (nullptr != pszValue && CPLStrnlen(pszValue, 512) > 0)
274 {
275
276 CPLString osCurrentKey;
277 if (nLevel == 0)
278 {
279 osCurrentKey = CPLOPrintf("%s", pszKey);
280 }
281 else if (nLevel == 1)
282 {
283 osCurrentKey =
284 osKeyLevel1 + "." + CPLOPrintf("%s", pszKey + nSpaceCount);

Callers

nothing calls this directly

Calls 6

CSLLoadFunction · 0.85
CPLStrnlenFunction · 0.85
CPLParseNameValueFunction · 0.85
CPLOPrintfFunction · 0.85
CSLAddNameValueFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected