@@ -1209,6 +1209,7 @@ static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
1209
1209
const char * name = NULL , * pattern = NULL ;
1210
1210
const char * format = NULL , * nullFormat = NULL ;
1211
1211
int precision ;
1212
+ int padding ;
1212
1213
int uc , lc , commify ;
1213
1214
int escape ;
1214
1215
@@ -1224,7 +1225,8 @@ static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
1224
1225
while (tagStart ) {
1225
1226
format = "$value" ; /* initialize the tag arguments */
1226
1227
nullFormat = "" ;
1227
- precision = -1 ;
1228
+ precision = -1 ;
1229
+ padding = -1 ;
1228
1230
name = pattern = NULL ;
1229
1231
uc = lc = commify = MS_FALSE ;
1230
1232
escape = ESCAPE_HTML ;
@@ -1241,6 +1243,9 @@ static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
1241
1243
argValue = msLookupHashTable (tagArgs , "precision" );
1242
1244
if (argValue ) precision = atoi (argValue );
1243
1245
1246
+ argValue = msLookupHashTable (tagArgs , "padding" );
1247
+ if (argValue ) padding = atoi (argValue );
1248
+
1244
1249
argValue = msLookupHashTable (tagArgs , "format" );
1245
1250
if (argValue ) format = argValue ;
1246
1251
@@ -1310,6 +1315,15 @@ static int processItemTag(layerObj *layer, char **line, shapeObj *shape)
1310
1315
tagValue = msReplaceSubstring (tagValue , "$value" , itemValue );
1311
1316
msFree (itemValue );
1312
1317
1318
+ if (padding > 0 && padding < 1000 ) {
1319
+ int paddedSize = strlen (tagValue ) + padding + 1 ;
1320
+ char * paddedValue = NULL ;
1321
+ paddedValue = (char * ) msSmallMalloc (paddedSize );
1322
+ snprintf (paddedValue , paddedSize , "%-*s" , padding , tagValue );
1323
+ msFree (tagValue );
1324
+ tagValue = paddedValue ;
1325
+ }
1326
+
1313
1327
if (!tagValue ) {
1314
1328
msSetError (MS_WEBERR , "Error applying item format." , "processItemTag()" );
1315
1329
return (MS_FAILURE ); /* todo leaking... */
0 commit comments