allocate the iteminfo index array - same order as the item list */
| 1230 | |
| 1231 | /* allocate the iteminfo index array - same order as the item list */ |
| 1232 | int msClusterLayerInitItemInfo(layerObj *layer) |
| 1233 | { |
| 1234 | int i, numitems; |
| 1235 | int *itemindexes; |
| 1236 | |
| 1237 | msClusterLayerInfo* layerinfo = (msClusterLayerInfo*)layer->layerinfo; |
| 1238 | |
| 1239 | if(layer->numitems == 0) |
| 1240 | { |
| 1241 | return MS_SUCCESS; |
| 1242 | } |
| 1243 | |
| 1244 | if (!layerinfo) |
| 1245 | return MS_FAILURE; |
| 1246 | |
| 1247 | /* Cleanup any previous item selection */ |
| 1248 | msClusterLayerFreeItemInfo(layer); |
| 1249 | |
| 1250 | layer->iteminfo = (int *) msSmallMalloc(sizeof(int) * layer->numitems); |
| 1251 | |
| 1252 | itemindexes = layer->iteminfo; |
| 1253 | |
| 1254 | /* check whether we require attributes from the source layers also */ |
| 1255 | numitems = 0; |
| 1256 | for (i = 0; i < layer->numitems; i++) |
| 1257 | { |
| 1258 | if (EQUAL(layer->items[i], MSCLUSTER_FEATURECOUNT)) |
| 1259 | itemindexes[i] = MSCLUSTER_FEATURECOUNTINDEX; |
| 1260 | else if (EQUAL(layer->items[i], MSCLUSTER_GROUP)) |
| 1261 | itemindexes[i] = MSCLUSTER_GROUPINDEX; |
| 1262 | else |
| 1263 | itemindexes[i] = numitems++; |
| 1264 | } |
| 1265 | |
| 1266 | msLayerFreeItemInfo(&layerinfo->srcLayer); |
| 1267 | if(layerinfo->srcLayer.items) |
| 1268 | { |
| 1269 | msFreeCharArray(layerinfo->srcLayer.items, layerinfo->srcLayer.numitems); |
| 1270 | layerinfo->srcLayer.items = NULL; |
| 1271 | layerinfo->srcLayer.numitems = 0; |
| 1272 | } |
| 1273 | |
| 1274 | if (numitems > 0) |
| 1275 | { |
| 1276 | /* now allocate and set the layer item parameters */ |
| 1277 | layerinfo->srcLayer.items = (char **)msSmallMalloc(sizeof(char *)*numitems); |
| 1278 | layerinfo->srcLayer.numitems = numitems; |
| 1279 | |
| 1280 | for (i = 0; i < layer->numitems; i++) |
| 1281 | { |
| 1282 | if (itemindexes[i] >= 0) |
| 1283 | { |
| 1284 | if (EQUALN(layer->items[i], "Min:", 4)) |
| 1285 | layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 4); |
| 1286 | else if (EQUALN(layer->items[i], "Max:", 4)) |
| 1287 | layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 4); |
| 1288 | else if (EQUALN(layer->items[i], "Sum:", 4)) |
| 1289 | layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 4); |
no test coverage detected