maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH 1/2] multi-page index: en entry repeated several


From: David MENTRE
Subject: [Maposmatic-dev] [PATCH 1/2] multi-page index: en entry repeated several times in a row is only printed once
Date: Sat, 31 Mar 2012 10:52:11 +0200

Signed-off-by: David MENTRE <address@hidden>
---
 ocitysmap2/indexlib/commons.py              |    8 +++++---
 ocitysmap2/layoutlib/multi_page_renderer.py |   12 ++++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/ocitysmap2/indexlib/commons.py b/ocitysmap2/indexlib/commons.py
index f4c19bb..45a72eb 100644
--- a/ocitysmap2/indexlib/commons.py
+++ b/ocitysmap2/indexlib/commons.py
@@ -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):
diff --git a/ocitysmap2/layoutlib/multi_page_renderer.py 
b/ocitysmap2/layoutlib/multi_page_renderer.py
index 75359fe..bec94d1 100644
--- a/ocitysmap2/layoutlib/multi_page_renderer.py
+++ b/ocitysmap2/layoutlib/multi_page_renderer.py
@@ -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],
-- 
1.7.5.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]