@@ -491,7 +491,7 @@ int msLegendCalcSize(mapObj *map, int scale_independent, int *size_x, int *size_
491
491
for (j = lp -> numclasses - 1 ; j >=0 ; j -- ) {
492
492
textSymbolObj ts ;
493
493
text = lp -> class [j ]-> title ?lp -> class [j ]-> title :lp -> class [j ]-> name ; /* point to the right legend text, title takes precedence */
494
- if (!text || ! * text ) continue ; /* skip it */
494
+ if (!text ) continue ; /* skip it */
495
495
496
496
/* skip the class if the classgroup is defined */
497
497
if (lp -> classgroup && (lp -> class [j ]-> group == NULL || strcasecmp (lp -> class [j ]-> group , lp -> classgroup ) != 0 ))
@@ -504,16 +504,20 @@ int msLegendCalcSize(mapObj *map, int scale_independent, int *size_x, int *size_
504
504
}
505
505
if (hittest && hittest -> layerhits [layerindex ].classhits [j ].status == 0 ) continue ;
506
506
507
- initTextSymbol (& ts );
508
- msPopulateTextSymbolForLabelAndString (& ts ,& map -> legend .label ,msStrdup (text ),lp -> scalefactor * resolutionfactor ,resolutionfactor , 0 );
509
- if (UNLIKELY (MS_FAILURE == msGetTextSymbolSize (map ,& ts ,& rect ))) {
507
+ if (* text ) {
508
+ initTextSymbol (& ts );
509
+ msPopulateTextSymbolForLabelAndString (& ts ,& map -> legend .label ,msStrdup (text ),lp -> scalefactor * resolutionfactor ,resolutionfactor , 0 );
510
+ if (UNLIKELY (MS_FAILURE == msGetTextSymbolSize (map ,& ts ,& rect ))) {
511
+ freeTextSymbol (& ts );
512
+ return MS_FAILURE ;
513
+ }
510
514
freeTextSymbol (& ts );
511
- return MS_FAILURE ;
512
- }
513
- freeTextSymbol (& ts );
514
515
515
- maxwidth = MS_MAX (maxwidth , MS_NINT (rect .maxx - rect .minx ));
516
- * size_y += MS_MAX (MS_NINT (rect .maxy - rect .miny ), map -> legend .keysizey );
516
+ maxwidth = MS_MAX (maxwidth , MS_NINT (rect .maxx - rect .minx ));
517
+ * size_y += MS_MAX (MS_NINT (rect .maxy - rect .miny ), map -> legend .keysizey );
518
+ } else {
519
+ * size_y += map -> legend .keysizey ;
520
+ }
517
521
nLegendItems ++ ;
518
522
}
519
523
}
@@ -599,7 +603,7 @@ imageObj *msDrawLegend(mapObj *map, int scale_independent, map_hittest *hittest)
599
603
600
604
for (j = lp -> numclasses - 1 ; j >=0 ; j -- ) {
601
605
text = lp -> class [j ]-> title ?lp -> class [j ]-> title :lp -> class [j ]-> name ; /* point to the right legend text, title takes precedence */
602
- if (!text || ! * text ) continue ; /* skip it */
606
+ if (!text ) continue ; /* skip it */
603
607
604
608
/* skip the class if the classgroup is defined */
605
609
if (lp -> classgroup && (lp -> class [j ]-> group == NULL || strcasecmp (lp -> class [j ]-> group , lp -> classgroup ) != 0 ))
@@ -616,20 +620,24 @@ imageObj *msDrawLegend(mapObj *map, int scale_independent, map_hittest *hittest)
616
620
617
621
cur = (legendlabel * ) msSmallMalloc (sizeof (legendlabel ));
618
622
initTextSymbol (& cur -> ts );
619
- msPopulateTextSymbolForLabelAndString (& cur -> ts ,& map -> legend .label ,msStrdup (text ),lp -> scalefactor * map -> resolution /map -> defresolution ,map -> resolution /map -> defresolution , 0 );
620
- if (UNLIKELY (MS_FAILURE == msComputeTextPath (map ,& cur -> ts ))) {
621
- ret = MS_FAILURE ;
622
- goto cleanup ;
623
- }
624
- if (UNLIKELY (MS_FAILURE == msGetTextSymbolSize (map ,& cur -> ts ,& rect ))) {
625
- ret = MS_FAILURE ;
626
- goto cleanup ;
623
+ if (* text ) {
624
+ msPopulateTextSymbolForLabelAndString (& cur -> ts ,& map -> legend .label ,msStrdup (text ),lp -> scalefactor * map -> resolution /map -> defresolution ,map -> resolution /map -> defresolution , 0 );
625
+ if (UNLIKELY (MS_FAILURE == msComputeTextPath (map ,& cur -> ts ))) {
626
+ ret = MS_FAILURE ;
627
+ goto cleanup ;
628
+ }
629
+ if (UNLIKELY (MS_FAILURE == msGetTextSymbolSize (map ,& cur -> ts ,& rect ))) {
630
+ ret = MS_FAILURE ;
631
+ goto cleanup ;
632
+ }
633
+ cur -> height = MS_MAX (MS_NINT (rect .maxy - rect .miny ), map -> legend .keysizey );
634
+ } else {
635
+ cur -> height = map -> legend .keysizey ;
627
636
}
628
637
629
638
cur -> classindex = j ;
630
639
cur -> layerindex = i ;
631
640
cur -> pred = head ;
632
- cur -> height = MS_MAX (MS_NINT (rect .maxy - rect .miny ), map -> legend .keysizey );
633
641
head = cur ;
634
642
}
635
643
}
@@ -668,16 +676,20 @@ imageObj *msDrawLegend(mapObj *map, int scale_independent, map_hittest *hittest)
668
676
if (msDrawLegendIcon (map , map -> layers [cur -> layerindex ], map -> layers [cur -> layerindex ]-> class [cur -> classindex ], map -> legend .keysizex , map -> legend .keysizey , image , HMARGIN , (int ) pnt .y , scale_independent , ch ) != MS_SUCCESS )
669
677
return NULL ;
670
678
671
- pnt .y += cur -> height - cur -> ts .textpath -> bounds .bbox .maxy ;
672
-
673
- ret = msDrawTextSymbol (map ,image ,pnt ,& cur -> ts );
674
- if (UNLIKELY (ret == MS_FAILURE ))
675
- goto cleanup ;
679
+ pnt .y += cur -> height ;
680
+
681
+ if (cur -> ts .annotext ) {
682
+ pnt .y -= cur -> ts .textpath -> bounds .bbox .maxy ;
683
+ ret = msDrawTextSymbol (map ,image ,pnt ,& cur -> ts );
684
+ if (UNLIKELY (ret == MS_FAILURE ))
685
+ goto cleanup ;
686
+ pnt .y += cur -> ts .textpath -> bounds .bbox .maxy ;
687
+ freeTextSymbol (& cur -> ts );
688
+ }
676
689
677
- pnt .y += map -> legend .keyspacingy + cur -> ts . textpath -> bounds . bbox . maxy ; /* bump y for next label */
690
+ pnt .y += map -> legend .keyspacingy ; /* bump y for next label */
678
691
679
692
/* clean up */
680
- freeTextSymbol (& cur -> ts );
681
693
head = cur ;
682
694
cur = cur -> pred ;
683
695
free (head );
0 commit comments