qgreenland/util/qgis.py
def _add_layer_metadata(map_layer, layer_cfg):
    """Add layer metadata.

    Renders a jinja template to a temporary file location as a valid QGIS qmd
    metadata file. This metadata then gets associated with the `map_layer` using
    its `loadNamedMetadata` method. This metadata gets written to the project
    file when the layer is added to the `project`.
    """
    # Load/render the template.
    template_path = os.path.join(ASSETS_DIR, 'templates', 'metadata.jinja')
    with open(template_path, 'r') as f:
        qmd_template_str = ' '.join(f.readlines())

    # Set the layer's tooltip
    tooltip = build_layer_tooltip(layer_cfg)
    map_layer.setAbstract(tooltip)

    # Render the qmd template.
    abstract = build_layer_abstract(layer_cfg)
    layer_extent = map_layer.extent()
    qmd_template = Template(qmd_template_str)
    rendered_qmd = qmd_template.render(
        abstract=abstract,
        title=layer_cfg['title'],
        minx=layer_extent.xMinimum(),
        miny=layer_extent.yMinimum(),
        maxx=layer_extent.xMaximum(),
        maxy=layer_extent.yMaximum()
    )

    # Write the rendered tempalte to a temporary file
    # location. `map_layer.loadNamedMetadata` expects a string URI corresponding
    # to a file on disk.
    with tempfile.NamedTemporaryFile('w') as temp_file:
        temp_file.write(rendered_qmd)
        temp_file.flush()
        map_layer.loadNamedMetadata(temp_file.name)
Add layer metadata.

    Renders a jinja template to a temporary file location as a valid QGIS qmd
    metadata file. This metadata then gets associated with the `map_layer` using
    its `loadNamedMetadata` method. This metadata gets written to the project
    file when the layer is added to the `project`.
    
Add layer metadata.
Renders a jinja template to a temporary file location as a valid QGIS qmd
metadata file. This metadata then gets associated with the `map_layer` using
its `loadNamedMetadata` method. This metadata gets written to the project
file when the layer is added to the `project`.
Add layer metadata . Renders a jinja template to a temporary file location as a valid QGIS qmd metadata file . This metadata then gets associated with the ` map_layer ` using its ` loadNamedMetadata ` method . This metadata gets written to the project file when the layer is added to the ` project ` .
def _add_layer_metadata(map_layer, layer_cfg):
    template_path = os.path.join(ASSETS_DIR, 'templates', 'metadata.jinja')
    with open(template_path, 'r') as f:
        qmd_template_str = ' '.join(f.readlines())
    tooltip = build_layer_tooltip(layer_cfg)
    map_layer.setAbstract(tooltip)
    abstract = build_layer_abstract(layer_cfg)
    layer_extent = map_layer.extent()
    qmd_template = Template(qmd_template_str)
    rendered_qmd = qmd_template.render(
        abstract=abstract,
        title=layer_cfg['title'],
        minx=layer_extent.xMinimum(),
        miny=layer_extent.yMinimum(),
        maxx=layer_extent.xMaximum(),
        maxy=layer_extent.yMaximum()
    )
    with tempfile.NamedTemporaryFile('w') as temp_file:
        temp_file.write(rendered_qmd)
        temp_file.flush()
        map_layer.loadNamedMetadata(temp_file.name)
def _add_layer_metadata ( map_layer , layer_cfg ) : template_path = os . path . join ( ASSETS_DIR , 'templates' , 'metadata.jinja' ) with open ( template_path , 'r' ) as f : qmd_template_str = ' ' . join ( f . readlines ( ) ) tooltip = build_layer_tooltip ( layer_cfg ) map_layer . setAbstract ( tooltip ) abstract = build_layer_abstract ( layer_cfg ) layer_extent = map_layer . extent ( ) qmd_template = Template ( qmd_template_str ) rendered_qmd = qmd_template . render ( abstract = abstract , title = layer_cfg [ 'title' ] , minx = layer_extent . xMinimum ( ) , miny = layer_extent . yMinimum ( ) , maxx = layer_extent . xMaximum ( ) , maxy = layer_extent . yMaximum ( ) ) with tempfile . NamedTemporaryFile ( 'w' ) as temp_file : temp_file . write ( rendered_qmd ) temp_file . flush ( ) map_layer . loadNamedMetadata ( temp_file . name )
Add layer metadata.
Add layer metadata .
"""Add layer metadata.

    Renders a jinja template to a temporary file location as a valid QGIS qmd
    metadata file. This metadata then gets associated with the `map_layer` using
    its `loadNamedMetadata` method. This metadata gets written to the project
    file when the layer is added to the `project`.
    """ # Load/render the template. # Set the layer's tooltip # Render the qmd template. # Write the rendered tempalte to a temporary file # location. `map_layer.loadNamedMetadata` expects a string URI corresponding # to a file on disk.
map_layer
layer_cfg