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

Function msReturnOpenLayersPage

maptemplate.c:4379–4432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4377}
4378
4379int msReturnOpenLayersPage(mapservObj *mapserv)
4380{
4381 int i;
4382 char *buffer = NULL, *layer = NULL;
4383 const char *tmpUrl = NULL;
4384 char *openlayersUrl = olUrl;
4385 char *projection = NULL;
4386
4387 /* 2 CGI parameters are used in the template. we need to transform them
4388 * to be sure the case match during the template processing. We also
4389 * need to search the SRS/CRS parameter to get the projection info. OGC
4390 * services version >= 1.3.0 uses CRS rather than SRS */
4391 for( i=0; i<mapserv->request->NumParams; i++)
4392 {
4393 if( (strcasecmp(mapserv->request->ParamNames[i], "SRS") == 0) ||
4394 (strcasecmp(mapserv->request->ParamNames[i], "CRS") == 0) ) {
4395 projection = mapserv->request->ParamValues[i];
4396 }
4397 else if(strcasecmp(mapserv->request->ParamNames[i], "LAYERS") == 0) {
4398 free(mapserv->request->ParamNames[i]);
4399 mapserv->request->ParamNames[i] = msStrdup("LAYERS");
4400 }
4401 else if(strcasecmp(mapserv->request->ParamNames[i], "VERSION") == 0) {
4402 free(mapserv->request->ParamNames[i]);
4403 mapserv->request->ParamNames[i] = msStrdup("VERSION");
4404 }
4405 }
4406
4407 /* check if the environment variable or config MS_OPENLAYERS_JS_URL is set */
4408 tmpUrl = msGetConfigOption(mapserv->map, "MS_OPENLAYERS_JS_URL");
4409 if (tmpUrl)
4410 openlayersUrl = (char*)tmpUrl;
4411 else if (getenv("MS_OPENLAYERS_JS_URL"))
4412 openlayersUrl = getenv("MS_OPENLAYERS_JS_URL");
4413
4414 if (mapserv->Mode == BROWSE) {
4415 msSetError(MS_WMSERR, "At least one layer name required in LAYERS.",
4416 "msWMSLoadGetMapParams()");
4417 layer = processLine(mapserv, olLayerMapServerTag, NULL, BROWSE);
4418 }
4419 else
4420 layer = processLine(mapserv, olLayerWMSTag, NULL, BROWSE);
4421
4422 buffer = processLine(mapserv, olTemplate, NULL, BROWSE);
4423 buffer = msReplaceSubstring(buffer, "[openlayers_js_url]", openlayersUrl);
4424 buffer = msReplaceSubstring(buffer, "[openlayers_layer]", layer);
4425 if (projection)
4426 buffer = msReplaceSubstring(buffer, "[openlayers_projection]", projection);
4427 msIO_fwrite(buffer, strlen(buffer), 1, stdout);
4428 free(layer);
4429 free(buffer);
4430
4431 return MS_SUCCESS;
4432}
4433
4434mapservObj *msAllocMapServObj()
4435{

Callers 1

mainFunction · 0.85

Calls 7

strcasecmpFunction · 0.85
msStrdupFunction · 0.85
msGetConfigOptionFunction · 0.85
msSetErrorFunction · 0.85
processLineFunction · 0.85
msReplaceSubstringFunction · 0.85
msIO_fwriteFunction · 0.85

Tested by

no test coverage detected