From 1869b9c5fda88eb18841bab8649acbf497b77141 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 31 Mar 2012 19:22:30 +0200 Subject: [PATCH] renderers: add a get_compatible_output_formats() method The single page renderers can output PNG, SVGZ, PDF and CSV, but by design, the multi page renderer can only output PDF and CSV. So we introduce a get_compatible_output_formats() in the renderer class so that users of OcitySMap2 can find out which formats are possible depending on the choosen layout. Signed-off-by: Thomas Petazzoni --- ocitysmap2/layoutlib/abstract_renderer.py | 4 ++++ ocitysmap2/layoutlib/multi_page_renderer.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ocitysmap2/layoutlib/abstract_renderer.py b/ocitysmap2/layoutlib/abstract_renderer.py index 5da2fde..11aed7d 100644 --- a/ocitysmap2/layoutlib/abstract_renderer.py +++ b/ocitysmap2/layoutlib/abstract_renderer.py @@ -295,6 +295,10 @@ class Renderer: """ raise NotImplementedError + @staticmethod + def get_compatible_output_formats(): + return [ "png", "svgz", "pdf", "csv" ] + @staticmethod def get_compatible_paper_sizes(bounding_box, zoom_level, resolution_km_in_mm): diff --git a/ocitysmap2/layoutlib/multi_page_renderer.py b/ocitysmap2/layoutlib/multi_page_renderer.py index 1acab3b..a27b6f3 100644 --- a/ocitysmap2/layoutlib/multi_page_renderer.py +++ b/ocitysmap2/layoutlib/multi_page_renderer.py @@ -664,6 +664,11 @@ class MultiPageRenderer(Renderer): def _paper_pt_to_geo_m(self, paper_pt): return self._paper_mm_to_geo_m(commons.convert_pt_to_mm(paper_pt)) + # In multi-page mode, we only render pdf and csv formats + @staticmethod + def get_compatible_output_formats(): + return [ "pdf", "csv" ] + # In multi-page mode, we only accept A4, A5 and US letter as paper # sizes. The goal is to render booklets, not posters. @staticmethod