LeafletTab package

Layer Generation Dialog Module

This module provides dialog interfaces for heat network layer generation, including OSM data handling and building coordinate management.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

class districtheatingsim.gui.LeafletTab.layer_generation_dialog.LayerGenerationDialog(base_path, config_manager, parent=None)[source]

Bases: QDialog

Dialog for generating layers for heat network visualization.

accepted_inputs

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

request_map_coordinate

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(base_path, config_manager, parent=None)[source]

Initialize layer generation dialog.

Parameters:
  • base_path (str) – Base path for file operations

  • config_manager (ConfigManager) – Configuration manager instance

  • parent (QWidget or None) – Parent widget

initUI()[source]

Initialize user interface components.

Creates the complete dialog layout including data input section, coordinate management, and OSMnx advanced settings.

setVisualizationTab(visualization_tab)[source]

Set visualization tab reference.

Parameters:

visualization_tab (QWidget) – VisualizationTab instance

toggleLocationInputMode(index)[source]

Toggle input fields based on location mode.

Parameters:

index (int) – Selected mode index

toggleGenerationMode(index)[source]

Toggle street layer visibility based on generation mode.

Parameters:

index (int) – Selected generation mode index

toggleOSMnxAdvancedSettings()[source]

Toggle visibility of OSMnx advanced settings.

Switches between expanded and collapsed state of the advanced settings panel and updates the toggle button text accordingly.

setAllHighwayCheckboxes(checked)[source]

Set all highway checkboxes to checked or unchecked.

Parameters:

checked (bool) – True to check all, False to uncheck all

updateFilters()[source]

Update custom filter string based on selected highway types.

Builds an OSMnx-compatible filter string from the selected highway type checkboxes for network generation.

createFileInputLayout(lineEdit, button)[source]

Create file input layout.

Parameters:
  • lineEdit (QLineEdit) – File path input widget

  • button (QPushButton) – Browse button widget

Returns:

Layout containing file input widgets

Return type:

QHBoxLayout

createFileInput(default_path)[source]

Create file input widget with browse button.

Parameters:

default_path (str) – Default file path

Returns:

Line edit and button widgets

Return type:

tuple

openFileDialog(lineEdit)[source]

Open file dialog and update line edit.

Parameters:

lineEdit (QLineEdit) – Widget to update with selected file path

addCoordFromInput()[source]

Add coordinates from input field to table.

Parses coordinate input, transforms to EPSG:25833 if needed, and adds the coordinate pair to the table.

geocodeAndAdd()[source]

Geocode address and add coordinates to table.

Converts the address input to coordinates using geocoding service and adds result to coordinate table.

importCoordsFromCSV()[source]

Import coordinates from CSV file.

Opens file dialog to select CSV with UTM_X and UTM_Y columns and imports all coordinates to the table.

transform_coordinates(x, y, source_crs)[source]

Transform coordinates to EPSG:25833.

Parameters:
  • x (float) – X-coordinate

  • y (float) – Y-coordinate

  • source_crs (str) – Source coordinate system

Returns:

Transformed coordinates

Return type:

tuple

insertRowInTable(x, y)[source]

Insert coordinate row in table.

Parameters:
  • x (str) – X-coordinate

  • y (str) – Y-coordinate

deleteSelectedRow()[source]

Delete selected row from coordinates table.

Removes the currently selected coordinate row from the table.

clearAllCoordinates()[source]

Clear all coordinates from table.

Shows confirmation dialog and removes all coordinate rows from the table if confirmed.

copyCoordinates()[source]

Copy all coordinates to clipboard.

Exports all coordinate pairs from the table to the system clipboard in comma-separated format.

pasteCoordinates()[source]

Paste coordinates from clipboard.

Parses coordinate data from clipboard and adds valid coordinate pairs to the table.

saveCoordinatesToCSV()[source]

Save coordinates to CSV file.

Prompts user for save format (with or without addresses) and exports coordinates to a CSV file.

reverse_geocode(x, y)[source]

Simple reverse geocoding (returns formatted coordinates if geocoding fails).

Parameters:
  • x (float) – UTM X coordinate

  • y (float) – UTM Y coordinate

Returns:

Address string or formatted coordinates

Return type:

str

activateMapPicker()[source]

Activate map coordinate picker mode.

Enables interactive coordinate selection from the map view and updates button state to indicate waiting status.

receiveMapCoordinates(lat, lon)[source]

Receive coordinates from map click.

Parameters:
  • lat (float) – Latitude (WGS84)

  • lon (float) – Longitude (WGS84)

getInputs()[source]

Get dialog inputs.

Returns:

Dictionary containing input values

Return type:

dict

onAccept()[source]

Handle accept event.

Collects all input data and emits the accepted_inputs signal before closing the dialog.

Leaflet Tab Module

This module provides Leaflet map integration for district heating network visualization and interactive network generation.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

class districtheatingsim.gui.LeafletTab.leaflet_tab.GeoJsonReceiver(base_path='')[source]

Bases: QObject

Bridge for receiving GeoJSON data from JavaScript.

coordinate_picked

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

polygon_drawn

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

polygon_ready

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(base_path='')[source]

Initialize GeoJsonReceiver with base path.

Parameters:

base_path (str) – Base path for file dialogs

sendGeoJSONToPython(geojson_str)[source]

Receive GeoJSON from JavaScript and save to file.

Parameters:

geojson_str (str) – GeoJSON data as string

exportGeoJSON(geojsonString)[source]

Export GeoJSON with file dialog.

Parameters:

geojsonString (str) – GeoJSON data as string

exportUnifiedNetworkGeoJSON(geojsonString)[source]

Export edited network in unified format, preserving protected data.

This merges edited geometries from the map with protected building data to create a complete unified network GeoJSON.

Parameters:

geojsonString (str) – GeoJSON data from map (edited geometries)

saveEditedNetwork(geojsonString, filepath)[source]

Save edited network back to unified GeoJSON file.

Merges edited geometries from map with original protected data. This is called when user saves changes in the map.

Parameters:
  • geojsonString (str) – Edited GeoJSON data from map

  • filepath (str) – Path to save the network

receiveCoordinateFromMap(lat, lon)[source]

Receive coordinate from map click.

Parameters:
  • lat (float) – Latitude (WGS84)

  • lon (float) – Longitude (WGS84)

polygonReadyForCapture()[source]

Signal that polygon has been drawn and is ready for capture.

Emits polygon_ready signal to notify listeners.

receivePolygonFromMap(geojson_str)[source]

Receive polygon GeoJSON from map drawing.

Parameters:

geojson_str (str) – GeoJSON string of the drawn polygon

class districtheatingsim.gui.LeafletTab.leaflet_tab.VisualizationModel[source]

Bases: object

Data model for map visualization operations.

__init__()[source]

Initialize model with empty layers and base path.

Sets up initial state for visualization model.

set_base_path(base_path)[source]

Set base path for file operations.

Parameters:

base_path (str) – Base path to set

get_base_path()[source]

Get current base path.

Returns:

Current base path

Return type:

str

load_geojson(file_path)[source]

Load GeoJSON file as GeoDataFrame.

Parameters:

file_path (str) – Path to GeoJSON file

Returns:

Loaded GeoJSON data

Return type:

GeoDataFrame

create_geojson_from_csv(csv_file_path, geojson_file_path)[source]

Create GeoJSON from CSV with coordinates.

Parameters:
  • csv_file_path (str) – Path to CSV file

  • geojson_file_path (str) – Output GeoJSON path

get_resource_path(relative_path)[source]

Get absolute path to resource.

Parameters:

relative_path (str) – Relative path to resource

Returns:

Absolute path to resource

Return type:

str

class districtheatingsim.gui.LeafletTab.leaflet_tab.VisualizationPresenter(model, view, folder_manager, data_manager, config_manager)[source]

Bases: QObject

Presenter mediating between model and view for map visualization.

layers_imported

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(model, view, folder_manager, data_manager, config_manager)[source]

Initialize presenter with model, view, and managers.

Parameters:
  • model (VisualizationModel) – Model instance

  • view (VisualizationTabView) – View instance

  • folder_manager (FolderManager) – Folder manager instance

  • data_manager (DataManager) – Data manager instance

  • config_manager (ConfigManager) – Configuration manager instance

on_project_folder_changed(new_base_path)[source]

Update base path when project folder changes.

Parameters:

new_base_path (str) – New base path

open_geocode_addresses_dialog()[source]

Open dialog to select CSV file for geocoding addresses.

Displays file selection dialog and starts geocoding process if file is selected.

geocode_addresses(inputfilename)[source]

Start geocoding process for CSV file.

Parameters:

inputfilename (str) – Path to CSV file

on_geocode_done(fname)[source]

Handle successful geocoding completion.

Parameters:

fname (str) – Path to generated CSV file

on_geocode_error(error_message)[source]

Handle geocoding errors.

Parameters:

error_message (str) – Error message

load_csv_coordinates(fname=None)[source]

Load coordinates from CSV and add to map.

Parameters:

fname (str or None) – CSV file path

import_geojson()[source]

Import GeoJSON files and add to map.

Displays file selection dialog for GeoJSON files and adds selected layers to the map.

add_geojson_layer(filenames)[source]

Add GeoJSON layers to map.

Parameters:

filenames (list) – List of GeoJSON file paths

open_layer_generation_dialog()[source]

Open dialog for generating layers from data.

Creates and displays layer generation dialog with map picker support.

generate_and_import_layers(inputs)[source]

Start layer generation process.

Parameters:

inputs (dict) – Generation inputs

on_generation_done(results)[source]

Handle successful layer generation.

Parameters:

results (dict) – Generation results

on_generation_error(error_message)[source]

Handle layer generation errors.

Parameters:

error_message (str) – Error message

save_network()[source]

Save edited network back to unified GeoJSON file.

Requests current network data from JavaScript and saves to file.

activate_map_coordinate_picker()[source]

Activate map coordinate picker mode by calling JavaScript.

Enables interactive coordinate selection on the map.

open_osm_data_dialog()[source]

Open dialog for downloading OSM data.

Displays non-modal dialog allowing map interaction during OSM download.

open_osm_building_query_dialog()[source]

Open dialog for querying OSM building data.

Displays non-modal dialog for building queries with map interaction.

class districtheatingsim.gui.LeafletTab.leaflet_tab.VisualizationTabView(parent=None)[source]

Bases: QWidget

View component for map visualization interface.

__init__(parent=None)[source]

Initialize view with UI components.

Parameters:

parent (QWidget or None) – Parent widget

initUI()[source]

Initialize user interface components.

Sets up layout with menu bar, map view, and progress bar.

initMenuBar()[source]

Initialize menu bar with actions.

Creates file menu with geocoding, import, and network generation actions.

initMapView()[source]

Initialize map view with WebEngine and WebChannel.

Sets up web view configuration and Python-JavaScript bridge.

update_map_view(map_obj)[source]

Update map view with new data.

Parameters:

map_obj (object) – Map object to display

set_base_path(base_path)[source]

Set base path for GeoJsonReceiver.

Parameters:

base_path (str) – Base path for file dialogs

show_error_message(title, message)[source]

Show error message dialog.

Parameters:
  • title (str) – Dialog title

  • message (str) – Error message text

class districtheatingsim.gui.LeafletTab.leaflet_tab.VisualizationTabLeaflet(folder_manager, data_manager, config_manager, parent=None)[source]

Bases: QMainWindow

Main window integrating model, view, and presenter for map visualization.

__init__(folder_manager, data_manager, config_manager, parent=None)[source]

Initialize visualization tab with managers.

Parameters:
  • folder_manager (FolderManager) – Folder manager instance

  • data_manager (DataManager) – Data manager instance

  • config_manager (ConfigManager) – Configuration manager instance

  • parent (QWidget or None) – Parent widget

update_base_path(base_path)[source]

Update base path in model and view.

Parameters:

base_path (str) – New base path for project.

Net Generation Threads Module

This module provides threading classes for network generation, file import, and geocoding operations to maintain GUI responsiveness.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

class districtheatingsim.gui.LeafletTab.net_generation_threads.NetGenerationThread(inputs, base_path)[source]

Bases: QThread

Thread for generating district heating networks.

calculation_done

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

calculation_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(inputs, base_path)[source]

Initialize network generation thread.

Sets up the thread with input parameters for generating district heating networks using different algorithms.

Parameters:
  • inputs (dict) – Input parameters for network generation

  • base_path (str) – Base path for file operations

run()[source]

Run network generation process.

Executes the network generation based on the selected algorithm (OSMnx or traditional MST/Steiner) and emits signals on completion or error.

stop()[source]

Stop thread execution.

Requests interruption and waits for the thread to finish if it is currently running.

class districtheatingsim.gui.LeafletTab.net_generation_threads.OSMStreetDownloadThread(download_func, *args, **kwargs)[source]

Bases: QThread

Thread for downloading OSM street data.

download_done

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

download_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(download_func, *args, **kwargs)[source]

Initialize OSM street download thread.

Sets up the thread with a download function and its arguments for downloading OpenStreetMap street data asynchronously.

Parameters:
  • download_func (callable) – The download function to execute

  • args (tuple) – Positional arguments for download_func

  • kwargs (dict) – Keyword arguments for download_func

run()[source]

Run download process.

Executes the download function and emits the filepath on success or an error message on failure.

class districtheatingsim.gui.LeafletTab.net_generation_threads.OSMBuildingDownloadThread(download_func, *args, **kwargs)[source]

Bases: QThread

Thread for downloading OSM building data.

download_done

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

download_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(download_func, *args, **kwargs)[source]

Initialize OSM building download thread.

Sets up the thread with a download function and its arguments for downloading OpenStreetMap building data asynchronously.

Parameters:
  • download_func (callable) – The download function to execute

  • args (tuple) – Positional arguments for download_func

  • kwargs (dict) – Keyword arguments for download_func

run()[source]

Run download process.

Executes the download function and emits the filepath and building count on success or an error message on failure.

class districtheatingsim.gui.LeafletTab.net_generation_threads.FileImportThread(m, filenames, color)[source]

Bases: QThread

Thread for importing geospatial files.

calculation_done

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

calculation_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(m, filenames, color)[source]

Initialize file import thread.

Sets up the thread with map object, filenames, and styling color for importing geospatial files asynchronously.

Parameters:
  • m (object) – Map object for visualization

  • filenames (list) – List of filenames to import

  • color (str) – Color for visualization styling

run()[source]

Run file import process.

Reads geospatial files using geopandas and emits the results with styling information for visualization on success or an error message on failure.

stop()[source]

Stop thread execution.

Requests interruption and waits for the thread to finish if it is currently running.

class districtheatingsim.gui.LeafletTab.net_generation_threads.GeocodingThread(inputfilename)[source]

Bases: QThread

Thread for geocoding address data.

calculation_done

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

calculation_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(inputfilename)[source]

Initialize geocoding thread.

Sets up the thread with an input filename for processing geocoding operations asynchronously.

Parameters:

inputfilename (str) – Input filename for geocoding data

run()[source]

Run geocoding process.

Processes the geocoding data from the input file and emits the filename on success or an error message on failure.

stop()[source]

Stop thread execution.

Requests interruption and waits for the thread to finish if it is currently running.

class districtheatingsim.gui.LeafletTab.net_generation_threads.GeoJSONToCSVThread(geojson_file_path, output_file_path, default_values, model)[source]

Bases: QThread

Thread for converting GeoJSON to CSV with reverse geocoding.

progress_update

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

calculation_done

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

calculation_error

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(geojson_file_path, output_file_path, default_values, model)[source]

Initialize GeoJSON to CSV conversion thread.

Sets up the thread with file paths, default values, and model instance for converting GeoJSON building data to CSV with reverse geocoding.

Parameters:
  • geojson_file_path (str) – Input GeoJSON file path

  • output_file_path (str) – Output CSV file path

  • default_values (dict) – Default values for building parameters

  • model (ProjectModel) – Model instance with calculate_centroid method

run()[source]

Run GeoJSON to CSV conversion with reverse geocoding.

Reads GeoJSON building data, performs reverse geocoding for each building, and writes the results to a CSV file with progress updates.

stop()[source]

Stop thread execution.

Requests interruption and waits for the thread to finish if it is currently running.

OSM Dialogs Module

This module provides dialog interfaces for OSM data download and building queries through interactive user interfaces.

author:

Dipl.-Ing. (FH) Jonas Pfeiffer

class districtheatingsim.gui.LeafletTab.osm_dialogs.DownloadOSMDataDialog(base_path, config_manager, parent, parent_pres)[source]

Bases: QDialog

Dialog for downloading OSM street data with OSMnx.

__init__(base_path, config_manager, parent, parent_pres)[source]

Initialize OSM data download dialog.

Sets up the dialog with configuration for downloading OpenStreetMap street data using different methods and area selection types.

Parameters:
  • base_path (str) – Base path for file operations

  • config_manager (ConfigManager) – Configuration manager instance

  • parent (QWidget) – Parent widget

  • parent_pres (object) – Parent presenter instance

initUI()[source]

Initialize user interface components.

Creates and arranges all UI elements including area selection, method selection, filter options, and download controls.

setVisualizationTab(visualization_tab)[source]

Set visualization tab reference for map interaction.

Stores a reference to the visualization tab to enable polygon drawing and map-based area selection functionality.

Parameters:

visualization_tab (VisualizationTabLeaflet) – The visualization tab instance

toggleDownloadMethod(index)[source]

Toggle visibility based on download method.

Enables or disables area selection options depending on whether OSMnx or Overpass API is selected.

Parameters:

index (int) – Index of selected method

toggleAreaType(index)[source]

Toggle visibility based on area selection type.

Shows the appropriate input widgets based on the selected area type (city name, CSV, GeoJSON, or map drawing).

Parameters:

index (int) – Index of selected area type

setAllHighwayCheckboxes(checked)[source]

Set all highway checkboxes to checked or unchecked.

Applies the same checked state to all highway type filters.

Parameters:

checked (bool) – Target checked state

updateFilters()[source]

Update OSMnx filter based on selected highway types.

Builds a custom OSMnx filter string from the checked highway type checkboxes for network data download.

activateMapPolygonDrawing()[source]

Activate polygon drawing mode on map.

Enables the interactive polygon drawing functionality on the Leaflet map and connects signals for polygon completion.

onPolygonReady()[source]

Called when polygon has been drawn on the map.

Updates UI state and notifies the user that the polygon is ready and can be edited before starting the download.

getCapturedPolygonFromMap()[source]

Get the captured polygon from the map via JavaScript.

Returns:

Path to temporary GeoJSON file with polygon, or None if no polygon.

Return type:

str or None

clearCapturedPolygon()[source]

Clear the captured polygon from the map.

Removes the drawn polygon from the Leaflet map by calling JavaScript functionality.

createFileInput(default_path)[source]

Create file input widget with browse button.

Creates a QLineEdit and QPushButton combination for file path input with browse dialog functionality.

Parameters:

default_path (str) – Default file path

Returns:

Line edit and button widgets

Return type:

tuple

createFileInputLayout(lineEdit, button)[source]

Create file input layout.

Combines file path input widget and browse button into a horizontal layout for consistent UI presentation.

Parameters:
  • lineEdit (QLineEdit) – File path input widget

  • button (QPushButton) – Browse button widget

Returns:

Layout containing file input widgets

Return type:

QHBoxLayout

selectFile(lineEdit)[source]

Open file dialog and update line edit.

Displays a file selection dialog and updates the provided line edit widget with the selected file path.

Parameters:

lineEdit (QLineEdit) – Widget to update with selected file path

addTagField(key='', value='')[source]

Add tag field to layout.

Creates and adds a new key-value pair input row for OSM tag specification in the query dialog.

Parameters:
  • key (str) – Tag key

  • value (str) – Tag value

removeTagField()[source]

Remove last tag field from layout.

Removes the most recently added tag key-value pair from the tag specification form.

loadAllStandardTags()[source]

Load all standard tags into layout.

Populates the tag specification form with all predefined standard OSM tags for building queries.

loadSelectedStandardTag()[source]

Load selected standard tag into layout.

Adds the currently selected standard tag from the dropdown to the tag specification form.

startQuery()[source]

Start OSM data query and download.

Initiates the OpenStreetMap street data download process based on selected area type, method, and filter settings.

downloadWithOSMnx(filename, area_params)[source]

Download street network using OSMnx.

Downloads OpenStreetMap street network data using the OSMnx library based on various area selection methods (city name, CSV buffer, polygon).

Parameters:
  • filename (str) – Output file path

  • area_params (dict) – Dictionary with area type and file paths (no GUI access!)

class districtheatingsim.gui.LeafletTab.osm_dialogs.OSMBuildingQueryDialog(base_path, config_manager, parent, parent_pres, visualization_tab=None)[source]

Bases: QDialog

Dialog for querying OSM building data with multiple area selection modes.

__init__(base_path, config_manager, parent, parent_pres, visualization_tab=None)[source]

Initialize OSM building query dialog.

Sets up the dialog for downloading OpenStreetMap building data with multiple area selection modes and configuration options.

Parameters:
  • base_path (str) – Base path for file operations

  • config_manager (ConfigManager) – Configuration manager instance

  • parent (QWidget) – Parent widget

  • parent_pres (object) – Parent presenter instance

  • visualization_tab (LeafletTab) – Reference to visualization tab for polygon drawing

initUI()[source]

Initialize user interface components.

Creates and arranges all UI elements for area selection, tag specification, default values, and download controls.

toggleAreaType()[source]

Show/hide widgets based on selected area type.

Displays the appropriate input widgets for the selected area selection method (CSV, GeoJSON, or map drawing).

browseFile(line_edit, file_filter)[source]

Open file dialog for selecting input file.

Displays a file selection dialog with the specified filter and updates the line edit widget with the chosen file path.

Parameters:
  • line_edit (QLineEdit) – Line edit to update with selected path

  • file_filter (str) – File filter string for dialog

browseSaveFile(line_edit)[source]

Open file dialog for selecting output file.

Displays a save file dialog for GeoJSON output and updates the line edit widget with the chosen file path.

Parameters:

line_edit (QLineEdit) – Line edit to update with selected path

activateMapPolygonDrawing()[source]

Activate polygon drawing mode on the map.

Enables interactive polygon drawing on the Leaflet map for defining the area for building data download.

onPolygonReady()[source]

Handle polygon ready signal from map.

Updates UI state when the polygon drawing is completed on the map, allowing the user to proceed with the download.

getCapturedPolygonFromMap()[source]

Get the captured polygon from the map via JavaScript.

Returns:

Path to temporary GeoJSON file with polygon, or None if no polygon.

Return type:

str or None

clearCapturedPolygon()[source]

Clear the captured polygon from the map.

startQuery()[source]

Start OSM building data query and download.

downloadBuildings(filename, area_params)[source]

Download building data using Overpass API.

Downloads OpenStreetMap building data using the Overpass API based on various area selection methods (CSV buffer, GeoJSON polygon, map drawing).

Parameters:
  • filename (str) – Output file path

  • area_params (dict) – Dictionary with area type and file paths