allocate the iteminfo index array - same order as the item list */
| 257 | |
| 258 | /* allocate the iteminfo index array - same order as the item list */ |
| 259 | int msUnionLayerInitItemInfo(layerObj *layer) |
| 260 | { |
| 261 | int i, numitems; |
| 262 | int *itemindexes; |
| 263 | char* itemlist = NULL; |
| 264 | |
| 265 | msUnionLayerInfo* layerinfo = (msUnionLayerInfo*)layer->layerinfo; |
| 266 | |
| 267 | if(layer->numitems == 0) |
| 268 | { |
| 269 | return MS_SUCCESS; |
| 270 | } |
| 271 | |
| 272 | if (!layerinfo || !layer->map) |
| 273 | return MS_FAILURE; |
| 274 | |
| 275 | /* Cleanup any previous item selection */ |
| 276 | msUnionLayerFreeItemInfo(layer); |
| 277 | |
| 278 | layer->iteminfo = (int *) malloc(sizeof(int) * layer->numitems); |
| 279 | MS_CHECK_ALLOC(layer->iteminfo, sizeof(int) * layer->numitems, MS_FAILURE); |
| 280 | |
| 281 | itemindexes = (int*)layer->iteminfo; |
| 282 | |
| 283 | /* check whether we require attributes from the source layers also */ |
| 284 | numitems = 0; |
| 285 | for (i = 0; i < layer->numitems; i++) |
| 286 | { |
| 287 | if (EQUAL(layer->items[i], MSUNION_SOURCELAYERNAME)) |
| 288 | itemindexes[i] = MSUNION_SOURCELAYERNAMEINDEX; |
| 289 | else if (EQUAL(layer->items[i], MSUNION_SOURCELAYERGROUP)) |
| 290 | itemindexes[i] = MSUNION_SOURCELAYERGROUPINDEX; |
| 291 | else if (EQUAL(layer->items[i], MSUNION_SOURCELAYERVISIBLE)) |
| 292 | itemindexes[i] = MSUNION_SOURCELAYERVISIBLEINDEX; |
| 293 | else |
| 294 | { |
| 295 | itemindexes[i] = numitems++; |
| 296 | if (itemlist) |
| 297 | { |
| 298 | itemlist = msStringConcatenate(itemlist, ","); |
| 299 | itemlist = msStringConcatenate(itemlist, layer->items[i]); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | itemlist = msStrdup(layer->items[i]); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | for (i = 0; i < layerinfo->layerCount; i++) |
| 309 | { |
| 310 | layerObj* srclayer = &layerinfo->layers[i]; |
| 311 | |
| 312 | msUnionLayerFreeExpressionTokens(srclayer); |
| 313 | |
| 314 | if (itemlist) |
| 315 | { |
| 316 | /* get items requested by the union layer plus the required items */ |
no test coverage detected