| 2323 | | |
|---|
| 2324 | | /* -------------------------------------------------------------------- */ |
|---|
| 2325 | | /* read up to 500 bytes from the indicated location. */ |
|---|
| 2326 | | /* -------------------------------------------------------------------- */ |
|---|
| 2327 | | char szMDValue[501]; |
|---|
| 2328 | | int nMDBytes = sizeof(szMDValue)-1; |
|---|
| 2329 | | |
|---|
| 2330 | | if( VSIFSeekL( hHFA->fp, columnDataPtr, SEEK_SET ) != 0 ) |
|---|
| 2331 | | continue; |
|---|
| 2332 | | |
|---|
| 2333 | | nMDBytes = VSIFReadL( szMDValue, 1, nMDBytes, hHFA->fp ); |
|---|
| 2334 | | if( nMDBytes == 0 ) |
|---|
| 2335 | | continue; |
|---|
| 2336 | | |
|---|
| 2337 | | szMDValue[nMDBytes] = '\0'; |
|---|
| 2338 | | |
|---|
| 2339 | | papszMD = CSLSetNameValue( papszMD, poColumn->GetName(), szMDValue ); |
|---|
| | 2323 | |
|---|
| | 2324 | /* -------------------------------------------------------------------- */ |
|---|
| | 2325 | /* read up to nMaxNumChars bytes from the indicated location. */ |
|---|
| | 2326 | /* allocate required space temporarily */ |
|---|
| | 2327 | /* nMaxNumChars should have been set by GDAL orginally so we can */ |
|---|
| | 2328 | /* trust it. */ |
|---|
| | 2329 | /* -------------------------------------------------------------------- */ |
|---|
| | 2330 | int nMaxNumChars = poColumn->GetIntField( "maxNumChars" ); |
|---|
| | 2331 | |
|---|
| | 2332 | if( nMaxNumChars == 0 ) |
|---|
| | 2333 | { |
|---|
| | 2334 | papszMD = CSLSetNameValue( papszMD, poColumn->GetName(), "" ); |
|---|
| | 2335 | } |
|---|
| | 2336 | else |
|---|
| | 2337 | { |
|---|
| | 2338 | char *pszMDValue = (char*) CPLMalloc(nMaxNumChars); |
|---|
| | 2339 | |
|---|
| | 2340 | if( VSIFSeekL( hHFA->fp, columnDataPtr, SEEK_SET ) != 0 ) |
|---|
| | 2341 | continue; |
|---|
| | 2342 | |
|---|
| | 2343 | int nMDBytes = VSIFReadL( pszMDValue, 1, nMaxNumChars, hHFA->fp ); |
|---|
| | 2344 | if( nMDBytes == 0 ) |
|---|
| | 2345 | { |
|---|
| | 2346 | CPLFree( pszMDValue ); |
|---|
| | 2347 | continue; |
|---|
| | 2348 | } |
|---|
| | 2349 | |
|---|
| | 2350 | pszMDValue[nMaxNumChars-1] = '\0'; |
|---|
| | 2351 | |
|---|
| | 2352 | papszMD = CSLSetNameValue( papszMD, poColumn->GetName(), |
|---|
| | 2353 | pszMDValue ); |
|---|
| | 2354 | CPLFree( pszMDValue ); |
|---|
| | 2355 | } |
|---|
| 2372 | | /* -------------------------------------------------------------------- */ |
|---|
| 2373 | | HFAEntry *poEdsc_Table; |
|---|
| 2374 | | |
|---|
| 2375 | | poEdsc_Table = new HFAEntry( hHFA, "GDAL_MetaData", "Edsc_Table", |
|---|
| | 2388 | /* Check we have no table with this name already */ |
|---|
| | 2389 | /* -------------------------------------------------------------------- */ |
|---|
| | 2390 | HFAEntry *poEdsc_Table = poNode->GetNamedChild( "GDAL_MetaData" ); |
|---|
| | 2391 | |
|---|
| | 2392 | if( poEdsc_Table == NULL || !EQUAL(poEdsc_Table->GetType(),"Edsc_Table") ) |
|---|
| | 2393 | poEdsc_Table = new HFAEntry( hHFA, "GDAL_MetaData", "Edsc_Table", |
|---|
| 2383 | | /* -------------------------------------------------------------------- */ |
|---|
| 2384 | | HFAEntry *poEdsc_BinFunction; |
|---|
| 2385 | | |
|---|
| 2386 | | poEdsc_BinFunction = |
|---|
| 2387 | | new HFAEntry( hHFA, "#Bin_Function#", "Edsc_BinFunction", |
|---|
| 2388 | | poEdsc_Table ); |
|---|
| | 2401 | /* Check it doesn't exist already */ |
|---|
| | 2402 | /* -------------------------------------------------------------------- */ |
|---|
| | 2403 | HFAEntry *poEdsc_BinFunction = |
|---|
| | 2404 | poEdsc_Table->GetNamedChild( "#Bin_Function#" ); |
|---|
| | 2405 | |
|---|
| | 2406 | if( poEdsc_BinFunction == NULL |
|---|
| | 2407 | || !EQUAL(poEdsc_BinFunction->GetType(),"Edsc_BinFunction") ) |
|---|
| | 2408 | poEdsc_BinFunction = new HFAEntry( hHFA, "#Bin_Function#", |
|---|
| | 2409 | "Edsc_BinFunction", poEdsc_Table ); |
|---|
| 2413 | | /* -------------------------------------------------------------------- */ |
|---|
| 2414 | | poEdsc_Column = new HFAEntry( hHFA, pszKey, "Edsc_Column", |
|---|
| 2415 | | poEdsc_Table ); |
|---|
| | 2434 | /* Check it doesn't exist already */ |
|---|
| | 2435 | /* -------------------------------------------------------------------- */ |
|---|
| | 2436 | poEdsc_Column = poEdsc_Table->GetNamedChild(pszKey); |
|---|
| | 2437 | |
|---|
| | 2438 | if( poEdsc_Column == NULL |
|---|
| | 2439 | || !EQUAL(poEdsc_Column->GetType(),"Edsc_Column") ) |
|---|
| | 2440 | poEdsc_Column = new HFAEntry( hHFA, pszKey, "Edsc_Column", |
|---|
| | 2441 | poEdsc_Table ); |
|---|
| | 2442 | |
|---|