marche_a_lombre package

Submodules

marche_a_lombre.geo_definitions module

marche_a_lombre.marche_a_lombre module

class marche_a_lombre.marche_a_lombre.MarcheALOmbrePlugin(iface)[source]

Bases: object

initGui()[source]
initProcessing()[source]

Init Processing provider for QGIS >= 3.8.

open_help()[source]

Opens the documentation in a web browser

run()[source]
unload()[source]

marche_a_lombre.marche_a_lombre_algorithm module

class marche_a_lombre.marche_a_lombre_algorithm.MarcheALOmbreAlgorithm(*args: Any, **kwargs: Any)[source]

Bases: QgsProcessingAlgorithm

This is an example algorithm that takes a vector layer and creates a new identical one.

It is meant to be used as an example of how to create your own algorithms and explain methods and variables used to do it. An algorithm like this will be available in all elements, and there is not need for additional work.

All Processing algorithms should extend the QgsProcessingAlgorithm class.

ADJUST_FOR_SLOPE = 'ADJUST_FOR_SLOPE'
BUFFER_MODE = 'BUFFER_MODE'
DEPARTURE_TIME = 'DEPARTURE_TIME'
HIKING_SPEED = 'HIKING_SPEED'
INPUT = 'INPUT'
LOW_RES_MNS = 'LOW_RES_MNS'
OUTPUT = 'OUTPUT'
OUTPUT_CSV = 'OUTPUT_CSV'
OUTPUT_POINTS = 'OUTPUT_POINTS'
PICNIC_DURATION = 'PICNIC_DURATION'
PICNIC_POINT = 'PICNIC_POINT'
REVERSE_DIRECTION = 'REVERSE_DIRECTION'
createInstance()[source]
displayName()[source]

Returns the translated algorithm name, which should be used for any user-visible display of the algorithm name.

group()[source]

Returns the name of the group this algorithm belongs to. This string should be localised.

groupId()[source]

Returns the unique ID of the group this algorithm belongs to. This string should be fixed for the algorithm, and must not be localised. The group id should be unique within each provider. Group id should contain lowercase alphanumeric characters only and no spaces or other formatting characters.

helpUrl()[source]

Returns the URL to the help page

icon()[source]
initAlgorithm(config)[source]

Here we define the inputs and output of the algorithm, along with some other properties.

name()[source]

Returns the algorithm name, used for identifying the algorithm. This string should be fixed for the algorithm, and must not be localised. The name should be unique within each provider. Names should contain lowercase alphanumeric characters only and no spaces or other formatting characters.

postProcessAlgorithm(context, feedback)[source]
processAlgorithm(parameters, context, feedback)[source]

Here is where the processing itself takes place.

shortHelpString()[source]

Returns a brief description of the algorithm (appears in the right-hand panel of the dialog)

tr(string)[source]

marche_a_lombre.marche_a_lombre_provider module

class marche_a_lombre.marche_a_lombre_provider.MarcheALOmbreProvider(*args: Any, **kwargs: Any)[source]

Bases: QgsProcessingProvider

icon()[source]

Returns a QIcon which is used for the provider inside the Processing toolbox.

id()[source]

Returns the unique provider id, used for identifying the provider. This string should be a unique, short, character only string, eg “qgis” or “gdal”. This string should not be localised.

loadAlgorithms()[source]

Loads all algorithms belonging to this provider.

longName()[source]

Returns the a longer version of the provider name, which can include extra details such as version numbers. E.g. “Lastools LIDAR tools (version 2.2.1)”. This string should be localised. The default implementation returns the same string as name().

name()[source]

Returns the provider name, which is used to describe the provider within the GUI.

This string should be short (e.g. “Lastools”) and localised.

unload()[source]

Unloads the provider. Any tear-down steps required by the provider should be implemented here.

marche_a_lombre.mns_downloader module

Part of MarcheALOmbre QGIS Plugin Copyright (C) 2025 Yolanda Seifert Licensed under GPL v2+

class marche_a_lombre.mns_downloader.MNSDownloader(crs, transform_context, feedback=None)[source]

Bases: object

BASE_URL = 'https://data.geopf.fr/wms-r'
CAPABILITIES_URL = 'https://data.geopf.fr/wms-r?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities'
TILE_SIZE_PX = 4000
download_dual_quality_mns(trail_extent, high_res_path, low_res_path, trail_lat, input_crs, high_res=0.5, low_res=15.0)[source]

Download two MNS, one high quality around the trail and one low resolution with a greater extent for longer shadows

Parameters:
  • trail_extent (QgsRectangle) – Extent around the hiking trail

  • high_res_path (str) – Path to High-Res MNS

  • low_res_path (str) – Path to Low-Res MNS

  • trail_lat (float) – latitude of trail_extent center

  • input_crs (str) – Coordinate Reference System

  • high_res (float, optional) – High resolution. Defaults to 0.5.

  • low_res (float, optional) – Low resolution. Defaults to 30.0.

Returns:

True if download successful

Return type:

bool

get_layer_candidates(wgs84_point, is_mns=True)[source]

Parses capabilities to find the best layer for the location

Parameters:
  • wgs84_point (QgsPointXY) – point to query in WGS84 coordinates

  • is_mns (bool, optional) – True -> searches for Surface Models (MNS) False -> searches for Terrain Models (MNT)

Returns:

A list of layer candidates containing ‘name’ and ‘score’.

Return type:

list[dict]

log(message)[source]
read_tif(extent, resolution, output_path, input_crs, is_mns=True)[source]

Dowloads the MNS/MNT data for a specific extent and resolution

Parameters:
  • extent (QgsRectangle) – The area to download

  • resolution (float) – Pixel resolution in meters

  • output_path (str) – File path to save the GeoTIFF

  • input_crs (str) – epsg code of the CRS

  • is_mns (bool, optional) – True -> MNS (Surface), False -> MNT (Terrain). Defaults to True.

Returns:

True if successful, False otherwise

Return type:

bool

validate_raster_content(file_path)[source]

Validates the downloaded file by reading it

Parameters:

file_path (str) – Path to the file to check

Returns:

(isValid, statusMessage)

Return type:

tuple[bool, str]

marche_a_lombre.plugin_upload module

marche_a_lombre.shadow_calculator module

Part of MarcheALOmbre QGIS Plugin Copyright (C) 2025 Yolanda Seifert Licensed under GPL v2+

class marche_a_lombre.shadow_calculator.ShadowCalculator(high_res_path, low_res_path)[source]

Bases: object

calc_angle(trail_point, index_list, start_px, mns_data, resolution, min_dist_m=0)[source]

Calculates angles for all points in bresenham line at once using numpy

Parameters:
  • trail_point – trail point from where angles are calculated

  • index_list (int,int) – index list from bresenham line

  • start_px (int, int) – starting pixel (col, row)

  • mns_data (array) – MNS raster data

  • resolution (float) – resolution of the raster

  • min_dist_m (float) – minimum distance to check (overlap)

Returns:

list of angles, furthest distance checked

Return type:

(float[], float)

calculate_shadows(trail_points, max_dist_m=20000)[source]

Calculate if trail points are in shadow or sun along a trail. Iterates through every trail point, casts a line in the direction of the sun azimuth, and checks if any obstacle (from High-Res or Low-Res MNS) has an elevation angle greater than the sun’s current elevation

Parameters:
  • [TrailPoint] (trail_points) – trail points

  • max_dist_m (int, optional) – maximum distance in which an obstacle which could cause shadow is searched

Returns:

list of shadows (0=sunny,1=shady)

Return type:

int[]

draw_bresenham_line(x0, y0, max_dist_pixels, azimuth, rows, cols)[source]

Draw bresenham line on a raster with given starting point

Parameters:
  • x0 (int) – start x value

  • y0 (int) – start y value

  • max_dist_pixels (float) – maximum distance in pixels

  • azimuth (float) – direction angle of line in radians

  • rows (int) – number of rows in raster

  • cols (int) – number of columns in raster

Returns:

list of indices of resulting line

Return type:

(int,int)[]

marche_a_lombre.trail module

Part of MarcheALOmbre QGIS Plugin Copyright (C) 2025 Yolanda Seifert Licensed under GPL v2+

class marche_a_lombre.trail.Trail(max_sep, speed, source_crs, transform_context, feedback=None)[source]

Bases: object

calc_meridian_convergence(source_center)[source]

Calculates Meridian Convergence correction

Parameters:

source_center (QgsPointXY) – Center point of trail extent

Returns:

Convergence value

Return type:

float

calculate_times_with_slope(start_time, buffered)[source]

Recalculate arrival times for all trail points accounting for slope Must be called after sample_elevation() has populated z values

Uses Tobler’s hiking function: - Flat terrain: base speed - Uphill: speed decreases - Downhill: speed increases

Parameters:
  • start_time (QDateTime) – Start time for recalculating arrival times

  • buffer (bool) – If True, only calculate for center trail and copy times to left/right

log(message)[source]

Logs a message to the feedback object

Parameters:

message (str) – The message to log

process_trail(source_tracks, start_time, break_point, picnic_duration=0, reverse=False, buffer=False, project_crs=None, adjust_for_slope=False)[source]

Processes input GPX source tracks into a list of TrailPoint objects

Parameters:
  • source_tracks (QgsProcessingFeatureSource]) – Tracks from the gpx trail

  • start_time (QDateTime) – Hikers time of departure

  • break_point (QgsPointXY) – Coordinates of an optional picnic point

  • picnic_duration (float) – Duration of the hikers picnic break (minutes)

  • reverse (bool, optional) – Optional reversing of the trails direction. Defaults to False.

  • buffer (bool, optional) – Optional buffering so that 10m left and right of the trail buffer trails are formed. Defaults to False.

  • project_crs (QgsCoordinateReferenceSystem, optional) – The CRS for transforming break_point. Defaults to None.

  • adjust_for_slope (bool) – If to adjust speed based on terrain slope. Defaults to False.

Raises:

Exception – If coordinate transformation fails or no valid trail points are generated

reverse_trail(geometry)[source]

Reverses the order of the linestring

Parameters:

geometry (QgsGeometry) – The input linestring geometry

Returns:

New linestring with reversed vertices

Return type:

QgsGeometry

sample_elevation(mnt_path, start_time, buffered)[source]

Loads the MNT raster from the given path and updates the z-value of all trail points

Parameters:
  • mnt_path (str) – File path to the MNT raster

  • start_time (QDateTime) – Start time for recalculating arrival times

  • buffer (bool) – For time recalculation in calculate_times_with_slope

marche_a_lombre.trail_point module

Part of MarcheALOmbre QGIS Plugin Copyright (C) 2025 Yolanda Seifert Licensed under GPL v2+

class marche_a_lombre.trail_point.TrailPoint(lon, lat, x, y, z, datetime, convergence)[source]

Bases: object

calc_solar_pos(dt)[source]

Calculates Solar Azimuth and Elevation for a given place and time. Uses pvlib if installed

Parameters:

dt (datetime) – A datetime object

Returns:

(elevation, azimuth) in radians

Return type:

tuple (float)

Module contents

marche_a_lombre.classFactory(iface)[source]

Load MarcheALOmbre class from file MarcheALOmbre.

Parameters:

iface (QgsInterface) – A QGIS interface instance.