safe.gui.tools.osm_downloader_dialog module

InaSAFE Disaster risk assessment tool developed by AusAid - Import Dialog.

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.gui.tools.osm_downloader_dialog.OsmDownloaderDialog(parent=None, iface=None)[source]

Bases: PyQt4.QtGui.QDialog, Ui_OsmDownloaderDialogBase

Downloader for OSM data.

accept()[source]

Do osm download and display it in QGIS.

drag_rectangle_on_map_canvas()[source]

Hide the dialog and allow the user to draw a rectangle.

get_checked_features()[source]

Create a tab with all checked features.

:return A list with all features which are checked in the UI. :rtype list

get_output_base_path(output_directory, output_prefix, feature_type, overwrite)[source]

Get a full base name path to save the shapefile.

Parameters:
  • output_directory (str) – The directory where to put results.
  • output_prefix (str) – The prefix to add for the shapefile.
  • feature_type (str) – What kind of features should be downloaded. Currently ‘buildings’, ‘building-points’ or ‘roads’ are supported.
  • overwrite (bool) – Boolean to know if we can overwrite existing files.
Returns:

The base path.

Return type:

str

static get_unique_file_path_suffix(file_path, separator='-', i=0)[source]

Return the minimum number to suffix the file to not overwrite one. Example : /tmp/a.txt exists.

  • With file_path=’/tmp/b.txt’ will return 0.
  • With file_path=’/tmp/a.txt’ will return 1 (/tmp/a-1.txt)
Parameters:
  • file_path (str) – The file to check.
  • separator (str) – The separator to add before the prefix.
  • i (int) – The minimum prefix to check.
Returns:

The minimum prefix you should add to not overwrite a file.

Return type:

int

help_toggled(flag)[source]

Show or hide the help tab in the stacked widget.

..versionadded: 3.2

Parameters:flag (bool) – Flag indicating whether help should be shown or hidden.
hide_help()[source]

Hide the usage info from the user.

New in version 3.2.

load_shapefile(feature_type, base_path)[source]

Load downloaded shape file to QGIS Main Window.

Parameters:
  • feature_type (str) – What kind of features should be downloaded. Currently ‘buildings’, ‘building-points’ or ‘roads’ are supported.
  • base_path (str) – The base path of the shape file (without extension).
Raises:

FileMissingError - when buildings.shp not exist

on_directory_button_clicked()[source]

Show a dialog to choose directory.

populate_countries()[source]

Populate the combobox about countries and levels.

reject()[source]

Redefinition of the reject() method to remove the rectangle selection tool. It will call the super method.

require_directory()[source]

Ensure directory path entered in dialog exist.

When the path does not exist, this function will ask the user if he want to create it or not.

Raises:CanceledImportDialogError - when user choose ‘No’ in the question dialog for creating directory.
restore_state()[source]

Read last state of GUI from configuration file.

save_state()[source]

Store current state of GUI to configuration file

show_help()[source]

Show usage info to the user.

update_extent(extent)[source]

Update extent value in GUI based from an extent.

Parameters:extent (list) – A list in the form [xmin, ymin, xmax, ymax] where all coordinates provided are in Geographic / EPSG:4326.
update_extent_from_map_canvas()[source]

Update extent value in GUI based from value in map.

Note

Delegates to update_extent()

update_extent_from_rectangle()[source]

Update extent value in GUI based from the QgsMapTool rectangle.

Note

Delegates to update_extent()

update_helper_political_level()[source]

To update the helper about the country and the admin_level.