Explore non-additive flow metrics and weighted aggregation

Aperta
#125 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

This is exploratory design work, not a ready task. Start by reading PR #22 and its weighted aggregation discussion to see why its weights are lost and why location aggregation uses the computed metric. Then review the data aggregation layer, covering the local and worker data providers, to see where sum-based combining happens. Done means agreed semantics for weighted means, location summaries, and time aggregation, not a patch.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Flowmap.gl currently sums flow magnitudes when combining flows. This is appropriate for trips, people, goods, or money, but produces misleading results for non-additive metrics such as average journey time, average cost per trip, or a performance score weighted by trip volume.

This issue preserves the use case explored by @arashkav in #22 and its weighted aggregation example. The contribution identified a useful limitation. A future implementation should start from an active application's requirements and a representative dataset; this issue is exploratory, rather than a commitment to a general aggregation framework.

Example use case

A flow represents an average travel time plus the number of trips underlying that average. When locations merge into clusters, the resulting flow should show the trip-weighted average, and location summaries should remain consistent.

For example, 10 minutes across 100 trips and 20 minutes across one trip combine to (10 * 100 + 20 * 1) / 101 ≈ 10.10 minutes. Summing the averages, averaging them equally, or using the averages themselves as weights gives the wrong result.

Proposed direction

  • Keep sum as the default and preserve existing API behavior and the efficient summation path.
  • Initially support only operations justified by the concrete use case, likely sum and weighted mean, with ordinary mean if needed. Avoid exposing arbitrary reducers before their semantics and maintenance cost are understood.
  • Retain sufficient aggregation state: {sum, count} for a mean, or {weightedSum, weightSum} for a weighted mean. Combine that state and finalize to a display value only when needed. A finalized average alone cannot be correctly aggregated again.
  • Define how the metric affects flow thickness, ranking, legends, and tooltips. Decide separately what location summaries represent and what weights determine cluster positions; an average delay need not determine a location's geographic influence.
  • Apply the chosen semantics consistently to clustered flows, duplicate origin–destination rows without clustering, location summaries, time aggregation, and filtered/global summaries. If a summary is not meaningful for a metric, define that explicitly.
  • Keep the implementation in the data aggregation layer and account for local and worker data providers. Preserve numeric and string location IDs without coercing one into the other.

The public API should follow from those decisions; the accessor names and callback signature proposed in #22 are not requirements.

Lessons from #22

The existing PR needs redesign rather than a rebase. In particular, aggregation weights are lost when flows become aggregate records, and subsequent location aggregation uses the computed metric as its weight. The non-clustered and time aggregation paths also continue to sum. These are mathematical and behavioral consistency issues, beyond the age of the branch.

The PR's move to temporary accumulators and one final aggregation call per group is useful. For means, compact sufficient state can avoid retaining all source values.

Validation for a future implementation

  • Unequal group sizes and weights produce the same result when combined directly or in stages.
  • Clustering, zoom changes, filtering, and time aggregation follow the documented semantics.
  • Numeric and string IDs retain their identity.
  • Empty groups, missing/non-finite values, zero total weight, and any restrictions on weights have explicit behavior and tests.
  • Existing sum behavior and API compatibility remain intact, with representative checks for memory use and calculation cost.

For fixed-resolution applications, preprocessing one value per origin–destination pair and disabling clustering can cover part of the need today. Interactive reclustering is the stronger motivation for core support.

Contributions of concrete datasets and desired visual behavior would help determine the smallest useful scope.

Lingua principale
TypeScript
Stelle
143
Fork
24
Merge medio
1g 4h
PR unite (30g)
18

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di visgl/flowmap.gl

Tutte le issue di visgl/flowmap.gl

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.