chore: remove one-time route event patch workflow
This commit is contained in:
parent
df83274bed
commit
d1958faa02
|
|
@ -1,39 +0,0 @@
|
|||
name: Patch route event rendering
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
patch:
|
||||
if: github.actor != 'github-actions[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Expand acceleration and braking events to surrounding GPS points
|
||||
shell: python
|
||||
run: |
|
||||
from pathlib import Path
|
||||
|
||||
path = Path('lib/features/map/map_screen.dart')
|
||||
text = path.read_text()
|
||||
old = ''' List<AppPolyline> _buildLongitudinalEventPolylines(\n List<TelemetrySample> samples, {\n required bool Function(double g) predicate,\n required String idPrefix,\n required Color color,\n }) {\n final polylines = <AppPolyline>[];\n List<AppLatLng> segment = [];\n var segmentIndex = 0;\n\n void flush() {\n if (segment.length >= 2) {\n polylines.add(AppPolyline(\n id: '${idPrefix}_$segmentIndex',\n points: List<AppLatLng>.from(segment),\n color: color,\n width: 7.0,\n ));\n segmentIndex++;\n }\n segment = [];\n }\n\n for (final sample in samples) {\n final g = sample.longitudinalG ?? sample.accelX;\n if (g != null && g.isFinite && predicate(g)) {\n segment.add(AppLatLng(sample.latitude!, sample.longitude!));\n } else {\n flush();\n }\n }\n flush();\n return polylines;\n }'''
|
||||
new = ''' List<AppPolyline> _buildLongitudinalEventPolylines(\n List<TelemetrySample> samples, {\n required bool Function(double g) predicate,\n required String idPrefix,\n required Color color,\n }) {\n if (samples.isEmpty) return [];\n\n // A threshold crossing is often only one telemetry sample wide. Requiring\n // two consecutive qualifying samples made isolated acceleration/braking\n // events disappear from the map. Build event runs, then include one GPS\n // sample on each side so every event renders as a visible route segment.\n final polylines = <AppPolyline>[];\n final eventIndices = <int>[];\n\n for (var i = 0; i < samples.length; i++) {\n final g = samples[i].longitudinalG ?? samples[i].accelX;\n if (g != null && g.isFinite && predicate(g)) {\n eventIndices.add(i);\n }\n }\n if (eventIndices.isEmpty) return polylines;\n\n var runStart = eventIndices.first;\n var runEnd = eventIndices.first;\n var segmentIndex = 0;\n\n void emitRun(int start, int end) {\n final expandedStart = start > 0 ? start - 1 : start;\n final expandedEnd = end < samples.length - 1 ? end + 1 : end;\n final points = <AppLatLng>[];\n for (var i = expandedStart; i <= expandedEnd; i++) {\n final sample = samples[i];\n points.add(AppLatLng(sample.latitude!, sample.longitude!));\n }\n\n // The surrounding point guarantees two points for an isolated event\n // while preserving a single continuous segment for adjacent events.\n if (points.length >= 2) {\n polylines.add(AppPolyline(\n id: '${idPrefix}_$segmentIndex',\n points: points,\n color: color,\n width: 7.0,\n ));\n segmentIndex++;\n }\n }\n\n for (var i = 1; i < eventIndices.length; i++) {\n final index = eventIndices[i];\n // Keep nearby threshold samples in one event run. A gap of more than\n // two samples starts a new visual event while allowing brief sensor\n // dropouts inside a hard maneuver.\n if (index - runEnd <= 2) {\n runEnd = index;\n } else {\n emitRun(runStart, runEnd);\n runStart = runEnd = index;\n }\n }\n emitRun(runStart, runEnd);\n\n return polylines;\n }'''
|
||||
if old not in text:
|
||||
raise SystemExit('Expected route event polyline function was not found; refusing to modify the file.')
|
||||
path.write_text(text.replace(old, new, 1))
|
||||
|
||||
- name: Commit route event fix
|
||||
shell: bash
|
||||
run: |
|
||||
git config user.name 'github-actions[bot]'
|
||||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||
git add lib/features/map/map_screen.dart
|
||||
git commit -m 'fix: render isolated route acceleration and braking events'
|
||||
git push
|
||||
Loading…
Reference in New Issue