Explore non-additive flow metrics and weighted aggregation

Abierto
#125 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
15/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
143
Forks
24
Merge medio
1 d 4 h
PR fusionados (30 d)
18

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de visgl/flowmap.gl

Todos los issues de visgl/flowmap.gl

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.