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

Function msWMSGetStyles

mapwms.c:3779–3858  ·  view source on GitHub ↗

** msWMSGetStyles() : return an SLD document for all layers that ** have a status set to on or default. */

Source from the content-addressed store, hash-verified

3777** have a status set to on or default.
3778*/
3779int msWMSGetStyles(mapObj *map, int nVersion, char **names,
3780 char **values, int numentries, char *wms_exception_format)
3781
3782{
3783 int i,j,k;
3784 int validlayer = 0;
3785 int numlayers = 0;
3786 char **layers = NULL;
3787 char *sld = NULL;
3788 const char *encoding;
3789
3790 encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
3791
3792 for(i=0; map && i<numentries; i++)
3793 {
3794 /* getMap parameters */
3795 if (strcasecmp(names[i], "LAYERS") == 0)
3796 {
3797 layers = msStringSplit(values[i], ',', &numlayers);
3798 if (layers==NULL || numlayers < 1) {
3799 msSetError(MS_WMSERR, "At least one layer name required in LAYERS.",
3800 "msWMSGetStyles()");
3801 return msWMSException(map, nVersion, NULL, wms_exception_format);
3802 }
3803 for(j=0; j<map->numlayers; j++)
3804 GET_LAYER(map, j)->status = MS_OFF;
3805
3806 for (k=0; k<numlayers; k++)
3807 {
3808 for (j=0; j<map->numlayers; j++)
3809 {
3810 if ((GET_LAYER(map, j)->name &&
3811 strcasecmp(GET_LAYER(map, j)->name, layers[k]) == 0) ||
3812 (GET_LAYER(map, j)->group &&
3813 strcasecmp(GET_LAYER(map, j)->group, layers[k]) == 0))
3814 {
3815 GET_LAYER(map, j)->status = MS_ON;
3816 validlayer =1;
3817 }
3818 }
3819 }
3820
3821 msFreeCharArray(layers, numlayers);
3822 }
3823
3824 }
3825
3826 /* validate all layers given. If an invalid layer is sent, return an exception. */
3827 if (validlayer == 0)
3828 {
3829 msSetError(MS_WMSERR, "Invalid layer(s) given in the LAYERS parameter.",
3830 "msWMSGetStyles()");
3831 return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
3832 }
3833
3834 if (nVersion <= OWS_1_1_1)
3835 {
3836 if (encoding)

Callers 1

msWMSDispatchFunction · 0.85

Calls 8

msOWSLookupMetadataFunction · 0.85
strcasecmpFunction · 0.85
msStringSplitFunction · 0.85
msSetErrorFunction · 0.85
msWMSExceptionFunction · 0.85
msFreeCharArrayFunction · 0.85
msIO_printfFunction · 0.85
msSLDGenerateSLDFunction · 0.85

Tested by

no test coverage detected