Skip to content

feat: implement analytics component#84

Merged
drduhe merged 1 commit intomainfrom
feat/analytics-component
Feb 25, 2026
Merged

feat: implement analytics component#84
drduhe merged 1 commit intomainfrom
feat/analytics-component

Conversation

@drduhe
Copy link
Copy Markdown
Collaborator

@drduhe drduhe commented Feb 25, 2026

Issue #, if available: n/a

Analytics & Comparison Feature

Adds an analytics sidebar and enhanced globe visualization for viewing aggregate detection statistics, comparing model runs, and interactively filtering features by classification or confidence.

New: Analytics Panel & Charts

  • AnalyticsPanel — collapsible right-side sidebar toggled from a new button in the top-right, independent of the existing OsmlMenu
  • AnalyticsSummary — per-layer card showing feature count, average confidence, confidence histogram, and classification breakdown
  • ConfidenceHistogram — custom SVG bar chart (10 bins, red→green gradient); clickable bins create confidence-range filters
  • ClassificationChart — custom SVG stacked bar showing classification proportions; clickable segments create classification filters
  • FilterChips — removable filter pills with "Clear all"; filters combine with AND logic and dim non-matching features on the globe
  • ComparisonView — side-by-side stats table and spatial overlap summary when exactly two layers are selected

New: Analytics State & Computation

  • AnalyticsContext — lightweight React context layered on ResourceContext; manages color mode, active filters, selected layers, and memoized LayerStats per feature collection
  • analyticsCompute.ts — pure functions for confidence histograms, classification aggregation, and polygon/point spatial overlap detection (bounding-box pre-filter + edge-intersection)
  • analyticsExtract.ts — extracts FeatureRecord[] and entity geometries from Cesium GeoJsonDataSource, handling OSML feature_classes, nested properties, and multiple classification key conventions

New: Globe Styling

  • cesiumStyling.ts — three styling modes applied to Cesium entities in-place:
    • By layer (default) — existing behavior
    • By confidence — red→yellow→green gradient
    • By classification — 10-color palette with consistent assignment
  • Filter highlighting — matching features at full opacity, non-matching dimmed to ~8%
  • Comparison overlay — unique features outlined in their layer color, overlapping features in white with thicker outline
  • useAnalyticsGlobeStyling hook — single unified effect that sequences base color → comparison overlay → filter highlighting to avoid desync

Improved: Result Loading & Deduplication

  • ImageRequestModal now tracks imageName and modelName on request status, skips re-loading imagery layers that already exist
  • useImageRequestResults deduplicates result loads by imageName, uses a loadingRef guard against concurrent loads, and builds descriptive layer names (image / model results)
  • modelRunnerHelper uses functional setImageRequestStatus updater to preserve existing data fields

Other Changes

  • ResourceContextFeatureCollectionResource extended with optional filteredFeatureCount, confidenceThreshold, and imageName
  • types.tsImageRequestData extended with imageName and modelName
  • styles.css.analytics-toggle positioning
  • .gitignoredocs/ added (planning docs excluded from repo)

Tests

  • analyticsCompute.test.ts — histogram bucketing, stats aggregation, spatial overlap (polygon intersection, containment, point-in-polygon, non-intersecting)
  • analyticsExtract.test.ts — entity extraction, nested property formats, OSML feature_classes, hidden entity visibility
  • cesiumStyling.test.ts — confidence-to-color gradient, classification palette consistency, clamping

Checklist

Before you submit a pull request, please make sure you have the following:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Copy Markdown

@devinglauner devinglauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@drduhe drduhe merged commit 6d27e8a into main Feb 25, 2026
4 checks passed
@drduhe drduhe deleted the feat/analytics-component branch February 25, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants