Alpha stage commit
This commit is contained in:
95
packages/shared/src/profiles.js
Normal file
95
packages/shared/src/profiles.js
Normal file
@@ -0,0 +1,95 @@
|
||||
export const BIKEPACKING_PROFILES = {
|
||||
beginner_safe: {
|
||||
id: 'beginner_safe',
|
||||
label: 'Beginner-safe',
|
||||
dailyDistanceKm: { min: 40, target: 55, max: 70 },
|
||||
maxGradeWarningPercent: 10,
|
||||
waterGapMaxKm: 25,
|
||||
foodGapMaxKm: 40,
|
||||
repairGapMaxKm: 80,
|
||||
bailoutGapMaxKm: 50,
|
||||
sleepGapMaxKm: 65,
|
||||
roughSurfaceTolerance: 0.35,
|
||||
trafficTolerance: 0.25,
|
||||
unknownAccessPenalty: 18,
|
||||
preferredSurfaces: ['paved', 'asphalt', 'fine_gravel', 'compacted']
|
||||
},
|
||||
loaded_gravel: {
|
||||
id: 'loaded_gravel',
|
||||
label: 'Loaded gravel',
|
||||
dailyDistanceKm: { min: 60, target: 80, max: 100 },
|
||||
maxGradeWarningPercent: 12,
|
||||
waterGapMaxKm: 40,
|
||||
foodGapMaxKm: 70,
|
||||
repairGapMaxKm: 110,
|
||||
bailoutGapMaxKm: 90,
|
||||
sleepGapMaxKm: 95,
|
||||
roughSurfaceTolerance: 0.6,
|
||||
trafficTolerance: 0.45,
|
||||
unknownAccessPenalty: 12,
|
||||
preferredSurfaces: ['gravel', 'fine_gravel', 'compacted', 'paved', 'asphalt', 'dirt']
|
||||
},
|
||||
hardtail_bikepacking: {
|
||||
id: 'hardtail_bikepacking',
|
||||
label: 'Hardtail bikepacking',
|
||||
dailyDistanceKm: { min: 50, target: 70, max: 90 },
|
||||
maxGradeWarningPercent: 15,
|
||||
waterGapMaxKm: 55,
|
||||
foodGapMaxKm: 90,
|
||||
repairGapMaxKm: 130,
|
||||
bailoutGapMaxKm: 110,
|
||||
sleepGapMaxKm: 100,
|
||||
roughSurfaceTolerance: 0.8,
|
||||
trafficTolerance: 0.35,
|
||||
unknownAccessPenalty: 10,
|
||||
preferredSurfaces: ['dirt', 'singletrack', 'gravel', 'track', 'compacted']
|
||||
},
|
||||
road_touring: {
|
||||
id: 'road_touring',
|
||||
label: 'Road touring',
|
||||
dailyDistanceKm: { min: 70, target: 100, max: 130 },
|
||||
maxGradeWarningPercent: 10,
|
||||
waterGapMaxKm: 40,
|
||||
foodGapMaxKm: 70,
|
||||
repairGapMaxKm: 120,
|
||||
bailoutGapMaxKm: 90,
|
||||
sleepGapMaxKm: 115,
|
||||
roughSurfaceTolerance: 0.2,
|
||||
trafficTolerance: 0.5,
|
||||
unknownAccessPenalty: 14,
|
||||
preferredSurfaces: ['paved', 'asphalt', 'concrete']
|
||||
},
|
||||
ebikepacking: {
|
||||
id: 'ebikepacking',
|
||||
label: 'E-bikepacking',
|
||||
dailyDistanceKm: { min: 50, target: 75, max: 100 },
|
||||
maxGradeWarningPercent: 12,
|
||||
waterGapMaxKm: 40,
|
||||
foodGapMaxKm: 60,
|
||||
repairGapMaxKm: 100,
|
||||
bailoutGapMaxKm: 80,
|
||||
sleepGapMaxKm: 90,
|
||||
roughSurfaceTolerance: 0.5,
|
||||
trafficTolerance: 0.4,
|
||||
unknownAccessPenalty: 15,
|
||||
preferredSurfaces: ['paved', 'asphalt', 'gravel', 'compacted']
|
||||
}
|
||||
};
|
||||
export function getProfile(profileId) {
|
||||
return BIKEPACKING_PROFILES[profileId];
|
||||
}
|
||||
export function thresholdsFromTripRequest(request) {
|
||||
const profile = getProfile(request.profile);
|
||||
return {
|
||||
water: (request.waterGapMaxKm ?? profile.waterGapMaxKm) * 1000,
|
||||
food: (request.foodGapMaxKm ?? profile.foodGapMaxKm) * 1000,
|
||||
repair: profile.repairGapMaxKm * 1000,
|
||||
bailout: (request.requireBailoutEveryKm ?? profile.bailoutGapMaxKm) * 1000,
|
||||
sleep: profile.sleepGapMaxKm * 1000,
|
||||
charging: request.profile === 'ebikepacking' ? 60000 : undefined
|
||||
};
|
||||
}
|
||||
export function maxLoadedGradeForRequest(request) {
|
||||
return request.maxLoadedGradePercent ?? getProfile(request.profile).maxGradeWarningPercent;
|
||||
}
|
||||
//# sourceMappingURL=profiles.js.map
|
||||
Reference in New Issue
Block a user