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

Function msSLDGenerateTextSLD

mapogcsld.c:4007–4241  ·  view source on GitHub ↗

/ msSLDGenerateTextSLD */ / Generate a TextSymboliser SLD xml based on the class's label */ object. */ /

Source from the content-addressed store, hash-verified

4005/* object. */
4006/************************************************************************/
4007char *msSLDGenerateTextSLD(classObj *psClass, layerObj *psLayer, int nVersion)
4008{
4009#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR)
4010 char *pszSLD = NULL;
4011
4012 char szTmp[100];
4013 char **aszFontsParts = NULL;
4014 int nFontParts = 0;
4015 char szHexColor[7];
4016 int nColorRed=-1, nColorGreen=-1, nColorBlue=-1;
4017 double dfAnchorX = 0.5, dfAnchorY = 0.5;
4018 int i = 0;
4019 char sCssParam[30];
4020 char sNameSpace[10];
4021
4022 sCssParam[0] = '\0';
4023 if (nVersion > OWS_1_0_0)
4024 strcpy(sCssParam, "se:SvgParameter");
4025 else
4026 strcpy(sCssParam, "CssParameter");
4027
4028 sNameSpace[0] = '\0';
4029 if (nVersion > OWS_1_0_0)
4030 strcpy(sNameSpace, "se:");
4031
4032
4033 if (psClass && psLayer && psLayer->labelitem &&
4034 strlen(psLayer->labelitem) > 0)
4035 {
4036 snprintf(szTmp, sizeof(szTmp), "<%sTextSymbolizer>\n", sNameSpace);
4037 pszSLD = msStringConcatenate(pszSLD, szTmp);
4038
4039 snprintf(szTmp, sizeof(szTmp), "<%sLabel>%s</%sLabel>\n", sNameSpace,
4040 psLayer->labelitem, sNameSpace);
4041 pszSLD = msStringConcatenate(pszSLD, szTmp);
4042
4043/* -------------------------------------------------------------------- */
4044/* only true type fonts are exported. Font name should be */
4045/* something like arial-bold-italic. There are 3 parts to the */
4046/* name font-family, font-style (italic, oblique, nomal), */
4047/* font-weight (bold, normal). These 3 elements are separated */
4048/* with -. */
4049/* -------------------------------------------------------------------- */
4050 if (psClass->label.type == MS_TRUETYPE && psClass->label.font)
4051 {
4052 aszFontsParts = msStringSplit(psClass->label.font, '-', &nFontParts);
4053 if (nFontParts > 0)
4054 {
4055 snprintf(szTmp, sizeof(szTmp), "<%sFont>\n", sNameSpace);
4056 pszSLD = msStringConcatenate(pszSLD, szTmp);
4057
4058 /* assuming first one is font-family */
4059 snprintf(szTmp, sizeof(szTmp),
4060 "<%s name=\"font-family\">%s</%s>\n",
4061 sCssParam, aszFontsParts[0], sCssParam);
4062 pszSLD = msStringConcatenate(pszSLD, szTmp);
4063 for (i=1; i<nFontParts; i++)
4064 {

Callers 1

msSLDGenerateSLDLayerFunction · 0.85

Calls 4

msStringConcatenateFunction · 0.85
msStringSplitFunction · 0.85
strcasecmpFunction · 0.85
msFreeCharArrayFunction · 0.85

Tested by

no test coverage detected