multi-page index: en entry repeated several times in a row is only printed once

Signed-off-by: David MENTRE <dmentre@linux-france.org>
stable
David MENTRE 2012-03-31 10:52:11 +02:00 zatwierdzone przez Thomas Petazzoni
rodzic d3fdeffb21
commit cf6ce9585b
2 zmienionych plików z 17 dodań i 3 usunięć

Wyświetl plik

@ -173,9 +173,11 @@ class IndexItem:
baseline_x, baseline_y,
self.label)
draw_utils.draw_dotted_line(ctx, max(fheight/12, 1),
line_start + fheight/4, baseline_y,
line_end - line_start - fheight/2)
# In case of empty label, we don't draw the dots
if self.label != '':
draw_utils.draw_dotted_line(ctx, max(fheight/12, 1),
line_start + fheight/4, baseline_y,
line_end - line_start - fheight/2)
ctx.restore()
def update_location_str(self, grid):

Wyświetl plik

@ -347,6 +347,8 @@ class MultiPageRenderer(Renderer):
finally:
locale.setlocale(locale.LC_COLLATE, prev_locale)
self._blank_duplicated_names(grouped_items_sorted)
# Rebuild a IndexCategory object with the list of merged
# and sorted IndexItem
categories_merged.append(
@ -354,6 +356,16 @@ class MultiPageRenderer(Renderer):
return categories_merged
# We set the label to empty string in case of duplicated item. In
# multi-page renderer we won't draw the dots in that case
def _blank_duplicated_names(self, grouped_items_sorted):
prev_label = ''
for item in grouped_items_sorted:
if prev_label == item.label:
item.label = ''
else:
prev_label = item.label
def _project_envelope(self, bbox):
"""Project the given bounding box into the rendering projection."""
envelope = mapnik.Box2d(bbox.get_top_left()[1],