onroute-policy-engine 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,42 +28,43 @@ function runBridgeFormula(axleConfig, policy) {
|
|
|
28
28
|
// Do not process once we reach the last axle unit
|
|
29
29
|
// in the configuration, as they have all been calculated
|
|
30
30
|
// by then.
|
|
31
|
-
if (index
|
|
31
|
+
if (index <= axleConfig.length) {
|
|
32
32
|
// Initialize the variables for our start axle
|
|
33
33
|
const firstAxle = index + 1;
|
|
34
34
|
let nextAxle = firstAxle + 1;
|
|
35
35
|
if (!axle.numberOfAxles || axle.numberOfAxles < 0) {
|
|
36
36
|
throw new Error(`Invalid or missing number of axles for axle unit number ${firstAxle}`);
|
|
37
37
|
}
|
|
38
|
-
if (!axle.
|
|
38
|
+
if (!axle.axleUnitWeight || axle.axleUnitWeight < 0) {
|
|
39
39
|
throw new Error(`Invalid or missing weight for axle unit number ${firstAxle}`);
|
|
40
40
|
}
|
|
41
|
-
let totalWeight = axle.
|
|
41
|
+
let totalWeight = axle.axleUnitWeight;
|
|
42
42
|
// Spread may be zero or undefined if the axle unit
|
|
43
43
|
// is a single axle. Spacing to next will be zero or
|
|
44
44
|
// undefined for the final axle unit in the configuration.
|
|
45
|
-
if (axle.numberOfAxles > 1 && (!axle.
|
|
45
|
+
if (axle.numberOfAxles > 1 && (!axle.axleSpread || axle.axleSpread < 0)) {
|
|
46
46
|
throw new Error(`Invalid or missing axle spread for axle unit number ${firstAxle}`);
|
|
47
47
|
}
|
|
48
|
-
if (axle.numberOfAxles == 1 && axle.
|
|
48
|
+
if (axle.numberOfAxles == 1 && axle.axleSpread && axle.axleSpread < 0) {
|
|
49
49
|
throw new Error(`Invalid axle spread for single axle unit, cannot be a negative number`);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
throw new Error(`Invalid or missing axle spacing between axle units ${firstAxle} and ${firstAxle + 1}`);
|
|
53
|
-
}
|
|
54
|
-
let wheelbase = ((_a = axle.spread) !== null && _a !== void 0 ? _a : 0) + axle.spacingToNext;
|
|
51
|
+
let wheelbase = (_a = axle.axleSpread) !== null && _a !== void 0 ? _a : 0;
|
|
55
52
|
// Now loop through all of the next axles, building up a group
|
|
56
53
|
// for each.
|
|
57
54
|
axleConfig.slice(firstAxle).forEach((axleN) => {
|
|
58
|
-
var _a
|
|
59
|
-
if (!axleN.
|
|
55
|
+
var _a;
|
|
56
|
+
if (!axleN.axleUnitWeight || axleN.axleUnitWeight < 0) {
|
|
60
57
|
throw new Error(`Invalid or missing weight for axle unit number ${nextAxle}`);
|
|
61
58
|
}
|
|
62
|
-
totalWeight += axleN.
|
|
63
|
-
if (axleN.numberOfAxles > 1 &&
|
|
59
|
+
totalWeight += axleN.axleUnitWeight;
|
|
60
|
+
if (axleN.numberOfAxles > 1 &&
|
|
61
|
+
(!axleN.axleSpread || axleN.axleSpread < 0)) {
|
|
64
62
|
throw new Error(`Invalid or missing axle spread for axle unit number ${nextAxle}`);
|
|
65
63
|
}
|
|
66
|
-
|
|
64
|
+
if (!axleN.interaxleSpacing || axleN.interaxleSpacing < 0) {
|
|
65
|
+
throw new Error(`Invalid or missing axle spacing between axle units ${firstAxle} and ${nextAxle}`);
|
|
66
|
+
}
|
|
67
|
+
wheelbase += ((_a = axleN.axleSpread) !== null && _a !== void 0 ? _a : 0) + axleN.interaxleSpacing;
|
|
67
68
|
// The magic is in the next line
|
|
68
69
|
const maxBridge = BRIDGE_MULTIPLIER * wheelbase + BRIDGE_MIN_WEIGHT;
|
|
69
70
|
// Push the axle group result to the results array, including
|
|
@@ -75,14 +76,6 @@ function runBridgeFormula(axleConfig, policy) {
|
|
|
75
76
|
actualWeight: totalWeight,
|
|
76
77
|
success: totalWeight <= maxBridge,
|
|
77
78
|
});
|
|
78
|
-
// Add the wheelbase only if this end axle unit is not the
|
|
79
|
-
// final one in the configuration
|
|
80
|
-
if (nextAxle < axleConfig.length) {
|
|
81
|
-
if (!axleN.spacingToNext || axleN.spacingToNext < 0) {
|
|
82
|
-
throw new Error(`Invalid or missing axle spacing between axle units ${nextAxle} and ${nextAxle + 1}`);
|
|
83
|
-
}
|
|
84
|
-
wheelbase += (_b = axleN.spacingToNext) !== null && _b !== void 0 ? _b : 0;
|
|
85
|
-
}
|
|
86
79
|
nextAxle++;
|
|
87
80
|
});
|
|
88
81
|
}
|
package/dist/policy-engine.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class Policy {
|
|
|
68
68
|
* other keyed on 'trailers'. Each map consists of a string id for the
|
|
69
69
|
* vehicle, and a string common name for the vehicle.
|
|
70
70
|
*/
|
|
71
|
-
getPermittableVehicleTypes(permitTypeId: string, commodityId?: string): Map<string, Map<string, string>>;
|
|
71
|
+
getPermittableVehicleTypes(permitTypeId: string, commodityId?: string | null): Map<string, Map<string, string>>;
|
|
72
72
|
/**
|
|
73
73
|
* Gets a list of all allowable power unit types for the given permit type
|
|
74
74
|
* and commodity.
|
package/dist/policy-engine.js
CHANGED
|
@@ -719,6 +719,7 @@ class Policy {
|
|
|
719
719
|
* @param permitType Permit type definition
|
|
720
720
|
*/
|
|
721
721
|
getAllowedVehicles(permitType) {
|
|
722
|
+
var _a;
|
|
722
723
|
if (permitType.commodityRequired) {
|
|
723
724
|
// If commodity is required, this method cannot be used since it
|
|
724
725
|
// requires a fixed set of allowed vehicle types, not commodity-based
|
|
@@ -728,8 +729,7 @@ class Policy {
|
|
|
728
729
|
if (!allowedVehicles) {
|
|
729
730
|
return new Map();
|
|
730
731
|
}
|
|
731
|
-
if (!this.specialAuthorizations ||
|
|
732
|
-
!this.specialAuthorizations.isLcvAllowed) {
|
|
732
|
+
if (!((_a = this.specialAuthorizations) === null || _a === void 0 ? void 0 : _a.isLcvAllowed)) {
|
|
733
733
|
allowedVehicles = this.filterOutLongCombinationVehicles(allowedVehicles);
|
|
734
734
|
}
|
|
735
735
|
const allowedVehicleMap = new Map();
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "v1.
|
|
1
|
+
export declare const version = "v1.5.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED