fsanyoto commited on
Commit
76989b1
Β·
verified Β·
1 Parent(s): 7251a78

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "v46 (a8dc531)",
3
  "releases": [
4
  {
5
  "version": "v46",
 
1
  {
2
+ "current": "917f9a0",
3
  "releases": [
4
  {
5
  "version": "v46",
VERSION CHANGED
@@ -1 +1 @@
1
- v46 (a8dc531)
 
1
+ 917f9a0
api/routes_customers.py CHANGED
The diff for this file is too large to render. See raw diff
 
web/src/customer-grid/CustomerGrid.tsx CHANGED
The diff for this file is too large to render. See raw diff
 
web/src/customer-grid/MapView.tsx CHANGED
The diff for this file is too large to render. See raw diff
 
web/src/customer-grid/apiBridge.ts CHANGED
The diff for this file is too large to render. See raw diff
 
web/src/customer-grid/mapProjection.ts CHANGED
@@ -37,6 +37,34 @@ export interface View {
37
  k: number;
38
  tx: number;
39
  ty: number;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
  /** lon/lat -> the fixed projected plane (0..WORLD on both axes). */
@@ -57,7 +85,11 @@ export function unproject(p: Pt): { lon: number; lat: number } {
57
 
58
  /** Screen -> the fixed projected plane, through a view. The inverse of `toScreen`. */
59
  export function fromScreen(s: Pt, view: View): Pt {
60
- return { x: (s.x - view.tx) / view.k, y: (s.y - view.ty) / view.k };
 
 
 
 
61
  }
62
 
63
  // -------------------------------------------------------- the Google hand-off
@@ -120,7 +152,33 @@ export function googleDirectionsUrl(lat: number, lon: number): string {
120
 
121
  /** Projected point -> screen, through a view. */
122
  export function toScreen(p: Pt, view: View): Pt {
123
- return { x: view.tx + p.x * view.k, y: view.ty + p.y * view.k };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  /**
@@ -158,11 +216,22 @@ export function fitView(
158
  }
159
 
160
  /** Zoom by `factor` while holding the point under (mx, my) still β€” the gesture
161
- * every map has and the reason zoom cannot be a plain scale on the group. */
 
 
 
 
 
 
 
 
 
 
162
  export function zoomAt(view: View, factor: number, mx: number, my: number, kMin: number, kMax: number): View {
163
  const k = Math.max(kMin, Math.min(kMax, view.k * factor));
164
  if (k === view.k) return view;
165
  return {
 
166
  k,
167
  tx: mx - ((mx - view.tx) * k) / view.k,
168
  ty: my - ((my - view.ty) * k) / view.k,
@@ -599,6 +668,25 @@ function _fnv1a(text: string, base: number): string {
599
  return h.toString(16).padStart(8, "0");
600
  }
601
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  // --------------------------------------------------- handing the route over
603
  //
604
  // MEASURED 2026-07-29, do not re-derive: Google Maps URLs need NO API key and
@@ -624,7 +712,7 @@ export function routeStopCap(coarsePointer: boolean, roundTrip = false): number
624
  * ([[no-unverifiable-aggregates]]). Shrinks further if the character budget
625
  * binds, which it can with a long tail of 6-dp coordinates.
626
  */
627
- export function googleRouteUrl(
628
  stops: GeoStop[],
629
  opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
630
  ): { url: string; used: number } | null {
@@ -645,50 +733,50 @@ export function googleRouteUrl(
645
  if (url.length <= MAX_MAPS_URL || used <= 2) return { url, used };
646
  used -= 1;
647
  }
648
- }
649
-
650
- /**
651
- * Split a long ordered route into contiguous Google Maps links. Adjacent links share their
652
- * boundary stop, so every stop is represented while each individual URL stays within Google's
653
- * free-link limit. `googleRouteUrl` remains the single-link primitive for callers that want its
654
- * reported cap; the map planner uses this list so it never hides the tail of a route.
655
- */
656
- export function googleRouteUrls(
657
- stops: GeoStop[],
658
- opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
659
- ): { url: string; index: number; start: number; end: number }[] {
660
- if (stops.length < 2) return [];
661
- const links: { url: string; index: number; start: number; end: number }[] = [];
662
- const cap = routeStopCap(!!opts.coarsePointer, false);
663
- let start = 0;
664
- while (start < stops.length - 1) {
665
- const end = Math.min(stops.length, start + cap);
666
- const segment = stops.slice(start, end);
667
- const built = googleRouteUrl(segment, { coarsePointer: opts.coarsePointer });
668
- if (!built || built.used < 2) break;
669
- links.push({
670
- url: built.url,
671
- index: links.length + 1,
672
- start,
673
- end: start + built.used,
674
- });
675
- if (start + built.used >= stops.length) break;
676
- // Share the last stop so route 2 starts where route 1 ends.
677
- start = start + built.used - 1;
678
- }
679
- // A round trip is represented honestly by adding the original origin to the final segment when
680
- // there is room. If the segment is full, the contiguous links still cover every visit; Google
681
- // cannot express the global return without dropping a visit, which this helper never does.
682
- if (opts.roundTrip && links.length) {
683
- const last = links[links.length - 1];
684
- const segment = stops.slice(last.start, last.end);
685
- if (segment.length >= 2 && last.end === stops.length) {
686
- const returned = googleRouteUrl([...segment, stops[0]], { roundTrip: false, coarsePointer: opts.coarsePointer });
687
- if (returned) last.url = returned.url;
688
- }
689
- }
690
- return links;
691
- }
692
 
693
  /** An svg's own bounding box in client px β€” the `getBoundingClientRect()` half
694
  * of the conversion below, taken as plain data so the maths stays testable
 
37
  k: number;
38
  tx: number;
39
  ty: number;
40
+ /**
41
+ * ⭐⭐ OWNER ITEM 1 (2026-08-23) β€” THE BEARING, IN DEGREES CLOCKWISE. Absent is north up.
42
+ *
43
+ * The painted transform is `translate(tx ty) rotate(rot) scale(k)`, i.e. `t + R(rot) . k . p`,
44
+ * which is exactly what `toScreen` computes and `fromScreen` inverts. Three consequences worth
45
+ * writing down because each one is a function this wave did NOT have to change:
46
+ *
47
+ * Β· `zoomAt` is bearing-agnostic. Holding the point under the cursor still means
48
+ * `t' = m - (k'/k)(m - t)` whatever R is, because R cancels on both sides.
49
+ * Β· PANNING is bearing-agnostic. `tx += dx` is applied AFTER the rotation, so a drag still
50
+ * moves the map the way the hand moved.
51
+ * Β· `fitView` needs no rotation at all, because Fit RESETS the bearing (see MapView's
52
+ * `doFit`). A fit that preserved a bearing would have to frame the AABB of the ROTATED
53
+ * points, and a compass that cannot be put back to north is a control with no undo.
54
+ *
55
+ * ⚠ OPTIONAL, AND THAT IS LOAD-BEARING RATHER THAN LAZY. Every existing caller and every
56
+ * fixture in `_test/map.test.ts` writes `{k, tx, ty}`; `rot` undefined reads as 0 and their
57
+ * arithmetic is byte-identical, so this widening cannot silently change a single one of them.
58
+ */
59
+ rot?: number;
60
+ }
61
+
62
+ /** `cos` and `sin` of a view's bearing. One place converts degrees to radians. */
63
+ function _bearing(view: View): { c: number; s: number } {
64
+ const rot = view.rot ?? 0;
65
+ if (!rot) return { c: 1, s: 0 };
66
+ const rad = (rot * Math.PI) / 180;
67
+ return { c: Math.cos(rad), s: Math.sin(rad) };
68
  }
69
 
70
  /** lon/lat -> the fixed projected plane (0..WORLD on both axes). */
 
85
 
86
  /** Screen -> the fixed projected plane, through a view. The inverse of `toScreen`. */
87
  export function fromScreen(s: Pt, view: View): Pt {
88
+ const u = (s.x - view.tx) / view.k;
89
+ const v = (s.y - view.ty) / view.k;
90
+ const { c, s: sn } = _bearing(view);
91
+ // R(-rot) applied to the unscaled offset. At rot = 0 this is `{x: u, y: v}` exactly.
92
+ return { x: u * c + v * sn, y: -u * sn + v * c };
93
  }
94
 
95
  // -------------------------------------------------------- the Google hand-off
 
152
 
153
  /** Projected point -> screen, through a view. */
154
  export function toScreen(p: Pt, view: View): Pt {
155
+ const { c, s } = _bearing(view);
156
+ // t + R(rot) . k . p, which is the SVG transform list `translate(tx ty) rotate(rot) scale(k)`
157
+ // read right to left. At rot = 0 this is `tx + p.x * k` exactly, so nothing that never rotates
158
+ // changes by a floating-point ulp.
159
+ return {
160
+ x: view.tx + view.k * (p.x * c - p.y * s),
161
+ y: view.ty + view.k * (p.x * s + p.y * c),
162
+ };
163
+ }
164
+
165
+ /**
166
+ * ⭐⭐ OWNER ITEM 1 (2026-08-23) β€” TURN THE MAP BY `deg`, HOLDING THE POINT AT (mx, my) STILL.
167
+ *
168
+ * `zoomAt`'s sibling, and written the same way for the same reason: the anchored version is the
169
+ * only one that does not feel like the map jumping. The buttons pass the viewport centre, which
170
+ * is what a compass control means by "turn".
171
+ *
172
+ * ⚠ THE BEARING WRAPS INTO [0, 360). Without it a user who holds Rotate left for a minute has a
173
+ * view carrying -305 degrees, which reads correctly and prints wrong the moment anything shows it.
174
+ */
175
+ export function rotateAt(view: View, deg: number, mx: number, my: number): View {
176
+ const at = fromScreen({ x: mx, y: my }, view);
177
+ const rot = (((view.rot ?? 0) + deg) % 360 + 360) % 360;
178
+ const turned: View = { ...view, rot };
179
+ // Put `at` back under (mx, my): solve `m = t + R(rot') . k . at` for t.
180
+ const moved = toScreen(at, { ...turned, tx: 0, ty: 0 });
181
+ return { ...turned, tx: mx - moved.x, ty: my - moved.y };
182
  }
183
 
184
  /**
 
216
  }
217
 
218
  /** Zoom by `factor` while holding the point under (mx, my) still β€” the gesture
219
+ * every map has and the reason zoom cannot be a plain scale on the group.
220
+ *
221
+ * β›”β›” OWNER ITEM 1 (2026-08-23) β€” `...view` IS LOAD-BEARING AND WAS ADDED AFTER A MEASUREMENT.
222
+ * The recentring arithmetic below is genuinely bearing-agnostic: `t' = m - (k'/k)(m - t)` holds
223
+ * whatever R is, because R cancels on both sides. That was reasoned about, believed, and WRONG
224
+ * about this function anyway β€” not because the maths was wrong but because the RETURN was a
225
+ * fresh object literal, so every zoom silently dropped `rot` and snapped the map back to north.
226
+ * The gate leg caught it on its first run: the anchor point landed 1,900 px away.
227
+ * ⚠ So the rule this records is not about rotation. It is that a function which rebuilds a
228
+ * value instead of amending it has to be revisited every time the value grows a field, and the
229
+ * only defence is to amend. [[a-widened-record-needs-its-builders-revisited]] */
230
  export function zoomAt(view: View, factor: number, mx: number, my: number, kMin: number, kMax: number): View {
231
  const k = Math.max(kMin, Math.min(kMax, view.k * factor));
232
  if (k === view.k) return view;
233
  return {
234
+ ...view,
235
  k,
236
  tx: mx - ((mx - view.tx) * k) / view.k,
237
  ty: my - ((my - view.ty) * k) / view.k,
 
668
  return h.toString(16).padStart(8, "0");
669
  }
670
 
671
+ /**
672
+ * ⭐⭐ OWNER ITEM 3 (2026-08-23) β€” THE MOST STOPS ONE ROUTE MAY CARRY.
673
+ *
674
+ * β›” THIS NUMBER IS NOT A TASTE CALL AND IT IS NOT OURS. It MIRRORS
675
+ * `aios-web/api/routes_geo.py::MAX_ROUTE_STOPS`, the ceiling the road-routing provider is asked
676
+ * under. A plan longer than this is refused by `POST /geo/route` with `too_many_stops`, so a
677
+ * client cap of anything higher buys nothing but a spent click and a red message; a lower one
678
+ * would withhold stops the service would happily have taken.
679
+ *
680
+ * ⚠ THE LOCAL SOLVE IS NOWHERE NEAR THE BINDING CONSTRAINT, and that is worth writing down so
681
+ * nobody "optimises" the wrong end. `planRoute` is nearest-neighbour plus 2-opt: at 100 stops
682
+ * that is ~10k distance calls to construct and ~120k across 24 improvement passes, single-digit
683
+ * milliseconds. The provider request is what stops at 100.
684
+ *
685
+ * ⚠ REPORTED, NEVER SILENT (standing rule 1's second sentence). Wherever this cap actually bites,
686
+ * the panel says so, says why, and says which stops it took.
687
+ */
688
+ export const ROUTE_STOP_CAP = 100;
689
+
690
  // --------------------------------------------------- handing the route over
691
  //
692
  // MEASURED 2026-07-29, do not re-derive: Google Maps URLs need NO API key and
 
712
  * ([[no-unverifiable-aggregates]]). Shrinks further if the character budget
713
  * binds, which it can with a long tail of 6-dp coordinates.
714
  */
715
+ export function googleRouteUrl(
716
  stops: GeoStop[],
717
  opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
718
  ): { url: string; used: number } | null {
 
733
  if (url.length <= MAX_MAPS_URL || used <= 2) return { url, used };
734
  used -= 1;
735
  }
736
+ }
737
+
738
+ /**
739
+ * Split a long ordered route into contiguous Google Maps links. Adjacent links share their
740
+ * boundary stop, so every stop is represented while each individual URL stays within Google's
741
+ * free-link limit. `googleRouteUrl` remains the single-link primitive for callers that want its
742
+ * reported cap; the map planner uses this list so it never hides the tail of a route.
743
+ */
744
+ export function googleRouteUrls(
745
+ stops: GeoStop[],
746
+ opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
747
+ ): { url: string; index: number; start: number; end: number }[] {
748
+ if (stops.length < 2) return [];
749
+ const links: { url: string; index: number; start: number; end: number }[] = [];
750
+ const cap = routeStopCap(!!opts.coarsePointer, false);
751
+ let start = 0;
752
+ while (start < stops.length - 1) {
753
+ const end = Math.min(stops.length, start + cap);
754
+ const segment = stops.slice(start, end);
755
+ const built = googleRouteUrl(segment, { coarsePointer: opts.coarsePointer });
756
+ if (!built || built.used < 2) break;
757
+ links.push({
758
+ url: built.url,
759
+ index: links.length + 1,
760
+ start,
761
+ end: start + built.used,
762
+ });
763
+ if (start + built.used >= stops.length) break;
764
+ // Share the last stop so route 2 starts where route 1 ends.
765
+ start = start + built.used - 1;
766
+ }
767
+ // A round trip is represented honestly by adding the original origin to the final segment when
768
+ // there is room. If the segment is full, the contiguous links still cover every visit; Google
769
+ // cannot express the global return without dropping a visit, which this helper never does.
770
+ if (opts.roundTrip && links.length) {
771
+ const last = links[links.length - 1];
772
+ const segment = stops.slice(last.start, last.end);
773
+ if (segment.length >= 2 && last.end === stops.length) {
774
+ const returned = googleRouteUrl([...segment, stops[0]], { roundTrip: false, coarsePointer: opts.coarsePointer });
775
+ if (returned) last.url = returned.url;
776
+ }
777
+ }
778
+ return links;
779
+ }
780
 
781
  /** An svg's own bounding box in client px β€” the `getBoundingClientRect()` half
782
  * of the conversion below, taken as plain data so the maths stays testable
web/src/index.css CHANGED
The diff for this file is too large to render. See raw diff