wolfhece._builtin_plugins.dtm_wallonia_1m.companion =================================================== .. py:module:: wolfhece._builtin_plugins.dtm_wallonia_1m.companion .. autoapi-nested-parse:: DTM Wallonie 1 m/2 m — built-in companion plugin. Loads the Wallonia 1 m DTM (LIDAXE) raster for the viewer's current zoom extent and adds it to the active WolfMapViewer as a *WolfArray*. Workflow -------- 1. On first use the plugin downloads the tile-index shapefile via :func:`~wolfhece.pydownloader.toys_dtm_wallonia_1m`. 2. When "Charger depuis le zoom actuel" is triggered it: - reads the current view bounds from the viewer, - delegates extraction to :class:`~wolfhece.services.dtm_wallonia.DtmWalloniaService`, - inserts the resulting :class:`~wolfhece.wolf_array.WolfArray` in the viewer tree. Module Contents --------------- .. py:data:: _logger .. py:data:: _DtmWalloniaTiles .. py:class:: DtmWalloniaModel Bases: :py:obj:`wolfhece.plugins.abc.AbstractCompanionModel` .. autoapi-inheritance-diagram:: wolfhece._builtin_plugins.dtm_wallonia_1m.companion.DtmWalloniaModel :parts: 1 :private-bases: Pure plugin state independent from viewer/wx/OpenGL APIs. This model intentionally stores only business/session state so that the UI companion remains focused on event wiring and viewer integration. .. py:attribute:: load_count :type: int :value: 0 .. py:attribute:: last_layer_id :type: str | None :value: None .. py:attribute:: last_bounds :type: tuple[float, float, float, float] | None :value: None .. py:attribute:: _service :type: wolfhece.services.dtm_wallonia.DtmWalloniaService | None :value: None .. py:method:: reset() -> None Reset transient domain state (no-op by default). .. py:method:: next_layer_id() -> str .. py:method:: is_valid_extent(xmin: float, xmax: float, ymin: float, ymax: float) -> bool :staticmethod: .. py:property:: has_service :type: bool Whether the cached DTM service is already initialized. .. py:method:: ensure_service() -> wolfhece.services.dtm_wallonia.DtmWalloniaService Return the cached DTM service, creating it if needed. .. py:method:: force_download_index() -> str Force (re-)download of the tile-index shapefile. .. py:method:: get_dtm_1m(bounds_vec: wolfhece.pyvertexvectors.vector, force: bool = False) -> wolfhece.wolf_array.WolfArray Return 1m DTM for the given bounds vector. .. py:method:: get_dtm_2m(bounds_vec: wolfhece.pyvertexvectors.vector, force: bool = False) -> wolfhece.wolf_array.WolfArray Return 2m DTM for the given bounds vector. .. py:method:: get_dtm_1m_xx_yy(xmin: float, xmax: float, ymin: float, ymax: float, force: bool = False) -> wolfhece.wolf_array.WolfArray Return 1m DTM for raw bounds. .. py:method:: get_dtm_2m_xx_yy(xmin: float, xmax: float, ymin: float, ymax: float, force: bool = False) -> wolfhece.wolf_array.WolfArray Return 2m DTM for raw bounds. .. py:method:: load_from_extent(xmin: float, xmax: float, ymin: float, ymax: float, force: bool = False) -> tuple[wolfhece.wolf_array.WolfArray, str] Execute the domain workflow for one extent. 1. Validate extent, 2. Build closed bounds vector, 3. Fetch DTM, 4. Allocate next layer id. .. py:class:: DtmWallonia1mCompanion Bases: :py:obj:`wolfhece.plugins.abc.AbstractUICompanion` .. autoapi-inheritance-diagram:: wolfhece._builtin_plugins.dtm_wallonia_1m.companion.DtmWallonia1mCompanion :parts: 1 :private-bases: Companion plugin that loads Wallonia DTM for the current zoom. Menu: **DTM Wallonie 1m** * *Load from current zoom* — adds a 1 m DTM layer for the current view. * Public helpers also expose 2 m DTM (mean-rebinned from 1 m). * *Télécharger l'index des tuiles* — (re-)downloads only the tile-index shapefile, useful for an initial setup or refresh. .. py:method:: create_model() -> DtmWalloniaModel Create the companion's optional pure business model. Override this to keep domain logic independent from UI concerns while staying in the same plugin module (companion + model in one file). Default implementation returns ``None``. .. py:property:: model_state :type: DtmWalloniaModel .. py:method:: menu_spec() Declare the companion's menu as a ``(title, items)`` pair. Override this to add a menu without writing wx code:: def menu_spec(self) -> tuple[str, list[MenuEntry]] | None: return (_('My Tool'), [ MenuItem(_('Run'), self._on_run, _('Execute the tool')), SEPARATOR, SubMenuSpec(_('Settings'), [ MenuItem(_('Configure…'), self._on_configure), ]), ]) Return ``None`` (the default) when no top-level menu is needed. Called automatically by :meth:`build`. Do not call directly. .. py:method:: start() -> None Programmatic activation — load DTM for the current view. .. py:method:: _on_load_from_zoom(_ctx: wolfhece._viewer_plugin_handlers.MouseContext) -> None .. py:method:: _on_load_from_zoom_force(_ctx: wolfhece._viewer_plugin_handlers.MouseContext) -> None .. py:method:: _on_show_index(_ctx: wolfhece._viewer_plugin_handlers.MouseContext) -> None .. py:method:: _on_download_index(_ctx: wolfhece._viewer_plugin_handlers.MouseContext) -> None .. py:method:: _show_index_in_viewer() -> None Add the tile-index grid to the viewer, using display lists for performance. Idempotent — does nothing if the layer is already present. Reuses the already-loaded :attr:`_DtmWalloniaTiles._tiles` object (which already has ``VectorOGLRenderer.LIST`` set) instead of re-reading the shapefile. .. py:method:: _do_download_index() -> None Force (re-)download of the tile-index shapefile. .. py:method:: get_dtm_1m(bounds_vec: wolfhece.pyvertexvectors.vector, force: bool = False) -> wolfhece.wolf_array.WolfArray Return a :class:`~wolfhece.wolf_array.WolfArray` cropped to *bounds_vec*. Downloads any missing tiles that intersect the polygon before assembling the result. :param bounds_vec: A closed :class:`~wolfhece.PyVertexvectors.vector` polygon that defines the region of interest. :param force: If True, bypass the >100 tiles safeguard in :meth:`_DtmWalloniaTiles.extract`. :returns: WolfArray covering the bounding box of *bounds_vec*. :raises FileNotFoundError: When no tile can be downloaded for the requested area. .. py:method:: get_dtm_2m(bounds_vec: wolfhece.pyvertexvectors.vector, force: bool = False) -> wolfhece.wolf_array.WolfArray Return a 2 m :class:`~wolfhece.wolf_array.WolfArray` by mean-rebinning the 1 m raster. .. py:method:: get_dtm_1m_xx_yy(xmin: float, xmax: float, ymin: float, ymax: float, force: bool = False) -> wolfhece.wolf_array.WolfArray Convenience wrapper around :meth:`get_dtm_1m` that takes raw bounds. :param xmin: Minimum X coordinate of the bounding box. :param xmax: Maximum X coordinate of the bounding box. :param ymin: Minimum Y coordinate of the bounding box. :param ymax: Maximum Y coordinate of the bounding box. :param force: If True, bypass the >100 tiles safeguard in :meth:`_DtmWalloniaTiles.extract`. :returns: WolfArray covering the specified bounding box. :raises FileNotFoundError: When no tile can be downloaded for the requested area. .. py:method:: get_dtm_2m_xx_yy(xmin: float, xmax: float, ymin: float, ymax: float, force: bool = False) -> wolfhece.wolf_array.WolfArray Convenience wrapper around :meth:`get_dtm_2m` that takes raw bounds. .. py:method:: _do_load_from_zoom(force: bool = False) -> None Load DTM for the current view extent and add it to the viewer.