How heremaps/here-qgis-python works
Purpose and Runtime
This repository delivers a Python library plus a QGIS plugin that connects desktop QGIS to HERE platform services, especially Mapmaking and IML/VML datasets. It runs inside QGIS 3.34+ / QGIS 4 across Qt5/Qt6; it is not a standalone server or web application.
Key package boundaries are the reusable library in src/here_qgis/ and the QGIS-hosted integration in here_qgis_plugin/.
Plugin Entry and Registration
QGIS loads the plugin package and initializes its UI, providers, and actions through:
• here_qgis_plugin/__init__.py
• here_qgis_plugin/here_qgis_plugin.py
• here_qgis_plugin/here_qgis_provider.py
plugin_without_dependencies.py supports bootstrap behavior where dependencies are not yet present. The provider exposes the plugin’s Processing algorithms to QGIS, while the main plugin coordinates menus, toolbars, dialogs, and project/layer interaction.
HERE Service Access and Authentication
The shared API layer isolates HERE HTTP/service interactions from QGIS UI and processing code:
• src/here_qgis/api/api.py
• src/here_qgis/api/mapmaking.py
• src/here_qgis/platform/platform_auth.py
Service domains include basemaps, geocoding, routing, map projects, Mapmaking, and VML. Authentication and credentials are managed separately in src/here_qgis/platform/platform_credentials.py; interactive QGIS login is implemented in here_qgis_plugin/ui/here_iml/login/login.py. API clients are constructed for plugin use through here_qgis_plugin/api_factory.py.
QGIS UI Workflows
The Qt/QGIS UI layer presents interactive Mapmaking, IML, editing, query, upload, reload, and settings workflows:
• here_qgis_plugin/ui/here_iml/edit_map/edit_map.py
• here_qgis_plugin/ui/here_iml/mapmaking/mapmaking_project.py
• here_qgis_plugin/ui/here_iml/upload_map/upload_map.py
UI controllers operate on QGIS layers and delegate remote/data operations to processing tools or shared APIs. Authentication includes QML/WebEngine assets under here_qgis_plugin/ui/here_iml/login/, a material Qt runtime boundary.
Processing Toolbox
QGIS Processing algorithms are the primary non-interactive automation boundary, covering service access, layer lifecycle, conversion, and publishing:
• here_qgis_plugin/processing_toolbox/here_processing_base.py
• here_qgis_plugin/processing_toolbox/iml_load_layer.py
• here_qgis_plugin/processing_toolbox/iml_upload.py
Other algorithm families provide basemap, geocoding, routing, Mapmaking upload, VML queries/batches, token refresh, and reload behavior. They can be invoked from QGIS toolbox/UI flows and should keep QGIS parameter/result handling separate from src/here_qgis service models.
Geospatial Data Transformation and Storage
Nested HERE/map data is made editable in QGIS through flatten/unflatten transformations:
• src/here_qgis/flatten/flatten.py
• src/here_qgis/flatten/unflatten.py
• here_qgis_plugin/flatten/qgis_to_geojson.py
The main data path is remote HERE payload or GeoJSON → flattened QGIS-friendly layers/attributes → user edits/styles → unflattened GeoJSON/map representation → upload to HERE. Local layer-related persistence is abstracted by src/here_qgis/io/layer_storage.py.
Mapmaking Semantics, Validation, and Styling
Mapmaking-specific formats and presets define domain conversion and editing semantics:
• here_qgis_plugin/mom/osm_to_mom_10.py
• here_qgis_plugin/mapping_preset/Preset_MapMaking.json
• here_qgis_plugin/style_set/style_set_24_01_30/loadStyleSets.py
The plugin ships QGIS QML style assets for standard, comparison, violation, and analysis views. These are presentation/validation resources applied to loaded QGIS layers, rather than a separate rendering service.
Telemetry and External Dependencies
The plugin emits product/usage events through an Amplitude integration:
• src/here_qgis/amplitude_events/amplitude_client.py
• src/here_qgis/amplitude_events/api_usage_event.py
External boundaries are QGIS/Qt, HERE platform APIs, optional Qt WebEngine for login, and Amplitude telemetry. Dependency installation and compatibility handling reside in here_qgis_plugin/utils/dependencies.py, supporting the intended one-click QGIS plugin installation path.
Main entry points: edit_map.py Mapmaking & IML UI · here_qgis_plugin.py Plugin Controller · here_processing_base.py Processing Algorithms · api.py HERE Service API
Components 18
QGIS Plugin
QGIS-hosted UI and Processing integration.
- Plugin Entry · Registers and initializes the QGIS plugin.
here_qgis_plugin/__init__.py - Plugin Controller · Coordinates actions, menus, dialogs, and project interaction.
here_qgis_plugin/here_qgis_plugin.py - Processing Provider · Exposes HERE algorithms in the QGIS Processing toolbox.
here_qgis_plugin/here_qgis_provider.py - Mapmaking & IML UI · Interactive editing, project, upload, query, reload, and settings workflows.
here_qgis_plugin/ui/here_iml/edit_map/edit_map.py - Interactive Login · Runs QML/WebEngine-backed authentication inside QGIS.
here_qgis_plugin/ui/here_iml/login/login.py - Processing Algorithms · Automation for loading, conversion, querying, publishing, and reload.
here_qgis_plugin/processing_toolbox/here_processing_base.py - Plugin API Factory · Constructs shared API clients for plugin workflows.
here_qgis_plugin/api_factory.py - QGIS GeoJSON Adapter · Converts QGIS layer data to GeoJSON for publishing.
here_qgis_plugin/flatten/qgis_to_geojson.py - Mapmaking Presets & Styles · Defines Mapmaking conversion, validation, and layer presentation.
here_qgis_plugin/mom/osm_to_mom_10.py
Shared Library
Reusable HERE access and geospatial data logic.
- HERE Service API · Accesses basemap, geocoding, routing, Mapmaking, and VML services.
src/here_qgis/api/api.py - Mapmaking API · Encapsulates Mapmaking-specific remote operations.
src/here_qgis/api/mapmaking.py - Auth & Credentials · Manages HERE authentication and stored credentials.
src/here_qgis/platform/platform_auth.py - Flatten / Unflatten · Maps nested HERE data to editable QGIS-friendly attributes and back.
src/here_qgis/flatten/flatten.py - Layer Storage · Abstracts persistence for layer-related data.
src/here_qgis/io/layer_storage.py - Amplitude Events · Emits product and API-usage events.
src/here_qgis/amplitude_events/amplitude_client.py
External Boundaries
- QGIS / Qt Runtime · Hosts plugin UI, layers, projects, and Processing.
- HERE Platform APIs · Remote HERE datasets and service endpoints.
- Amplitude
Connections 23
- QGIS / Qt Runtime → Plugin Entry: loads
- Plugin Entry → Plugin Controller: initializes
- Plugin Controller → Processing Provider: registers
- Plugin Controller → Mapmaking & IML UI: opens
- Mapmaking & IML UI → Interactive Login: authenticates through
- Mapmaking & IML UI → Processing Algorithms: invokes
- Processing Provider → Processing Algorithms: publishes
- Plugin API Factory → HERE Service API: constructs
- Plugin API Factory → Auth & Credentials: configures
- Mapmaking & IML UI → Plugin API Factory: uses
- Processing Algorithms → HERE Service API: calls
- HERE Service API → Mapmaking API: includes
- HERE Service API → HERE Platform APIs: requests
- Mapmaking API → HERE Platform APIs: reads and uploads
- Interactive Login → Auth & Credentials: obtains credentials
- Auth & Credentials → HERE Platform APIs: authorizes
- Processing Algorithms → Flatten / Unflatten: transforms payloads
- Mapmaking & IML UI → QGIS GeoJSON Adapter: exports edits
- QGIS GeoJSON Adapter → Flatten / Unflatten: supplies GeoJSON
- Flatten / Unflatten → Layer Storage: persists layer data
- Mapmaking & IML UI → Mapmaking Presets & Styles: applies semantics and styles
- Plugin Controller → Amplitude Events: emits events
- Amplitude Events → Amplitude: sends events