Skip to content

feature/9528-extend-sections-and-tracks-with-optional-geo-coordinates#831

Merged
schubsen merged 109 commits into
mainfrom
feature/9528-extend-sections-and-tracks-with-optional-geo-coordinates
May 26, 2026
Merged

feature/9528-extend-sections-and-tracks-with-optional-geo-coordinates#831
schubsen merged 109 commits into
mainfrom
feature/9528-extend-sections-and-tracks-with-optional-geo-coordinates

Conversation

@randy-seng

@randy-seng randy-seng commented Apr 28, 2026

Copy link
Copy Markdown
Member

PR Description

Summary

Extends track, section, and event processing to support optional geo coordinates while preserving existing image-coordinate behavior for datasets without complete geo data.

Changes

  • Adds optional geo coordinate propagation through track datasets, section events, event serialization, and CSV exports.
  • Uses geo coordinates for intersection detection/event creation when complete geo data is available; otherwise falls back to image coordinates.
  • Preserves georeference metadata across parsing, filtering, splitting, merging, and dataset lifecycle operations.
  • Improves mixed-dataset handling by null-padding missing geo columns instead of dropping geo data.
  • Adds PolarsTrackDataset.merge_all for efficient bulk dataset concatenation.
  • Refactors track CSV export behind writer adapters for Polars, Pandas, and domain fallback datasets.
  • Includes geo coordinates in road-user assignment exports when present, omitting all-null geo columns.
  • Adds logging to indicate whether geo or image coordinates are used during intersection/event generation.
  • Expands tests around geo metadata propagation, mixed geo/non-geo datasets, merge behavior, parser behavior, and export output.

Notes

  • Existing workflows without geo coordinates remain supported.
  • Mixed inputs with partial/missing geo data are handled safely by falling back to image-space calculations where needed.

OP#9528
OP#9529
OP#9530

Covers Detection interface, parser layer, Polars DataFrame segment
propagation, linear geo interpolation at intersections, Event fields,
and event list CSV export. Section geo coordinates are deferred.
…olumns present

Add START_GEO_X, START_GEO_Y, END_GEO_X, END_GEO_Y constants to track_dataset.py
and conditionally include them in the create_track_segments output when both
GEO_X and GEO_Y columns are present in the input DataFrame.
Adds GEO_X/GEO_Y constants to event_list.py and updates
EventListDataFrameBuilder to append geo coordinate columns to the
exported DataFrame only when events carry numeric geo values.
Also guards _round() against non-numeric (all-None) columns.
…track files

When multiple ottrk files are loaded, add_all's .select(COLUMNS) dropped
geo_x/geo_y because they were absent from the COLUMNS constant. This caused
geometry datasets created for a changed section offset to be built from a
DataFrame without geo columns, so geo coordinate interpolation was silently
skipped. The original offset's geometry (cached before the second file load)
still worked, making the bug appear only on offset changes.

Fix: collect geo columns that exist in both DataFrames and include them in
the select, so merging two geo-tagged files preserves geo data end-to-end.
…acks

Fusion ottrk files (e.g. OTFusion outputs) have w=0, h=0 for all
detections. The RelativeOffsetCoordinate formula multiplies by w/h,
so the offset evaluates to zero — intentional, as a relative offset
is undefined for point detections with no bounding box.
Log at DEBUG level whether events are being created with geo coordinates
(OTFusion fusion tracks) or image coordinates (standard tracks).
Propagate geo_x/geo_y through segment creation so that get_first_segments()
and get_last_segments() carry start_geo_x/start_geo_y and end_geo_x/end_geo_y
when the underlying dataset has geo columns present.
Comment thread tests/unit/OTAnalytics/domain/track_dataset/test_track_dataset.py Outdated
randy-seng added 19 commits May 18, 2026 20:32
…me_empty_input_preserves_georeference_metadata
…ropping them

Previously, merging datasets where only some had geo coordinates silently
discarded geo data from the files that did have it. Now both merge_all and
add_all preserve geo columns by null-padding whichever side lacks them.

The use_geo gate in wrap_intersection_points is updated to require null-free
geo columns (not just column presence), so null-padded datasets correctly
fall back to image-space intersection. A new dataset_has_complete_geo_values
helper captures this completeness check for use by callers.
…rve null-geo segments

drop_nulls() without a subset dropped every row where any column was null,
including segments from null-padded tracks (geo columns present but null).
This caused tracks without geo data in a mixed dataset to have zero segments
in the geometry store, making them invisible to intersection detection.

Restrict the drop to the non-geo shifted columns whose nulls exclusively
mark the first (incomplete) detection row of each track.
…reation

Adds debug/info log messages indicating whether geo or image coordinates
are selected when detecting intersections and when creating section events.
… adapters

Introduce TrackDatasetCsvWriter protocol with Polars, Pandas, and domain
fallback implementations behind a ResolvingTrackDatasetCsvWriter. CsvTrackExport
now delegates CSV writing entirely to the injected writer instead of branching
on dataset implementation types.
…port

Adds start_geo_x/y and end_geo_x/y from section events to the road user
assignment export. Columns are omitted when all values are null to avoid
cluttering output for datasets without geo data.
@randy-seng randy-seng requested a review from schubsen May 21, 2026 18:36
@randy-seng randy-seng self-assigned this May 21, 2026
@schubsen schubsen merged commit f039958 into main May 26, 2026
13 checks passed
@schubsen schubsen deleted the feature/9528-extend-sections-and-tracks-with-optional-geo-coordinates branch May 26, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants