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

Function msWCSGetCoverage20_GetBands

mapwcs20.c:3483–3555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3481/************************************************************************/
3482
3483static int msWCSGetCoverage20_GetBands(mapObj *map, layerObj *layer,
3484 wcs20ParamsObjPtr params, wcs20coverageMetadataObjPtr cm, char **bandlist)
3485{
3486 int i = 0, count, maxlen, index;
3487 char *current = NULL, *tmp = NULL;
3488 char **band_ids = NULL;
3489
3490 /* if rangesubset parameter is not given, default to all bands */
3491 if(NULL == params->range_subset)
3492 {
3493 *bandlist = msStrdup("1");
3494 for(i = 1; i < cm->numbands; ++i)
3495 {
3496 char strnumber[10];
3497 snprintf(strnumber, sizeof(strnumber), ",%d", i + 1);
3498 *bandlist = msStringConcatenate(*bandlist, strnumber);
3499 }
3500 return MS_SUCCESS;
3501 }
3502
3503 count = CSLCount(params->range_subset);
3504 maxlen = count * 4 * sizeof(char);
3505 *bandlist = msSmallCalloc(sizeof(char), maxlen);
3506 current = *bandlist;
3507
3508 if (NULL == (tmp = msOWSGetEncodeMetadata(&layer->metadata,
3509 "CO", "rangeset_axes", NULL)))
3510 {
3511 tmp = msOWSGetEncodeMetadata(&layer->metadata,
3512 "CO", "band_names", NULL);
3513 }
3514
3515 if(NULL != tmp)
3516 {
3517 band_ids = CSLTokenizeString2(tmp, " ", 0);
3518 msFree(tmp);
3519 }
3520
3521 for(i = 0; i < count; ++i)
3522 {
3523 /* print ',' if not the first value */
3524 if(i != 0)
3525 {
3526 current = strlcat(*bandlist, ",", maxlen) + *bandlist;
3527 }
3528
3529 /* check if the string represents an integer */
3530 if(msStringParseInteger(params->range_subset[i], &index) == MS_SUCCESS)
3531 {
3532 tmp = msIntToString((int)index);
3533 strlcat(*bandlist, tmp, maxlen);
3534 msFree(tmp);
3535 continue;
3536 }
3537
3538 /* check if the string is equal to a band identifier */
3539 /* if so, what is the index of the band */
3540 index = CSLFindString(band_ids, params->range_subset[i]);

Callers 1

msWCSGetCoverage20Function · 0.85

Calls 9

msStrdupFunction · 0.85
msStringConcatenateFunction · 0.85
msSmallCallocFunction · 0.85
msOWSGetEncodeMetadataFunction · 0.85
msFreeFunction · 0.85
strlcatFunction · 0.85
msStringParseIntegerFunction · 0.85
msIntToStringFunction · 0.85
msSetErrorFunction · 0.85

Tested by

no test coverage detected