### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe_qgis »

# Module: safe_qgis.map

InaSAFE Disaster risk assessment tool developed by AusAid -
  InaSAFE map making module.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class `safe_qgis.map.``Map`(theIface)

  A class for creating a map.

  `composeMap`()

    Place all elements on the map ready for printing.

    Args:
      None
    Returns:
      None
    Raises:
      Any exceptions raised will be propagated.
  `drawDisclaimer`()

    Add a disclaimer to the composition.

    Args:
      None
    Returns:
      None
    Raises:
      None
  `drawGraticuleMask`(theTopOffset)

    A helper function to mask out graticule labels on the right side by over painting a white rectangle with white border on them.

    Args:
      theTopOffset - vertical offset at which the map should be drawn
    Returns:
      None
    Raises:
      None
  `drawHostAndTime`(theTopOffset)

    Add a disclaimer to the composition.

    Args:
      theTopOffset - vertical offset at which to begin drawing
    Returns:
      None
    Raises:
      None
  `drawImpactTitle`(theTopOffset)

    Draw the map subtitle - obtained from the impact layer keywords.

    Args:
      theTopOffset - vertical offset at which to begin drawing
    Returns:
      float - the height of the label as rendered
    Raises:
      None
  `drawLegend`(theTopOffset)

    Add a legend to the map using our custom legend renderer.

    Note

    getLegend generates a pixmap in 150dpi so if you set the map to a higher dpi it will appear undersized.

    Args:
      theTopOffset - vertical offset at which to begin drawing
    Returns:
      None
    Raises:
      None
  `drawLogo`(theTopOffset)

    Add a picture containing the logo to the map top left corner

    Args:
      theTopOffset - vertical offset at which the logo shoudl be drawn
    Returns:
      None
    Raises:
      None
  `drawMap`(theTopOffset)

    Add a map to the composition and return the compsermap instance.

    Args:
      theTopOffset - vertical offset at which the map should be drawn
    Returns:
      A QgsComposerMap instance is returned
    Raises:
      None
  `drawNativeScaleBar`(theComposerMap, theTopOffset)

    Draw a scale bar using QGIS’ native drawing - in the case of geographic maps, scale will be in degrees, not km.

    Args:
      None
    Returns:
      None
    Raises:
      Any exceptions raised by the InaSAFE library will be propagated.
  `drawPixmap`(thePixmap, theWidthMM, theLeftOffset, theTopOffset)

    Helper to draw a pixmap directly onto the QGraphicsScene. This is an alternative to using QgsComposerPicture which in some cases leaves artifacts under windows.

    The Pixmap will have a transform applied to it so that it is rendered with the same resolution as the composition.

    Args:

    > - thePixmap
    > - theWidthMM - desired width in mm of output on page
    > - theLeftOffset
    > - theTopOffset

    Returns:
      QGraphicsSceneItem is returned
    Raises:
      None
  `drawScaleBar`(theComposerMap, theTopOffset)

    Add a numeric scale to the bottom left of the map

    We draw the scale bar manually because QGIS does not yet support rendering a scalebar for a geographic map in km.

    See also

    `drawNativeScaleBar()`

    Args:
      - theComposerMap - QgsComposerMap instance used as the basis scale calculations.
      - theTopOffset - vertical offset at which the map should be drawn
    Returns:
      None
    Raises:
      Any exceptions raised by the InaSAFE library will be propagated.
  `drawTitle`(theTopOffset)

    Add a title to the composition.

    Args:
      theTopOffset - vertical offset at which the map should be drawn
    Returns:
      float - the height of the label as rendered
    Raises:
      None
  `getMapTitle`()

    Get the map title from the layer keywords if possible.

    Args:
      None
    Returns:
      None on error, otherwise the title
    Raises:
      Any exceptions raised by the InaSAFE library will be propagated.
  `printToPdf`(theFilename)

    Generate the printout for our final map.

    Args:
      theFilename: str - optional path on the file system to which the
        pdf should be saved. If None, a generated file name will be used.
    Returns:
      str: file name of the output file (equivalent to theFilename if
        provided).
    Raises:
      None
  `renderComposition`()

    Render the map composition to an image and save that to disk.

    Args:
      None
    Returns:
      tuple:
        - str: myImagePath - absolute path to png of rendered map
        - QImage: myImage - in memory copy of rendered map
        - QRectF: myTargetArea - dimensions of rendered map

      str: Absolute file system path to the rendered image.

    Raises:
      None
  `renderTemplate`(theTemplateFilePath, theOutputFilePath)

    Load a QgsComposer map from a template and render it

    Note

    THIS METHOD IS EXPERIMENTAL AND CURRENTLY NON FUNCTIONAL

    Args:
      theTemplateFilePath - path to the template that should be loaded. theOutputFilePath - path for the output pdf
    Returns:
      None
    Raises:
      None
  `setImpactLayer`(theLayer)

    Mutator for the impact layer that will be used for stats, legend and reporting.

    Args:
      theLayer - a valid QgsMapLayer
    Returns:
      None
    Raises:
      Any exceptions raised by the InaSAFE library will be propagated.
  `setupComposition`()

    Set up the composition ready for drawing elements onto it.

    Args:
      None
    Returns:
      None
    Raises:
      None
  `showComposer`()

    Show the composition in a composer view so the user can tweak it if they want to.

    Args:
      None
    Returns:
      None
    Raises:
      None
  `tr`(theString)

    We implement this since we do not inherit QObject.

    Args:
      theString - string for translation.
    Returns:
      Translated version of theString.
    Raises:
      no exceptions explicitly raised.
  `writeTemplate`(theTemplateFilePath)

    Write the current composition as a template that can be re-used in QGIS.

This module forms part of the InaSAFE tool.

### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe_qgis »