| 4377 | } |
| 4378 | |
| 4379 | int 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 | |
| 4434 | mapservObj *msAllocMapServObj() |
| 4435 | { |
no test coverage detected