[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 10/22] renderers: pass the db connection to the
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 10/22] renderers: pass the db connection to the Renderer class constructor |
Date: |
Fri, 30 Mar 2012 13:00:27 +0200 |
For the multi-page renderer, we need a reference to the GIS database
connection in order to build custom indexes for each page of the
map. Therefore, we modify the Renderer constructor so that it takes as
argument a reference to the database connection.
Signed-off-by: Thomas Petazzoni <address@hidden>
---
ocitysmap2/__init__.py | 2 +-
ocitysmap2/layoutlib/abstract_renderer.py | 3 ++-
ocitysmap2/layoutlib/single_page_renderers.py | 18 ++++++++----------
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/ocitysmap2/__init__.py b/ocitysmap2/__init__.py
index 054d4bf..ceba182 100644
--- a/ocitysmap2/__init__.py
+++ b/ocitysmap2/__init__.py
@@ -520,7 +520,7 @@ SELECT ST_AsText(ST_LongestLine(
raise ValueError, \
'Unsupported output format: %s!' % output_format.upper()
- renderer = renderer_cls(config, tmpdir, dpi, street_index)
+ renderer = renderer_cls(self._db, config, tmpdir, dpi, street_index)
# Update the street_index to reflect the grid's actual position
if renderer.grid and street_index:
diff --git a/ocitysmap2/layoutlib/abstract_renderer.py
b/ocitysmap2/layoutlib/abstract_renderer.py
index f2bc858..713bf58 100644
--- a/ocitysmap2/layoutlib/abstract_renderer.py
+++ b/ocitysmap2/layoutlib/abstract_renderer.py
@@ -58,7 +58,7 @@ class Renderer:
# on the rendered map of a kilometer
DEFAULT_KM_IN_MM = 100
- def __init__(self, rc, tmpdir, street_index):
+ def __init__(self, db, rc, tmpdir, street_index):
"""
Create the renderer.
@@ -68,6 +68,7 @@ class Renderer:
street_index (StreetIndex): None or the street index object.
"""
# Note: street_index may be None
+ self.db = db
self.rc = rc
self.tmpdir = tmpdir
self.grid = None # The implementation is in charge of it
diff --git a/ocitysmap2/layoutlib/single_page_renderers.py
b/ocitysmap2/layoutlib/single_page_renderers.py
index 1cbdc83..e5137c8 100644
--- a/ocitysmap2/layoutlib/single_page_renderers.py
+++ b/ocitysmap2/layoutlib/single_page_renderers.py
@@ -55,7 +55,7 @@ class SinglePageRenderer(Renderer):
MAX_INDEX_OCCUPATION_RATIO = 1/3.
- def __init__(self, rc, tmpdir, dpi,
+ def __init__(self, db, rc, tmpdir, dpi,
street_index = None, index_position = 'side'):
"""
Create the renderer.
@@ -67,7 +67,7 @@ class SinglePageRenderer(Renderer):
index_position (str): None or 'side' (index on side),
'bottom' (index at bottom).
"""
- Renderer.__init__(self, rc, tmpdir, street_index)
+ Renderer.__init__(self, db, rc, tmpdir, street_index)
self._grid_legend_margin_pt = \
min(Renderer.GRID_LEGEND_MARGIN_RATIO * self.paper_width_pt,
@@ -489,7 +489,7 @@ class SinglePageRendererNoIndex(SinglePageRenderer):
name = 'plain'
description = 'Full-page layout without index.'
- def __init__(self, rc, tmpdir, dpi, street_index):
+ def __init__(self, db, rc, tmpdir, dpi, street_index):
"""
Create the renderer.
@@ -498,7 +498,7 @@ class SinglePageRendererNoIndex(SinglePageRenderer):
tmpdir (os.path): Path to a temp dir that can hold temp files.
street_index (StreetIndex): None or the street index object.
"""
- SinglePageRenderer.__init__(self, rc, tmpdir, dpi, None, None)
+ SinglePageRenderer.__init__(self, db, rc, tmpdir, dpi, None, None)
@staticmethod
@@ -527,7 +527,7 @@ class SinglePageRendererIndexOnSide(SinglePageRenderer):
name = 'single_page_index_side'
description = 'Full-page layout with the index on the side.'
- def __init__(self, rc, tmpdir, dpi, street_index):
+ def __init__(self, db, rc, tmpdir, dpi, street_index):
"""
Create the renderer.
@@ -536,8 +536,7 @@ class SinglePageRendererIndexOnSide(SinglePageRenderer):
tmpdir (os.path): Path to a temp dir that can hold temp files.
street_index (StreetIndex): None or the street index object.
"""
- SinglePageRenderer.__init__(self, rc, tmpdir, dpi, street_index,
'side')
-
+ SinglePageRenderer.__init__(self, db, rc, tmpdir, dpi, street_index,
'side')
@staticmethod
def get_compatible_paper_sizes(bounding_box, zoom_level,
@@ -565,7 +564,7 @@ class SinglePageRendererIndexBottom(SinglePageRenderer):
name = 'single_page_index_bottom'
description = 'Full-page layout with the index at the bottom.'
- def __init__(self, rc, tmpdir, dpi, street_index):
+ def __init__(self, db, rc, tmpdir, dpi, street_index):
"""
Create the renderer.
@@ -574,8 +573,7 @@ class SinglePageRendererIndexBottom(SinglePageRenderer):
tmpdir (os.path): Path to a temp dir that can hold temp files.
street_index (StreetIndex): None or the street index object.
"""
- SinglePageRenderer.__init__(self, rc, tmpdir, dpi, street_index,
'bottom')
-
+ SinglePageRenderer.__init__(self, db, rc, tmpdir, dpi, street_index,
'bottom')
@staticmethod
def get_compatible_paper_sizes(bounding_box, zoom_level,
--
1.7.4.1
- [Maposmatic-dev] Implementation of a multi-page renderer, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 01/22] Initial version of a multi-page renderer, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 03/22] multi-page: add a shape file that greys out the overlayed area between pages, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 06/22] multi-page: add grid and grid labels, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 05/22] multi-page: differentiate overlap margin and grayed margin, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 04/22] multi-page: show page number at the bottom of each page, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 07/22] indexlib: add page_number to IndexItem, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 02/22] coords: add BoundingBox::as_javascript() method, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 08/22] indexlib: do not raise exception when index is empty, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 09/22] indexlib: villages section is not of street type, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 10/22] renderers: pass the db connection to the Renderer class constructor,
Thomas Petazzoni <=
- [Maposmatic-dev] [PATCH 12/22] indexlib: render page number as part of the street/amenity location, Thomas Petazzoni, 2012/03/30
- [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