Skip to content

Commit

Permalink
first draft of new toc parameters implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
voisardf committed Aug 27, 2024
1 parent f50347b commit 69e23c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions dev/config/pyramid_oereb.yml.mako
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ pyramid_oereb:
# more time to generate the PDF. If set to false, it will assume that only one TOC page exists, and this can
# lead to wrong numbering in the TOC.
compute_toc_pages: true
# To avoid the potentially time consuming computing of the estimated toc pages number and its verification
# you can specify a default length for the number of TOC pages. - For most of the cantons the length of the
# TOC is pretty consistent unless a real estate is concerned by none or a huge number of restrictions.
# An additional page break might also occur if the number of published topics is close to a threshold number.
# So be aware that fixing this value and deactivating the compute_toc_pages above may lead to wrong page numbers
# in the table of content.
default_toc_length: 2
# Depending on your toc configuration and number of disclaimer entries, the first page break of the table of content
# may appear when a real estate is concerned by one, two or more topics.
concerned_themes_for_first_toc_pagebreak: 3
# Specify any additional URL parameters that the print shall use for WMS calls
wms_url_params:
TRANSPARENT: 'true'
Expand Down
6 changes: 6 additions & 0 deletions doc/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Changes/Hints for migration
This chapter will give you hints on how to handle version migration, in particular regarding what you may need
to adapt in your project configuration, database etc. when upgrading to a new version.

Version 2.6.0
-------------
* New parameter 'default_toc_length' allows to define a expected table of content pages number avoiding the extra
computation of the expected length. This value should only be set if >95% of the PDF have the same number of TOC pages.
Default setting: 1

Version 2.5.2
-------------
Feature and maintenance release:
Expand Down
12 changes: 9 additions & 3 deletions pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,23 @@ def __call__(self, value, system):
extract_as_dict = self._render(extract_record, value[1])
feature_geometry = mapping(extract_record.real_estate.limit)

print_config = Config.get('print', {})

if Config.get('print', {}).get('compute_toc_pages', False):
extract_as_dict['nbTocPages'] = TocPages(extract_as_dict).getNbPages()
else:
extract_as_dict['nbTocPages'] = 1
if print_config.get('default_toc_length', 1):
if len(extract_as_dict['ConcernedTheme']) < print_config.get('concerned_themes_for_first_toc_pagebreak', 2):
extract_as_dict['nbTocPages'] = 1
else:
extract_as_dict['nbTocPages'] = print_config.get('default_toc_length', 1)
else:
extract_as_dict['nbTocPages'] = 1

# set the global_datetime variable so that it can be used later for the archive
self.set_global_datetime(extract_as_dict['CreationDate'])
self.convert_to_printable_extract(extract_as_dict, feature_geometry)

print_config = Config.get('print', {})

extract_as_dict['Display_RealEstate_SubunitOfLandRegister'] = print_config.get(
'display_real_estate_subunit_of_land_register', True
)
Expand Down

0 comments on commit 69e23c4

Please sign in to comment.