[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 17/22] index for multi-page: improve page_number
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 17/22] index for multi-page: improve page_number handling |
Date: |
Fri, 30 Mar 2012 13:00:34 +0200 |
The page_number is now directly given to the StreetIndex constructor,
which in turn ensures that each IndexItem it creates have it.
Signed-off-by: Thomas Petazzoni <address@hidden>
---
ocitysmap2/indexlib/commons.py | 4 ++--
ocitysmap2/indexlib/indexer.py | 12 ++++++++----
ocitysmap2/layoutlib/multi_page_renderer.py | 5 +----
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/ocitysmap2/indexlib/commons.py b/ocitysmap2/indexlib/commons.py
index 2bdd4a8..8143ebc 100644
--- a/ocitysmap2/indexlib/commons.py
+++ b/ocitysmap2/indexlib/commons.py
@@ -106,13 +106,13 @@ class IndexItem:
location_str = None # str or None
page_number = None # integer or None. Only used by multi-page renderer.
- def __init__(self, label, endpoint1, endpoint2):
+ def __init__(self, label, endpoint1, endpoint2, page_number=None):
assert label is not None
self.label = label
self.endpoint1 = endpoint1
self.endpoint2 = endpoint2
self.location_str = None
- self.page_number = None
+ self.page_number = page_number
def __str__(self):
return '%s...%s' % (self.label, self.location_str)
diff --git a/ocitysmap2/indexlib/indexer.py b/ocitysmap2/indexlib/indexer.py
index 663ca52..0c17173 100644
--- a/ocitysmap2/indexlib/indexer.py
+++ b/ocitysmap2/indexlib/indexer.py
@@ -45,7 +45,7 @@ l = logging.getLogger('ocitysmap')
class StreetIndex:
- def __init__(self, db, polygon_wkt, i18n):
+ def __init__(self, db, polygon_wkt, i18n, page_number=None):
"""
Prepare the index of the streets inside the given WKT. This
constructor will perform all the SQL queries.
@@ -58,6 +58,7 @@ class StreetIndex:
Note: All the arguments have to be provided !
"""
self._i18n = i18n
+ self._page_number = page_number
# Build the contents of the index
self._categories = \
@@ -228,7 +229,8 @@ class StreetIndex:
endpoint2 = coords.Point(s_endpoint2[1], s_endpoint2[0])
current_category.items.append(commons.IndexItem(street_name,
endpoint1,
- endpoint2))
+ endpoint2,
+ self._page_number))
return result
@@ -348,7 +350,8 @@ order by amenity_name""" \
endpoint2 = coords.Point(s_endpoint2[1], s_endpoint2[0])
current_category.items.append(commons.IndexItem(amenity_name,
endpoint1,
- endpoint2))
+ endpoint2,
+
self._page_number))
l.debug("Got %d amenities for %s/%s."
% (len(current_category.items), catname, db_amenity))
@@ -414,7 +417,8 @@ order by village_name""" \
endpoint2 = coords.Point(s_endpoint2[1], s_endpoint2[0])
current_category.items.append(commons.IndexItem(village_name,
endpoint1,
- endpoint2))
+ endpoint2,
+ self._page_number))
l.debug("Got %d villages for %s."
% (len(current_category.items), 'Villages'))
diff --git a/ocitysmap2/layoutlib/multi_page_renderer.py
b/ocitysmap2/layoutlib/multi_page_renderer.py
index 1748ac6..df6cef6 100644
--- a/ocitysmap2/layoutlib/multi_page_renderer.py
+++ b/ocitysmap2/layoutlib/multi_page_renderer.py
@@ -218,7 +218,7 @@ class MultiPageRenderer(Renderer):
# Create the index for the current page
index = StreetIndex(self.db,
bb_inner.as_wkt(),
- self.rc.i18n)
+ self.rc.i18n, page_number=(i + 1))
index.apply_grid(map_grid)
indexes.append(index)
@@ -236,9 +236,6 @@ class MultiPageRenderer(Renderer):
all_categories_others = []
for page_number, idx in enumerate(indexes):
for cat in idx.categories:
- # Mark each IndexItem with its page number
- for item in cat.items:
- item.page_number = (page_number + 1)
# Split in two lists depending on the category type
# (street or other)
if cat.is_street:
--
1.7.4.1
- [Maposmatic-dev] [PATCH 15/22] indexlib: properly differentiate the page_number=None and page_number=0 cases, (continued)
- [Maposmatic-dev] [PATCH 15/22] indexlib: properly differentiate the page_number=None and page_number=0 cases, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 13/22] multi-page: add in dex rendering with a new MultiPageStreetIndexRenderer cl ass, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 11/22] multi-page: prepare data for index generation, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 14/22] multi-page: remove multiple debugging outputs, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 18/22] indexlib: add min_drawing_width() method, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 19/22] MultiPageStreetIndexRenderer: remove debugging background rectangle, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 16/22] multi-page: in the street index, start page numbering at 1, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 21/22] MultiPageStreetIndexRenderer: automatically compute the number of columns, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 20/22] MultiPageStreetIndexRenderer: reduce size of default font, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 22/22] multi-page: minor fixups for compatibility with Gaël's work to remo ve the scaling, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 17/22] index for multi-page: improve page_number handling,
Thomas Petazzoni <=
- Re: [Maposmatic-dev] Implementation of a multi-page renderer, Jeroen van Rijn, 2012/03/30
Re: [Maposmatic-dev] Implementation of a multi-page renderer, Thomas Petazzoni, 2012/03/30