/ void msSLDParsePolygonFill(CPLXMLNode *psFill, styleObj *psStyle, */ mapObj *map) */ / Parse the Fill node for a polygon into a style. */ /
| 1482 | /* Parse the Fill node for a polygon into a style. */ |
| 1483 | /************************************************************************/ |
| 1484 | int msSLDParsePolygonFill(CPLXMLNode *psFill, styleObj *psStyle, |
| 1485 | mapObj *map) |
| 1486 | { |
| 1487 | CPLXMLNode *psCssParam, *psGraphicFill; |
| 1488 | char *psColor=NULL, *psFillName=NULL; |
| 1489 | int nLength = 0; |
| 1490 | |
| 1491 | if (!psFill || !psStyle || !map) |
| 1492 | return MS_FAILURE; |
| 1493 | |
| 1494 | /* sets the default fill color defined in the spec #808080 */ |
| 1495 | psStyle->color.red = 128; |
| 1496 | psStyle->color.green = 128; |
| 1497 | psStyle->color.blue = 128; |
| 1498 | |
| 1499 | psCssParam = CPLGetXMLNode(psFill, "CssParameter"); |
| 1500 | /*sld 1.1 used SvgParameter*/ |
| 1501 | if (psCssParam == NULL) |
| 1502 | psCssParam = CPLGetXMLNode(psFill, "SvgParameter"); |
| 1503 | |
| 1504 | while (psCssParam && psCssParam->pszValue && |
| 1505 | (strcasecmp(psCssParam->pszValue, "CssParameter") == 0 || |
| 1506 | strcasecmp(psCssParam->pszValue, "SvgParameter") == 0)) |
| 1507 | { |
| 1508 | psFillName = (char*)CPLGetXMLValue(psCssParam, "name", NULL); |
| 1509 | if (psFillName) |
| 1510 | { |
| 1511 | if (strcasecmp(psFillName, "fill") == 0) |
| 1512 | { |
| 1513 | if(psCssParam->psChild && psCssParam->psChild->psNext && |
| 1514 | psCssParam->psChild->psNext->pszValue) |
| 1515 | psColor = psCssParam->psChild->psNext->pszValue; |
| 1516 | |
| 1517 | if (psColor) |
| 1518 | { |
| 1519 | nLength = strlen(psColor); |
| 1520 | /* expecting hexadecimal ex : #aaaaff */ |
| 1521 | if (nLength == 7 && psColor[0] == '#') |
| 1522 | { |
| 1523 | psStyle->color.red = msHexToInt(psColor+1); |
| 1524 | psStyle->color.green = msHexToInt(psColor+3); |
| 1525 | psStyle->color.blue= msHexToInt(psColor+5); |
| 1526 | } |
| 1527 | } |
| 1528 | } |
| 1529 | else if (strcasecmp(psFillName, "fill-opacity") == 0) |
| 1530 | { |
| 1531 | if(psCssParam->psChild && psCssParam->psChild->psNext && |
| 1532 | psCssParam->psChild->psNext->pszValue) |
| 1533 | { |
| 1534 | psStyle->color.alpha = (int)(atof(psCssParam->psChild->psNext->pszValue)*255); |
| 1535 | } |
| 1536 | } |
| 1537 | } |
| 1538 | psCssParam = psCssParam->psNext; |
| 1539 | } |
| 1540 | |
| 1541 | /* graphic fill and graphic stroke pare parsed the same way : */ |
no test coverage detected