Skip to content

Commit

Permalink
better logging of toc length calculation (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschaer committed Aug 30, 2024
1 parent 90affa3 commit 6bb3c87
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pyramid_oereb/contrib/print_proxy/mapfish_print/toc_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def compute_d1(self):
# The ConcernedTheme-Heading cannot be calculated at runtime. The used label
# is defined in the mfp-templates which are not accessible here. Therefore
# we assume one line without a line break.
log.debug(f"d1 total_size: {self.d1_height}")
return self.d1_height

def compute_d2(self):
Expand All @@ -34,6 +35,7 @@ def compute_d2(self):
total_size += blank_space_above + page_label_height
toc_item_height = 17 # toc.jrxml (20 in tocConcernedTheme.jrxml)
total_size += len(self.extract['ConcernedTheme']) * toc_item_height
log.debug(f"d2 total_size: {total_size}")
if total_size > self.d2_height:
return total_size
else:
Expand All @@ -47,7 +49,7 @@ def compute_d3(self):
not_concerned_themes_item_height = 15 # toc.jrxml (12 in themelist.jrxml)
total_size += blank_space_above + not_concerned_themes_title_height + blank_space_between
total_size += len(self.extract['NotConcernedTheme']) * not_concerned_themes_item_height

log.debug(f"d3 total_size: {total_size}")
if total_size > self.d3_height:
return total_size
else:
Expand All @@ -57,12 +59,14 @@ def compute_d4(self):
# The NoDataTheme-Heading cannot be calculated at runtime. The used label
# is defined in the mfp-templates which are not accessible here. Therefore
# we assume one line without a line break.
log.debug(f"d4 total_size: {self.d4_height}")
return self.d4_height

def compute_d5(self):
total_size = 0
theme_without_data_item_height = 15 # toc.jrxml (12 in themelist.jrxml)
total_size += len(self.extract['ThemeWithoutData'] * theme_without_data_item_height)
log.debug(f"d5 total_size: {total_size}")
if total_size > self.d5_height:
return total_size
else:
Expand Down Expand Up @@ -131,6 +135,7 @@ def compute_d6_right(self):

def compute_d6(self):
total_size = max(self.compute_d6_left(), self.compute_d6_right())
log.debug(f"d6 total_size: {total_size}")
if total_size > self.d6_height:
return total_size
else:
Expand All @@ -144,7 +149,10 @@ def compute_total_lenght(self):
self.compute_d5() + \
self.compute_d6()
log.debug('TOC total page length : {}'.format(x))
log.debug(f"disposable height: {self.disposable_height}")
return x

def getNbPages(self):
return -(-self.total_length // self.disposable_height) # ceil number of pages needed
number_of_pages = -(-self.total_length // self.disposable_height) # ceil number of pages needed
log.debug(f"number of pages: {number_of_pages}")
return number_of_pages

0 comments on commit 6bb3c87

Please sign in to comment.