Skip to content

Commit fbc6878

Browse files
Tests 1
1 parent 37326c4 commit fbc6878

File tree

19 files changed

+219
-64
lines changed

19 files changed

+219
-64
lines changed

assets/controllers/_stimulus_autocomplete.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ export default class Autocomplete extends Controller {
5858
}
5959

6060
this.readyValue = true
61-
62-
this._loadingDisabled = false;
6361
}
6462

6563
disconnect() {

src/Application/Regulation/Command/Location/SaveNumberedRoadCommand.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ final class SaveNumberedRoadCommand implements RoadCommandInterface
1818
public ?string $roadType = null; // Used by validation
1919
public ?string $administrator = null;
2020
public ?string $roadNumber = null;
21-
public ?string $fromPointNumber = null;
2221
public ?string $fromDepartmentCode = null;
22+
public ?string $fromPointNumber = null;
2323
public ?int $fromAbscissa = null;
2424
public ?string $fromSide = null;
25-
public ?string $toPointNumber = null;
2625
public ?string $toDepartmentCode = null;
26+
public ?string $toPointNumber = null;
2727
public ?int $toAbscissa = null;
2828
public ?string $toSide = null;
2929
public string $direction = DirectionEnum::BOTH->value;
@@ -40,32 +40,32 @@ final class SaveNumberedRoadCommand implements RoadCommandInterface
4040
public function __construct(
4141
public ?NumberedRoad $numberedRoad = null,
4242
) {
43-
$fromPointNumber = $numberedRoad?->getFromPointNumber();
4443
$fromDepartmentCode = $numberedRoad?->getFromDepartmentCode();
45-
$toPointNumber = $numberedRoad?->getToPointNumber();
44+
$fromPointNumber = $numberedRoad?->getFromPointNumber();
4645
$toDepartmentCode = $numberedRoad?->getToDepartmentCode();
46+
$toPointNumber = $numberedRoad?->getToPointNumber();
4747

4848
$this->administrator = $numberedRoad?->getAdministrator();
4949
$this->roadNumber = $numberedRoad?->getRoadNumber();
5050
$this->fromSide = $numberedRoad?->getFromSide();
51-
$this->fromPointNumber = $fromPointNumber;
5251
$this->fromDepartmentCode = $fromDepartmentCode;
52+
$this->fromPointNumber = $fromPointNumber;
5353
$this->fromAbscissa = $numberedRoad?->getFromAbscissa();
54-
$this->toPointNumber = $toPointNumber;
5554
$this->toDepartmentCode = $toDepartmentCode;
55+
$this->toPointNumber = $toPointNumber;
5656
$this->toAbscissa = $numberedRoad?->getToAbscissa();
5757
$this->toSide = $numberedRoad?->getToSide();
5858
$this->direction = $numberedRoad?->getDirection() ?? DirectionEnum::BOTH->value;
5959
$this->storageArea = $numberedRoad?->getLocation()?->getStorageArea();
6060
$this->roadType = $numberedRoad?->getLocation()?->getRoadType();
6161

62-
$this->fromPointNumberValue = self::encodePointNumberValue($fromPointNumber, $fromDepartmentCode);
63-
$this->fromPointNumberDisplayedValue = self::encodePointNumberDisplayedValue($fromPointNumber, $fromDepartmentCode);
64-
$this->toPointNumberValue = self::encodePointNumberValue($toPointNumber, $toDepartmentCode);
65-
$this->toPointNumberDisplayedValue = self::encodePointNumberDisplayedValue($toPointNumber, $toDepartmentCode);
62+
$this->fromPointNumberValue = self::encodePointNumberValue($fromDepartmentCode, $fromPointNumber);
63+
$this->fromPointNumberDisplayedValue = self::encodePointNumberDisplayedValue($fromDepartmentCode, $fromPointNumber);
64+
$this->toPointNumberValue = self::encodePointNumberValue($toDepartmentCode, $toPointNumber);
65+
$this->toPointNumberDisplayedValue = self::encodePointNumberDisplayedValue($toDepartmentCode, $toPointNumber);
6666
}
6767

68-
public static function encodePointNumberValue(?string $pointNumber, ?string $departmentCode): ?string
68+
public static function encodePointNumberValue(?string $departmentCode, ?string $pointNumber): ?string
6969
{
7070
if (empty($pointNumber)) {
7171
return null;
@@ -75,19 +75,23 @@ public static function encodePointNumberValue(?string $pointNumber, ?string $dep
7575
return $pointNumber;
7676
}
7777

78-
return implode('##', [$pointNumber, $departmentCode]);
78+
return implode('##', [$departmentCode, $pointNumber]);
7979
}
8080

81-
public static function decodePointNumberValue(string $value): array
81+
public static function decodePointNumberValue(?string $value): array
8282
{
83-
// '122' -> ['122', null]
84-
// '122#22' -> ['122', '22']
83+
if (empty($value)) {
84+
return [null, null];
85+
}
86+
87+
// '122' -> [null, '122]
88+
// '122#22' -> ['22', '122']
8589
$parts = explode('##', $value, 2);
8690

87-
return \count($parts) === 2 ? $parts : [$value, null];
91+
return \count($parts) === 2 ? $parts : [null, $value];
8892
}
8993

90-
public static function encodePointNumberDisplayedValue(?string $pointNumber, ?string $departmentCode): ?string
94+
public static function encodePointNumberDisplayedValue(?string $departmentCode, ?string $pointNumber): ?string
9195
{
9296
if (empty($pointNumber)) {
9397
return null;
@@ -118,7 +122,7 @@ public function clean(): void
118122
$this->storageArea = null;
119123
}
120124

121-
[$this->fromPointNumber, $this->fromDepartmentCode] = self::decodePointNumberValue($this->fromPointNumberValue);
122-
[$this->toPointNumber, $this->toDepartmentCode] = self::decodePointNumberValue($this->toPointNumberValue);
125+
[$this->fromDepartmentCode, $this->fromPointNumber] = self::decodePointNumberValue($this->fromPointNumberValue);
126+
[$this->toDepartmentCode, $this->toPointNumber] = self::decodePointNumberValue($this->toPointNumberValue);
123127
}
124128
}

src/Application/Regulation/Command/Location/SaveNumberedRoadCommandHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function __invoke(SaveNumberedRoadCommand $command): NumberedRoad
2626
direction: $command->direction,
2727
roadNumber: $command->roadNumber,
2828
administrator: $command->administrator,
29-
fromPointNumber: $command->fromPointNumber,
3029
fromDepartmentCode: $command->fromDepartmentCode,
30+
fromPointNumber: $command->fromPointNumber,
3131
fromAbscissa: $command->fromAbscissa,
3232
fromSide: $command->fromSide,
33-
toPointNumber: $command->toPointNumber,
3433
toDepartmentCode: $command->toDepartmentCode,
34+
toPointNumber: $command->toPointNumber,
3535
toAbscissa: $command->toAbscissa,
3636
toSide: $command->toSide,
3737
),
@@ -48,12 +48,12 @@ public function __invoke(SaveNumberedRoadCommand $command): NumberedRoad
4848
$command->numberedRoad->update(
4949
administrator: $command->administrator,
5050
roadNumber: $command->roadNumber,
51-
fromPointNumber: $command->fromPointNumber,
5251
fromDepartmentCode: $command->fromDepartmentCode,
52+
fromPointNumber: $command->fromPointNumber,
5353
fromAbscissa: $command->fromAbscissa,
5454
fromSide: $command->fromSide,
55-
toPointNumber: $command->toPointNumber,
5655
toDepartmentCode: $command->toDepartmentCode,
56+
toPointNumber: $command->toPointNumber,
5757
toAbscissa: $command->toAbscissa,
5858
toSide: $command->toSide,
5959
direction: $command->direction,

src/Application/Regulation/Query/Location/GetNumberedRoadGeometryQueryHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ private function computeGeometry(GetNumberedRoadGeometryQuery $query): string
4040
$command->roadType,
4141
$command->administrator,
4242
$command->roadNumber,
43-
$command->fromPointNumber,
4443
$command->fromDepartmentCode,
44+
$command->fromPointNumber,
4545
$command->fromSide,
4646
$command->fromAbscissa ?? 0,
47-
$command->toPointNumber,
4847
$command->toDepartmentCode,
48+
$command->toPointNumber,
4949
$command->toSide,
5050
$command->toAbscissa ?? 0,
5151
$command->direction,
@@ -60,6 +60,8 @@ private function shouldRecomputeGeometry(GetNumberedRoadGeometryQuery $query): b
6060
return !$numberedRoad
6161
|| $command->roadNumber !== $numberedRoad->getRoadNumber()
6262
|| $command->administrator !== $numberedRoad->getAdministrator()
63+
|| $command->fromDepartmentCode !== $numberedRoad->getFromDepartmentCode()
64+
|| $command->toDepartmentCode !== $numberedRoad->getToDepartmentCode()
6365
|| $command->fromPointNumber !== $numberedRoad->getFromPointNumber()
6466
|| $command->toPointNumber !== $numberedRoad->getToPointNumber()
6567
|| $command->fromAbscissa !== $numberedRoad->getFromAbscissa()

src/Application/RoadGeocoderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function computeReferencePoint(
2222
string $roadType,
2323
string $administrator,
2424
string $roadNumber,
25-
string $pointNumber,
2625
?string $departmentCode,
26+
string $pointNumber,
2727
string $side,
2828
int $abscissa,
2929
): Coordinates;
3030

31-
public function findSides(string $administrator, string $roadNumber, string $pointNumber, ?string $departmentCode): array;
31+
public function findSides(string $administrator, string $roadNumber, ?string $departmentCode, string $pointNumber): array;
3232

3333
public function findRoadNames(string $search, string $cityCode): array;
3434

src/Application/RoadSectionMakerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public function computeSection(
1111
string $roadType,
1212
string $administrator,
1313
string $roadNumber,
14-
string $fromPointNumber,
1514
?string $fromDepartmentCode,
15+
string $fromPointNumber,
1616
string $fromSide,
1717
int $fromAbscissa,
18-
string $toPointNumber,
1918
?string $toDepartmentCode,
19+
string $toPointNumber,
2020
string $toSide,
2121
int $toAbscissa,
2222
string $direction,

src/Domain/Regulation/Location/NumberedRoad.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public function __construct(
1212
private string $direction,
1313
private ?string $administrator = null,
1414
private ?string $roadNumber = null,
15-
private ?string $fromPointNumber = null,
1615
private ?string $fromDepartmentCode = null,
16+
private ?string $fromPointNumber = null,
1717
private ?string $fromSide = null,
1818
private ?int $fromAbscissa = null,
19-
private ?string $toPointNumber = null,
2019
private ?string $toDepartmentCode = null,
20+
private ?string $toPointNumber = null,
2121
private ?string $toSide = null,
2222
private ?int $toAbscissa = null,
2323
) {
@@ -92,23 +92,23 @@ public function update(
9292
string $direction,
9393
?string $administrator = null,
9494
?string $roadNumber = null,
95-
?string $fromPointNumber = null,
9695
?string $fromDepartmentCode = null,
96+
?string $fromPointNumber = null,
9797
?string $fromSide = null,
9898
?int $fromAbscissa = null,
99-
?string $toPointNumber = null,
10099
?string $toDepartmentCode = null,
100+
?string $toPointNumber = null,
101101
?string $toSide = null,
102102
?int $toAbscissa = null,
103103
): void {
104104
$this->administrator = $administrator;
105105
$this->roadNumber = $roadNumber;
106-
$this->fromPointNumber = $fromPointNumber;
107106
$this->fromDepartmentCode = $fromDepartmentCode;
107+
$this->fromPointNumber = $fromPointNumber;
108108
$this->fromSide = $fromSide;
109109
$this->fromAbscissa = $fromAbscissa;
110-
$this->toPointNumber = $toPointNumber;
111110
$this->toDepartmentCode = $toDepartmentCode;
111+
$this->toPointNumber = $toPointNumber;
112112
$this->toSide = $toSide;
113113
$this->toAbscissa = $toAbscissa;
114114
$this->direction = $direction;

src/Infrastructure/Adapter/BdTopoRoadGeocoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public function computeReferencePoint(
179179
string $roadType,
180180
string $administrator,
181181
string $roadNumber,
182-
string $pointNumber,
183182
?string $departmentCode,
183+
string $pointNumber,
184184
string $side,
185185
int $abscissa,
186186
): Coordinates {
@@ -266,7 +266,7 @@ public function computeReferencePoint(
266266
}
267267
}
268268

269-
public function findSides(string $administrator, string $roadNumber, string $pointNumber, ?string $departmentCode): array
269+
public function findSides(string $administrator, string $roadNumber, ?string $departmentCode, string $pointNumber): array
270270
{
271271
try {
272272
$rows = $this->bdtopoConnection->fetchAllAssociative(

src/Infrastructure/Adapter/RoadSectionMaker.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public function computeSection(
2727
string $roadType,
2828
string $administrator,
2929
string $roadNumber,
30-
string $fromPointNumber,
3130
?string $fromDepartmentCode,
31+
string $fromPointNumber,
3232
string $fromSide,
3333
?int $fromAbscissa,
34-
string $toPointNumber,
3534
?string $toDepartmentCode,
35+
string $toPointNumber,
3636
string $toSide,
3737
int $toAbscissa,
3838
string $direction,
3939
): string {
4040
try {
4141
$fromCoords = $this->roadGeocoder
42-
->computeReferencePoint($roadType, $administrator, $roadNumber, $fromPointNumber, $fromDepartmentCode, $fromSide, $fromAbscissa);
42+
->computeReferencePoint($roadType, $administrator, $roadNumber, $fromDepartmentCode, $fromPointNumber, $fromSide, $fromAbscissa);
4343
} catch (AbscissaOutOfRangeException $e) {
4444
throw new StartAbscissaOutOfRangeException($roadType, previous: $e);
4545
} catch (GeocodingFailureException $e) {
@@ -48,7 +48,7 @@ public function computeSection(
4848

4949
try {
5050
$toCoords = $this->roadGeocoder
51-
->computeReferencePoint($roadType, $administrator, $roadNumber, $toPointNumber, $toDepartmentCode, $toSide, $toAbscissa);
51+
->computeReferencePoint($roadType, $administrator, $roadNumber, $toDepartmentCode, $toPointNumber, $toSide, $toAbscissa);
5252
} catch (AbscissaOutOfRangeException $e) {
5353
throw new EndAbscissaOutOfRangeException($roadType, previous: $e);
5454
} catch (GeocodingFailureException $e) {

src/Infrastructure/Controller/Regulation/Fragments/ReferencePointSideOptionsFragmentController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function __invoke(
3333
#[MapQueryParameter] string $currentOption,
3434
#[MapQueryParameter] string $targetId,
3535
): Response {
36-
[$pointNumber, $departmentCode] = SaveNumberedRoadCommand::decodePointNumberValue($pointNumberValue);
36+
[$departmentCode, $pointNumber] = SaveNumberedRoadCommand::decodePointNumberValue($pointNumberValue);
3737

38-
$sides = $this->roadGeocoder->findSides($administrator, $roadNumber, $pointNumber, $departmentCode);
38+
$sides = $this->roadGeocoder->findSides($administrator, $roadNumber, $departmentCode, $pointNumber);
3939

4040
$request->setRequestFormat(TurboBundle::STREAM_FORMAT);
4141

0 commit comments

Comments
 (0)