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

Function msSLDParseRasterSymbolizer

mapogcsld.c:2446–2762  ·  view source on GitHub ↗

/ msSLDParseRasterSymbolizer */ / Supports the ColorMap parameter in a Raster Symbolizer. In */ the ColorMap, only color and quantity are used here. */ / */ */ */ <xs:elemen

Source from the content-addressed store, hash-verified

2444/* */
2445/************************************************************************/
2446int msSLDParseRasterSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer)
2447{
2448 CPLXMLNode *psColorMap = NULL, *psColorEntry = NULL, *psOpacity=NULL;
2449 char *pszColor=NULL, *pszQuantity=NULL;
2450 char *pszPreviousColor=NULL, *pszPreviousQuality=NULL;
2451 colorObj sColor;
2452 char szExpression[100];
2453 int nClassId = 0;
2454 double dfOpacity = 1.0;
2455 char *pszLabel = NULL, *pszPreviousLabel = NULL;
2456 char *pch = NULL, *pchPrevious=NULL;
2457
2458 CPLXMLNode *psNode=NULL, *psCategorize=NULL;
2459 char **papszValues = (char **)malloc(sizeof(char*)*100);
2460 char **papszThresholds = (char **)malloc(sizeof(char*)*100);
2461 char *pszTmp = NULL;
2462 int nValues=0, nThresholds=0;
2463 int i,nMaxValues= 100, nMaxThreshold=100;
2464
2465 if (!psRoot || !psLayer)
2466 return MS_FAILURE;
2467
2468/* ==================================================================== */
2469/* The default opacity value is 0 : we set it here to -1 */
2470/* so that when testing the values in msSLDApplySLD (to be */
2471/* applied on the layer), we can assume that a value of 0 comes */
2472/* from the sld. */
2473/* ==================================================================== */
2474 psLayer->opacity = -1;
2475
2476 psOpacity = CPLGetXMLNode(psRoot, "Opacity");
2477 if (psOpacity)
2478 {
2479 if (psOpacity->psChild && psOpacity->psChild->pszValue)
2480 dfOpacity = atof(psOpacity->psChild->pszValue);
2481
2482 /* values in sld goes from 0.0 (for transparent) to 1.0 (for full opacity); */
2483 if (dfOpacity >=0.0 && dfOpacity <=1.0)
2484 psLayer->opacity = (int)(dfOpacity * 100);
2485 else
2486 {
2487 msSetError(MS_WMSERR, "Invalid opacity value. Values should be between 0.0 and 1.0", "msSLDParseRasterSymbolizer()");
2488 return MS_FAILURE;
2489 }
2490 }
2491 psColorMap = CPLGetXMLNode(psRoot, "ColorMap");
2492 if (psColorMap)
2493 {
2494 psColorEntry = CPLGetXMLNode(psColorMap, "ColorMapEntry");
2495
2496 if (psColorEntry) /*SLD 1.0*/
2497 {
2498 while (psColorEntry && psColorEntry->pszValue &&
2499 strcasecmp(psColorEntry->pszValue, "ColorMapEntry") == 0)
2500 {
2501 pszColor = (char *)CPLGetXMLValue(psColorEntry, "color", NULL);
2502 pszQuantity = (char *)CPLGetXMLValue(psColorEntry, "quantity", NULL);
2503 pszLabel = (char *)CPLGetXMLValue(psColorEntry, "label", NULL);

Callers 1

msSLDParseRuleFunction · 0.85

Calls 10

msSetErrorFunction · 0.85
strcasecmpFunction · 0.85
msHexToIntFunction · 0.85
msGrowLayerClassesFunction · 0.85
initClassFunction · 0.85
msStrdupFunction · 0.85
msLoadExpressionStringFunction · 0.85
freeClassFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected