Area of Interest / Fetch Statistics Plugin#93
Open
BhattaraiSijan wants to merge 22 commits into
Open
Conversation
This reverts commit c0455ea.
…re-up
Reverts the Prettier-style whitespace changes that drifted in over the
branch's life. The only functional change vs feat/imapengine-drawing now
is the engine.onFeatureClick → mmgisAPI.emit('map:featureClick') line,
which AOI's inspect mode depends on.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Adds the AOI plugin — pick an area of interest on the map (search / inspect / draw / upload), then run per-layer statistics analysis against every visible analysis-supported layer. Publishes the keyed results on the
mmgisAPIevent bus for downstream consumers (e.g. the Chart plugin) to render.Proposed Changes
src/essence/Tools/AOI/— new pluginAOITool.js— MMGIS wrapper; only file in the plugin that touchesmmgisAPI/L_/Map_AOIComponent.tsx+.scss+_aoi-tokens.scss— panel UI with theme-token CSS vars (--aoi-* = var(--mmgis-*, fallback))AOITooltip.tsx— anchored "Analyze area / Cancel" confirm popoveraoiHelpers.ts— pure parse / search / centroid / bounds helpersaoiBoundaryLoader.ts— webpackrequire.contextdiscovery + lazy fetch + dedupconfig.json— Configure UI registrationsrc/essence/Tools/AOI/assets/geo-data/states/plugin:aoi:)areaDrawn,analysisAOIReady,analysisReady,drawingCleared,drawingCancelledgetCurrentSelectiontool:change,map:drawstart/drawvertex/drawcomplete/drawcancel,map:featureClick, self-listensplugin:aoi:analysisAOIReadymap:createLayer/removeLayer,map:fitBounds,map:enableDrawing/finishDrawing/disableDrawing,map:addOverlay/removeOverlay,layers:getVisible/layers:getConfigsrc/essence/Basics/Map_/Map_.js(4 lines):Exposes the engine adapter's already-existing per-feature click handler on the bus so plugin-created vector layers (Inspect-mode boundaries) can receive clicks without going through the standard MMGIS layer pipeline. Engine-agnostic — both LeafletAdapter and DeckGLAdapter already implement onFeatureClick.
Issues
#81
Testing
Manually tested on a DeckGL mission with two analysis-supported layers (Sentinel2-Colorir-Daily, Sentinel-2 dNBR):
Search → pick a state → tooltip appears at centroid, map fits to bounds, areaDrawn fires with source: 'search'
Inspect → click any US state on the map → that state is selected (not the country polygon); areaDrawn fires with source: 'inspect'
Draw polygon (≥3 vertices), rectangle (2 corner clicks), circle (centre + edge) → Confirm finalises; drawcomplete flows into selection
Upload → .geojson, .json, .kml, .zip (shapefile with .shp/.dbf/.prj) → each parses into a selection
Analyze area → panel switches to the loading state with spinner and done/total progress bar; on completion fires plugin:aoi:analysisReady with keyed analysisData
Per-layer failure handling — layers whose /statistics POST returns non-2xx come back as null entries in analysisData; the run still succeeds for the other layers
Cancel + tool switch — both clear the selection layer and tooltip and emit the appropriate event
Tested on macOS, Chrome
Known follow-ups (separate branches)
LeafletAdapter.onFeatureClick uses a bbox picker rather than a true polygon hit-test — works for the DeckGL flow this PR exercises; flagged for the engine branch