[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 03/22] multi-page: add a shape file that greys o
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 03/22] multi-page: add a shape file that greys out the overlayed area between pages |
Date: |
Fri, 30 Mar 2012 13:00:20 +0200 |
Signed-off-by: Thomas Petazzoni <address@hidden>
---
ocitysmap2/layoutlib/multi_page_renderer.py | 47 +++++++++++++++-----------
1 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/ocitysmap2/layoutlib/multi_page_renderer.py
b/ocitysmap2/layoutlib/multi_page_renderer.py
index e1c1f24..59aa001 100644
--- a/ocitysmap2/layoutlib/multi_page_renderer.py
+++ b/ocitysmap2/layoutlib/multi_page_renderer.py
@@ -37,6 +37,8 @@ from ocitysmap2.maplib.map_canvas import MapCanvas
import ocitysmap2
import commons
+import shapely.wkt
+from ocitysmap2 import maplib
LOG = logging.getLogger('ocitysmap')
PAGE_STR = " - Page %(page_number)d"
@@ -68,13 +70,9 @@ class MultiPageRenderer(Renderer):
(2 * Renderer.PRINT_SAFE_MARGIN_PT))
scale_denom = 10000
- OUTTER_MARGIN_MM = 20
+ OUTTER_MARGIN_MM = 10
- print 'BoundingBox(%f,%f,%f,%f,"original", {color: "#00ff00"})' % \
- (self.rc.bounding_box.get_top_left()[0],
- self.rc.bounding_box.get_top_left()[1],
- self.rc.bounding_box.get_bottom_right()[0],
- self.rc.bounding_box.get_bottom_right()[1])
+ print self.rc.bounding_box.as_javascript("original", "#00ff00")
# Convert the original Bounding box into Mercator meters
self._proj = mapnik.Projection(_MAPNIK_PROJECTION)
@@ -139,11 +137,7 @@ class MultiPageRenderer(Renderer):
envelope = mapnik.Box2d(off_x, off_y, off_x + width, off_y + height)
self._geo_bbox = self._inverse_envelope(envelope)
- print 'BoundingBox(%f,%f,%f,%f,"extended", {color: "#0f0f0f"})' % \
- (self._geo_bbox.get_top_left()[0],
- self._geo_bbox.get_top_left()[1],
- self._geo_bbox.get_bottom_right()[0],
- self._geo_bbox.get_bottom_right()[1])
+ print self._geo_bbox.as_javascript("extended", "#0f0f0f")
# Convert the usable area on each sheet of paper into the
# amount of Mercator meters we can render in this area.
@@ -162,24 +156,37 @@ class MultiPageRenderer(Renderer):
envelope = mapnik.Box2d(cur_x, cur_y,
cur_x+usable_area_merc_m_width,
cur_y+usable_area_merc_m_height)
- bboxes.append(self._inverse_envelope(envelope))
- for i, bb in enumerate(bboxes):
- print 'BoundingBox(%f,%f,%f,%f,"p%d")' % \
- (bb.get_top_left()[0],
- bb.get_top_left()[1],
- bb.get_bottom_right()[0],
- bb.get_bottom_right()[1], i)
+ envelope_inner = mapnik.Box2d(cur_x + outter_margin_merc_m,
+ cur_y + outter_margin_merc_m,
+ cur_x + usable_area_merc_m_width
- outter_margin_merc_m,
+ cur_y +
usable_area_merc_m_height - outter_margin_merc_m)
+
+ bboxes.append((self._inverse_envelope(envelope),
+ self._inverse_envelope(envelope_inner)))
+
+ for i, (bb, bb_inner) in enumerate(bboxes):
+ print bb.as_javascript(name="p%d" % i)
# Create the map canvas for each page
self.canvas = []
print "List of all bboxes"
- for bb in bboxes:
- print bb
+ for i, (bb, bb_inner) in enumerate(bboxes):
+ exterior = shapely.wkt.loads(bb.as_wkt())
+ print bb.as_javascript("before-%d" % i, "#ff0000")
+ print bb_inner.as_javascript("after-%d" % i, "#00ff00")
+ interior = shapely.wkt.loads(bb_inner.as_wkt())
+ shade_wkt = exterior.difference(interior).wkt
+ shade = maplib.shapes.PolyShapeFile(
+ bb, os.path.join(self.tmpdir, 'shape%d.shp' % i),
+ 'shade%d' % i)
+ shade.add_shade_from_wkt(shade_wkt)
+
# Create one canvas for each page
map_canvas = MapCanvas(self.rc.stylesheet,
bb, graphical_ratio=None)
+ map_canvas.add_shape_file(shade)
map_canvas.render()
self.canvas.append(map_canvas)
--
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 <=
- [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, 2012/03/30
- [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