Exemple #1
0
    def action_checklist(self):
        """Action checklist for the itb earthquake fatality report.

        :returns: The action checklist
        :rtype: list
        """
        total_fatalities = self.total_fatalities
        total_displaced = self.total_evacuated
        rounded_displaced = format_int(population_rounding(total_displaced))
        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Action checklist'), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        if total_fatalities:
            checklist.add(tr(
                'Are there enough victim identification units available '
                'for %s people?') % (
                    format_int(population_rounding(total_fatalities))))
        if total_displaced:
            checklist.add(tr(
                'Are there enough shelters and relief items available for '
                '%s people?') % rounded_displaced)
        if rounded_displaced:
            checklist.add(tr(
                'If yes, where are they located and how will we '
                'distribute them?'))
        if total_displaced:
            checklist.add(tr(
                'If no, where can we obtain additional relief items '
                'from and how will we transport them?'))
        message.add(checklist)
        return message
Exemple #2
0
    def notes(self):
        """Return the notes section of the report.

        .. versionadded:: 3.2.1

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """

        hazard_terminology = tr('inundated')
        flood_value = [
            unicode(hazard_class)
            for hazard_class in self.hazard_class_mapping[self.wet]
        ]

        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Notes and assumptions'),
                              **styles.INFO_STYLE))

        checklist = m.BulletedList()
        checklist.add(
            tr('Roads are said to be %s when in a region with field "%s" in '
               '"%s" .' % (hazard_terminology, self.hazard_class_attribute,
                           ', '.join(flood_value))))
        checklist.add(
            tr('Roads are closed if they are %s.' % hazard_terminology))
        checklist.add(
            tr('Roads are open if they are not %s.' % hazard_terminology))

        message.add(checklist)
        return message
Exemple #3
0
    def emit_pre_run_message(self):
        """Inform the user about parameters before starting the processing."""
        title = tr('Processing started')
        details = tr(
            'Please wait - processing may take a while depending on your '
            'hardware configuration and the analysis extents and data.')
        # trap for issue 706
        try:
            exposure_name = self.exposure.name
            hazard_name = self.hazard.name
            # aggregation layer could be set to AOI so no check for that
        except AttributeError:
            title = tr('No valid layers')
            details = tr(
                'Please ensure your hazard and exposure layers are set '
                'in the question area and then press run again.')
            message = m.Message(LOGO_ELEMENT,
                                m.Heading(title, **WARNING_STYLE),
                                m.Paragraph(details))
            raise NoValidLayerError(message)
        text = m.Text(
            tr('This analysis will calculate the impact of'),
            m.EmphasizedText(hazard_name),
            tr('on'),
            m.EmphasizedText(exposure_name),
        )
        if self.aggregation is not None:
            try:
                aggregation_name = self.aggregation.name
                # noinspection PyTypeChecker
                text.add(
                    m.Text(tr('and bullet list the results'),
                           m.ImportantText(tr('aggregated by')),
                           m.EmphasizedText(aggregation_name)))
            except AttributeError:
                pass
        text.add('.')
        message = m.Message(LOGO_ELEMENT,
                            m.Heading(title, **PROGRESS_UPDATE_STYLE),
                            m.Paragraph(details), m.Paragraph(text))
        try:
            # add which postprocessors will run when appropriated
            # noinspection PyTypeChecker
            post_processors_names = self.parameters['postprocessors']
            post_processors = get_postprocessors(post_processors_names)
            message.add(
                m.Paragraph(tr('The following postprocessors will be used:')))

            bullet_list = m.BulletedList()

            for name, post_processor in post_processors.iteritems():
                bullet_list.add('%s: %s' % (get_postprocessor_human_name(name),
                                            post_processor.description()))
            message.add(bullet_list)

        except (TypeError, KeyError):
            # TypeError is for when function_parameters is none
            # KeyError is for when ['postprocessors'] is unavailable
            pass
        send_static_message(self, message)
Exemple #4
0
    def notes(self):
        """Return the notes section of the report.

        .. versionadded: 3.2.1

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """

        threshold = self.parameters['min threshold'].value
        hazard = self.hazard.keyword('hazard')
        hazard_terminology = tr('flooded')
        hazard_object = tr('flood')
        if hazard == 'flood':
            # Use flooded
            pass
        elif hazard == 'tsunami':
            hazard_terminology = tr('inundated')
            hazard_object = tr('water')

        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Notes and assumptions'),
                              **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(
            tr('Roads are %s when %s levels exceed %.2f m.' %
               (hazard_terminology, hazard_object, threshold)))
        checklist.add(
            tr('Roads are closed if they are %s.' % hazard_terminology))
        checklist.add(
            tr('Roads are open if they are not %s.' % hazard_terminology))

        message.add(checklist)
        return message
Exemple #5
0
def generate_expression_help(description, examples):
    """Generate the help message for QGIS Expressions.

    It will format nicely the help string with some examples.

    :param description: A description of the expression.
    :type description: basestring

    :param examples: A dictionnary of examples
    :type examples: dict

    :return: A message object.
    :rtype: message
    """
    help = m.Message()
    help.add(m.Paragraph(description))
    help.add(m.Paragraph(tr('Examples:')))
    bullets = m.BulletedList()
    for expression, result in examples.iteritems():
        if result:
            bullets.add(
                m.Text(m.ImportantText(expression), m.Text('→'),
                       m.Text(result)))
        else:
            bullets.add(m.Text(m.ImportantText(expression)))
    help.add(bullets)
    return help
    def action_checklist(self):
        """Action checklist for the itb earthquake fatality report.

        .. versionadded:: 3.2.1

        :returns: The action checklist
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Action checklist'), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(
            tr('Try to Identify which potential roads that able to '
               'access for evacuation and logistic distribution purpose. '
               'What type of transportation reliable to use in that order?'))
        checklist.add(
            tr('Identify what equipment needed to open access of '
               'affected roads. Where the resources or equipment to open '
               'access affected roads located? who/what department '
               'responsible to mobilize?'))
        checklist.add(
            tr('Which roads can be used to evacuate people or to '
               'distribute logistics?'))
        checklist.add(
            tr('What type of vehicles can use the unaffected roads?'))
        checklist.add(
            tr('What sort of equipment will be needed to reopen roads & '
               'where will we get it?'))
        checklist.add(
            tr('Which government department is responsible for supplying '
               'equipment ?'))
        message.add(checklist)
        return message
    def show_info(self):
        """Show usage text to the user."""
        header = html_header()
        footer = html_footer()
        string = header

        heading = m.Heading(self.tr('Shakemap Grid Importer'), **INFO_STYLE)
        body = self.tr(
            'This tool will convert an earthquake \'shakemap\' that is in '
            'grid xml format to a GeoTIFF file. The imported file can be used '
            'in InaSAFE as an input for impact functions that require and '
            'earthquake layer.  To use this tool effectively:'
        )
        tips = m.BulletedList()
        tips.add(self.tr(
            'Select a grid.xml for the input layer.'))
        tips.add(self.tr(
            'Choose where to write the output layer to.'
        ))
        tips.add(self.tr(
            'Choose the interpolation algorithm that should be used when '
            'converting the xml grid to a raster. If unsure keep the default.'
        ))
        tips.add(self.tr(
            'If you want to obtain shake data you can get it for free from '
            'the USGS shakemap site: '
            'http://earthquake.usgs.gov/earthquakes/shakemap/list.php?y=2013'))
        message = m.Message()
        message.add(heading)
        message.add(body)
        message.add(tips)
        string += message.to_html()
        string += footer

        self.webView.setHtml(string)
Exemple #8
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')

        message.add(m.Heading(tr('Notes and assumptions'),
                              **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(
            tr('Total population in the analysis area: %s') %
            population_rounding(self.total_population))
        checklist.add(
            tr('<sup>1</sup>People need evacuation if they are in a '
               'hazard zone.'))

        if self.no_data_warning:
            checklist.add(
                tr('The layers contained "no data" values. This missing data '
                   'was carried through to the impact layer.'))
            checklist.add(
                tr('"No data" values in the impact layer were treated as 0 '
                   'when counting the affected or total population.'))
        checklist.add(
            tr('All values are rounded up to the nearest integer in '
               'order to avoid representing human lives as fractions.'))
        checklist.add(
            tr('Population rounding is applied to all population '
               'values, which may cause discrepancies when adding value.'))

        message.add(checklist)
        return message
Exemple #9
0
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.2

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """

    message = m.Message()
    body = tr(
        'This tool will convert an earthquake \'shakemap\' that is in '
        'grid xml format to a GeoTIFF file. The imported file can be used '
        'in InaSAFE as an input for impact functions that require an '
        'earthquake layer.  To use this tool effectively:')
    tips = m.BulletedList()
    tips.add(tr('Select a grid.xml for the input layer.'))
    tips.add(tr('Choose where to write the output layer to.'))
    tips.add(
        tr('Choose the interpolation algorithm that should be used when '
           'converting the xml grid to a raster. If unsure keep the default.'))
    tips.add(
        tr('If you want to obtain shake data you can get download it free from '
           'the USGS shakemap site: '
           'http://earthquake.usgs.gov/earthquakes/shakemap/list.php?y=2013'))

    message.add(body)
    message.add(tips)
    return message
Exemple #10
0
    def action_checklist(self):
        """Breakdown by building type.

        :returns: The buildings breakdown report.
        :rtype: safe.messaging.Message
        """
        schools_closed = self.schools_closed
        hospitals_closed = self.hospitals_closed

        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Action checklist'), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(
            tr('Which structures have warning capacity (eg. sirens, speakers, '
               'etc.)?'))
        checklist.add(
            tr('Are the water and electricity services still operating?'))
        checklist.add(tr('Are the health centres still open?'))
        checklist.add(tr('Are the other public services accessible?'))
        checklist.add(tr('Which buildings will be evacuation centres?'))
        checklist.add(tr('Where will we locate the operations centre?'))
        checklist.add(
            tr('Where will we locate warehouse and/or distribution centres?'))
        checklist.add(tr('Are the schools and hospitals still active?'))
        if schools_closed > 0:
            checklist.add(
                tr('Where will the students from the %s closed schools '
                   'go to study?') % format_int(schools_closed))
        if hospitals_closed > 0:
            checklist.add(
                tr('Where will the patients from the %s closed hospitals go '
                   'for treatment and how will we transport them?') %
                format_int(hospitals_closed))
        message.add(checklist)
        return message
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.2

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    paragraph = m.Paragraph(m.Image('file:///%s/img/screenshots/'
                                    'batch-calculator-screenshot.png' %
                                    resources_path()),
                            style_class='text-center')
    message.add(paragraph)
    message.add(
        m.Paragraph(
            tr('Depending on which Impact Function you have chosen you have '
               'different options available for adjusting the parameters of the '
               'question you are asking. Some Impact Functions have more '
               'configurable Options than others. To open the Impact Function '
               'Configuration Dialog you need to click on the "Options ..." '
               'button next to the selected impact function paragraph in the '
               'InaSAFE dock. You can have up to 3 tabs visible:')))

    bullets = m.BulletedList()
    bullets.add(
        m.Text(
            m.ImportantText(tr('Options')),
            tr('- Depending in the Impact function you selected, you can '
               'influence the result of your question here (the Impact Function) '
               'by setting different values to the defaults that will be loaded. '
               'The options available will depend on the Impact Function you '
               'choose (some Impact Functions do not allow users to change the '
               'default parameters).')))
    bullets.add(
        m.Text(
            m.ImportantText(tr('Post-processors')),
            tr('- Takes the results from the Impact Function and calculates '
               'derivative indicators, for example if you have an affected '
               'population total, the Gender postprocessor will calculate gender '
               'specific indicators such as additional nutritional requirements '
               'for pregnant women.')))
    bullets.add(
        m.Text(
            m.ImportantText(tr('Minimum Needs')),
            tr('- If the analysis uses population exposure, InaSAFE calculates '
               'the minimum needs of the people affected by the impact scenario. '
               'You should refer to the minimum needs tool for configuring the '
               'global defaults used in these calculations. '),
            m.Image(
                'file:///%s/img/icons/'
                'show-minimum-needs.svg' % resources_path(),
                **SMALL_ICON_STYLE),
            tr(' This panel will let you override global defaults for a specific '
               'analysis run.')))
    message.add(bullets)
    return message
Exemple #12
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(
            m.Heading(tr('Notes and assumptions'), **styles.INFO_STYLE))
        checklist = m.BulletedList()

        # Thresholds for mmi breakdown.
        t0 = self.parameters['low_threshold'].value
        t1 = self.parameters['medium_threshold'].value
        t2 = self.parameters['high_threshold'].value
        is_nexis = self.is_nexis

        checklist.add(tr(
            'High hazard is defined as shake levels greater '
            'than %i on the MMI scale.') % t2)

        checklist.add(tr(
            'Medium hazard is defined as shake levels '
            'between %i and %i on the MMI scale.') % (t1, t2))

        checklist.add(tr(
            'Low hazard is defined as shake levels '
            'between %i and %i on the MMI scale.') % (t0, t1))

        if is_nexis:
            checklist.add(tr(
                'Values are in units of 1 million Australian Dollars'))

        message.add(checklist)
        return message
Exemple #13
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Notes and assumptions'),
                              **styles.INFO_STYLE))
        checklist = m.BulletedList()
        population = format_int(population_rounding(self.total_population))
        checklist.add(
            tr('Total population in the analysis area: %s') % population)
        checklist.add(
            tr('<sup>1</sup>People need evacuation if they are in a '
               'hazard zone.'))
        checklist.add(
            tr('Map shows population count in high, medium, and low '
               'hazard areas.'))
        checklist.add(
            tr('All values are rounded up to the nearest integer in '
               'order to avoid representing human lives as fractions.'))
        checklist.add(
            tr('Population rounding is applied to all population '
               'values, which may cause discrepancies when adding values.'))
        message.add(checklist)
        return message
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.2

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    message.add(m.Paragraph(tr(
        'This tool will calculated minimum needs for evacuated people. To '
        'use this tool effectively:'
    )))
    tips = m.BulletedList()
    tips.add(tr(
        'Load a point or polygon layer in QGIS. Typically the layer will '
        'represent administrative districts where people have gone to an '
        'evacuation center.'))
    tips.add(tr(
        'Ensure that the layer has an INTEGER attribute for the number of '
        'displaced people associated with each feature.'
    ))
    tips.add(tr(
        'Use the pick lists to select the layer and the population '
        'field and then press \'OK\'.'
    ))
    tips.add(tr(
        'A new layer will be added to QGIS after the calculation is '
        'complete. The layer will contain the minimum needs per district '
        '/ administrative boundary.'))
    message.add(tips)
    return message
Exemple #15
0
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 4.0.0

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    paragraph = m.Paragraph(
        m.Image(
            'file:///%s/img/screenshots/'
            'multi-buffer-screenshot.png' % resources_path()),
        style_class='text-center'
    )
    message.add(paragraph)
    message.add(m.Paragraph(tr(
        'This tool will generate a polygon layer by multi-buffering the input '
        'layer. '
        'To use this tool effectively:'
    )))
    tips = m.BulletedList()
    tips.add(tr(
        'Load a point or line layer in QGIS. Typically, the layer will '
        'represent hazard source such as volcano and river.'
    ))
    tips.add(tr(
        'Choose where to save the output layer to.'
    ))
    tips.add(tr(
        'Create one or more entries in the classes list, and define '
        'the appropriate distances for each buffer. You should give '
        'each buffer distance a corresponding name '
        'e.g. "high", "medium", "low". Click the add (+) button to '
        'record your entries.'
    ))
    tips.add(tr(
        'To remove the classification, select the classification you want to '
        'remove, then click the remove (-) button.'
    ))
    tips.add(tr(
        'Check the "launch keywords wizard" checkbox to launch the keywords '
        'creation wizard after the buffering is complete. If you want assign '
        'keywords later, uncheck the "launch keywords wizard" checkbox.'
    ))
    tips.add(tr(
        'A new layer will be added to QGIS after the buffering is complete. '
        'The layer will contain new buffer polygon(s) and the class name will '
        'be stored as an attribute of each polygon. If you check the '
        'launch keywords wizard checkbox, the keywords creation wizard will '
        'launch right after the buffering process has completed. '
        'You can assign the keywords to the output layer.'
    ))
    message.add(tips)
    return message
    def show_info(self):
        """Show usage info to the user."""
        # Read the header and footer html snippets
        header = html_header()
        footer = html_footer()

        string = header

        heading = m.Heading(self.tr('OSM Downloader'), **INFO_STYLE)
        body = self.tr(
            'This tool will fetch building (\'structure\') or road ('
            '\'highway\') data from the OpenStreetMap project for you. '
            'The downloaded data will have InaSAFE keywords defined and a '
            'default QGIS style applied. To use this tool effectively:'
        )
        tips = m.BulletedList()
        tips.add(self.tr(
            'Your current extent will be used to determine the area for which '
            'you want data to be retrieved. You can adjust it manually using '
            'the bounding box options below.'))
        tips.add(self.tr(
            'Check the output directory is correct. Note that the saved '
            'dataset will be called either roads.shp or buildings.shp (and '
            'associated files).'
        ))
        tips.add(self.tr(
            'By default simple file names will be used (e.g. roads.shp, '
            'buildings.shp). If you wish you can specify a prefix to '
            'add in front of this default name. For example using a prefix '
            'of \'padang-\' will cause the downloaded files to be saved as '
            '\'padang-roads.shp\' and \'padang-buildings.shp\'. Note that '
            'the only allowed prefix characters are A-Z, a-z, 0-9 and the '
            'characters \'-\' and \'_\'. You can leave this blank if you '
            'prefer.'
        ))
        tips.add(self.tr(
            'If a dataset already exists in the output directory it will be '
            'overwritten.'
        ))
        tips.add(self.tr(
            'This tool requires a working internet connection and fetching '
            'buildings or roads will consume your bandwidth.'))
        tips.add(m.Link(
            'http://www.openstreetmap.org/copyright',
            text=self.tr(
                'Downloaded data is copyright OpenStreetMap contributors'
                ' (click for more info).')
        ))
        message = m.Message()
        message.add(heading)
        message.add(body)
        message.add(tips)
        string += message.to_html()
        string += footer

        self.web_view.setHtml(string)
Exemple #17
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(
            m.Heading(tr('Notes and assumptions'), **styles.INFO_STYLE))
        checklist = m.BulletedList()

        # Thresholds for tsunami hazard zone breakdown.
        low_max = self.parameters['low_threshold']
        medium_max = self.parameters['medium_threshold']
        high_max = self.parameters['high_threshold']

        checklist.add(tr(
            'Dry zone is defined as non-inundated area or has inundation '
            'depth is 0 %s') % (low_max.unit.abbreviation)
        )

        checklist.add(tr(
            'Low tsunami hazard zone is defined as inundation depth is more '
            'than 0 %s but less than %.1f %s') % (
            low_max.unit.abbreviation,
            low_max.value,
            low_max.unit.abbreviation)
        )
        checklist.add(tr(
            'Moderate tsunami hazard zone is defined as inundation depth is '
            'more than %.1f %s but less than %.1f %s') % (
            low_max.value,
            low_max.unit.abbreviation,
            medium_max.value,
            medium_max.unit.abbreviation)
        )
        checklist.add(tr(
            'High tsunami hazard zone is defined as inundation depth is '
            'more than %.1f %s but less than %.1f %s') % (
            medium_max.value,
            medium_max.unit.abbreviation,
            high_max.value,
            high_max.unit.abbreviation)
        )
        checklist.add(tr(
            'Very high tsunami hazard zone is defined as inundation depth is '
            'more than %.1f %s') % (
            high_max.value, high_max.unit.abbreviation))

        checklist.add(tr(
            'Buildings are closed if they are in low, moderate, high, or very '
            'high tsunami hazard zone.'))
        checklist.add(tr(
            'Buildings are opened if they are in dry zone.'))
        message.add(checklist)
        return message
Exemple #18
0
    def _dict_to_row(keyword_value):
        """Helper to make a message row from a keyword where value is a dict.

        .. versionadded:: 3.2

        Use this when constructing a table from keywords to display as
        part of a message object. This variant will unpack the dict and
        present it nicely in the keyword value area as a nested table in the
        cell.

        We are expecting keyword value would be something like this:

            "{'high': ['Kawasan Rawan Bencana III'], "
            "'medium': ['Kawasan Rawan Bencana II'], "
            "'low': ['Kawasan Rawan Bencana I']}"

        Or by passing a python dict object with similar layout to above.

        i.e. A string representation of a dict where the values are lists.

        :param keyword_value: Value of the keyword to be rendered. This must
            be a string representation of a dict, or a dict.
        :type keyword_value: basestring, dict

        :returns: A table to be added into a cell in the keywords table.
        :rtype: safe.messaging.items.table
        """
        if isinstance(keyword_value, basestring):
            keyword_value = literal_eval(keyword_value)
        table = m.Table(style_class='table table-condensed')
        for key, value in keyword_value.items():
            row = m.Row()
            # First the heading
            if definition(key):
                name = definition(key)['name']
            else:
                name = tr(key.capitalize())
            row.add(m.Cell(m.ImportantText(name)))
            # Then the value. If it contains more than one element we
            # present it as a bullet list, otherwise just as simple text
            if isinstance(value, (tuple, list, dict, set)):
                if len(value) > 1:
                    bullets = m.BulletedList()
                    for item in value:
                        bullets.add(item)
                    row.add(m.Cell(bullets))
                elif len(value) == 0:
                    row.add(m.Cell(""))
                else:
                    row.add(m.Cell(value[0]))
            else:
                row.add(m.Cell(value))

            table.add(row)
        return table
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.2

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    body = tr('This tool will fetch building (\'structure\') or road ('
              '\'highway\') data from the OpenStreetMap project for you. '
              'The downloaded data will have InaSAFE keywords defined and a '
              'default QGIS style applied. To use this tool effectively:')
    tips = m.BulletedList()
    tips.add(
        tr('Your current extent, when opening this window, will be used to '
           'determine the area for which you want data to be retrieved.'
           'You can interactively select the area by using the '
           '\'select on map\' button - which will temporarily hide this '
           'window and allow you to drag a rectangle on the map. After you '
           'have finished dragging the rectangle, this window will '
           'reappear.'))
    tips.add(
        tr('Check the output directory is correct. Note that the saved '
           'dataset will be called either roads.shp or buildings.shp (and '
           'associated files).'))
    tips.add(
        tr('By default simple file names will be used (e.g. roads.shp, '
           'buildings.shp). If you wish you can specify a prefix to '
           'add in front of this default name. For example using a prefix '
           'of \'padang-\' will cause the downloaded files to be saved as '
           '\'padang-roads.shp\' and \'padang-buildings.shp\'. Note that '
           'the only allowed prefix characters are A-Z, a-z, 0-9 and the '
           'characters \'-\' and \'_\'. You can leave this blank if you '
           'prefer.'))
    tips.add(
        tr('If a dataset already exists in the output directory it will be '
           'overwritten.'))
    tips.add(
        tr('This tool requires a working internet connection and fetching '
           'buildings or roads will consume your bandwidth.'))
    tips.add(
        m.Link('http://www.openstreetmap.org/copyright',
               text=tr(
                   'Downloaded data is copyright OpenStreetMap contributors'
                   ' (click for more info).')))
    message.add(body)
    message.add(tips)
    return message
Exemple #20
0
def generate_insufficient_overlap_message(e, exposure_geoextent,
                                          exposure_layer, hazard_geoextent,
                                          hazard_layer, viewport_geoextent):
    """Generate insufficient overlap message.

    :param e: An exception.
    :type e: Exception

    :param exposure_geoextent: Extent of the exposure layer in the form
        [xmin, ymin, xmax, ymax] in EPSG:4326.
    :type exposure_geoextent: list

    :param exposure_layer: Exposure layer.
    :type exposure_layer: QgsMapLayer

    :param hazard_geoextent: Extent of the hazard layer in the form
        [xmin, ymin, xmax, ymax] in EPSG:4326.
    :type hazard_geoextent: list

    :param hazard_layer:  Hazard layer instance.
    :type hazard_layer: QgsMapLayer

    :param viewport_geoextent: Viewport extents
        as a list [xmin, ymin, xmax, ymax] in EPSG:4326.
    :type viewport_geoextent: list

    :return: An InaSAFE message object.
    :rtype: Message
    """
    description = tr(
        'There was insufficient overlap between the input layers and / or the '
        'layers and the viewable area. Please select two overlapping layers '
        'and zoom or pan to them or disable viewable area clipping in the '
        'options dialog. Full details follow:')
    message = m.Message(description)
    text = m.Paragraph(tr('Failed to obtain the optimal extent given:'))
    message.add(text)
    analysis_inputs = m.BulletedList()
    # We must use Qt string interpolators for tr to work properly
    analysis_inputs.add(tr('Hazard: %s') % (hazard_layer.source()))
    analysis_inputs.add(tr('Exposure: %s') % (exposure_layer.source()))
    analysis_inputs.add(
        tr('Viewable area Geo Extent: %s') % (get_unicode(viewport_geoextent)))
    analysis_inputs.add(
        tr('Hazard Geo Extent: %s') % (get_unicode(hazard_geoextent)))
    analysis_inputs.add(
        tr('Exposure Geo Extent: %s') % (get_unicode(exposure_geoextent)))
    analysis_inputs.add(tr('Details: %s') % (get_unicode(e)))
    message.add(analysis_inputs)

    return message
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.3

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()
    paragraph = m.Paragraph(m.Image('file:///%s/img/screenshots/'
                                    'petabencana-screenshot.png' %
                                    resources_path()),
                            style_class='text-center')
    message.add(paragraph)
    link = m.Link('https://petabencana.id', 'PetaBencana.id')
    body = m.Paragraph(
        tr('This tool will fetch current flood data for Jakarta from '), link)
    tips = m.BulletedList()
    tips.add(
        tr('Check the output directory is correct. Note that the saved '
           'dataset will be called jakarta_flood.shp (and associated files).'))
    tips.add(
        tr('If you wish you can specify a prefix to '
           'add in front of this default name. For example using a prefix '
           'of \'foo-\' will cause the downloaded files to be saved as e.g. '
           '\'foo-rw-jakarta-flood.shp\'. Note that the only allowed prefix '
           'characters are A-Z, a-z, 0-9 and the characters \'-\' and \'_\'. '
           'You can leave this blank if you prefer.'))
    tips.add(
        tr('If a dataset already exists in the output directory it will be '
           'overwritten if the "overwrite existing files" checkbox is ticked.')
    )
    tips.add(
        tr('If the "include date/time in output filename" option is ticked, '
           'the filename will be prefixed with a time stamp e.g. '
           '\'foo-22-Mar-2015-08-01-2015-rw-jakarta-flood.shp\' where the date '
           'timestamp is in the form DD-MMM-YYYY.'))
    tips.add(
        tr('This tool requires a working internet connection and fetching '
           'data will consume your bandwidth.'))
    tips.add(
        m.Link(production_api['help_url'],
               text=tr(
                   'Downloaded data is copyright the PetaBencana contributors'
                   ' (click for more info).')))
    message.add(body)
    message.add(tips)
    return message
Exemple #22
0
    def show_info(self):
        """Show usage info to the user."""
        # Read the header and footer html snippets
        header = html_header()
        footer = html_footer()

        string = header

        heading = m.Heading(self.tr('Impact Layer Merge Tool'), **INFO_STYLE)
        body = self.tr(
            'This tool will merge the outputs from two impact maps for the '
            'same area. The maps must be created using the same aggregation '
            'areas and same hazard. To use:')
        tips = m.BulletedList()
        tips.add(
            self.tr(
                'Run an impact assessment for an area using aggregation. e.g.'
                'Flood Impact on Buildings aggregated by municipal boundaries.'
            ))
        tips.add(
            self.
            tr('Run a second impact assessment for the same area using the same '
               'aggregation. e.g. Flood Impact on People aggregated by '
               'municipal boundaries.'))
        tips.add(
            self.
            tr('Open this tool and select each impact layer from the pick lists '
               'provided below.'))
        tips.add(
            self.tr(
                'Select the aggregation layer that was used to generate the '
                'first and second impact layer.'))
        tips.add(self.tr('Select an output directory.'))
        tips.add(
            self.
            tr('Check "Use customized report template" checkbox and select the '
               'report template file if you want to use your own template. Note '
               'that all the map composer components that are needed must be '
               'fulfilled.'))
        tips.add(
            self.tr('Click OK to generate the per aggregation area combined '
                    'summaries.'))
        message = m.Message()
        message.add(heading)
        message.add(body)
        message.add(tips)
        string += message.to_html()
        string += footer

        self.web_view.setHtml(string)
Exemple #23
0
def content():
    """Helper method that returns just the content.

    This method was added so that the text could be reused in the
    dock_help module.

    .. versionadded:: 3.2.2

    :returns: A message object without brand element.
    :rtype: safe.messaging.message.Message
    """
    message = m.Message()

    message.add(m.Paragraph(tr(
        'To start report generation you need to click on the Print... '
        'button in the buttons area. This will open the Impact report '
        'dialog which has three main areas.')))

    bullets = m.BulletedList()
    bullets.add(m.Text(
        m.ImportantText(tr('Area to print')),
        tr(
            ' - There are two options available. Choose Current extent if '
            'current canvas extent represents necessary area. Analysis '
            'extent will set extent of the report map to impact layer '
            'extent.'
           )))
    bullets.add(m.Text(
        m.ImportantText(tr('Template to use')),
        tr(
            ' - Here you can select desired template for your report. All '
            'templates bundled with InaSAFE are available here, plus '
            'templates from user-defined template directory (see Options '
            'for information how to set templates directory). It is also '
            'possible to select custom template from any location: just '
            'activate radiobutton under combobox and provide path to template '
            'using the "..." button.'
           )))
    bullets.add(m.Text(
        m.ImportantText(tr('Buttons area')),
        tr(
            ' - In this area you will find buttons to open the report as '
            'a PDF or in the QGIS print composer. You can also get help by '
            'clicking on the help button or using the close button to close '
            'the print dialog.'
        )))
    message.add(bullets)

    return message
    def format_notes(self):
        """Format notes..

        :returns: The notes.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(self.notes['title'], **styles.INFO_STYLE))

        checklist = m.BulletedList()
        for field in self.notes['fields']:
            checklist.add(field)

        message.add(checklist)
        return message
Exemple #25
0
def _citations_to_message(message, definition):
    citations = m.Message()
    bullets = m.BulletedList()
    for citation in definition['citations']:
        if citation['text'] in [None, '']:
            continue
        if citation['link'] in [None, '']:
            bullets.add(m.Paragraph(citation['text']))
        else:
            bullets.add(m.Paragraph(m.Link(citation['link'],
                                           citation['text'])))
    if not bullets.is_empty():
        citations.add(m.Paragraph(m.ImportantText(tr('Citations:'))))
        citations.add(bullets)
        message.add(citations)
Exemple #26
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(
            tr('Notes and assumptions'), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(tr(
            'Map shows buildings affected in each of these hazard '
            'zones: %s') % ', '.join(self.hazard_zones))
        message.add(checklist)
        return message
    def format_action_check_list(self):
        """Format action check list.

        :returns: The action check list.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(
            m.Heading(self.action_check_list['title'], **styles.INFO_STYLE))

        checklist = m.BulletedList(style_class='customBulletList',
                                   bullet_style='tick')
        for text in self.action_check_list['fields']:
            checklist.add(text)

        message.add(checklist)
        return message
Exemple #28
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Notes and assumptions'),
                              **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(
            tr('Map shows buildings affected in each of the volcano hazard '
               'polygons.'))
        names = tr('Volcanoes considered: %s.') % self.volcano_names
        checklist.add(names)
        message.add(checklist)
        return message
Exemple #29
0
    def notes(self):
        """Notes and caveats for the IF report.

        :returns: List of dicts containing notes.
        :rtype: list
        """
        message = m.Message(style_class='container')
        message.add(
            m.Heading(tr('Notes and assumptions'), **styles.INFO_STYLE))

        checklist = m.BulletedList()

        checklist.add(tr(
            'Total population in the analysis area: %s'
            ) % format_int(population_rounding(self.total_population)))

        checklist.add(tr(
            '<sup>1</sup>People are displaced if '
            'they experience and survive a shake level'
            'of more than 5 on the MMI scale.'))

        checklist.add(tr(
            'The fatality calculation assumes that '
            'no fatalities occur for shake levels below 4 '
            'and fatality counts of less than 50 are '
            'disregarded.'))

        if self.__class__ != ITBFatalityFunction:
            checklist.add(tr(
                'Fatality model is from Institut Teknologi Bandung 2012.'))
            checklist.add(tr(
                'Fatality model is from the Population Vulnerability '
                'Pager Model.'))

        checklist.add(tr('Map shows the estimation of displaced population.'))

        checklist.add(tr(get_needs_provenance_value(self.parameters)))
        checklist.add(tr(
            'All values are rounded up to the nearest integer in '
            'order to avoid representing human lives as fractions.'))
        checklist.add(tr(
            'Population rounding is applied to all population '
            'values, which may cause discrepancies when adding values.'))

        message.add(checklist)
        return message
Exemple #30
0
    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Notes and assumptions'),
                              **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(
            tr('Buildings are flooded when in a region with '
               'field "%s" in "%s".') %
            (self.hazard_class_attribute, ', '.join([
                unicode(hazard_class)
                for hazard_class in self.hazard_class_mapping[self.wet]
            ])))
        message.add(checklist)
        return message