| 70 | } |
| 71 | |
| 72 | static int bindColorAttribute(colorObj *attribute, char *value) |
| 73 | { |
| 74 | int len; |
| 75 | |
| 76 | if(!value || ((len = strlen(value)) == 0)) return MS_FAILURE; |
| 77 | |
| 78 | if(value[0] == '#' && (len == 7 || len == 9)) { /* got a hex color */ |
| 79 | char hex[2]; |
| 80 | |
| 81 | hex[0] = value[1]; |
| 82 | hex[1] = value[2]; |
| 83 | attribute->red = msHexToInt(hex); |
| 84 | hex[0] = value[3]; |
| 85 | hex[1] = value[4]; |
| 86 | attribute->green = msHexToInt(hex); |
| 87 | hex[0] = value[5]; |
| 88 | hex[1] = value[6]; |
| 89 | attribute->blue = msHexToInt(hex); |
| 90 | if(len == 9) { |
| 91 | hex[0] = value[7]; |
| 92 | hex[1] = value[8]; |
| 93 | attribute->alpha = msHexToInt(hex); |
| 94 | } |
| 95 | return MS_SUCCESS; |
| 96 | } else { /* try a space delimited string */ |
| 97 | char **tokens=NULL; |
| 98 | int numtokens=0; |
| 99 | |
| 100 | tokens = msStringSplit(value, ' ', &numtokens); |
| 101 | if(tokens==NULL || numtokens != 3) { |
| 102 | msFreeCharArray(tokens, numtokens); |
| 103 | return MS_FAILURE; /* punt */ |
| 104 | } |
| 105 | |
| 106 | attribute->red = atoi(tokens[0]); |
| 107 | attribute->green = atoi(tokens[1]); |
| 108 | attribute->blue = atoi(tokens[2]); |
| 109 | msFreeCharArray(tokens, numtokens); |
| 110 | |
| 111 | return MS_SUCCESS; |
| 112 | } |
| 113 | |
| 114 | return MS_FAILURE; /* shouldn't get here */ |
| 115 | } |
| 116 | |
| 117 | static void bindStyle(layerObj *layer, shapeObj *shape, styleObj *style, int querymapMode) { |
| 118 | if(style->numbindings > 0) { |
no test coverage detected