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

Function msSLDApplySLDURL

mapogcsld.c:61–122  ·  view source on GitHub ↗

/ msSLDApplySLDURL */ / Use the SLD document given through a URL and apply the SLD */ on the map. Layer name and Named Layer's name parameter are */ used to do the match. */ /

Source from the content-addressed store, hash-verified

59/* used to do the match. */
60/************************************************************************/
61int msSLDApplySLDURL(mapObj *map, char *szURL, int iLayer,
62 char *pszStyleLayerName)
63{
64#ifdef USE_OGR
65
66/* needed for libcurl function msHTTPGetFile in maphttp.c */
67#if defined(USE_CURL)
68
69 char *pszSLDTmpFile = NULL;
70 int status = 0;
71 char *pszSLDbuf=NULL;
72 FILE *fp = NULL;
73 int nStatus = MS_FAILURE;
74
75 if (map && szURL)
76 {
77 pszSLDTmpFile = msTmpFile(map, map->mappath, NULL, "sld.xml");
78 if (pszSLDTmpFile == NULL)
79 {
80 pszSLDTmpFile = msTmpFile(map, NULL, NULL, "sld.xml" );
81 }
82 if (msHTTPGetFile(szURL, pszSLDTmpFile, &status,-1, 0, 0) == MS_SUCCESS)
83 {
84 if ((fp = fopen(pszSLDTmpFile, "rb")) != NULL)
85 {
86 int nBufsize=0;
87 fseek(fp, 0, SEEK_END);
88 nBufsize = ftell(fp);
89 rewind(fp);
90 pszSLDbuf = (char*)malloc((nBufsize+1)*sizeof(char));
91 fread(pszSLDbuf, 1, nBufsize, fp);
92 fclose(fp);
93 pszSLDbuf[nBufsize] = '\0';
94 unlink(pszSLDTmpFile);
95 }
96 }
97 else
98 {
99 msSetError(MS_WMSERR, "Could not open SLD %s and save it in temporary file %s. Please make sure that the sld url is valid and that the temporary path is set. The temporary path can be defined for example by setting TMPPATH in the map file. Please check the MapServer documentation on temporary path settings.", "msSLDApplySLDURL", szURL, pszSLDTmpFile);
100 }
101 if (pszSLDbuf)
102 nStatus = msSLDApplySLD(map, pszSLDbuf, iLayer, pszStyleLayerName);
103 }
104
105 return nStatus;
106
107#else
108 msSetError(MS_MISCERR, "WMS/WFS client support is not enabled .", "msSLDApplySLDURL()");
109 return(MS_FAILURE);
110#endif
111
112#else
113/* ------------------------------------------------------------------
114 * OGR Support not included...
115 * ------------------------------------------------------------------ */
116
117 msSetError(MS_MISCERR, "OGR support is not available.", "msSLDApplySLDURL()");
118 return(MS_FAILURE);

Callers 4

msWMSLoadGetMapParamsFunction · 0.85
mapwms.cFile · 0.85
mapObj_applySLDURLFunction · 0.85
layerObj_applySLDURLFunction · 0.85

Calls 4

msTmpFileFunction · 0.85
msHTTPGetFileFunction · 0.85
msSetErrorFunction · 0.85
msSLDApplySLDFunction · 0.85

Tested by

no test coverage detected