Mapfish Print¶
Configuration¶
Sub themes¶
To enable separate pages per sub theme, enable the option split_sub_themes in the print section of your configuration.
print:
split_sub_themes: true
Sorting¶
You can influence the sort order for each theme separately. Per default, the sub themes are unsorted.
Example for alphabetic sort:
- name: plr119
sub_themes:
sorter:
module: pyramid_oereb.contrib.print_proxy.sub_themes.sorting
class_name: AlphabeticSort
The list sort provides a fix, non-alphabetic order. A ordered list as parameter defines the order. The sub theme names have to match exactly, otherwise they will be added at the end. Example configuration:
- name: plr119
sub_themes:
sorter:
module: pyramid_oereb.contrib.print_proxy.sub_themes.sorting
class_name: ListSort
params:
list:
- First sub theme
- Another sub theme
- Last sub theme
Mapfish Print Renderer¶
- class pyramid_oereb.contrib.print_proxy.mapfish_print.mapfish_print.Renderer(info)[source]¶
- __init__(info)[source]¶
Creates a new JSON renderer instance for extract rendering.
- Parameters:
info (pyramid.interfaces.IRendererInfo) – Info object.
- archive_pdf_file(pdf_archive_path, binary_content, extract_as_dict)[source]¶
Writes the static extract (pdf) into a dedicated file; this functionality can thus be used for archiving.
- Parameters:
pdf_archive_path (str) – directory path where the file shall be stored.
() (extract_as_dict) – the contents of the pdf.
() – the extract contents, used to retrieve metadata in order to produce the filename.
- Returns:
the name of the file that was written, including the path.
- Return type:
str
- convert_to_printable_extract(extract_dict, feature_geometry)[source]¶
Converts an oereb extract into a form suitable for printing by mapfish print.
- Parameters:
extract_dict – the oereb extract, will get converted by this function into a form convenient for mapfish-print
feature_geometry – the geometry for this extract, will get added to the extract information
- classmethod date_time(dt)¶
Formats the date/time according to the specification.
- Parameters:
dt (datetime.dateordatetime.timeordatetime.datetime) – The datetime object.
- Returns:
The formatted date/time.
- Return type:
str
- format_document(document)[source]¶
Formats a document record for rendering according to the federal specification.
- Parameters:
document (pyramid_oereb.lib.records.documents.DocumentRecord) – The document record to be formatted.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- format_geometry(geometry)[source]¶
Formats a geometry record for rendering according to the federal specification.
- Parameters:
geometry (pyramid_oereb.lib.records.geometry.GeometryRecord) – The geometry record to be formatted.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- format_legend_entry(legend_entry)[source]¶
Formats a legend entry record for rendering according to the federal specification.
- Parameters:
legend_entry (pyramid_oereb.lib.records.view_service.LegendEntryRecord) – The legend entry record to be formatted.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- format_map(map_)[source]¶
Formats a view service record for rendering according to the federal specification.
- Parameters:
map (pyramid_oereb.lib.records.view_service.ViewServiceRecord) – The view service record to be formatted.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- format_office(office)[source]¶
Formats an office record for rendering according to the federal specification.
- Parameters:
office (pyramid_oereb.lib.records.office.OfficeRecord) – The office record to be formatted.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- format_plr(plrs)[source]¶
Formats a public law restriction record for rendering according to the federal specification.
- Parameters:
plrs (list of pyramid_oereb.lib.records.plr.PlrRecord) – The public law restriction records to be formatted.
- Returns:
The formatted dictionaries for rendering.
- Return type:
list of dict
- format_real_estate(real_estate)[source]¶
Formats a real estate record for rendering according to the federal specification.
- Parameters:
real_estate (pyramid_oereb.lib.records.real_estate.RealEstateRecord) – The real estate record to be formatted.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- format_theme(theme, sub_theme=None)[source]¶
Formats a theme record for rendering according to the federal specification.
- Parameters:
theme (pyramid_oereb.lib.records.theme.ThemeRecord) – The theme record to be formatted.
sub_theme (pyramid_oereb.lib.records.theme.ThemeRecord) – The optional sub theme record.
- Returns:
The formatted dictionary for rendering.
- Return type:
dict
- static from_shapely(geom)¶
Formats shapely geometry for rendering according to the federal specification.
- Parameters:
geom (shapely.geometry.base.BaseGeometry) – The geometry object to be formatted.
- Returns:
The formatted geometry.
- Return type:
dict
- get_custom_wms_params(params)[source]¶
From a given dictionary filter out all the parameters that are specified in the config and return these. Only values which exist in the given params are added. If there is nothing configured or the config is not a list the configured wms_url_params are used as fallback.
- Parameters:
params (dict) – Parameters available in the URL
- Returns:
dictionary of filtered params
- Return type:
custom_params (dict)
- get_localized_image(values)¶
Returns the requested language of a multilingual binary image dictionary.
- Parameters:
values (dict) – The multilingual values encoded as JSON.
- Returns:
Dictionary containing the localized representation.
- Return type:
dict of str
- get_localized_text(values, not_null=True)¶
Returns the requested language of a multilingual text element.
- Parameters:
values (str or dict) – The multilingual values encoded as JSON.
not_null (boolean) – Throws an error if there is no value for this language.
- Returns:
Dictionary containing the localized representation.
- Return type:
dict of str
- classmethod get_logo_ref(request, logo_code, language, image_dict)¶
Returns the link to the symbol of the specified logo.
- Parameters:
request (pyramid.request.Request) – The current request instance.
logo_code (str) – Code of logo, eg. bs or ch.
language (str) – language of extract.
image_dict (dict) – dict of image
- Returns:
The link to the symbol for the specified logo.
- Return type:
uri
- get_multilingual_text(values, not_null=True)¶
Returns the set language of a multilingual text element.
- Parameters:
values (str or dict) – The multilingual values encoded as JSON.
not_null (boolean) – Throws an error if there is no value for this language.
- Returns:
List of dictionaries containing the multilingual representation.
- Return type:
list of dict
- classmethod get_qr_code_ref(request, qr_code_ref)¶
Returns the link for the qr_code.
- Parameters:
request (pyramid.request.Request) – The current request instance.
qr_code_ref (str) – The string of qr-code url.
- Returns:
the link to the qr_code.
- Return type:
uri
- classmethod get_request(system)¶
Returns the request object if available.
- Parameters:
system (dict) – The available system properties.
- Returns:
The request object.
- Return type:
pyramid.request.Request or None
- classmethod get_response(system)¶
Returns the response object if available.
- Parameters:
system (dict) – The available system properties.
- Returns:
The response object.
- Return type:
pyramid.response.Response or None
- classmethod get_symbol_ref(request, record)¶
Returns the link to the symbol of the specified public law restriction.
- Parameters:
request (pyramid.request.Request) – The current request instance.
or (record (pyramid_oereb.core.records.plr.PlrRecord) – pyramid_oereb.core.records.view_service.LegendEntryRecord): The record of the public law restriction to get the symbol reference for.
- Returns:
The link to the symbol for the specified public law restriction.
- Return type:
uri
- static get_wms_url_params()[source]¶
Returns the list of additionally configured wms_url_params.
- Returns:
The configured wms_url_params.
- Return type:
(dict)
- static group_legal_provisions(legal_provisions)[source]¶
Group PLR documents which have the same title together.
- Parameters:
legal_provisions (list) – the list of legal provision documents for a PLR
- Returns:
the list of grouped legal provision documents
- Return type:
list
- property info¶
The passed renderer info object.
- Type:
pyramid.interfaces.IRendererInfo
- lpra_flatten(items)[source]¶
Flattens a list of PLRs.
- Parameters:
items (tuple) – a list of PLR documents.
- set_global_datetime(date_time)[source]¶
Set/initialize the class variable global_datetime with a given date-time :param value: date value of the format Y-m-dTH:M:S’ :type value: str
- static sort_by_index(elem)[source]¶
Provides the sort key for the supplied hint / law / legal provision element as a tuple consisting of: * index
Notes
index is defined by Interlis model OeREBKRM_V2_0 as range -1000..1000
“Index = None” if geolink_formatter processes entry from OEREBLEX that has no index
- Parameters:
elem (dict) – one element of the hints / laws / legal provisions list
- Returns:
sort key (tuple)
- sort_by_localized_text(multilingual_elements, value_accessor, not_null=True)¶
Sort a list of translated text elements alphabetically.
- Parameters:
multilingual_elements (list of dict) – A list of multilingual elements
elements. (or dict that contains multilingual)
value_accessor (function(dict)->string) – A function to access the text of a multilingual object to us to sort the list
- Returns:
- Alphabetically and language specific sorted elements
if translations exist or the list of unsorted element if sorting failed.
- Return type:
list of dict
- static sort_dict_list(legend_list, sort_keys)[source]¶
Sorts list of dictionaries by one or more sort keys. This function makes it possible to run test on the sorted list and assure the correctness of the sorting.
- Parameters:
legend_list (list(dict)) – list of legend dictionaries
sort_keys (tuple/any) – tuple of keys according to which the list of dictionaries will be
sorted (at least one is needed)
- Returns:
sorted list of legend dictionaries
- static sort_legal_provision(elem)[source]¶
- Provides the sort key for the supplied legal provision element as a tuple consisting of:
title
Official number
- Parameters:
elem (dict) – one element of the legal provision list
- Returns:
sort key (tuple)
- static sort_legend_elem(elem)[source]¶
- Provides the sort key for the supplied legend element as a tuple consisting of:
rank of the geometry type as defined in LEGEND_ELEMENT_SORT_ORDER
value of the geometry if available (AreaShare and LengthShare)
- Parameters:
elem (dict) – legend entry
- Returns:
sort key (tuple)
- static sort_restriction_on_landownership_documents(restriction_on_landownership)[source]¶
sort legal provisioning, hints and laws on restriction_on_landownership
- Parameters:
restriction_on_landownership (list(dict)) – restrictions on landownership
- static string_check(value)[source]¶
Check if the value given is a string. If it is not, assume it is a list and join the values using comma separator.
- Parameters:
value (str or list) – value to be treated.
- Returns:
converted value
- Return type:
(str)
- static unaccent_lower(text)¶
Replaces all special characters so that an alphabetical sorting can be done.
- Parameters:
text (str) – The text value.
- Returns:
The text value converted to lower case and striped of special characters.
- Return type:
new_text (str)