/ msSLDGenerateSLD(mapObj *map, int iLayer) */ / Return an SLD document for all layers that are on or */ default. The second argument should be set to -1 to genarte */ on all layers. Or set to the layer index to generate an SLD */ for a specific layer. */ / The caller should free the returned string. */ /
| 3239 | /* The caller should free the returned string. */ |
| 3240 | /************************************************************************/ |
| 3241 | char *msSLDGenerateSLD(mapObj *map, int iLayer, const char *pszVersion) |
| 3242 | { |
| 3243 | #if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR) |
| 3244 | |
| 3245 | #ifdef USE_OGR |
| 3246 | |
| 3247 | |
| 3248 | char szTmp[500]; |
| 3249 | int i = 0; |
| 3250 | char *pszTmp = NULL; |
| 3251 | char *pszSLD = NULL; |
| 3252 | char *schemalocation = NULL; |
| 3253 | int sld_version = OWS_VERSION_NOTSET; |
| 3254 | |
| 3255 | sld_version = msOWSParseVersionString(pszVersion); |
| 3256 | |
| 3257 | if (sld_version == OWS_VERSION_NOTSET || |
| 3258 | (sld_version!= OWS_1_0_0 && sld_version!= OWS_1_1_0)) |
| 3259 | sld_version = OWS_1_0_0; |
| 3260 | |
| 3261 | if (map) |
| 3262 | { |
| 3263 | schemalocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map)); |
| 3264 | if (sld_version == OWS_1_0_0) |
| 3265 | snprintf(szTmp, sizeof(szTmp), "<StyledLayerDescriptor version=\"1.0.0\" xmlns=\"http://www.opengis.net/sld\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/sld %s/sld/1.0.0/StyledLayerDescriptor.xsd\">\n",schemalocation ); |
| 3266 | else |
| 3267 | snprintf(szTmp, sizeof(szTmp), "<StyledLayerDescriptor version=\"1.1.0\" xsi:schemaLocation=\"http://www.opengis.net/sld %s/sld/1.1.0/StyledLayerDescriptor.xsd\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:se=\"http://www.opengis.net/se\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n", schemalocation); |
| 3268 | |
| 3269 | free(schemalocation); |
| 3270 | |
| 3271 | pszSLD = msStringConcatenate(pszSLD, szTmp); |
| 3272 | if (iLayer < 0 || iLayer > map->numlayers -1) |
| 3273 | { |
| 3274 | for (i=0; i<map->numlayers; i++) |
| 3275 | { |
| 3276 | pszTmp = msSLDGenerateSLDLayer(GET_LAYER(map, i), sld_version); |
| 3277 | if (pszTmp) |
| 3278 | { |
| 3279 | pszSLD= msStringConcatenate(pszSLD, pszTmp); |
| 3280 | free(pszTmp); |
| 3281 | } |
| 3282 | } |
| 3283 | } |
| 3284 | else |
| 3285 | { |
| 3286 | pszTmp = msSLDGenerateSLDLayer(GET_LAYER(map, iLayer), sld_version); |
| 3287 | if (pszTmp) |
| 3288 | { |
| 3289 | pszSLD = msStringConcatenate(pszSLD, pszTmp); |
| 3290 | free(pszTmp); |
| 3291 | } |
| 3292 | } |
| 3293 | snprintf(szTmp, sizeof(szTmp), "%s", "</StyledLayerDescriptor>\n"); |
| 3294 | pszSLD = msStringConcatenate(pszSLD, szTmp); |
| 3295 | } |
| 3296 | |
| 3297 | return pszSLD; |
| 3298 |
no test coverage detected