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

Function msSLDParseExternalGraphic

mapogcsld.c:2158–2225  ·  view source on GitHub ↗

/ msSLDParseExternalGraphic */ / Parse extrenal graphic node : download the symbol referneced */ by the URL and create a PIXMAP inmap symbol. Only GIF and */ PNG are supported. */ /

Source from the content-addressed store, hash-verified

2156/* PNG are supported. */
2157/************************************************************************/
2158int msSLDParseExternalGraphic(CPLXMLNode *psExternalGraphic,
2159 styleObj *psStyle, mapObj *map)
2160{
2161/* needed for libcurl function msHTTPGetFile in maphttp.c */
2162#if defined(USE_CURL)
2163
2164 char *pszFormat = NULL;
2165 CPLXMLNode *psURL=NULL, *psFormat=NULL, *psTmp=NULL;
2166 char *pszURL=NULL, *pszTmpSymbolName=NULL;
2167 int status;
2168
2169
2170 if (!psExternalGraphic || !psStyle || !map)
2171 return MS_FAILURE;
2172
2173 psFormat = CPLGetXMLNode(psExternalGraphic, "Format");
2174 if (psFormat && psFormat->psChild && psFormat->psChild->pszValue)
2175 pszFormat = psFormat->psChild->pszValue;
2176
2177 /* supports GIF and PNG */
2178 if (pszFormat &&
2179 (strcasecmp(pszFormat, "GIF") == 0 ||
2180 strcasecmp(pszFormat, "image/gif") == 0 ||
2181 strcasecmp(pszFormat, "PNG") == 0 ||
2182 strcasecmp(pszFormat, "image/png") == 0))
2183 {
2184
2185 /* <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.vendor.com/geosym/2267.svg"/> */
2186 psURL = CPLGetXMLNode(psExternalGraphic, "OnlineResource");
2187 if (psURL && psURL->psChild)
2188 {
2189 psTmp = psURL->psChild;
2190 while (psTmp != NULL &&
2191 psTmp->pszValue &&
2192 strcasecmp(psTmp->pszValue, "xlink:href") != 0)
2193 {
2194 psTmp = psTmp->psNext;
2195 }
2196 if (psTmp && psTmp->psChild)
2197 {
2198 pszURL = (char*)psTmp->psChild->pszValue;
2199
2200 /*external symbols using http will be automaticallly downloaded. The file should be
2201 saved in a temporary directory (msAddImageSymbol) #2305*/
2202 psStyle->symbol = msGetSymbolIndex(&map->symbolset,
2203 pszURL,
2204 MS_TRUE);
2205
2206 if (psStyle->symbol > 0 && psStyle->symbol < map->symbolset.numsymbols)
2207 psStyle->symbolname = msStrdup(map->symbolset.symbol[psStyle->symbol]->name);
2208
2209 /* set the color parameter if not set. Does not make sense */
2210 /* for pixmap but mapserver needs it. */
2211 if (psStyle->color.red == -1 || psStyle->color.green || psStyle->color.blue)
2212 {
2213 psStyle->color.red = 0;
2214 psStyle->color.green = 0;
2215 psStyle->color.blue = 0;

Callers 1

Calls 3

strcasecmpFunction · 0.85
msGetSymbolIndexFunction · 0.85
msStrdupFunction · 0.85

Tested by

no test coverage detected