61 lines
3.2 KiB
Python
61 lines
3.2 KiB
Python
# geoelevation/map_viewer/__init__.py
|
|
"""
|
|
GeoElevation Map Viewer Subpackage.
|
|
|
|
This package provides the components necessary for displaying and interacting
|
|
with tiled web maps (e.g., OpenStreetMap) within the main GeoElevation application.
|
|
It is designed to run in a separate process to keep the main GUI responsive.
|
|
|
|
Key components include:
|
|
- GeoElevationMapViewer: Orchestrates the map display, data fetching for tiles,
|
|
user interaction (mouse clicks), and communication with
|
|
the main application GUI.
|
|
- MapDisplayWindow: Manages the OpenCV window used for rendering the map and
|
|
capturing mouse events.
|
|
- MapTileManager: Handles the logic for retrieving map tiles from a specified
|
|
map service, including caching and stitching tiles together.
|
|
- MapServices: Defines an interface (BaseMapService) and concrete implementations
|
|
(e.g., OpenStreetMapService) for different map tile providers.
|
|
- MapUtils: Contains utility functions for common geographic and map-tile
|
|
related calculations (e.g., bounding boxes, tile ranges).
|
|
"""
|
|
|
|
# To make the main orchestrator class easily importable from this subpackage,
|
|
# e.g., `from geoelevation.map_viewer import GeoElevationMapViewer`
|
|
# We perform a guarded import here. If critical dependencies for GeoElevationMapViewer
|
|
# (like OpenCV, Pillow, which are checked in geo_map_viewer.py itself) are missing,
|
|
# this import might fail. The main application (elevation_gui.py) has its own
|
|
# checks for MAP_VIEWER_SYSTEM_AVAILABLE to handle this gracefully.
|
|
|
|
try:
|
|
from .geo_map_viewer import GeoElevationMapViewer
|
|
# You could also expose other key classes or factory functions if desired:
|
|
# from .map_services import OpenStreetMapService, get_map_service_instance
|
|
# from .map_utils import get_bounding_box_from_center_size
|
|
|
|
# Define what `from geoelevation.map_viewer import *` will import.
|
|
# It's generally good practice to be explicit.
|
|
__all__ = [
|
|
"GeoElevationMapViewer",
|
|
# "OpenStreetMapService",
|
|
# "get_map_service_instance",
|
|
# "get_bounding_box_from_center_size",
|
|
# Add other names here if you want them to be part of the public API
|
|
# of this sub-package when imported with '*'.
|
|
]
|
|
|
|
except ImportError as e_map_viewer_init_import:
|
|
# This might happen if, for example, OpenCV is not installed, and thus
|
|
# geo_map_viewer.py (or one of its imports like map_display.py) fails to load.
|
|
# The main application GUI (elevation_gui.py) has more robust checks.
|
|
import logging
|
|
# Use the name of this __init__.py file for the logger
|
|
logger_init = logging.getLogger(__name__) # Will be 'geoelevation.map_viewer'
|
|
logger_init.warning(
|
|
f"Could not import GeoElevationMapViewer or other components from the "
|
|
f"map_viewer subpackage, possibly due to missing dependencies (e.g., OpenCV, Pillow): {e_map_viewer_init_import}. "
|
|
f"Map functionality might be limited if this subpackage is used directly."
|
|
)
|
|
# If the core component fails to import, __all__ should reflect that
|
|
# nothing (or very little) is available.
|
|
__all__ = [] |