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

Function msOWSRequestLayersEnabled

mapows.c:260–322  ·  view source on GitHub ↗

** msOWSRequestLayersEnabled() ** ** Check if the layers are visible for a specific OWS request. ** ** 'namespaces' is a string with a letter for each namespace to lookup ** in the order they should be looked up. e.g. "MO" to lookup wms_ and ows_ ** If namespaces is NULL then this function just does a regular metadata ** lookup. ** ** Generates an array of the layer ids enabled. */

Source from the content-addressed store, hash-verified

258** Generates an array of the layer ids enabled.
259*/
260void msOWSRequestLayersEnabled(mapObj *map, const char *namespaces,
261 const char *request, owsRequestObj *ows_request)
262{
263 int disabled = MS_FALSE; /* explicitly disabled flag */
264 int globally_enabled = MS_FALSE;
265 const char *enable_request;
266
267 if (ows_request->numlayers > 0)
268 msFree(ows_request->enabled_layers);
269
270 ows_request->numlayers = 0;
271 ows_request->enabled_layers = NULL;
272
273 if (request == NULL || (map == NULL) || (map->numlayers <= 0))
274 return;
275
276 enable_request = msOWSLookupMetadata(&map->web.metadata, namespaces, "enable_request");
277 globally_enabled = msOWSParseRequestMetadata(enable_request, request, &disabled);
278
279 if (!globally_enabled && !disabled)
280 {
281 enable_request = msOWSLookupMetadata(&map->web.metadata, "O", "enable_request");
282 globally_enabled = msOWSParseRequestMetadata(enable_request, request, &disabled);
283 }
284
285 if (map->numlayers)
286 {
287 int i, layers_size = map->numlayers; //for most of cases, this will be relatively small
288
289 ows_request->enabled_layers = (int*)msSmallMalloc(sizeof(int)*layers_size);
290
291 for(i=0; i<map->numlayers; i++)
292 {
293 int result = MS_FALSE;
294 layerObj *lp;
295 lp = (GET_LAYER(map, i));
296
297 enable_request = msOWSLookupMetadata(&lp->metadata, namespaces, "enable_request");
298 result = msOWSParseRequestMetadata(enable_request, request, &disabled);
299 if (!result && disabled) continue; /* if the request has been explicitly set to disabled, continue */
300
301 if (!result && !disabled) /* if the request has not been found in the wms metadata, */
302 { /* check the ows namespace */
303
304 enable_request = msOWSLookupMetadata(&lp->metadata, "O", "enable_request");
305 result = msOWSParseRequestMetadata(enable_request, request, &disabled);
306 if (!result && disabled) continue;
307 }
308
309 if (result || (!disabled && globally_enabled))
310 {
311 ows_request->enabled_layers[ows_request->numlayers] = lp->index;
312 ows_request->numlayers++;
313 }
314 }
315
316 if (ows_request->numlayers == 0)
317 {

Callers 7

msWCSDispatchFunction · 0.85
msWCSDispatch20Function · 0.85
msWMSDispatchFunction · 0.85
msMapLoadOWSParametersFunction · 0.85
msWFSDispatchFunction · 0.85
msWFSParseRequestFunction · 0.85
msSOSDispatchFunction · 0.85

Calls 4

msFreeFunction · 0.85
msOWSLookupMetadataFunction · 0.85
msSmallMallocFunction · 0.85

Tested by

no test coverage detected