mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 07:53:09 +00:00
fix(maps): stop the day route drawing drives to airports you flew from
A flight leaving overnight contributes only its departure airport on the day it leaves, and the evening hotel bookend was attaching to whatever point sat at the day's edge. So the map drew a straight line from the airport you took off from to the hotel you were checking into. The same blind spot on the run builder produced the long rays: a day's order is a bare wall clock, so an inbound long-haul whose departure clock reads late sorts after the day's local stops, and its far departure airport got appended to that run. OSRM answers such a pair with NoRoute and the fallback straightens the whole chunk, taking the genuine local drive with it. Both now ask whether the pair could be driven at all. A flight, train, ferry, cruise or coach carries you out of the day's geography, so its departure point has no drive back to tonight's hotel and its arrival point had no drive from this morning's. A hire car is the opposite and stays out of that set: you keep driving it, so a multi-day rental's pickup and drop-off points keep their hotel legs. Alongside it, any leg touching a booking endpoint has to be within MAX_DRIVE_KM, which catches the mis-sorted edges the role alone cannot see. The sidebar gets both guards so its hotel connectors stay in step with the drawn route; the mobile map and timeline read the same hook.
This commit is contained in:
@@ -166,6 +166,25 @@ describe('shouldDrawMorningLeg', () => {
|
||||
expect(shouldDrawMorningLeg(bookends, checkInDay, { isPlace: true, time: '06:00' })).toBe(true)
|
||||
})
|
||||
|
||||
it('does NOT draw when the day opens on an airport you landed at (#2133)', () => {
|
||||
// You flew in. Even on a night you provably slept in this hotel, nobody drove out
|
||||
// of it to the airport that set you down.
|
||||
const bookends = { morning: into(), morningIsSleptHere: true }
|
||||
expect(shouldDrawMorningLeg(bookends, checkInDay, { isPlace: false, carrierEdge: 'arrival' })).toBe(false)
|
||||
})
|
||||
|
||||
it('still draws when the day opens on an airport you departed from (#2133)', () => {
|
||||
// The legitimate mirror: you woke in the hotel and drove to your outbound airport.
|
||||
const bookends = { morning: into(), morningIsSleptHere: true }
|
||||
expect(shouldDrawMorningLeg(bookends, checkInDay, { isPlace: false, carrierEdge: 'departure' })).toBe(true)
|
||||
})
|
||||
|
||||
it('still draws for a hire-car drop-off point, which carries no carrierEdge (#2133)', () => {
|
||||
// A car you keep driving is not a carrier: the hotel → drop-off depot drive is real.
|
||||
const bookends = { morning: into(), morningIsSleptHere: true }
|
||||
expect(shouldDrawMorningLeg(bookends, checkInDay, { isPlace: false, carrierEdge: null })).toBe(true)
|
||||
})
|
||||
|
||||
it('does NOT draw on a check-in day when the first place is before check-in (#1465)', () => {
|
||||
const bookends = { morning: into({ check_in: '15:00' }), morningIsSleptHere: false }
|
||||
// Airport place at 10:00, check-in 15:00 — you have not reached the hotel yet.
|
||||
@@ -218,6 +237,25 @@ describe('shouldDrawEveningLeg', () => {
|
||||
expect(shouldDrawEveningLeg(bookends, checkOutDay, { isPlace: true, time: '23:00' })).toBe(true)
|
||||
})
|
||||
|
||||
it('does NOT draw when the day ends at an airport you took off from (#2133)', () => {
|
||||
// The reported bug: an overnight flight leaves only its departure airport on the
|
||||
// day it leaves, and that airport was being joined to tonight's hotel.
|
||||
const bookends = { evening: out(), eveningIsOvernight: true }
|
||||
expect(shouldDrawEveningLeg(bookends, checkOutDay, { isPlace: false, carrierEdge: 'departure' })).toBe(false)
|
||||
})
|
||||
|
||||
it('still draws when the day ends at an airport you landed at (#2133)', () => {
|
||||
// The legitimate case the fix must not eat: you land, then drive to the hotel.
|
||||
const bookends = { evening: out(), eveningIsOvernight: true }
|
||||
expect(shouldDrawEveningLeg(bookends, checkOutDay, { isPlace: false, carrierEdge: 'arrival' })).toBe(true)
|
||||
})
|
||||
|
||||
it('still draws for a hire-car pickup point, which carries no carrierEdge (#2133)', () => {
|
||||
// You collect the car at 18:00 and drive it to tonight's hotel — a real leg.
|
||||
const bookends = { evening: out(), eveningIsOvernight: true }
|
||||
expect(shouldDrawEveningLeg(bookends, checkOutDay, { isPlace: false, carrierEdge: null })).toBe(true)
|
||||
})
|
||||
|
||||
it('does NOT draw on a check-out day when the last place is after check-out (#1465)', () => {
|
||||
const bookends = { evening: out({ check_out: '11:00' }), eveningIsOvernight: false }
|
||||
// "home" place at 18:00, check-out 11:00 — you have already left the hotel.
|
||||
|
||||
Reference in New Issue
Block a user