From 69e23c46b546cfc3e7845be890396bc5a5620b1e Mon Sep 17 00:00:00 2001 From: voisardf Date: Tue, 27 Aug 2024 16:49:00 +0200 Subject: [PATCH 01/35] first draft of new toc parameters implementation --- dev/config/pyramid_oereb.yml.mako | 10 ++++++++++ doc/source/changes.rst | 6 ++++++ .../print_proxy/mapfish_print/mapfish_print.py | 12 +++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dev/config/pyramid_oereb.yml.mako b/dev/config/pyramid_oereb.yml.mako index 94c1228c16..95a0d75825 100644 --- a/dev/config/pyramid_oereb.yml.mako +++ b/dev/config/pyramid_oereb.yml.mako @@ -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' diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 9eb919fbee..3e6a3057d8 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -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: diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index 06c9f31591..2668372d38 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -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 ) From 3b55d99efb3fc73bc8543104cb45718021ed44fe Mon Sep 17 00:00:00 2001 From: voisardf Date: Wed, 28 Aug 2024 17:11:06 +0200 Subject: [PATCH 02/35] Refactured the process and added more logging --- dev/config/pyramid_oereb.yml.mako | 3 -- doc/source/changes.rst | 7 ++-- .../mapfish_print/mapfish_print.py | 38 ++++++++++++++++--- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/dev/config/pyramid_oereb.yml.mako b/dev/config/pyramid_oereb.yml.mako index 95a0d75825..0cc3d97a6b 100644 --- a/dev/config/pyramid_oereb.yml.mako +++ b/dev/config/pyramid_oereb.yml.mako @@ -95,9 +95,6 @@ pyramid_oereb: # 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' diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 3e6a3057d8..e82036c99d 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -8,9 +8,10 @@ to adapt in your project configuration, database etc. when upgrading to a new ve 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 +* New parameter 'default_toc_length' allows to define a default table of content pages number avoiding a second +call for the pdf extract in most cases. This value should be set if >95% of the PDF have the same number of TOC +pages. +Default setting: 2 Version 2.5.2 ------------- diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index 2668372d38..b1dd94fa3d 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -78,11 +78,8 @@ def __call__(self, value, system): if Config.get('print', {}).get('compute_toc_pages', False): extract_as_dict['nbTocPages'] = TocPages(extract_as_dict).getNbPages() else: - 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) + if Config.get('print', {}).get('default_toc_length', False): + extract_as_dict['nbTocPages'] = print_config.get('default_toc_length', 2) else: extract_as_dict['nbTocPages'] = 1 @@ -122,6 +119,8 @@ def __call__(self, value, system): data=json.dumps(spec) ) try: + log.debug('Validation of the TOC length with compute_toc_pages set to {} and default_toc_length set to {}'.format( \ + print_config.get('compute_toc_pages'),print_config.get('default_toc_length'))) if Config.get('print', {}).get('compute_toc_pages', False): with io.BytesIO() as pdf: pdf.write(print_result.content) @@ -137,14 +136,43 @@ def __call__(self, value, system): except ValueError: true_nb_of_toc = 1 + log.debug('True number of TOC pages is {}'.format(true_nb_of_toc)) + if true_nb_of_toc != extract_as_dict['nbTocPages']: + log.warning('nbTocPages in result pdf: {} are not equal to the one predicted : {}, request new pdf'.format(true_nb_of_toc,extract_as_dict['nbTocPages'])) # noqa + log.debug('Secondary PDF extract call STARTED') + extract_as_dict['nbTocPages'] = true_nb_of_toc + print_result = requests.post( + pdf_url, + headers=pdf_headers, + data=json.dumps(spec) + ) + log.debug('Secondary PDF extract call to fix TOC pages number FINISHED') + elif Config.get('print', {}).get('default_toc_length', 2): + with io.BytesIO() as pdf: + pdf.write(print_result.content) + pdf_reader = PdfReader(pdf) + x = [] + for i in range(len(pdf_reader.outline)): + if isinstance(pdf_reader.outline[i], list): + x.append(pdf_reader.outline[i][0]['/Page']['/StructParents']) + else: + x.append(pdf_reader.outline[i]['/Page']['/StructParents']) + try: + true_nb_of_toc = min(x)-1 + except ValueError: + true_nb_of_toc = 1 + + log.debug('True number of TOC pages is {}'.format(true_nb_of_toc)) if true_nb_of_toc != extract_as_dict['nbTocPages']: log.warning('nbTocPages in result pdf: {} are not equal to the one predicted : {}, request new pdf'.format(true_nb_of_toc,extract_as_dict['nbTocPages'])) # noqa extract_as_dict['nbTocPages'] = true_nb_of_toc + log.debug('Secondary PDF extract call STARTED') print_result = requests.post( pdf_url, headers=pdf_headers, data=json.dumps(spec) ) + log.debug('Secondary PDF extract call FINISHED') except PdfReadError as e: err_msg = 'a problem occurred while generating the pdf file' log.error(err_msg + ': ' + str(e)) From d8c72dbcb3d480084b048e30b4a493b10fbe03e5 Mon Sep 17 00:00:00 2001 From: voisardf Date: Wed, 28 Aug 2024 17:26:31 +0200 Subject: [PATCH 03/35] added linting comments --- .../contrib/print_proxy/mapfish_print/mapfish_print.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index b1dd94fa3d..a34f986cfb 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -119,8 +119,7 @@ def __call__(self, value, system): data=json.dumps(spec) ) try: - log.debug('Validation of the TOC length with compute_toc_pages set to {} and default_toc_length set to {}'.format( \ - print_config.get('compute_toc_pages'),print_config.get('default_toc_length'))) + log.debug('Validation of the TOC length with compute_toc_pages set to {} and default_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('default_toc_length'))) # noqa if Config.get('print', {}).get('compute_toc_pages', False): with io.BytesIO() as pdf: pdf.write(print_result.content) From 7296571201a87af99d308a02e0bd5d9b2e2206ee Mon Sep 17 00:00:00 2001 From: voisardf Date: Thu, 29 Aug 2024 11:46:02 +0200 Subject: [PATCH 04/35] added two config tests --- .../resources/test_config.yml | 2 ++ .../test_mapfish_print_configuration.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml index 3b1dd144ee..4776cc2245 100644 --- a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml +++ b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml @@ -4,6 +4,8 @@ pyramid_oereb: wms_url_params: TRANSPARENT: 'true' OTHERCUSTOM: 'myvalue' + compute_toc_pages: false + default_toc_length: 2 theme: source: diff --git a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py index a2ff8d4aae..d03f26f08d 100644 --- a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py +++ b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py @@ -100,3 +100,14 @@ def test_default_wms_url_param_config(DummyRenderInfo): config = renderer.get_wms_url_params() # Do the check for this test. Value should be the default setting. assert config == {'TRANSPARENT': 'true'} + + +def test_toc_pages_default_config(): + Config._config = None + Config.init('./tests/contrib.print_proxy.mapfish_print/resources/test_config.yml', 'pyramid_oereb') + compute_toc_pages = Config.get('print', {}).get('compute_toc_pages') + default_toc_length = Config.get('print', {}).get('default_toc_length') + + assert compute_toc_pages == False + assert default_toc_length == 2 + From 087b45d5836de7b128f177972a2dd18b2b972398 Mon Sep 17 00:00:00 2001 From: voisardf Date: Thu, 29 Aug 2024 12:12:20 +0200 Subject: [PATCH 05/35] fixed some test and linting --- .../test_mapfish_print_configuration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py index d03f26f08d..06146040fa 100644 --- a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py +++ b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py @@ -108,6 +108,6 @@ def test_toc_pages_default_config(): compute_toc_pages = Config.get('print', {}).get('compute_toc_pages') default_toc_length = Config.get('print', {}).get('default_toc_length') - assert compute_toc_pages == False + assert isinstance(compute_toc_pages,bool) + assert bool(compute_toc_pages) == False assert default_toc_length == 2 - From c4b9261f8cecf9e30ed502afe5ef303a8d9e279a Mon Sep 17 00:00:00 2001 From: voisardf Date: Thu, 29 Aug 2024 12:16:07 +0200 Subject: [PATCH 06/35] more linting, sorry --- .../test_mapfish_print_configuration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py index 06146040fa..f19e8268e8 100644 --- a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py +++ b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py @@ -108,6 +108,6 @@ def test_toc_pages_default_config(): compute_toc_pages = Config.get('print', {}).get('compute_toc_pages') default_toc_length = Config.get('print', {}).get('default_toc_length') - assert isinstance(compute_toc_pages,bool) - assert bool(compute_toc_pages) == False + assert isinstance(compute_toc_pages, bool) + assert bool(compute_toc_pages) is False assert default_toc_length == 2 From a5157d012d09fad58e4d28d2e26e2e9c698d337c Mon Sep 17 00:00:00 2001 From: voisardf Date: Thu, 29 Aug 2024 16:35:56 +0200 Subject: [PATCH 07/35] improved code as discussed and suggested --- dev/config/pyramid_oereb.yml.mako | 25 +++-- doc/source/changes.rst | 6 +- .../mapfish_print/mapfish_print.py | 92 +++++++------------ .../resources/test_config.yml | 2 +- .../test_mapfish_print_configuration.py | 4 +- 5 files changed, 51 insertions(+), 78 deletions(-) diff --git a/dev/config/pyramid_oereb.yml.mako b/dev/config/pyramid_oereb.yml.mako index 335fd302c6..991f220fd4 100644 --- a/dev/config/pyramid_oereb.yml.mako +++ b/dev/config/pyramid_oereb.yml.mako @@ -85,19 +85,18 @@ pyramid_oereb: # Will make an estimation of the total length of the Table of Content (TOC) and control that the page # numbering in the output pdf is consistent with TOC numbering. If it is known that the TOC is very long and # could run over more than one page, it is preferred to set this to true. The drawback is that it might need - # 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 second computing of the PDF extract and skip the the computation - # of the estimated TOC length, 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 - # where the TOC fits just about on one or two pages. - for those case estimate the TOC length ist preferable. - # In both cases (computing an estimated length or setting a default length) the exact number of TOC pages is - # extracted from the created PDF and if it is different from the expected value the PDF extract is called a - # second time with the correct page numbers. - default_toc_length: 2 + # more time to generate the PDF. If set to false, the general_toc_length setting below will be used. If it is + # not set it will assume that only one TOC page exists, and this can lead to wrong numbering in the TOC, which + # will be fixed by a second PDF extract call that has an impact on performance. + compute_toc_pages: false + # In order to skip the computation of the estimated number of TOC pages which might return an erroneous result + # for your setting, you can specify a default for the number of TOC pages. For most of the cantons the number of + # TOC pages is pretty constant unless a real estate is concerned by none or a huge number of restrictions. + # In both cases (computing an estimate or setting a default for the number of TOC pages) the exact number of TOC + # pages is extracted from the created PDF and if it differs from the expected value the PDF is created a second + # time with the correct page numbers. + # Note that if "compute_toc_pages" is set true the "general_toc_length" is not taken into account. + general_toc_length: 2 # Specify any additional URL parameters that the print shall use for WMS calls wms_url_params: TRANSPARENT: 'true' diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 70e651fd30..af31a10664 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -8,9 +8,9 @@ to adapt in your project configuration, database etc. when upgrading to a new ve Version 2.6.0 ------------- -* New parameter 'default_toc_length' allows to define a default table of content pages number avoiding a second -call for the pdf extract in most cases. This value should be set if >95% of the PDF have the same number of TOC -pages. +* New parameter 'general_toc_length' allows to define a default table of content pages number avoiding a second +call for the pdf extract in most cases. This value should be set if most of the PDF extracts have the same number +of TOC pages. Default setting: 2 Version 2.5.3 diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index a34f986cfb..61491862d0 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -75,11 +75,11 @@ def __call__(self, value, system): print_config = Config.get('print', {}) - if Config.get('print', {}).get('compute_toc_pages', False): + if print_config.get('compute_toc_pages', False): extract_as_dict['nbTocPages'] = TocPages(extract_as_dict).getNbPages() else: - if Config.get('print', {}).get('default_toc_length', False): - extract_as_dict['nbTocPages'] = print_config.get('default_toc_length', 2) + if print_config.get('general_toc_length') and int(print_config.get('general_toc_length')) > 0: + extract_as_dict['nbTocPages'] = print_config.get('general_toc_length', 2) else: extract_as_dict['nbTocPages'] = 1 @@ -100,7 +100,7 @@ def __call__(self, value, system): ) spec = { - 'layout': Config.get('print', {})['template_name'], + 'layout': print_config['template_name'], 'outputFormat': 'pdf', 'lang': self._language, 'attributes': extract_as_dict, @@ -111,67 +111,41 @@ def __call__(self, value, system): if self._request.GET.get('getspec', 'no') != 'no': response.headers['Content-Type'] = 'application/json; charset=UTF-8' return json.dumps(spec, sort_keys=True, indent=4) - pdf_url = urlparse.urljoin(Config.get('print', {})['base_url'] + '/', 'buildreport.pdf') - pdf_headers = Config.get('print', {})['headers'] + pdf_url = urlparse.urljoin(print_config['base_url'] + '/', 'buildreport.pdf') + pdf_headers = print_config['headers'] print_result = requests.post( pdf_url, headers=pdf_headers, data=json.dumps(spec) ) try: - log.debug('Validation of the TOC length with compute_toc_pages set to {} and default_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('default_toc_length'))) # noqa - if Config.get('print', {}).get('compute_toc_pages', False): - with io.BytesIO() as pdf: - pdf.write(print_result.content) - pdf_reader = PdfReader(pdf) - x = [] - for i in range(len(pdf_reader.outline)): - if isinstance(pdf_reader.outline[i], list): - x.append(pdf_reader.outline[i][0]['/Page']['/StructParents']) - else: - x.append(pdf_reader.outline[i]['/Page']['/StructParents']) - try: - true_nb_of_toc = min(x)-1 - except ValueError: - true_nb_of_toc = 1 - - log.debug('True number of TOC pages is {}'.format(true_nb_of_toc)) - if true_nb_of_toc != extract_as_dict['nbTocPages']: - log.warning('nbTocPages in result pdf: {} are not equal to the one predicted : {}, request new pdf'.format(true_nb_of_toc,extract_as_dict['nbTocPages'])) # noqa - log.debug('Secondary PDF extract call STARTED') - extract_as_dict['nbTocPages'] = true_nb_of_toc - print_result = requests.post( - pdf_url, - headers=pdf_headers, - data=json.dumps(spec) - ) - log.debug('Secondary PDF extract call to fix TOC pages number FINISHED') - elif Config.get('print', {}).get('default_toc_length', 2): - with io.BytesIO() as pdf: - pdf.write(print_result.content) - pdf_reader = PdfReader(pdf) - x = [] - for i in range(len(pdf_reader.outline)): - if isinstance(pdf_reader.outline[i], list): - x.append(pdf_reader.outline[i][0]['/Page']['/StructParents']) - else: - x.append(pdf_reader.outline[i]['/Page']['/StructParents']) - try: - true_nb_of_toc = min(x)-1 - except ValueError: - true_nb_of_toc = 1 - - log.debug('True number of TOC pages is {}'.format(true_nb_of_toc)) - if true_nb_of_toc != extract_as_dict['nbTocPages']: - log.warning('nbTocPages in result pdf: {} are not equal to the one predicted : {}, request new pdf'.format(true_nb_of_toc,extract_as_dict['nbTocPages'])) # noqa - extract_as_dict['nbTocPages'] = true_nb_of_toc - log.debug('Secondary PDF extract call STARTED') - print_result = requests.post( - pdf_url, - headers=pdf_headers, - data=json.dumps(spec) - ) - log.debug('Secondary PDF extract call FINISHED') + log.debug('Validation of the TOC length with compute_toc_pages set to {} and general_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('general_toc_length'))) # noqa + with io.BytesIO() as pdf: + pdf.write(print_result.content) + pdf_reader = PdfReader(pdf) + x = [] + for i in range(len(pdf_reader.outline)): + if isinstance(pdf_reader.outline[i], list): + x.append(pdf_reader.outline[i][0]['/Page']['/StructParents']) + else: + x.append(pdf_reader.outline[i]['/Page']['/StructParents']) + try: + true_nb_of_toc = min(x)-1 + except ValueError: + true_nb_of_toc = 1 + + log.debug('True number of TOC pages is {}, expected number was {}'.format(true_nb_of_toc, extract_as_dict['nbTocPages'])) #noqa + if true_nb_of_toc != extract_as_dict['nbTocPages']: + log.warning('nbTocPages in result pdf: {} are not equal to the one predicted : {}, request new pdf'.format(true_nb_of_toc,extract_as_dict['nbTocPages'])) # noqa + log.debug('Secondary PDF extract call STARTED') + extract_as_dict['nbTocPages'] = true_nb_of_toc + print_result = requests.post( + pdf_url, + headers=pdf_headers, + data=json.dumps(spec) + ) + log.debug('Secondary PDF extract call to fix TOC pages number DONE') + except PdfReadError as e: err_msg = 'a problem occurred while generating the pdf file' log.error(err_msg + ': ' + str(e)) diff --git a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml index 4776cc2245..6189143f97 100644 --- a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml +++ b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml @@ -5,7 +5,7 @@ pyramid_oereb: TRANSPARENT: 'true' OTHERCUSTOM: 'myvalue' compute_toc_pages: false - default_toc_length: 2 + general_toc_length: 2 theme: source: diff --git a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py index f19e8268e8..cab5ea78c3 100644 --- a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py +++ b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py @@ -106,8 +106,8 @@ def test_toc_pages_default_config(): Config._config = None Config.init('./tests/contrib.print_proxy.mapfish_print/resources/test_config.yml', 'pyramid_oereb') compute_toc_pages = Config.get('print', {}).get('compute_toc_pages') - default_toc_length = Config.get('print', {}).get('default_toc_length') + general_toc_length = Config.get('print', {}).get('general_toc_length') assert isinstance(compute_toc_pages, bool) assert bool(compute_toc_pages) is False - assert default_toc_length == 2 + assert general_toc_length == 2 From 77f6db111c1fa61955531e94fe14e7e0010fe09e Mon Sep 17 00:00:00 2001 From: voisardf Date: Thu, 29 Aug 2024 17:15:52 +0200 Subject: [PATCH 08/35] typo with lint --- .../contrib/print_proxy/mapfish_print/mapfish_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index 61491862d0..64b3c9458f 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -134,7 +134,7 @@ def __call__(self, value, system): except ValueError: true_nb_of_toc = 1 - log.debug('True number of TOC pages is {}, expected number was {}'.format(true_nb_of_toc, extract_as_dict['nbTocPages'])) #noqa + log.debug('True number of TOC pages is {}, expected number was {}'.format(true_nb_of_toc, extract_as_dict['nbTocPages'])) # noqa if true_nb_of_toc != extract_as_dict['nbTocPages']: log.warning('nbTocPages in result pdf: {} are not equal to the one predicted : {}, request new pdf'.format(true_nb_of_toc,extract_as_dict['nbTocPages'])) # noqa log.debug('Secondary PDF extract call STARTED') From a5f42fac29b3c52819a1da07aa6e9e94f247a9a0 Mon Sep 17 00:00:00 2001 From: voisardf Date: Fri, 30 Aug 2024 10:32:14 +0200 Subject: [PATCH 09/35] renamed parameter as requested --- dev/config/pyramid_oereb.yml.mako | 6 +++--- doc/source/changes.rst | 2 +- .../contrib/print_proxy/mapfish_print/mapfish_print.py | 6 +++--- .../resources/test_config.yml | 2 +- .../test_mapfish_print_configuration.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/config/pyramid_oereb.yml.mako b/dev/config/pyramid_oereb.yml.mako index 991f220fd4..079a06f913 100644 --- a/dev/config/pyramid_oereb.yml.mako +++ b/dev/config/pyramid_oereb.yml.mako @@ -85,7 +85,7 @@ pyramid_oereb: # Will make an estimation of the total length of the Table of Content (TOC) and control that the page # numbering in the output pdf is consistent with TOC numbering. If it is known that the TOC is very long and # could run over more than one page, it is preferred to set this to true. The drawback is that it might need - # more time to generate the PDF. If set to false, the general_toc_length setting below will be used. If it is + # more time to generate the PDF. If set to false, the expected_toc_length setting below will be used. If it is # not set it will assume that only one TOC page exists, and this can lead to wrong numbering in the TOC, which # will be fixed by a second PDF extract call that has an impact on performance. compute_toc_pages: false @@ -95,8 +95,8 @@ pyramid_oereb: # In both cases (computing an estimate or setting a default for the number of TOC pages) the exact number of TOC # pages is extracted from the created PDF and if it differs from the expected value the PDF is created a second # time with the correct page numbers. - # Note that if "compute_toc_pages" is set true the "general_toc_length" is not taken into account. - general_toc_length: 2 + # Note that if "compute_toc_pages" is set true the "expected_toc_length" is not taken into account. + expected_toc_length: 2 # Specify any additional URL parameters that the print shall use for WMS calls wms_url_params: TRANSPARENT: 'true' diff --git a/doc/source/changes.rst b/doc/source/changes.rst index af31a10664..df897b75d8 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -8,7 +8,7 @@ to adapt in your project configuration, database etc. when upgrading to a new ve Version 2.6.0 ------------- -* New parameter 'general_toc_length' allows to define a default table of content pages number avoiding a second +* New parameter 'expected_toc_length' allows to define a default table of content pages number avoiding a second call for the pdf extract in most cases. This value should be set if most of the PDF extracts have the same number of TOC pages. Default setting: 2 diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index 64b3c9458f..62dee7749e 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -78,8 +78,8 @@ def __call__(self, value, system): if print_config.get('compute_toc_pages', False): extract_as_dict['nbTocPages'] = TocPages(extract_as_dict).getNbPages() else: - if print_config.get('general_toc_length') and int(print_config.get('general_toc_length')) > 0: - extract_as_dict['nbTocPages'] = print_config.get('general_toc_length', 2) + if print_config.get('expected_toc_length') and int(print_config.get('expected_toc_length')) > 0: + extract_as_dict['nbTocPages'] = print_config.get('expected_toc_length') else: extract_as_dict['nbTocPages'] = 1 @@ -119,7 +119,7 @@ def __call__(self, value, system): data=json.dumps(spec) ) try: - log.debug('Validation of the TOC length with compute_toc_pages set to {} and general_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('general_toc_length'))) # noqa + log.debug('Validation of the TOC length with compute_toc_pages set to {} and expected_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('expected_toc_length'))) # noqa with io.BytesIO() as pdf: pdf.write(print_result.content) pdf_reader = PdfReader(pdf) diff --git a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml index 6189143f97..027758c227 100644 --- a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml +++ b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml @@ -5,7 +5,7 @@ pyramid_oereb: TRANSPARENT: 'true' OTHERCUSTOM: 'myvalue' compute_toc_pages: false - general_toc_length: 2 + expected_toc_length: 2 theme: source: diff --git a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py index cab5ea78c3..9066a8050b 100644 --- a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py +++ b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py @@ -106,8 +106,8 @@ def test_toc_pages_default_config(): Config._config = None Config.init('./tests/contrib.print_proxy.mapfish_print/resources/test_config.yml', 'pyramid_oereb') compute_toc_pages = Config.get('print', {}).get('compute_toc_pages') - general_toc_length = Config.get('print', {}).get('general_toc_length') + expected_toc_length = Config.get('print', {}).get('expected_toc_length') assert isinstance(compute_toc_pages, bool) assert bool(compute_toc_pages) is False - assert general_toc_length == 2 + assert expected_toc_length == 2 From ea54626afb1693644d5db177ff866ddc5f60361e Mon Sep 17 00:00:00 2001 From: voisardf Date: Mon, 2 Sep 2024 16:41:23 +0200 Subject: [PATCH 10/35] adapted documentation of new parameter --- doc/source/changes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/changes.rst b/doc/source/changes.rst index df897b75d8..cf0c1542ca 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -9,9 +9,9 @@ to adapt in your project configuration, database etc. when upgrading to a new ve Version 2.6.0 ------------- * New parameter 'expected_toc_length' allows to define a default table of content pages number avoiding a second -call for the pdf extract in most cases. This value should be set if most of the PDF extracts have the same number -of TOC pages. -Default setting: 2 +call for the pdf extract in most cases. This value may be be set if most of the PDF extracts have the same number +of TOC pages. It complements the 'compute_toc_pages' parameter. If the latter is set to true 'expected_toc_length' +is ignored. Version 2.5.3 ------------- From 7bf123b09b2d7df8a4b2783720cdd017003fe107 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Sep 2024 16:08:35 +0200 Subject: [PATCH 11/35] handle in function "collect_legend_entries_by_bbox" all law status --- .../data_sources/interlis_2_3/sources/plr.py | 41 +++++++++++------- .../data_sources/standard/sources/plr.py | 43 ++++++++++++------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py index 0306a86b29..b3a5664814 100644 --- a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py @@ -470,7 +470,7 @@ def collect_related_geometries_by_real_estate(self, session, real_estate): .selectinload(self.models.MultilingualUri.localised_uri) ).all() - def collect_legend_entries_by_bbox(self, session, bbox, law_status): + def collect_legend_entries_by_bbox(self, session, bbox): """ Extracts all legend entries in the topic which have spatial relation with the passed bounding box of visible extent. @@ -478,12 +478,11 @@ def collect_legend_entries_by_bbox(self, session, bbox, law_status): Args: session (sqlalchemy.orm.Session): The requested clean session instance ready for use bbox (shapely.geometry.base.BaseGeometry): The bbox to search the records. - law_status (str): String of the law status for which the legend entries should be queried. Returns: list: The result of the related geometries unique by the public law restriction id and law status """ - distinct_legend_entry_ids = [] + # Select the legend entries of all plr within bbox geometries = session.query(self._model_).filter( or_( self._model_.point.ST_Intersects(from_shape(bbox, srid=Config.get('srid'))), @@ -493,13 +492,31 @@ def collect_legend_entries_by_bbox(self, session, bbox, law_status): selectinload(self.models.Geometry.public_law_restriction) ).all() + # Compile a list of unique legend entry ids for each law status + legend_entry_ids = dict() for geometry in geometries: - if geometry.public_law_restriction.legend_entry_id not in distinct_legend_entry_ids\ - and geometry.public_law_restriction.law_status == law_status: - distinct_legend_entry_ids.append(geometry.public_law_restriction.legend_entry_id) + if geometry.public_law_restriction.law_status not in legend_entry_ids.keys(): + legend_entry_ids[geometry.public_law_restriction.law_status] = { + geometry.public_law_restriction.legend_entry_id + } + else: + legend_entry_ids[geometry.public_law_restriction.law_status].add( + geometry.public_law_restriction.legend_entry_id + ) + + # Retrieve legend entries + legend_entries_from_db = [] + for law_status in legend_entry_ids.keys(): + legend_entries_from_db.append( + [ + session.query(self.legend_entry_model).filter( + self.legend_entry_model.t_id.in_(list(legend_entry_ids[law_status])) + ).all(), + law_status + ] + ) - return session.query(self.legend_entry_model).filter( - self.legend_entry_model.t_id.in_((distinct_legend_entry_ids))).all() + return legend_entries_from_db def read(self, params, real_estate, bbox): """ @@ -543,14 +560,8 @@ def read(self, params, real_estate, bbox): if (geometry.public_law_restriction.law_status not in law_status_of_geometry): law_status_of_geometry.append(geometry.public_law_restriction.law_status) - legend_entries_from_db = [] # get legend_entries per law_status - for law_status in law_status_of_geometry: - legend_entry_with_law_status = [ - self.collect_legend_entries_by_bbox(session, bbox, law_status), - law_status - ] - legend_entries_from_db.append(legend_entry_with_law_status) + legend_entries_from_db = self.collect_legend_entries_by_bbox(session, bbox) self.records = [] for geometry_result in geometry_results: diff --git a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py index 3aa9028ae1..ab5c2a653c 100644 --- a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py @@ -614,7 +614,7 @@ def collect_related_geometries_by_real_estate(self, session, real_estate): .selectinload(self.models.PublicLawRestriction.responsible_office), ).all() - def collect_legend_entries_by_bbox(self, session, bbox, law_status): + def collect_legend_entries_by_bbox(self, session, bbox): """ Extracts all legend entries in the topic which have spatial relation with the passed bounding box of visible extent. @@ -622,22 +622,41 @@ def collect_legend_entries_by_bbox(self, session, bbox, law_status): Args: session (sqlalchemy.orm.Session): The requested clean session instance ready for use bbox (shapely.geometry.base.BaseGeometry): The bbox to search the records. - law_status (str): String of the law status for which the legend entries should be queried. Returns: list: The result of the related geometries unique by the public law restriction id and law status """ - distinct_legend_entry_ids = [] + # Select the legend entries of all plr within bbox geometries = self.handle_collection(session, bbox).options( selectinload(self.models.Geometry.public_law_restriction) ).all() + + # Compile a list of unique legend entry ids for each law status + legend_entry_ids = dict() for geometry in geometries: - if geometry.public_law_restriction.legend_entry_id not in distinct_legend_entry_ids \ - and geometry.public_law_restriction.law_status == law_status: - distinct_legend_entry_ids.append(geometry.public_law_restriction.legend_entry_id) - return session.query(self.legend_entry_model).filter( - self.legend_entry_model.id.in_((distinct_legend_entry_ids))).all() + if geometry.public_law_restriction.law_status not in legend_entry_ids.keys(): + legend_entry_ids[geometry.public_law_restriction.law_status] = { + geometry.public_law_restriction.legend_entry_id + } + else: + legend_entry_ids[geometry.public_law_restriction.law_status].add( + geometry.public_law_restriction.legend_entry_id + ) + + # Retrieve legend entries + legend_entries_from_db = [] + for law_status in legend_entry_ids.keys(): + legend_entries_from_db.append( + [ + session.query(self.legend_entry_model).filter( + self.legend_entry_model.id.in_(list(legend_entry_ids[law_status])) + ).all(), + law_status + ] + ) + + return legend_entries_from_db def read(self, params, real_estate, bbox): # pylint: disable=W:0221 """ @@ -680,14 +699,8 @@ def read(self, params, real_estate, bbox): # pylint: disable=W:0221 if (geometry.public_law_restriction.law_status not in law_status_of_geometry): law_status_of_geometry.append(geometry.public_law_restriction.law_status) - legend_entries_from_db = [] # get legend_entries per law_status - for law_status in law_status_of_geometry: - legend_entry_with_law_status = [ - self.collect_legend_entries_by_bbox(session, bbox, law_status), - law_status - ] - legend_entries_from_db.append(legend_entry_with_law_status) + legend_entries_from_db = self.collect_legend_entries_by_bbox(session, bbox) self.records = [] for geometry_result in geometry_results: From 15dd32e6a5bb0cca77ff220f2752764d771c8003 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 8 Oct 2024 11:03:37 +0200 Subject: [PATCH 12/35] remove not used code --- .../contrib/data_sources/interlis_2_3/sources/plr.py | 5 ----- pyramid_oereb/contrib/data_sources/standard/sources/plr.py | 6 ------ 2 files changed, 11 deletions(-) diff --git a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py index b3a5664814..4d15c5beef 100644 --- a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py @@ -554,11 +554,6 @@ def read(self, params, real_estate, bbox): else: # We found spatially related elements. This means we need to extract the actual plr # information related to the found geometries. - law_status_of_geometry = [] - # get distinct values of law_status for all geometries found - for geometry in geometry_results: - if (geometry.public_law_restriction.law_status not in law_status_of_geometry): - law_status_of_geometry.append(geometry.public_law_restriction.law_status) # get legend_entries per law_status legend_entries_from_db = self.collect_legend_entries_by_bbox(session, bbox) diff --git a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py index ab5c2a653c..3d61ed567c 100644 --- a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py @@ -693,12 +693,6 @@ def read(self, params, real_estate, bbox): # pylint: disable=W:0221 # We found spatially related elements. This means we need to extract the actual plr # information related to the found geometries. - law_status_of_geometry = [] - # get distinct values of law_status for all geometries found - for geometry in geometry_results: - if (geometry.public_law_restriction.law_status not in law_status_of_geometry): - law_status_of_geometry.append(geometry.public_law_restriction.law_status) - # get legend_entries per law_status legend_entries_from_db = self.collect_legend_entries_by_bbox(session, bbox) From cf380376c91938acfa02f8a57131b7aadb350f06 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 16 Oct 2024 11:07:30 +0200 Subject: [PATCH 13/35] add test for collect_legend_entries_by_bbox --- .../data_sources/interlis_2_3/sources/plr.py | 18 ++- .../data_sources/standard/sources/plr.py | 19 ++- .../sources/test_plr.py | 120 ++++++++++++++++++ .../sources/test_plr.py | 87 +++++++++++++ 4 files changed, 238 insertions(+), 6 deletions(-) diff --git a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py index 4d15c5beef..8a5fdacb51 100644 --- a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py @@ -470,6 +470,20 @@ def collect_related_geometries_by_real_estate(self, session, real_estate): .selectinload(self.models.MultilingualUri.localised_uri) ).all() + def get_legend_entries_from_db(self, session, legend_entry_ids): + """ + Retrieves the legend entries for a list of t_id-values. + + Args: + session (sqlalchemy.orm.Session): The requested clean session instance ready for use + legend_entry_ids (list): list of the egend entry ids + + Returns: + list: the query result represented as a list. + """ + return session.query(self.legend_entry_model).filter( + self.legend_entry_model.t_id.in_(legend_entry_ids)).all() + def collect_legend_entries_by_bbox(self, session, bbox): """ Extracts all legend entries in the topic which have spatial relation with the passed bounding box of @@ -509,9 +523,7 @@ def collect_legend_entries_by_bbox(self, session, bbox): for law_status in legend_entry_ids.keys(): legend_entries_from_db.append( [ - session.query(self.legend_entry_model).filter( - self.legend_entry_model.t_id.in_(list(legend_entry_ids[law_status])) - ).all(), + self.get_legend_entries_from_db(session, list(legend_entry_ids[law_status])), law_status ] ) diff --git a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py index 3d61ed567c..0df7ad1431 100644 --- a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py @@ -614,6 +614,21 @@ def collect_related_geometries_by_real_estate(self, session, real_estate): .selectinload(self.models.PublicLawRestriction.responsible_office), ).all() + def get_legend_entries_from_db(self, session, legend_entry_ids): + """ + Retrieves the legend entries for a list of id-values. + + Args: + session (sqlalchemy.orm.Session): The requested clean session instance ready for use + legend_entry_ids (list): list of the egend entry ids + + Returns: + list: the query result represented as a list. + """ + + return session.query(self.legend_entry_model).filter( + self.legend_entry_model.id.in_(legend_entry_ids)).all() + def collect_legend_entries_by_bbox(self, session, bbox): """ Extracts all legend entries in the topic which have spatial relation with the passed bounding box of @@ -649,9 +664,7 @@ def collect_legend_entries_by_bbox(self, session, bbox): for law_status in legend_entry_ids.keys(): legend_entries_from_db.append( [ - session.query(self.legend_entry_model).filter( - self.legend_entry_model.id.in_(list(legend_entry_ids[law_status])) - ).all(), + self.get_legend_entries_from_db(session, list(legend_entry_ids[law_status])), law_status ] ) diff --git a/tests/contrib.data_sources.interlis_2_3/sources/test_plr.py b/tests/contrib.data_sources.interlis_2_3/sources/test_plr.py index 5cc5598897..b7844e0ed9 100644 --- a/tests/contrib.data_sources.interlis_2_3/sources/test_plr.py +++ b/tests/contrib.data_sources.interlis_2_3/sources/test_plr.py @@ -20,6 +20,7 @@ from pyramid_oereb.contrib.data_sources.interlis_2_3.sources.plr import ( StandardThemeConfigParser ) +from pyramid_oereb.contrib.data_sources.interlis_2_3.sources.plr import DatabaseSource @pytest.fixture(scope='session') @@ -209,6 +210,21 @@ def oblique_limit_real_estate_record(): ) +@pytest.fixture +def plr_source_params(db_connection): + yield { + "source": { + "class": "pyramid_oereb.contrib.data_sources.interlis_2_3.sources.plr.DatabaseSource", + "params": { + "db_connection": db_connection, + "model_factory": "pyramid_oereb.contrib.data_sources.interlis_2_3." + "models.theme.model_factory_integer_pk", + "schema_name": "land_use_plans" + } + } + } + + # @pytest.fixture # def interlis_real_estate(): # theme = ThemeRecord('code', dict(), 100) @@ -286,3 +302,107 @@ def test_related_geometries(processor_data, pyramid_oereb_test_config, interlis_ assert len(extract_raw.real_estate.public_law_restrictions) == nb_results extract = processor.plr_tolerance_check(extract_raw) assert len(extract.real_estate.public_law_restrictions) == nb_results + + +def mock_session_object_query_geometries(items_list): + class PublicLawRestrictionTest(): + def __init__(self, law_status, legend_entry_id): + self.law_status = law_status + self.legend_entry_id = legend_entry_id + + class GeometryTest(): + def __init__(self, public_law_restriction): + self.public_law_restriction = public_law_restriction + + geometries = [] + for item in items_list: + geometries.append(GeometryTest(PublicLawRestrictionTest(item[0], item[1]))) + + class AllTest(): + def all(): + return iter(geometries) + + class DistinctTest(): + def __init__(self): + pass + + def options(arg2): + return AllTest + + class FilterTest(): + def __init__(self): + pass + + def distinct(arg2): + return DistinctTest + + class QueryTest(): + def __init__(self): + pass + + def filter(arg3): + return FilterTest + + class SessionTest(): + def __init__(self): + pass + + def query(arg1): + return QueryTest + + return SessionTest + + +def get_return_vals_of_get_legend_entries_from_db(arg1, arg2, list_of_ids): + return_value = [] + for id in list_of_ids: + return_value.append((id, )) + return return_value + + +@pytest.mark.parametrize('idx,items_list', [ + (0, [ + ["inForce", 1], + ["changeWithoutPreEffect", 1], + ["changeWithoutPreEffect", 2], + ["inForce", 3], + ["inForce", 4], + ["inForce", 3], + ["changeWithoutPreEffect", 6], + ["inForce", 7], + ["changeWithoutPreEffect", 2], + ["inForce", 9], + ["changeWithoutPreEffect", 7] + ]), + (1, [ + ["inForce", 1], + ["inForce", 3], + ["inForce", 4], + ["inForce", 3], + ["inForce", 7], + ["inForce", 9], + ]) +]) +def test_collect_legend_entries_by_bbox(idx, items_list, plr_source_params): + with ( + patch.object( + DatabaseSource, + 'get_legend_entries_from_db', + get_return_vals_of_get_legend_entries_from_db + ) + ): + source = DatabaseSource(**plr_source_params) + result = source.collect_legend_entries_by_bbox( + mock_session_object_query_geometries(items_list), + Polygon(((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.)))) + + if idx == 0: + assert len(result) == 2 + assert sorted([x[0] for x in result if x[1] == 'inForce'][0]) == \ + [(1, ), (3, ), (4, ), (7, ), (9, )] + assert sorted([x[0] for x in result if x[1] == 'changeWithoutPreEffect'][0]) == \ + [(1, ), (2, ), (6, ), (7, )] + if idx == 1: + assert len(result) == 1 + assert sorted([x[0] for x in result if x[1] == 'inForce'][0]) == \ + [(1, ), (3, ), (4, ), (7, ), (9, )] diff --git a/tests/contrib.data_sources.standard/sources/test_plr.py b/tests/contrib.data_sources.standard/sources/test_plr.py index 33fe945136..8e4a8c7713 100644 --- a/tests/contrib.data_sources.standard/sources/test_plr.py +++ b/tests/contrib.data_sources.standard/sources/test_plr.py @@ -1247,3 +1247,90 @@ def test_handle_collection(plr_source_params, all_plr_result_session, real_estat ST_GeomFromWKB(%(ST_GeomFromWKB_1)s, %(ST_GeomFromWKB_2)s) ) '''.replace('\n', '').replace(' ', '') + + +def mock_return_value_handle_collection(items_list): + class PublicLawRestrictionTest(): + def __init__(self, law_status, legend_entry_id): + self.law_status = law_status + self.legend_entry_id = legend_entry_id + + class GeometryTest(): + def __init__(self, public_law_restriction): + self.public_law_restriction = public_law_restriction + + geometries = [] + for item in items_list: + geometries.append(GeometryTest(PublicLawRestrictionTest(item[0], item[1]))) + + class AllTest(): + def __init__(arg1, arg2): + pass + + def all(arg3): + return iter(geometries) + + class OptionsTest(): + def __init__(self, arg1, arg2): + pass + options = AllTest + + return OptionsTest + + +def get_return_vals_of_get_legend_entries_from_db(arg1, arg2, list_of_ids): + return_value = [] + for id in list_of_ids: + return_value.append((id, )) + return return_value + + +@pytest.mark.parametrize('idx,items_list', [ + (0, [ + ["inForce", 1], + ["changeWithoutPreEffect", 1], + ["changeWithoutPreEffect", 2], + ["inForce", 3], + ["inForce", 4], + ["inForce", 3], + ["changeWithoutPreEffect", 6], + ["inForce", 7], + ["changeWithoutPreEffect", 2], + ["inForce", 9], + ["changeWithoutPreEffect", 7] + ]), + (1, [ + ["inForce", 1], + ["inForce", 3], + ["inForce", 4], + ["inForce", 3], + ["inForce", 7], + ["inForce", 9], + ]) +]) +def test_collect_legend_entries_by_bbox(idx, items_list, plr_source_params): + with ( + patch.object( + DatabaseSource, + 'handle_collection', + mock_return_value_handle_collection(items_list) + ), + patch.object( + DatabaseSource, + 'get_legend_entries_from_db', + get_return_vals_of_get_legend_entries_from_db + ) + ): + source = DatabaseSource(**plr_source_params) + result = source.collect_legend_entries_by_bbox("", "") + + if idx == 0: + assert len(result) == 2 + assert sorted([x[0] for x in result if x[1] == 'inForce'][0]) == \ + [(1, ), (3, ), (4, ), (7, ), (9, )] + assert sorted([x[0] for x in result if x[1] == 'changeWithoutPreEffect'][0]) == \ + [(1, ), (2, ), (6, ), (7, )] + if idx == 1: + assert len(result) == 1 + assert sorted([x[0] for x in result if x[1] == 'inForce'][0]) == \ + [(1, ), (3, ), (4, ), (7, ), (9, )] From ef972291d51f41dde01d1558fb2dc5e98fd37fa1 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 16 Oct 2024 11:37:26 +0200 Subject: [PATCH 14/35] remove "keys()" --- .../contrib/data_sources/interlis_2_3/sources/plr.py | 4 ++-- pyramid_oereb/contrib/data_sources/standard/sources/plr.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py index 8a5fdacb51..21cb0edfe9 100644 --- a/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/interlis_2_3/sources/plr.py @@ -509,7 +509,7 @@ def collect_legend_entries_by_bbox(self, session, bbox): # Compile a list of unique legend entry ids for each law status legend_entry_ids = dict() for geometry in geometries: - if geometry.public_law_restriction.law_status not in legend_entry_ids.keys(): + if geometry.public_law_restriction.law_status not in legend_entry_ids: legend_entry_ids[geometry.public_law_restriction.law_status] = { geometry.public_law_restriction.legend_entry_id } @@ -520,7 +520,7 @@ def collect_legend_entries_by_bbox(self, session, bbox): # Retrieve legend entries legend_entries_from_db = [] - for law_status in legend_entry_ids.keys(): + for law_status in legend_entry_ids: legend_entries_from_db.append( [ self.get_legend_entries_from_db(session, list(legend_entry_ids[law_status])), diff --git a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py index 0df7ad1431..c041c1caf1 100644 --- a/pyramid_oereb/contrib/data_sources/standard/sources/plr.py +++ b/pyramid_oereb/contrib/data_sources/standard/sources/plr.py @@ -650,7 +650,7 @@ def collect_legend_entries_by_bbox(self, session, bbox): # Compile a list of unique legend entry ids for each law status legend_entry_ids = dict() for geometry in geometries: - if geometry.public_law_restriction.law_status not in legend_entry_ids.keys(): + if geometry.public_law_restriction.law_status not in legend_entry_ids: legend_entry_ids[geometry.public_law_restriction.law_status] = { geometry.public_law_restriction.legend_entry_id } @@ -661,7 +661,7 @@ def collect_legend_entries_by_bbox(self, session, bbox): # Retrieve legend entries legend_entries_from_db = [] - for law_status in legend_entry_ids.keys(): + for law_status in legend_entry_ids: legend_entries_from_db.append( [ self.get_legend_entries_from_db(session, list(legend_entry_ids[law_status])), From 90e106fe9602eecf084808dc1ac09dc62381eb5c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:27:27 +0100 Subject: [PATCH 15/35] Update dependency sqlalchemy to v2.0.36 (#2051) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dcf901b44b..d5a4830b15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ recommend = [ "qrcode==7.4.2", "image==1.5.33", "shapely==2.0.6", - "SQLAlchemy==2.0.32", + "SQLAlchemy==2.0.36", "pyaml-env==1.2.1", "urllib3==2.2.2", "waitress==3.0.0", From a426685b0c0d4f22ad7bc325747406a9918705d0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:27:44 +0100 Subject: [PATCH 16/35] Update dependency urllib3 to v2.2.3 (#2054) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d5a4830b15..2db7f70a31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ recommend = [ "shapely==2.0.6", "SQLAlchemy==2.0.36", "pyaml-env==1.2.1", - "urllib3==2.2.2", + "urllib3==2.2.3", "waitress==3.0.0", "pyreproj==3.0.0", "mako-render==0.1.0", From f99a50030ea373b0b2a06bf9b16b74bdc7a9f218 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:28:01 +0100 Subject: [PATCH 17/35] Update dependency webtest to v3.0.1 (#2048) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2db7f70a31..ee5f47a1d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ testing = [ "pytest-ordering==0.6", "requests-mock==1.12.1", "responses==0.25.3", - "webtest==3.0.0", + "webtest==3.0.1", "pillow==10.4.0"] dev = [ "flake8==7.1.1", From 946bc58067c68bfa5e205a9fedbf212d874e6f76 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:28:25 +0100 Subject: [PATCH 18/35] Update dependency pypdf to v5 (#2055) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ee5f47a1d4..e67cfe6672 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ Changelog = "https://github.com/openoereb/pyramid_oereb/blob/master/CHANGES.rst" [project.optional-dependencies] # Dependencies listed in "recommend" must be included in "no-version" without explicit version number recommend = [ - "pypdf==4.3.1", + "pypdf==5.1.0", "filetype==1.2.0", "geoalchemy2==0.15.2", "pyramid==2.0.2", From 300479f01cb57b90cbed40c78e9232b3afbb6bd7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:28:54 +0100 Subject: [PATCH 19/35] Update dependency qrcode to v8 (#2058) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e67cfe6672..6079c9fdef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ recommend = [ "geoalchemy2==0.15.2", "pyramid==2.0.2", "pyramid-debugtoolbar==4.12.1", - "qrcode==7.4.2", + "qrcode==8.0", "image==1.5.33", "shapely==2.0.6", "SQLAlchemy==2.0.36", From 2738acced4becffa74d7c9dcf7bffa0f8024b956 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:29:41 +0100 Subject: [PATCH 20/35] Update dependency pytest to v8.3.3 (#2053) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6079c9fdef..ea8b06cad5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,7 @@ no-version = [ testing = [ "jsonschema==4.23.0", "lxml==5.3.0", - "pytest==8.3.2", + "pytest==8.3.3", "pytest-cov==5.0.0", "pytest-ordering==0.6", "requests-mock==1.12.1", From 4dc5325c7fe2eb0cc524a097b242c02ab0064191 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:37:06 +0100 Subject: [PATCH 21/35] Update dependency psycopg2 to v2.9.10 (#2062) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ea8b06cad5..084c4519e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ dev = [ "pycodestyle==2.12.1", "Sphinx==7.4.7", "sphinx_rtd_theme==2.0.0", - "psycopg2==2.9.9", + "psycopg2==2.9.10", "mccabe==0.7.0", "c2c.template==2.4.2", "yappi"] From 1751e9e3f491d022b3896986d5ea9ec6b0ace0c2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:37:44 +0100 Subject: [PATCH 22/35] Update actions/checkout digest to 11bd719 (#2061) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 10 +++++----- .github/workflows/daily_check.yaml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7ff42ec7de..5f2d082638 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,7 @@ jobs: name: Check style (lint) runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list - run: sudo apt update - run: sudo apt-get install libpq-dev @@ -18,7 +18,7 @@ jobs: name: Check style (git-attributes) runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list - run: sudo apt update - run: sudo apt-get install libpq-dev @@ -52,7 +52,7 @@ jobs: - '3.11' - '3.12' steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Set up Python v${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -78,7 +78,7 @@ jobs: name: Check federal data definitions runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list - run: sudo apt update - run: sudo apt-get install xsltproc @@ -95,7 +95,7 @@ jobs: if: github.ref == 'refs/heads/master' runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Make documentation run: | sudo rm /etc/apt/sources.list.d/*.list diff --git a/.github/workflows/daily_check.yaml b/.github/workflows/daily_check.yaml index 72d7c7abcc..198ee010b4 100644 --- a/.github/workflows/daily_check.yaml +++ b/.github/workflows/daily_check.yaml @@ -8,7 +8,7 @@ jobs: name: Check federal data definitions runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list - run: sudo apt update - run: sudo apt-get install xsltproc @@ -47,7 +47,7 @@ jobs: - python3.11 - python3.12 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list - run: sudo apt update - run: sudo apt-get install libpq-dev From c8a98ed8b301aaa44cafc393b9bfbd49d646a1d9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:38:38 +0100 Subject: [PATCH 23/35] Update JamesIves/github-pages-deploy-action action to v4.6.8 (#2049) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f2d082638..4a1e7613ce 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -103,7 +103,7 @@ jobs: sudo apt-get install libpq-dev make doc-html - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.6.3 + uses: JamesIves/github-pages-deploy-action@v4.6.8 with: branch: gh-pages # The branch the action should deploy to. folder: doc/build/html # The folder the action should deploy. From fbf59beda9beff7eab2826f5216cc2bb0f8f997b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:39:29 +0100 Subject: [PATCH 24/35] Update dependency ubuntu to v24 (#2057) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 12 ++++++------ .github/workflows/daily_check.yaml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4a1e7613ce..c20d0dfe66 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,7 +5,7 @@ jobs: lint: name: Check style (lint) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list @@ -16,7 +16,7 @@ jobs: gitattributes: name: Check style (git-attributes) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list @@ -27,7 +27,7 @@ jobs: test-py: name: Test Python - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 services: # Label used to access the service container postgres: @@ -76,7 +76,7 @@ jobs: test-fed-data: name: Check federal data definitions - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list @@ -93,7 +93,7 @@ jobs: doc: name: Make and deploy documentation if: github.ref == 'refs/heads/master' - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Make documentation @@ -110,7 +110,7 @@ jobs: build-and-publish: name: Build and publish Python 🐍 distributions 📦 to PyPI - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [lint, gitattributes] steps: - uses: actions/checkout@master diff --git a/.github/workflows/daily_check.yaml b/.github/workflows/daily_check.yaml index 198ee010b4..5145f33a22 100644 --- a/.github/workflows/daily_check.yaml +++ b/.github/workflows/daily_check.yaml @@ -6,7 +6,7 @@ on: jobs: test-fed-data: name: Check federal data definitions - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: sudo rm /etc/apt/sources.list.d/*.list @@ -22,7 +22,7 @@ jobs: test-py: name: Test Python - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 services: # Label used to access the service container postgres: From 1545caa6f2ca2da3f1d7e3ea098f4ed59bb02150 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:45:18 +0100 Subject: [PATCH 25/35] Update dependency waitress to v3.0.1 (#2063) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 084c4519e9..a20b0dec6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ recommend = [ "SQLAlchemy==2.0.36", "pyaml-env==1.2.1", "urllib3==2.2.3", - "waitress==3.0.0", + "waitress==3.0.1", "pyreproj==3.0.0", "mako-render==0.1.0", "requests==2.32.3", From 5d9db7b0ce9a64e41ef7c64b423adf748479f027 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:46:42 +0100 Subject: [PATCH 26/35] Update dependency pytest-cov to v6 (#2066) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a20b0dec6a..45c3517a34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ testing = [ "jsonschema==4.23.0", "lxml==5.3.0", "pytest==8.3.3", - "pytest-cov==5.0.0", + "pytest-cov==6.0.0", "pytest-ordering==0.6", "requests-mock==1.12.1", "responses==0.25.3", From a608fd69b9214aae700be70c540b0f6c702af71d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:47:14 +0100 Subject: [PATCH 27/35] Update dependency pillow to v11 (#2065) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 45c3517a34..7c6751d296 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ testing = [ "requests-mock==1.12.1", "responses==0.25.3", "webtest==3.0.1", - "pillow==10.4.0"] + "pillow==11.0.0"] dev = [ "flake8==7.1.1", "Flake8-pyproject==1.2.3", From 8246e329c9133b842c1869bb0ae16b3589057c5d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:47:41 +0100 Subject: [PATCH 28/35] Update python Docker tag to v3.13.0 (#2052) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8edd46b9f1..69ad332aa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12.5-bullseye +FROM python:3.13.0-bullseye ENV DEBIAN_FRONTEND=noninteractive From bdd2e34f36346b102d8a5b3b677023b31cfc810f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:10:40 +0100 Subject: [PATCH 29/35] Update dependency sphinx-rtd-theme to v3 (#2067) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7c6751d296..abecba69de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,7 +88,7 @@ dev = [ "pyflakes==3.2.0", "pycodestyle==2.12.1", "Sphinx==7.4.7", - "sphinx_rtd_theme==2.0.0", + "sphinx_rtd_theme==3.0.1", "psycopg2==2.9.10", "mccabe==0.7.0", "c2c.template==2.4.2", From 3e04f31a451c2ce4e9d801bd4465363d15baacae Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Mon, 4 Nov 2024 14:34:25 +0100 Subject: [PATCH 30/35] New release --- CHANGES.rst | 6 ++++++ doc/source/changes.rst | 6 +++++- pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 38f62b2b09..3e91a5d054 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,12 @@ Notes: ------ - This python package specifies the version numbers only of directly imported python packages. This approach may result in a build failure of older versions of the project if incompatibilities arise between imported packages over time. The build process of the master branch is regularly tested in an automatic process. +2.5.4 +----- +- New parameter default_toc_length to define a default table of content pages number (#2042) +- Add timeout in address source (#2043) +- Library upgrades (waitress, sqlalchemy, psycopg2, urllib3) + 2.5.3 ----- - Provide a general WMS verify certificate option diff --git a/doc/source/changes.rst b/doc/source/changes.rst index cf0c1542ca..d911234de9 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -6,12 +6,16 @@ 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 +Version 2.5.4 ------------- +Feature and maintenance release: + * New parameter 'expected_toc_length' allows to define a default table of content pages number avoiding a second call for the pdf extract in most cases. This value may be be set if most of the PDF extracts have the same number of TOC pages. It complements the 'compute_toc_pages' parameter. If the latter is set to true 'expected_toc_length' is ignored. +* Add timeout in address source (#2043) +* Library upgrades (waitress, sqlalchemy, psycopg2, urllib3) Version 2.5.3 ------------- diff --git a/pyproject.toml b/pyproject.toml index abecba69de..8026e0c8ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "pyramid_oereb" -version = "2.5.3" +version = "2.5.4" description = "pyramid_oereb, extension for pyramid web frame work to provide a basic server part for the oereb project" classifiers=[ From d18517009ea28ce98cde0c05dac1d6210cb8be0f Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Mon, 4 Nov 2024 14:43:24 +0100 Subject: [PATCH 31/35] Repair doc formatting --- doc/source/changes.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/source/changes.rst b/doc/source/changes.rst index d911234de9..a70a750f10 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -10,10 +10,10 @@ Version 2.5.4 ------------- Feature and maintenance release: -* New parameter 'expected_toc_length' allows to define a default table of content pages number avoiding a second -call for the pdf extract in most cases. This value may be be set if most of the PDF extracts have the same number -of TOC pages. It complements the 'compute_toc_pages' parameter. If the latter is set to true 'expected_toc_length' -is ignored. +* New parameter 'expected_toc_length' allows to define a default table of content pages number avoiding a + second call for the pdf extract in most cases. This value may be be set if most of the PDF extracts have + the same number of TOC pages. It complements the 'compute_toc_pages' parameter. If the latter is set to true, + 'expected_toc_length' is ignored. * Add timeout in address source (#2043) * Library upgrades (waitress, sqlalchemy, psycopg2, urllib3) From 176b4b3245ed243d2892c9a604e370751283a98f Mon Sep 17 00:00:00 2001 From: Wolfgang Kaltz Date: Mon, 4 Nov 2024 15:09:04 +0100 Subject: [PATCH 32/35] Release notes: add missing pr --- CHANGES.rst | 1 + doc/source/changes.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 3e91a5d054..60d47f73fb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Notes: ----- - New parameter default_toc_length to define a default table of content pages number (#2042) - Add timeout in address source (#2043) +- Optimize legend entries retrieval (#2050) - Library upgrades (waitress, sqlalchemy, psycopg2, urllib3) 2.5.3 diff --git a/doc/source/changes.rst b/doc/source/changes.rst index a70a750f10..00c41de280 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -15,6 +15,7 @@ Feature and maintenance release: the same number of TOC pages. It complements the 'compute_toc_pages' parameter. If the latter is set to true, 'expected_toc_length' is ignored. * Add timeout in address source (#2043) +* Optimize legend entries retrieval (#2050) * Library upgrades (waitress, sqlalchemy, psycopg2, urllib3) Version 2.5.3 From 62131c7cac32569d2a90c7547d67e9392ffeb1ec Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 13 Dec 2024 14:07:23 +0100 Subject: [PATCH 33/35] geolink-formatter==2.0.6 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8026e0c8ab..779f4a0834 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ recommend = [ "pyreproj==3.0.0", "mako-render==0.1.0", "requests==2.32.3", - "geolink-formatter==2.0.5", + "geolink-formatter==2.0.6", "pyconizer==0.1.4", "c2cwsgiutils[standard]==6.0.8"] no-version = [ From 4c71517161684852a1a62fcb1dd97a4287950e74 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 13 Dec 2024 16:10:16 +0100 Subject: [PATCH 34/35] update change log due to added support of oereblex api version 1.2.5 --- CHANGES.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 60d47f73fb..3271c0acae 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,10 @@ Notes: ------ - This python package specifies the version numbers only of directly imported python packages. This approach may result in a build failure of older versions of the project if incompatibilities arise between imported packages over time. The build process of the master branch is regularly tested in an automatic process. +master +------ +- Support Oereblex API version 1.2.5 via geolink-formatter 2.0.6 (#2081) + 2.5.4 ----- - New parameter default_toc_length to define a default table of content pages number (#2042) From b1f2bec065ab7f9fd51a408c9effed1c8d257686 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 16 Dec 2024 08:36:26 +0100 Subject: [PATCH 35/35] update doc due to added support of oereblex api version 1.2.5 --- dev/config/pyramid_oereb.yml.mako | 10 +++++----- doc/source/changes.rst | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dev/config/pyramid_oereb.yml.mako b/dev/config/pyramid_oereb.yml.mako index 079a06f913..774c652d44 100644 --- a/dev/config/pyramid_oereb.yml.mako +++ b/dev/config/pyramid_oereb.yml.mako @@ -89,11 +89,11 @@ pyramid_oereb: # not set it will assume that only one TOC page exists, and this can lead to wrong numbering in the TOC, which # will be fixed by a second PDF extract call that has an impact on performance. compute_toc_pages: false - # In order to skip the computation of the estimated number of TOC pages which might return an erroneous result - # for your setting, you can specify a default for the number of TOC pages. For most of the cantons the number of + # In order to skip the computation of the estimated number of TOC pages which might return an erroneous result + # for your setting, you can specify a default for the number of TOC pages. For most of the cantons the number of # TOC pages is pretty constant unless a real estate is concerned by none or a huge number of restrictions. - # In both cases (computing an estimate or setting a default for the number of TOC pages) the exact number of TOC - # pages is extracted from the created PDF and if it differs from the expected value the PDF is created a second + # In both cases (computing an estimate or setting a default for the number of TOC pages) the exact number of TOC + # pages is extracted from the created PDF and if it differs from the expected value the PDF is created a second # time with the correct page numbers. # Note that if "compute_toc_pages" is set true the "expected_toc_length" is not taken into account. expected_toc_length: 2 @@ -180,7 +180,7 @@ pyramid_oereb: # OEREBlex host host: https://oereblex.sg.ch # geoLink schema version - version: 1.2.2 + version: 1.2.5 # Pass schema version in URL pass_version: true # Enable/disable XML validation diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 00c41de280..940fc55b50 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -6,6 +6,10 @@ 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. +master +------ +- Support of Oereblex API version 1.2.5 via geolink-formatter 2.0.6 added (#2081). The oereblex schema version that is used to download oereblex xmls can be set in the file pyramid_oereb.yaml. + Version 2.5.4 ------------- Feature and maintenance release: @@ -104,7 +108,7 @@ Maintenance release: * Add support for newest oereblex API (via geolink-formatter, #1703) * Various minor library upgrades (SQLAlchemy, geoalchemy, psycopg2, pypdf) - + Version 2.4.2 ------------- @@ -177,7 +181,7 @@ Version 2.2.4 ------------- New functionality for configuring tolerance (optional): -* Support tolerance per geometry type (#1603). See example definitions in the example project configuration file. +* Support tolerance per geometry type (#1603). See example definitions in the example project configuration file. * Library updates (#1604) .. _changes-version-2.2.3: