# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import cairo import math import pango import pangocairo import draw_utils import ocitysmap.layoutlib.commons as UTILS from ocitysmap.layoutlib.abstract_renderer import Renderer # FIXME: refactoring # We use the same 10mm as GRAYED_MARGIN_MM in the map multi-page renderer PAGE_NUMBER_MARGIN_PT = UTILS.convert_mm_to_pt(10) class MultiPageStreetIndexRenderer: """ The MultiPageStreetIndexRenderer class encapsulates all the logic related to the rendering of the street index on multiple pages """ # ctx: Cairo context # surface: Cairo surface def __init__(self, i18n, ctx, surface, index_categories, rendering_area, page_number): self._i18n = i18n self.ctx = ctx self.surface = surface self.index_categories = index_categories
def __init__(self): # self.path = '/home/sam/src/python/maposmatic/mapnik-osm/osm.xml' self.path = '/mnt/data1/common/home/d2/Downloads/svn/mapnik-osm/osm.xml' self.grid_line_color = 'black' self.grid_line_alpha = 0.9 self.grid_line_width = 2 self.shade_color = 'black' self.shade_alpha = 0.7 class RenderingConfigurationMock: def __init__(self): self.stylesheet = StylesheetMock() self.bounding_box = bbox self.paper_width_mm = papers[0][1] self.paper_height_mm = papers[0][2] self.i18n = i18n.i18n() self.title = 'Au Kremlin-Bycêtre' self.polygon_wkt = bbox.as_wkt() config = RenderingConfigurationMock() plain = renderer_cls(config, '/tmp', None) surface = cairo.PDFSurface('/tmp/plain.pdf', commons.convert_mm_to_pt(config.paper_width_mm), commons.convert_mm_to_pt(config.paper_height_mm)) plain.render(surface, commons.PT_PER_INCH) surface.finish() print("Generated /tmp/plain.pdf")
# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import cairo import math import pango import pangocairo import draw_utils import ocitysmap.layoutlib.commons as UTILS from ocitysmap.layoutlib.abstract_renderer import Renderer # FIXME: refactoring # We use the same 10mm as GRAYED_MARGIN_MM in the map multi-page renderer PAGE_NUMBER_MARGIN_PT = UTILS.convert_mm_to_pt(10) class MultiPageStreetIndexRenderer: """ The MultiPageStreetIndexRenderer class encapsulates all the logic related to the rendering of the street index on multiple pages """ # ctx: Cairo context # surface: Cairo surface def __init__(self, i18n, ctx, surface, index_categories, rendering_area, page_number): self._i18n = i18n self.ctx = ctx self.surface = surface
raise commons.IndexDoesNotFitError return int(n_cols), min_required_width raise ValueError, 'Invalid freedom direction!' if __name__ == '__main__': import random import string import commons logging.basicConfig(level=logging.DEBUG) width = UTILS.convert_mm_to_pt(210) height = UTILS.convert_mm_to_pt(294) random.seed(42) bbox = ocitysmap.coords.BoundingBox(48.8162, 2.3417, 48.8063, 2.3699) surface = cairo.PDFSurface('/tmp/myindex_render.pdf', width, height) def rnd_str(max_len, letters = string.letters): return ''.join(random.choice(letters) for i in xrange(random.randint(1, max_len))) class i18nMock: def __init__(self, rtl): self.rtl = rtl