Code Monkey home page Code Monkey logo

ortelius's Introduction

Ortelius

Showcase

Installation

Dependencies

These dependencies must be installed manually in OSGeo4W Shell:

  • docxtpl==0.16.7
  • jinja2==2.11.2
  • docx==0.2.4
  • qrcode==7.4.2
pip install docxtpl jinja2 docx qrcode

Basic usage

Getting help

Documentation

Jinja 2 placeholders and statements

  • {{ variable }}: An element from the dictionary named variable will be used to fill this placeholder
  • {% if <condition> %}, {% else %}, {% endif %}: An if statement can be built inside the template using these tags
  • {%- if <condition> -%}, {%- else -%}, {%- endif -%}: An if statement, but escaping the ENTER or the SHIFT+ENTER from MS Word
  • {% for <x> in <list> %}, {% endfor %}: A for statement can be built inside the template using these tags. Useful to iterate over child features

Structure

Each document has a complex dictionary with attributes extracted from the relational model centered in the reference layer. You can access all the attributes of the reference layer by calling the attribute name. Other dimenions are stores as dictionaries at the first level of the context dictionary, so:

  • Context
    • global
      • project_obj: A QgsProject object
      • mapCanvas: A QgsMapCanvas object
      • project_bbox: A list of 4 elements: xmin, ymin, xmax, ymax referring to the boundary of the project
      • global_vars: QGIS global variables
      • project_vars: QGIS project vairables
    • layer
      • layer_obj: QgsVectorLayer object
      • layer_type: The layer type
      • layer_geometry_type: The layer geometry type
      • layer_name: The layer name
      • layer_id: The layer unique ID
      • layer_source: The name of the source
      • layer_extent: A QgsRectangle object of the extent of the layer
      • layer_bbox: A list of 4 elements: xmin, ymin, xmax, ymax referring to the boundary of the layer
    • feature
      • feature_obj: QgsFeature object
      • feature_id: Feature ID (equivalent of $id in QGIS expression)
      • feature_wkt: Feature geometry as a well-known text string
      • feature_geojson: Feature geometry as GeoJSON string
      • feature_extent: QgsRectangle of the feature extent
      • feature_centroid: QgsPointXY object of the feature centroid
      • All the attributes of the feature are called by their name, not their alias
    • related layer name
      • layer
      • feature
      • related layer name and so on...
    • layouts
      • layout name
        • layout_obj: QgsPrintLayout object
        • layout_atlas: QgsLayoutAtlas object

Sample context dictionary

{
    "global": {
    },
    "layer": {
    },
    "feature": {
    },
    "IntLin": [
        {
            "layer": {...},
            "feature": {...},
            "IntLin__ATTACH": [
                {...},
                ...
            ]
        },
        {},
        {}
    ],
    "IntPoli": [...],
    "IntPto": [...],
    "LocAre": [...],
    "LocVer": [...],
    "Nascente": [...],
    "URUCUIA_PIALBE_V2__ATTACH": [...],
    "layouts": {
        "QgsMapaLocCad": {
            "layout_obj": "<qgis._core.QgsPrintLayout object at 0x000001566C6EB4C0>",
            "layout_atlas": "<qgis._core.QgsLayoutAtlas object at 0x000001566FE7B430>"
        },
        ...
    }
}

Filters

Filters are custom functions designed to extend the capabilities of the DOCX reports. Here is a list of the custom filters implemented by this plugin:

  • exportPrintLayout: Expects a layout dictionary, renders the map and returns a path pointing to the exported PNG figure. Parameters:
    • layout_dict: A layout dictionary
    • feature_dict: A feature dictionary
    • output_dir = None: If specified, export the layout to a folder. If not, export the layout to a temporary directory
  • exportPictureFromBase64: Expects a base64 string and returns the path of the exported image
    • base64string: A base64 string
    • filename: An output file name
    • output_dir: If specified, export the picture to a folder. If not, export the picture to a temporary directory
  • renderPictureFromPath: Expects a file path and returns an InlineImage object
    • path: The path of the image
    • width: If a number between 0 and 1 is specified, the width is a percentage of the page width available (without margins). If a number greater than 1 is specified, the width is a absolute value
    • height = None: If specified, forces a height value to the image. If not, preserves the aspect ratio of the image
  • xForMatch:
  • multipleCheckBoxes:

Further reading

ortelius's People

Contributors

rikalves avatar rikferreira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.