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

Function msBuildWMSLayerURLBase

mapwmslayer.c:231–444  ·  view source on GitHub ↗

* msBuildWMSLayerURLBase() * * Build the base of a GetMap or GetFeatureInfo URL using metadata. * The parameters to set are: * VERSION * LAYERS * FORMAT * TRANSPARENT * STYLES * QUERY_LAYERS (for queriable layers only) * * Returns a reference to a newly allocated string that should be freed * by the caller. **************************************

Source from the content-addressed store, hash-verified

229 * by the caller.
230 **********************************************************************/
231static int msBuildWMSLayerURLBase(mapObj *map, layerObj *lp,
232 wmsParamsObj *psWMSParams)
233{
234 const char *pszOnlineResource, *pszVersion, *pszName, *pszFormat;
235 const char *pszFormatList, *pszStyle, *pszStyleList, *pszTime;
236 const char *pszBgColor, *pszTransparent;
237 const char *pszSLD=NULL, *pszStyleSLDBody=NULL, *pszVersionKeyword=NULL;
238 const char *pszSLDBody=NULL, *pszSLDURL = NULL;
239 char *pszSLDGenerated = NULL;
240
241 /* If lp->connection is not set then use wms_onlineresource metadata */
242 pszOnlineResource = lp->connection;
243 if (pszOnlineResource == NULL)
244 pszOnlineResource = msOWSLookupMetadata(&(lp->metadata),
245 "MO", "onlineresource");
246
247 pszVersion = msOWSLookupMetadata(&(lp->metadata), "MO", "server_version");
248 pszName = msOWSLookupMetadata(&(lp->metadata), "MO", "name");
249 pszFormat = msOWSLookupMetadata(&(lp->metadata), "MO", "format");
250 pszFormatList = msOWSLookupMetadata(&(lp->metadata), "MO", "formatlist");
251 pszStyle = msOWSLookupMetadata(&(lp->metadata), "MO", "style");
252 pszStyleList = msOWSLookupMetadata(&(lp->metadata), "MO", "stylelist");
253 pszTime = msOWSLookupMetadata(&(lp->metadata), "MO", "time");
254 pszSLDBody = msOWSLookupMetadata(&(lp->metadata), "MO", "sld_body");
255 pszSLDURL = msOWSLookupMetadata(&(lp->metadata), "MO", "sld_url");
256 pszBgColor = msOWSLookupMetadata(&(lp->metadata), "MO", "bgcolor");
257 pszTransparent = msOWSLookupMetadata(&(lp->metadata), "MO", "transparent");
258
259 if (pszOnlineResource==NULL || pszVersion==NULL || pszName==NULL)
260 {
261 msSetError(MS_WMSCONNERR,
262 "One of wms_onlineresource, wms_server_version, wms_name "
263 "metadata is missing in layer %s. "
264 "Please either provide a valid CONNECTION URL, or provide "
265 "those values in the layer's metadata.\n",
266 "msBuildWMSLayerURLBase()", lp->name);
267 return MS_FAILURE;
268 }
269
270 psWMSParams->onlineresource = msStrdup(pszOnlineResource);
271
272 if (strncmp(pszVersion, "1.0.7", 5) < 0)
273 pszVersionKeyword = "WMTVER";
274 else
275 pszVersionKeyword = "VERSION";
276
277 msSetWMSParamString(psWMSParams, pszVersionKeyword, pszVersion, MS_FALSE);
278 msSetWMSParamString(psWMSParams, "SERVICE", "WMS", MS_FALSE);
279 msSetWMSParamString(psWMSParams, "LAYERS", pszName, MS_TRUE);
280
281 if (pszFormat==NULL && pszFormatList==NULL)
282 {
283 msSetError(MS_WMSCONNERR,
284 "At least wms_format or wms_formatlist is required for "
285 "layer %s. "
286 "Please either provide a valid CONNECTION URL, or provide "
287 "those values in the layer's metadata.\n",
288 "msBuildWMSLayerURLBase()", lp->name);

Callers 1

msBuildWMSLayerURLFunction · 0.85

Calls 9

msOWSLookupMetadataFunction · 0.85
msSetErrorFunction · 0.85
msStrdupFunction · 0.85
msSetWMSParamStringFunction · 0.85
msStringSplitFunction · 0.85
strcasecmpFunction · 0.85
msFreeCharArrayFunction · 0.85
msIsLayerQueryableFunction · 0.85
msSLDGenerateSLDFunction · 0.85

Tested by

no test coverage detected