iomapapps.pages_utils package

Submodules

iomapapps.pages_utils.map_explorer_utils module

Provides functions for managing the map explorer pages in the Streamlit app.

This module provides functions for managing geospatial data and Streamlit app settings, including loading and caching GeoJSON data, managing session state, and handling user interactions with map and interface elements in a Streamlit application.

iomapapps.pages_utils.map_explorer_utils.convert_timestamp(item: float | str | Timestamp) float | str

Convert a pandas Timestamp to an ISO formatted string.

If the item is a pandas.Timestamp, it is converted to an ISO 8601 formatted string. Otherwise, the item is returned unchanged.

Args:

item (float | str | Timestamp): The data item to check and possibly convert.

Returns:

float | str: An ISO formatted string if the item was a Timestamp,

otherwise the original item.

iomapapps.pages_utils.map_explorer_utils.get_place_color(marker_color: str, category: str) str

Determine the color of a map marker based on the category of the place and a base color.

This function assigns a base color to a place category, with variations based on the specific category to visually represent the population density and importance on a map.

Parameters:
  • marker_color (str) – The base color for the marker (e.g., ‘blue’, ‘green’, ‘red’).

  • category (str) –

    The category of the place (e.g., ‘Capital’, ‘Large City’, ‘City or Large Town’,

    ’Town or Village’).

Returns:

The specific color associated with the given category and base color. This color is used to visually represent the population density and importance on a map.

Return type:

str

iomapapps.pages_utils.map_explorer_utils.get_user_guide_page() str

Display the user guide for the current page.

This function returns a hardcoded user guide for the ‘Map Explorer’ page.

Returns:

str

Return type:

A formatted markdown string containing the user guide for the ‘Map Explorer’ page.

iomapapps.pages_utils.map_explorer_utils.initialize_settings() tuple[bool, str]

Initialize settings for a Streamlit app using Dynaconf.

Retrieves configuration parameters, creates necessary directories, and sets various settings in the Streamlit session state to be used throughout the app.

Returns:

Tuple[bool, str]

  • A boolean indicating if streamlit debug functions are enabled.

  • The directory path used as the working directory for the Streamlit application.

Return type:

A tuple containing:

iomapapps.pages_utils.map_explorer_utils.load_geojson_airports(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache airports from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_class_airspace(*, choice_local_data_source: bool, filename: str, class_b: bool, class_c: bool, class_d: bool, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache geographic data from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • class_b (bool) – Indicates if Class B airspace should be loaded.

  • class_c (bool) – Indicates if Class C airspace should be loaded.

  • class_d (bool) – Indicates if Class D airspace should be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_countries(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache country borders from a GeoJSON file.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_pja_airspace(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache geographic data from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_places(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache places from a GeoJSON file.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis, filtered by a specified bounding box.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_states(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache state borders from a GeoJSON file.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_sua_airspace(*, choice_local_data_source: bool, filename: str, type_code_a: bool, type_code_ada: bool, type_code_d: bool, type_code_moa: bool, type_code_p: bool, type_code_r: bool, type_code_w: bool, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache SUA airspace from a GeoJSON file.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Args:

choice_local_data_source (bool): Indicates if the local data source should be used. filename (str): The file path to the GeoJSON file to be loaded. type_code_a (bool): Filter option for type code ‘A’. type_code_ada (bool): Filter option for type code ‘ADA’. type_code_d (bool): Filter option for type code ‘D’. type_code_moa (bool): Filter option for type code ‘MOA’. type_code_p (bool): Filter option for type code ‘P’. type_code_r (bool): Filter option for type code ‘R’. type_code_w (bool): Filter option for type code ‘W’. bounds (Tuple[float, float, float, float]):

The bounds to filter the geographic data.

Returns:

GeoDataFrame

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

iomapapps.pages_utils.map_explorer_utils.load_geojson_tfr_airspace(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache TFR airspace from a GeoJSON file.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_weather_airsigmet(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache weather AIRMETs/SIGMETs from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_weather_metar(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache weather METARs from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_weather_station(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache weather stations from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.load_geojson_weather_taf(*, choice_local_data_source: bool, filename: str, bounds: tuple[float, float, float, float]) GeoDataFrame

Load and cache weather TAFs from a GeoJSON file using GeoPandas.

This function utilizes the caching capabilities provided by Streamlit to improve performance on subsequent calls with the same file path. It loads a GeoJSON file into a GeoDataFrame, which can be used for further geographic data manipulation and analysis.

Parameters:
  • choice_local_data_source (bool) – Indicates if the local data source should be used.

  • filename (str) – The file path to the GeoJSON file to be loaded.

  • bounds (Tuple[float, float, float, float]) – The bounds to filter the geographic data.

Returns:

A GeoDataFrame containing the geographic data loaded from the specified GeoJSON file, filtered to include only geometries that intersect with the provided bounding box.

Return type:

GeoDataFrame

iomapapps.pages_utils.map_explorer_utils.select_layer_bg_tile_server() tuple[str, str, str]

Select a background tile server from available options to enhance the aesthetics of the map.

This function utilizes a Streamlit interface for the user to select a background tile server. The chosen tile server provides essential map imagery and style, serving as an alternative or supplemental layer when VFR Raster Chart tiles are not available.

Returns:

A tuple containing the URL of the selected tile server and its corresponding attribution. The URL is used for fetching tiles, ensuring map coverage, while the attribution text provides necessary credits to the tile source.

Return type:

Tuple[str, str]

iomapapps.pages_utils.map_explorer_utils.select_layer_marker_color(default: str) str

Select a marker color from available options for displaying on a map.

This function allows the user to select a marker color for VFR Raster Charts, enhancing the map’s detail and aesthetics. The selection is made through a Streamlit interface.

Parameters:

default (str) – The default color to be selected.

Returns:

The chosen color code of the marker color.

Return type:

str

iomapapps.pages_utils.map_explorer_utils.setup_chrome_driver() WebDriver

Set up the Chrome driver for Selenium.

Returns:

WebDriver

Return type:

Configured Chrome WebDriver.

iomapapps.pages_utils.map_explorer_utils.setup_page_info(*, choice_about: bool | None, choice_ug_app: bool | None, choice_ug_page: bool | None) None

Set up the information section on the Streamlit page based on initial choices.

This function adds checkboxes for displaying information about the application, a user guide for the application, and a user guide for map exploration. The user’s choices are passed as parameters and stored in the session state. The corresponding information is displayed if the checkboxes are selected.

Parameters:
  • choice_about (bool | None) – Initial state of the ‘About this Application’ checkbox.

  • choice_ug_app (bool | None) – Initial state of the ‘User Guide: Application’ checkbox.

  • choice_ug_page (bool | None) – Initial state of the ‘User Guide: Map Exploration’ checkbox.

  • of (The checkboxes allow users to toggle visibility)

  • application (- About this)

  • Guide (- User)

  • Guide

iomapapps.pages_utils.map_explorer_utils.setup_sidebar(map_height_min: int, map_width_min: int) tuple[Any, ...]

Set up the sidebar for the Streamlit application.

This function initializes the sidebar with various UI components that handle user inputs and filtering controls. The sidebar serves as the primary navigation and interaction panel for users, allowing them to customize the map view based on these parameters dynamically.

Parameters:
  • map_height_min (int) – Minimum height for the map display in pixels.

  • map_width_min (int) – Minimum width for the map display in pixels.

Returns:

A tuple containing the state of each control element in the sidebar.

Return type:

Tuple[Any, …]

iomapapps.pages_utils.map_explorer_utils.setup_sidebar_layers(*, choice_local_data_source: bool) tuple[Any, ...]

Set up interactive filter controls in the Streamlit sidebar for map display settings.

Configures and displays UI elements to control various aspects of the map display, including layout settings, map dimensions, scale control, and geographic coordinates, allowing users to customize the map view dynamically based on these parameters.

Parameters:

choice_local_data_source (bool) – Initial state to determine if local data source should be used.

Returns:

A tuple containing the state of each control element related to the map display settings.

Return type:

Tuple[Any, …]

iomapapps.pages_utils.map_explorer_utils.wait_for_element(driver: WebDriver, by: By | str, value: str, timeout: int = 10) bool

Wait for an element to be present on the page within the specified timeout.

Args:

driver (WebDriver): The Selenium WebDriver instance. by (Union[By, str]): The method to locate elements (e.g., By.ID, By.XPATH). value (str): The value of the locator (e.g., the ID or XPath expression). timeout (int, optional): Maximum time to wait for the element to appear,

in seconds. Defaults to 10.

Returns:

bool: True if the element is found within the timeout, raises TimeoutError otherwise.

Raises:

TimeoutError: If the element is not found within the specified timeout.

Module contents

ioxpacore/pages_utils.