feat(roadtrip): lay a whole chain of via points in one write

The single-via route is right for a detour dragged by hand and wrong for
anything that derives its anchors from a line. Pinning a day onto a recorded
track or a signed scenic road means a couple of dozen points, and one request
each re-routes the entire trip once per point, spaced by the routing host's own
rate limit — twenty anchors would spend half a minute drawing routes nobody
asked to see.

replace_legs names the legs to clear rather than taking a flag for the day, and
that is the whole difference: a traveller who bent two legs by hand and then
adopts a scenic road for a third has not asked to lose the two.

The tools follow in the same change, as parity requires. Undoing a detour picks
this up too, where the vias of one leg were deleted one request at a time.
This commit is contained in:
Maurice
2026-09-04 21:21:53 +02:00
committed by Maurice
parent ba7bd1dd91
commit 67163e7224
9 changed files with 203 additions and 5 deletions
+23
View File
@@ -72,6 +72,29 @@ export const roadtripViaReanchorRequestSchema = z.object({
});
export type RoadtripViaReanchorRequest = z.infer<typeof roadtripViaReanchorRequestSchema>;
/**
* Laying a whole chain of vias on one day at once.
*
* The single-via route is right for a hand-dragged detour and wrong for everything that
* derives its anchors from a line: pinning a day onto a recorded track or a signed scenic
* road means a couple of dozen points, and one request each would re-route the entire trip
* once per point, at better than a second apart.
*
* `replace_legs` clears the vias on the named legs before inserting, and names legs rather
* than taking a boolean for the day: a traveller who already bent two legs by hand and
* then adopts a scenic road for a third has not asked to lose the two.
*/
export const roadtripViaBatchRequestSchema = z.object({
vias: z.array(z.object({
after_order_index: z.number().int().min(0),
lat: latSchema,
lng: lngSchema,
})).max(100),
/** Legs to clear first, by `after_order_index`. Absent means add to what is there. */
replace_legs: z.array(z.number().int().min(0)).max(100).optional(),
});
export type RoadtripViaBatchRequest = z.infer<typeof roadtripViaBatchRequestSchema>;
export const roadtripViaListResponseSchema = z.object({
vias: z.array(roadtripViaSchema),
});