MCPcopy Index your code
hub / github.com/MapServer/MapServer / msOGRLayerInitItemInfo

Function msOGRLayerInitItemInfo

mapogr.cpp:2469–2584  ·  view source on GitHub ↗

* msOGRLayerInitItemInfo() * * Init the itemindexes array after items[] has been reset in a layer. **********************************************************************/

Source from the content-addressed store, hash-verified

2467 * Init the itemindexes array after items[] has been reset in a layer.
2468 **********************************************************************/
2469static int msOGRLayerInitItemInfo(layerObj *layer)
2470{
2471#ifdef USE_OGR
2472 msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
2473 int i;
2474 OGRFeatureDefnH hDefn;
2475
2476 if (layer->numitems == 0)
2477 return MS_SUCCESS;
2478
2479 if( layer->tileindex != NULL )
2480 {
2481 if( psInfo->poCurTile == NULL
2482 && msOGRFileReadTile( layer, psInfo, -2 ) != MS_SUCCESS )
2483 return MS_FAILURE;
2484
2485 psInfo = psInfo->poCurTile;
2486 }
2487
2488 if (psInfo == NULL || psInfo->hLayer == NULL)
2489 {
2490 msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
2491 "msOGRLayerInitItemInfo()");
2492 return(MS_FAILURE);
2493 }
2494
2495 if((hDefn = OGR_L_GetLayerDefn( psInfo->hLayer )) == NULL)
2496 {
2497 msSetError(MS_OGRERR, "Layer contains no fields.",
2498 "msOGRLayerInitItemInfo()");
2499 return(MS_FAILURE);
2500 }
2501
2502 if (layer->iteminfo)
2503 free(layer->iteminfo);
2504 if((layer->iteminfo = (int *)malloc(sizeof(int)*layer->numitems))== NULL)
2505 {
2506 msSetError(MS_MEMERR, NULL, "msOGRLayerInitItemInfo()");
2507 return(MS_FAILURE);
2508 }
2509
2510 int *itemindexes = (int*)layer->iteminfo;
2511 for(i=0;i<layer->numitems;i++)
2512 {
2513 // Special case for handling text string and angle coming from
2514 // OGR style strings. We use special attribute snames.
2515 if (EQUAL(layer->items[i], MSOGR_LABELFONTNAMENAME))
2516 itemindexes[i] = MSOGR_LABELFONTNAMEINDEX;
2517 else if (EQUAL(layer->items[i], MSOGR_LABELSIZENAME))
2518 itemindexes[i] = MSOGR_LABELSIZEINDEX;
2519 else if (EQUAL(layer->items[i], MSOGR_LABELTEXTNAME))
2520 itemindexes[i] = MSOGR_LABELTEXTINDEX;
2521 else if (EQUAL(layer->items[i], MSOGR_LABELANGLENAME))
2522 itemindexes[i] = MSOGR_LABELANGLEINDEX;
2523 else if (EQUAL(layer->items[i], MSOGR_LABELFCOLORNAME))
2524 itemindexes[i] = MSOGR_LABELFCOLORINDEX;
2525 else if (EQUAL(layer->items[i], MSOGR_LABELBCOLORNAME))
2526 itemindexes[i] = MSOGR_LABELBCOLORINDEX;

Callers 3

msOGRGetValuesFunction · 0.85
msOGRFileReadTileFunction · 0.85
msOGRLayerGetItemsFunction · 0.85

Calls 2

msOGRFileReadTileFunction · 0.85
msSetErrorFunction · 0.85

Tested by

no test coverage detected