lsa-planer
LSA-Planer Professional – Planungssoftware für Lichtsignalanlagen nach RiLSA 2015 und § 45 StVO. EUPL-1.2.
/ tests domain haltlinienKennungen.test.ts
| 1 | import { describe, expect, it } from 'vitest'; |
| 2 | import { parseProject } from '@/domain/model/schema'; |
| 3 | |
| 4 | /* |
| 5 | * Befund 34, behoben in Fassung 5.9.0. |
| 6 | * |
| 7 | * Eine doppelte Haltlinienkennung wurde stumm neu vergeben. Die Fahrlinien der |
| 8 | * zweiten Haltlinie behielten ihren Verweis und zeigten danach auf die ERSTE |
| 9 | * Haltlinie, die die Kennung behalten hatte; `normalisiere` zog ihren ersten |
| 10 | * Punkt auf diese fremde Haltlinie. Die Zeichnung veraenderte sich beim blossen |
| 11 | * Oeffnen, und die daraus abgeleiteten Raeum- und Einfahrwege stimmten nicht |
| 12 | * mehr. |
| 13 | */ |
| 14 | describe('Doppelte Haltlinienkennungen beim Einlesen', () => { |
| 15 | const lageplanMitDoppelterKennung = { |
| 16 | haltlinien: [ |
| 17 | { id: 'hl-doppelt', name: 'Nord', art: 'zufahrt', von: { x: 0, y: 0 }, bis: { x: 40, y: 0 } }, |
| 18 | { |
| 19 | id: 'hl-doppelt', |
| 20 | name: 'Süd', |
| 21 | art: 'zufahrt', |
| 22 | von: { x: 0, y: 900 }, |
| 23 | bis: { x: 40, y: 900 }, |
| 24 | }, |
| 25 | ], |
| 26 | linien: [ |
| 27 | { |
| 28 | id: 'pl-sued', |
| 29 | name: 'Süd geradeaus', |
| 30 | mode: 'kfz', |
| 31 | movement: 'geradeaus', |
| 32 | punkte: [ |
| 33 | { x: 20, y: 900 }, |
| 34 | { x: 20, y: 500 }, |
| 35 | ], |
| 36 | haltlinieId: 'hl-doppelt', |
| 37 | startT: 0.5, |
| 38 | }, |
| 39 | ], |
| 40 | }; |
| 41 | |
| 42 | it('meldet die doppelte Haltlinienkennung, statt sie stumm neu zu vergeben', () => { |
| 43 | const { project, issues } = parseProject({ lageplan: lageplanMitDoppelterKennung }); |
| 44 | |
| 45 | expect(project.lageplan.haltlinien).toHaveLength(2); |
| 46 | expect(project.lageplan.haltlinien[0]!.id).not.toBe(project.lageplan.haltlinien[1]!.id); |
| 47 | expect( |
| 48 | issues.some((i) => i.path === 'lageplan.haltlinien[1]' && i.severity === 'warnung'), |
| 49 | ).toBe(true); |
| 50 | }); |
| 51 | |
| 52 | it('zieht die Fahrlinie nicht auf die fremde Haltlinie, sondern loest den mehrdeutigen Verweis auf', () => { |
| 53 | const { project, issues } = parseProject({ lageplan: lageplanMitDoppelterKennung }); |
| 54 | |
| 55 | expect(project.lageplan.linien[0]!.punkte[0]).toEqual({ x: 20, y: 900 }); |
| 56 | expect(project.lageplan.linien[0]!.haltlinieId).toBeNull(); |
| 57 | expect( |
| 58 | issues.some((i) => i.path === 'lageplan.linien[0].haltlinieId' && i.severity === 'warnung'), |
| 59 | ).toBe(true); |
| 60 | }); |
| 61 | |
| 62 | it('laesst eindeutige Haltlinienkennungen samt ihren Fahrlinien unberuehrt', () => { |
| 63 | const { project, issues } = parseProject({ |
| 64 | lageplan: { |
| 65 | haltlinien: [ |
| 66 | { |
| 67 | id: 'hl-nord', |
| 68 | name: 'Nord', |
| 69 | art: 'zufahrt', |
| 70 | von: { x: 0, y: 0 }, |
| 71 | bis: { x: 40, y: 0 }, |
| 72 | }, |
| 73 | { |
| 74 | id: 'hl-sued', |
| 75 | name: 'Süd', |
| 76 | art: 'zufahrt', |
| 77 | von: { x: 0, y: 900 }, |
| 78 | bis: { x: 40, y: 900 }, |
| 79 | }, |
| 80 | ], |
| 81 | linien: [ |
| 82 | { |
| 83 | id: 'pl-sued', |
| 84 | name: 'Süd geradeaus', |
| 85 | mode: 'kfz', |
| 86 | movement: 'geradeaus', |
| 87 | punkte: [ |
| 88 | { x: 20, y: 900 }, |
| 89 | { x: 20, y: 500 }, |
| 90 | ], |
| 91 | haltlinieId: 'hl-sued', |
| 92 | startT: 0.5, |
| 93 | }, |
| 94 | ], |
| 95 | }, |
| 96 | }); |
| 97 | |
| 98 | expect(project.lageplan.haltlinien.map((h) => h.id)).toEqual(['hl-nord', 'hl-sued']); |
| 99 | expect(project.lageplan.linien[0]!.haltlinieId).toBe('hl-sued'); |
| 100 | expect(project.lageplan.linien[0]!.punkte[0]).toEqual({ x: 20, y: 900 }); |
| 101 | expect(issues.filter((i) => i.path.startsWith('lageplan'))).toEqual([]); |
| 102 | }); |
| 103 | |
| 104 | it('haelt den Verweis auf die verbliebene Haltlinie, wenn die zweite ohne Ausdehnung verworfen wird', () => { |
| 105 | const { project } = parseProject({ |
| 106 | lageplan: { |
| 107 | haltlinien: [ |
| 108 | { |
| 109 | id: 'hl-doppelt', |
| 110 | name: 'Nord', |
| 111 | art: 'zufahrt', |
| 112 | von: { x: 0, y: 0 }, |
| 113 | bis: { x: 40, y: 0 }, |
| 114 | }, |
| 115 | { |
| 116 | id: 'hl-doppelt', |
| 117 | name: 'Entartet', |
| 118 | art: 'zufahrt', |
| 119 | von: { x: 5, y: 900 }, |
| 120 | bis: { x: 5, y: 900 }, |
| 121 | }, |
| 122 | ], |
| 123 | linien: [ |
| 124 | { |
| 125 | id: 'pl-nord', |
| 126 | name: 'Nord geradeaus', |
| 127 | mode: 'kfz', |
| 128 | movement: 'geradeaus', |
| 129 | punkte: [ |
| 130 | { x: 20, y: 0 }, |
| 131 | { x: 20, y: 400 }, |
| 132 | ], |
| 133 | haltlinieId: 'hl-doppelt', |
| 134 | startT: 0.5, |
| 135 | }, |
| 136 | ], |
| 137 | }, |
| 138 | }); |
| 139 | |
| 140 | expect(project.lageplan.haltlinien).toHaveLength(1); |
| 141 | expect(project.lageplan.linien[0]!.haltlinieId).toBe('hl-doppelt'); |
| 142 | }); |
| 143 | }); |