ropegeo-common 1.19.2 → 1.20.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.
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +18 -2
- package/dist/models/measurements/lengthMeasurement.d.ts +31 -0
- package/dist/models/measurements/lengthMeasurement.d.ts.map +1 -0
- package/dist/models/measurements/lengthMeasurement.js +185 -0
- package/dist/models/measurements/measurement.d.ts +34 -0
- package/dist/models/measurements/measurement.d.ts.map +1 -0
- package/dist/models/measurements/measurement.js +43 -0
- package/dist/models/measurements/measurementValue.d.ts +13 -0
- package/dist/models/measurements/measurementValue.d.ts.map +1 -0
- package/dist/models/measurements/measurementValue.js +37 -0
- package/dist/models/measurements/minMax.d.ts +30 -0
- package/dist/models/measurements/minMax.d.ts.map +1 -0
- package/dist/models/measurements/minMax.js +54 -0
- package/dist/models/measurements/timeMeasurement.d.ts +24 -0
- package/dist/models/measurements/timeMeasurement.d.ts.map +1 -0
- package/dist/models/measurements/timeMeasurement.js +140 -0
- package/dist/models/pageViews/offlineRopewikiPageView.d.ts +4 -16
- package/dist/models/pageViews/offlineRopewikiPageView.d.ts.map +1 -1
- package/dist/models/pageViews/onlineRopewikiPageView.d.ts +5 -5
- package/dist/models/pageViews/onlineRopewikiPageView.d.ts.map +1 -1
- package/dist/models/pageViews/onlineRopewikiPageView.js +4 -2
- package/dist/models/pageViews/ropewikiPageView.d.ts +27 -21
- package/dist/models/pageViews/ropewikiPageView.d.ts.map +1 -1
- package/dist/models/pageViews/ropewikiPageView.js +65 -16
- package/package.json +1 -1
package/dist/models/index.d.ts
CHANGED
|
@@ -86,6 +86,14 @@ export { OnlineRopewikiPageView } from './pageViews/onlineRopewikiPageView';
|
|
|
86
86
|
export { OfflineRopewikiPageView } from './pageViews/offlineRopewikiPageView';
|
|
87
87
|
export type { OnlinePageView } from './pageViews/onlinePageView';
|
|
88
88
|
export type { OfflinePageView } from './pageViews/offlinePageView';
|
|
89
|
+
export { formatMeasurementValue } from './measurements/measurementValue';
|
|
90
|
+
export { Measurement, FREEDOM_MEASUREMENT_SYSTEM } from './measurements/measurement';
|
|
91
|
+
export type { MeasurementUnit } from './measurements/measurement';
|
|
92
|
+
export { MinMax } from './measurements/minMax';
|
|
93
|
+
export { LengthMeasurement, MILES, FEET } from './measurements/lengthMeasurement';
|
|
94
|
+
export type { ImperialSystem, MetricSystem, FreedomSystem, LengthMeasurementUnit, LengthMeasurementSystem, } from './measurements/lengthMeasurement';
|
|
95
|
+
export { TimeMeasurement, MINUTES, HOURS, DAYS } from './measurements/timeMeasurement';
|
|
96
|
+
export type { StandardSystem, TimeMeasurementUnit, TimeMeasurementSystem, } from './measurements/timeMeasurement';
|
|
89
97
|
export { LinkPreview } from './linkPreview/linkPreview';
|
|
90
98
|
export { LinkPreviewImage } from './linkPreview/linkPreviewImage';
|
|
91
99
|
export { RopewikiPageLinkPreviewResult } from './api/results/ropewikiPageLinkPreviewResult';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,8CAA8C,CAAC;AACtD,OAAO,kDAAkD,CAAC;AAC1D,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,qCAAqC,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,iCAAiC,GACpC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACb,MAAM,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AAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,YAAY,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EACH,SAAS,EACT,uBAAuB,EACvB,qCAAqC,EACrC,KAAK,oBAAoB,EACzB,KAAK,iCAAiC,GACzC,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/models/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Preview = exports.RopewikiVehicleType = exports.PermitStatus = exports.SavedFilters = exports.SavedPagesFilter = exports.SearchFilter = exports.RouteFilter = exports.RiskMinMax = exports.TimeMinMax = exports.WaterMinMax = exports.TechnicalMinMax = exports.AcaDifficultyFilterOptions = exports.registerDifficultyFilterOptionsParser = exports.DifficultyFilterOptions = exports.Q_ACA_RISK = exports.Q_ACA_TIME = exports.Q_ACA_WATER = exports.Q_ACA_TECHNICAL = exports.Q_DIFFICULTY_TYPE = exports.AcaDifficultyParams = exports.isDifficultyParamsActive = exports.registerDifficultyParamsQueryParser = exports.registerDifficultyParamsQueryInference = exports.DifficultyParams = exports.AcaRiskRating = exports.AcaTimeRating = exports.AcaWaterRating = exports.AcaTechnicalRating = exports.AcaDifficulty = exports.Difficulty = exports.DifficultyType = exports.DifficultyRisk = exports.DifficultyTime = exports.DifficultyWater = exports.DifficultyTechnical = exports.AcaDifficultyRating = exports.RISK_ORDER = exports.AcaWaterSubRating = exports.AcaTimeSubRating = exports.AcaTechnicalSubRating = exports.AcaRiskSubRating = exports.ACA_WATER_ORDER = exports.ACA_TIME_ORDER = exports.ACA_TECHNICAL_ORDER = exports.ACA_RISK_ORDER = exports.resolveDifficultyRatingFromRecord = exports.registerDifficultyParser = exports.DifficultyRating = exports.DifficultyRatingSystem = exports.PageDataSource = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.DOWNLOADED_ROUTE_PREVIEWS_STORAGE_KEY = exports.SAVED_PAGES_STORAGE_KEY = exports.SavedPage = exports.ImageVersions = exports.VERSION_FORMAT = exports.ImageVersion = exports.RoutePreviewResult = exports.RopewikiRegionImagesResult = exports.RopewikiRegionImagesParams = exports.RopewikiRegionImageView = exports.RegionImagesCursor = exports.RopewikiRegionPreviewsResult = exports.RopewikiRegionPreviewsParams = exports.RegionPreviewsCursor = exports.RopewikiRegionViewResult = exports.RopewikiRegionView = exports.SearchResults = exports.SearchParams = exports.SearchCursor = exports.MapDataTileKeysResults = exports.registerPaginationParser = exports.PaginationResultType = exports.PaginationResults = exports.registerCursorPaginationParser = exports.CursorPaginationResultType = exports.CursorPaginationResults = exports.registerResultParser = exports.ResultType = exports.Result = exports.PaginationParams = void 0;
|
|
4
|
+
exports.MILES = exports.LengthMeasurement = exports.MinMax = exports.FREEDOM_MEASUREMENT_SYSTEM = exports.Measurement = exports.formatMeasurementValue = exports.OfflineRopewikiPageView = exports.OnlineRopewikiPageView = exports.BaseRopewikiPageView = exports.PageView = exports.PageViewType = exports.RopewikiPageViewResult = exports.RopewikiPageView = exports.OfflineCenteredRegionMiniMap = exports.OnlineCenteredRegionMiniMap = exports.OfflineRegionMiniMap = exports.OnlineRegionMiniMap = exports.OfflinePageMiniMap = exports.OnlinePageMiniMap = exports.CenteredRegionMiniMap = exports.PageMiniMap = exports.RegionMiniMap = exports.MiniMap = exports.MiniMapType = exports.PolygonLegendItem = exports.LineLegendItem = exports.PointLegendItem = exports.registerLegendItemParser = exports.LegendItem = exports.LEGEND_FEATURE_TYPES = exports.LegendFeatureType = exports.Bounds = exports.OfflineBetaSection = exports.OnlineBetaSection = exports.BetaSection = exports.DownloadBytes = exports.OfflineBetaSectionImage = exports.OnlineBetaSectionImage = exports.BetaSectionImage = exports.RoutesParams = exports.RouteResult = exports.RoutesGeojson = exports.RouteType = exports.RouteGeoJsonFeature = exports.Route = exports.RegionPreview = exports.OfflinePagePreview = exports.OnlinePagePreview = exports.PagePreview = exports.PreviewType = void 0;
|
|
5
|
+
exports.DOWNLOADED_ROUTE_PREVIEWS_STORAGE_KEY = exports.SAVED_PAGES_STORAGE_KEY = exports.SavedPage = exports.ImageVersions = exports.VERSION_FORMAT = exports.ImageVersion = exports.RoutePreviewResult = exports.RopewikiRegionImagesResult = exports.RopewikiRegionImagesParams = exports.RopewikiRegionImageView = exports.RegionImagesCursor = exports.RopewikiRegionPreviewsResult = exports.RopewikiRegionPreviewsParams = exports.RegionPreviewsCursor = exports.RopewikiRegionViewResult = exports.RopewikiRegionView = exports.SearchResults = exports.SearchParams = exports.SearchCursor = exports.MapDataTileKeysResults = exports.registerPaginationParser = exports.PaginationResultType = exports.PaginationResults = exports.registerCursorPaginationParser = exports.CursorPaginationResultType = exports.CursorPaginationResults = exports.registerResultParser = exports.ResultType = exports.Result = exports.PaginationParams = exports.CursorPaginationParams = exports.CursorType = exports.Cursor = exports.RopewikiPageLinkPreviewResult = exports.LinkPreviewImage = exports.LinkPreview = exports.DAYS = exports.HOURS = exports.MINUTES = exports.TimeMeasurement = exports.FEET = void 0;
|
|
6
6
|
require("./api/results/registerAllResultParsers");
|
|
7
7
|
require("./difficulty/registerDifficultyRatingParsers");
|
|
8
8
|
require("./filters/registerDifficultyFilterOptionsParsers");
|
|
@@ -181,6 +181,22 @@ var onlineRopewikiPageView_1 = require("./pageViews/onlineRopewikiPageView");
|
|
|
181
181
|
Object.defineProperty(exports, "OnlineRopewikiPageView", { enumerable: true, get: function () { return onlineRopewikiPageView_1.OnlineRopewikiPageView; } });
|
|
182
182
|
var offlineRopewikiPageView_1 = require("./pageViews/offlineRopewikiPageView");
|
|
183
183
|
Object.defineProperty(exports, "OfflineRopewikiPageView", { enumerable: true, get: function () { return offlineRopewikiPageView_1.OfflineRopewikiPageView; } });
|
|
184
|
+
var measurementValue_1 = require("./measurements/measurementValue");
|
|
185
|
+
Object.defineProperty(exports, "formatMeasurementValue", { enumerable: true, get: function () { return measurementValue_1.formatMeasurementValue; } });
|
|
186
|
+
var measurement_1 = require("./measurements/measurement");
|
|
187
|
+
Object.defineProperty(exports, "Measurement", { enumerable: true, get: function () { return measurement_1.Measurement; } });
|
|
188
|
+
Object.defineProperty(exports, "FREEDOM_MEASUREMENT_SYSTEM", { enumerable: true, get: function () { return measurement_1.FREEDOM_MEASUREMENT_SYSTEM; } });
|
|
189
|
+
var minMax_1 = require("./measurements/minMax");
|
|
190
|
+
Object.defineProperty(exports, "MinMax", { enumerable: true, get: function () { return minMax_1.MinMax; } });
|
|
191
|
+
var lengthMeasurement_1 = require("./measurements/lengthMeasurement");
|
|
192
|
+
Object.defineProperty(exports, "LengthMeasurement", { enumerable: true, get: function () { return lengthMeasurement_1.LengthMeasurement; } });
|
|
193
|
+
Object.defineProperty(exports, "MILES", { enumerable: true, get: function () { return lengthMeasurement_1.MILES; } });
|
|
194
|
+
Object.defineProperty(exports, "FEET", { enumerable: true, get: function () { return lengthMeasurement_1.FEET; } });
|
|
195
|
+
var timeMeasurement_1 = require("./measurements/timeMeasurement");
|
|
196
|
+
Object.defineProperty(exports, "TimeMeasurement", { enumerable: true, get: function () { return timeMeasurement_1.TimeMeasurement; } });
|
|
197
|
+
Object.defineProperty(exports, "MINUTES", { enumerable: true, get: function () { return timeMeasurement_1.MINUTES; } });
|
|
198
|
+
Object.defineProperty(exports, "HOURS", { enumerable: true, get: function () { return timeMeasurement_1.HOURS; } });
|
|
199
|
+
Object.defineProperty(exports, "DAYS", { enumerable: true, get: function () { return timeMeasurement_1.DAYS; } });
|
|
184
200
|
var linkPreview_1 = require("./linkPreview/linkPreview");
|
|
185
201
|
Object.defineProperty(exports, "LinkPreview", { enumerable: true, get: function () { return linkPreview_1.LinkPreview; } });
|
|
186
202
|
var linkPreviewImage_1 = require("./linkPreview/linkPreviewImage");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Measurement } from './measurement';
|
|
2
|
+
export type ImperialSystem = {
|
|
3
|
+
measurementSystem: 'Imperial';
|
|
4
|
+
name: 'feet' | 'miles';
|
|
5
|
+
};
|
|
6
|
+
export type MetricSystem = {
|
|
7
|
+
measurementSystem: 'Metric';
|
|
8
|
+
name: 'meters' | 'kilometers';
|
|
9
|
+
};
|
|
10
|
+
export type FreedomSystem = {
|
|
11
|
+
measurementSystem: 'Freedom';
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export type LengthMeasurementUnit = ImperialSystem | MetricSystem | FreedomSystem;
|
|
15
|
+
export type LengthMeasurementSystem = 'Imperial' | 'Metric' | 'Freedom';
|
|
16
|
+
/** Convenience unit descriptors for the units RopeWiki stores lengths/elevations in. */
|
|
17
|
+
export declare const MILES: ImperialSystem;
|
|
18
|
+
export declare const FEET: ImperialSystem;
|
|
19
|
+
/** A length with an explicit unit, convertible between Imperial, Metric, and Freedom systems. */
|
|
20
|
+
export declare class LengthMeasurement extends Measurement {
|
|
21
|
+
readonly measurementType: "length";
|
|
22
|
+
readonly unit: LengthMeasurementUnit;
|
|
23
|
+
constructor(value: number, unit: LengthMeasurementUnit);
|
|
24
|
+
toMeasurementSystem(system: LengthMeasurementSystem, unitName?: string): LengthMeasurement;
|
|
25
|
+
protected abbreviate(): string;
|
|
26
|
+
private toFreedom;
|
|
27
|
+
private static defaultTargetName;
|
|
28
|
+
static fromResult(json: unknown): LengthMeasurement;
|
|
29
|
+
static coerce(value: unknown, defaultUnit: LengthMeasurementUnit): LengthMeasurement | null;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=lengthMeasurement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lengthMeasurement.d.ts","sourceRoot":"","sources":["../../../src/models/measurements/lengthMeasurement.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG;IAAE,iBAAiB,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AACvF,MAAM,MAAM,YAAY,GAAG;IAAE,iBAAiB,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAA;CAAE,CAAC;AAC1F,MAAM,MAAM,aAAa,GAAG;IAAE,iBAAiB,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3E,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC;AAClF,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE,wFAAwF;AACxF,eAAO,MAAM,KAAK,EAAE,cAAiE,CAAC;AACtF,eAAO,MAAM,IAAI,EAAE,cAAgE,CAAC;AA8EpF,iGAAiG;AACjG,qBAAa,iBAAkB,SAAQ,WAAW;IAC9C,QAAQ,CAAC,eAAe,EAAG,QAAQ,CAAU;IAC7C,SAAiB,IAAI,EAAE,qBAAqB,CAAC;gBAEjC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB;IAItD,mBAAmB,CACf,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,CAAC,EAAE,MAAM,GAClB,iBAAiB;IAuBpB,SAAS,CAAC,UAAU,IAAI,MAAM;IAe9B,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAUhC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB;IAkBnD,MAAM,CAAC,MAAM,CACT,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,qBAAqB,GACnC,iBAAiB,GAAG,IAAI;CAiB9B"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LengthMeasurement = exports.FEET = exports.MILES = void 0;
|
|
4
|
+
const measurement_1 = require("./measurement");
|
|
5
|
+
/** Convenience unit descriptors for the units RopeWiki stores lengths/elevations in. */
|
|
6
|
+
exports.MILES = { measurementSystem: 'Imperial', name: 'miles' };
|
|
7
|
+
exports.FEET = { measurementSystem: 'Imperial', name: 'feet' };
|
|
8
|
+
const FEET_PER_METER = 3.280839895013123;
|
|
9
|
+
/** Length of one unit of each Imperial/Metric name, expressed in meters. */
|
|
10
|
+
const METERS_PER_UNIT = {
|
|
11
|
+
feet: 0.3048,
|
|
12
|
+
miles: 1609.344,
|
|
13
|
+
meters: 1,
|
|
14
|
+
kilometers: 1000,
|
|
15
|
+
};
|
|
16
|
+
const IMPERIAL_NAMES = ['feet', 'miles'];
|
|
17
|
+
const METRIC_NAMES = ['meters', 'kilometers'];
|
|
18
|
+
/** Imperial <-> Metric tier mapping used when no explicit unit name is requested. */
|
|
19
|
+
const TIER_MAP = {
|
|
20
|
+
feet: 'meters',
|
|
21
|
+
miles: 'kilometers',
|
|
22
|
+
meters: 'feet',
|
|
23
|
+
kilometers: 'miles',
|
|
24
|
+
};
|
|
25
|
+
const FEET_PER_INCH = 1 / 12;
|
|
26
|
+
function feetFromInches(inches) {
|
|
27
|
+
return inches * FEET_PER_INCH;
|
|
28
|
+
}
|
|
29
|
+
function feetFromMeters(meters) {
|
|
30
|
+
return meters * FEET_PER_METER;
|
|
31
|
+
}
|
|
32
|
+
function feetFromMiles(miles) {
|
|
33
|
+
return miles * METERS_PER_UNIT.miles * FEET_PER_METER;
|
|
34
|
+
}
|
|
35
|
+
/** Length of each freedom unit in feet. Ranges pick a random value within `[minFeet, maxFeet]`. */
|
|
36
|
+
const FREEDOM_LENGTH_UNITS = {
|
|
37
|
+
"McDonald's Big Macs": { minFeet: feetFromInches(2.75), maxFeet: feetFromInches(3.5) },
|
|
38
|
+
'Football Fields': fixed(300),
|
|
39
|
+
'Walmart Supercenters': { minFeet: 400, maxFeet: 500 },
|
|
40
|
+
'Olympic Swimming Pools': fixed(feetFromMeters(50)),
|
|
41
|
+
'M1A1 Abrams Main Battle Tanks': fixed(32.04),
|
|
42
|
+
'Mount Rushmores': fixed(5725),
|
|
43
|
+
'White Houses': fixed(168),
|
|
44
|
+
'AR-15 Carbines': { minFeet: feetFromInches(32.5), maxFeet: feetFromInches(36) },
|
|
45
|
+
'Rhode Islands': fixed(feetFromMiles(48)),
|
|
46
|
+
'Statues of Liberty': fixed(305 + feetFromInches(1)),
|
|
47
|
+
Horses: fixed(8),
|
|
48
|
+
'City Blocks': { minFeet: feetFromMeters(100), maxFeet: feetFromMeters(200) },
|
|
49
|
+
'Nautical Mile': fixed(feetFromMiles(1.151)),
|
|
50
|
+
Leagues: fixed(feetFromMiles(3)),
|
|
51
|
+
Cubits: fixed(feetFromInches(17.5)),
|
|
52
|
+
Fathoms: fixed(6),
|
|
53
|
+
Poppyseeds: fixed(feetFromInches(0.083)),
|
|
54
|
+
Furlongs: fixed(660),
|
|
55
|
+
Paces: fixed(feetFromInches(30)),
|
|
56
|
+
};
|
|
57
|
+
function fixed(feet) {
|
|
58
|
+
return { minFeet: feet, maxFeet: feet };
|
|
59
|
+
}
|
|
60
|
+
function randomInRange(min, max) {
|
|
61
|
+
if (min === max)
|
|
62
|
+
return min;
|
|
63
|
+
return min + Math.random() * (max - min);
|
|
64
|
+
}
|
|
65
|
+
function pickRandomKey(record) {
|
|
66
|
+
const keys = Object.keys(record);
|
|
67
|
+
return keys[Math.floor(Math.random() * keys.length)];
|
|
68
|
+
}
|
|
69
|
+
/** A length with an explicit unit, convertible between Imperial, Metric, and Freedom systems. */
|
|
70
|
+
class LengthMeasurement extends measurement_1.Measurement {
|
|
71
|
+
constructor(value, unit) {
|
|
72
|
+
super(value, unit);
|
|
73
|
+
this.measurementType = 'length';
|
|
74
|
+
}
|
|
75
|
+
toMeasurementSystem(system, unitName) {
|
|
76
|
+
const unit = this.unit;
|
|
77
|
+
if (unit.measurementSystem === measurement_1.FREEDOM_MEASUREMENT_SYSTEM) {
|
|
78
|
+
throw new Error('Freedom units cannot be converted to any other system because they are the best units.');
|
|
79
|
+
}
|
|
80
|
+
if (system === 'Freedom') {
|
|
81
|
+
return this.toFreedom(unit, unitName);
|
|
82
|
+
}
|
|
83
|
+
const targetName = unitName != null
|
|
84
|
+
? assertStandardUnit(system, unitName)
|
|
85
|
+
: LengthMeasurement.defaultTargetName(unit, system);
|
|
86
|
+
const meters = this.value * METERS_PER_UNIT[unit.name];
|
|
87
|
+
const value = meters / METERS_PER_UNIT[targetName];
|
|
88
|
+
const targetUnit = system === 'Imperial'
|
|
89
|
+
? { measurementSystem: 'Imperial', name: targetName }
|
|
90
|
+
: { measurementSystem: 'Metric', name: targetName };
|
|
91
|
+
return new LengthMeasurement(value, targetUnit);
|
|
92
|
+
}
|
|
93
|
+
abbreviate() {
|
|
94
|
+
switch (this.unit.name) {
|
|
95
|
+
case 'feet':
|
|
96
|
+
return 'ft';
|
|
97
|
+
case 'miles':
|
|
98
|
+
return 'mi';
|
|
99
|
+
case 'meters':
|
|
100
|
+
return 'm';
|
|
101
|
+
case 'kilometers':
|
|
102
|
+
return 'km';
|
|
103
|
+
default:
|
|
104
|
+
return this.unit.name;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
toFreedom(unit, unitName) {
|
|
108
|
+
const feet = this.value * METERS_PER_UNIT[unit.name] * FEET_PER_METER;
|
|
109
|
+
const name = unitName ?? pickRandomKey(FREEDOM_LENGTH_UNITS);
|
|
110
|
+
const entry = FREEDOM_LENGTH_UNITS[name];
|
|
111
|
+
if (entry == null) {
|
|
112
|
+
throw new Error(`LengthMeasurement: "${name}" is not a known Freedom unit`);
|
|
113
|
+
}
|
|
114
|
+
const unitFeet = randomInRange(entry.minFeet, entry.maxFeet);
|
|
115
|
+
return new LengthMeasurement(feet / unitFeet, {
|
|
116
|
+
measurementSystem: 'Freedom',
|
|
117
|
+
name,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
static defaultTargetName(unit, targetSystem) {
|
|
121
|
+
if (unit.measurementSystem === targetSystem) {
|
|
122
|
+
return unit.name;
|
|
123
|
+
}
|
|
124
|
+
return TIER_MAP[unit.name];
|
|
125
|
+
}
|
|
126
|
+
static fromResult(json) {
|
|
127
|
+
if (json == null || typeof json !== 'object') {
|
|
128
|
+
throw new Error('LengthMeasurement result must be an object');
|
|
129
|
+
}
|
|
130
|
+
const r = json;
|
|
131
|
+
if (r.measurementType !== 'length') {
|
|
132
|
+
throw new Error(`LengthMeasurement.measurementType must be "length", got: ${JSON.stringify(r.measurementType)}`);
|
|
133
|
+
}
|
|
134
|
+
if (typeof r.value !== 'number' || !Number.isFinite(r.value)) {
|
|
135
|
+
throw new Error(`LengthMeasurement.value must be a finite number, got: ${JSON.stringify(r.value)}`);
|
|
136
|
+
}
|
|
137
|
+
return new LengthMeasurement(r.value, parseLengthUnit(r.unit));
|
|
138
|
+
}
|
|
139
|
+
static coerce(value, defaultUnit) {
|
|
140
|
+
if (value == null) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
if (value instanceof LengthMeasurement) {
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
if (typeof value === 'number') {
|
|
147
|
+
if (!Number.isFinite(value)) {
|
|
148
|
+
throw new Error(`LengthMeasurement.coerce: numeric value must be finite, got: ${value}`);
|
|
149
|
+
}
|
|
150
|
+
return new LengthMeasurement(value, defaultUnit);
|
|
151
|
+
}
|
|
152
|
+
return LengthMeasurement.fromResult(value);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.LengthMeasurement = LengthMeasurement;
|
|
156
|
+
function assertStandardUnit(system, name) {
|
|
157
|
+
const allowed = system === 'Imperial' ? IMPERIAL_NAMES : METRIC_NAMES;
|
|
158
|
+
if (!allowed.includes(name)) {
|
|
159
|
+
throw new Error(`LengthMeasurement: "${name}" is not a valid ${system} unit (expected one of [${allowed.join(', ')}])`);
|
|
160
|
+
}
|
|
161
|
+
return name;
|
|
162
|
+
}
|
|
163
|
+
function parseLengthUnit(u) {
|
|
164
|
+
if (u == null || typeof u !== 'object') {
|
|
165
|
+
throw new Error('LengthMeasurement.unit must be an object');
|
|
166
|
+
}
|
|
167
|
+
const o = u;
|
|
168
|
+
const { measurementSystem, name } = o;
|
|
169
|
+
if (typeof name !== 'string') {
|
|
170
|
+
throw new Error('LengthMeasurement.unit.name must be a string');
|
|
171
|
+
}
|
|
172
|
+
if (measurementSystem === 'Imperial') {
|
|
173
|
+
return { measurementSystem: 'Imperial', name: assertStandardUnit('Imperial', name) };
|
|
174
|
+
}
|
|
175
|
+
if (measurementSystem === 'Metric') {
|
|
176
|
+
return {
|
|
177
|
+
measurementSystem: 'Metric',
|
|
178
|
+
name: assertStandardUnit('Metric', name),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (measurementSystem === 'Freedom') {
|
|
182
|
+
return { measurementSystem: 'Freedom', name };
|
|
183
|
+
}
|
|
184
|
+
throw new Error(`LengthMeasurement.unit.measurementSystem must be Imperial, Metric, or Freedom, got: ${JSON.stringify(measurementSystem)}`);
|
|
185
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Marker for the "best" measurement system; freedom units render/behave specially. */
|
|
2
|
+
export declare const FREEDOM_MEASUREMENT_SYSTEM = "Freedom";
|
|
3
|
+
/** Base shape shared by every unit descriptor. */
|
|
4
|
+
export interface MeasurementUnit {
|
|
5
|
+
measurementSystem: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Abstract base for {@link LengthMeasurement} and {@link TimeMeasurement}. Holds a numeric
|
|
10
|
+
* `value` and a `unit` descriptor, and centralizes value formatting + freedom spacing so a
|
|
11
|
+
* range wrapper ({@link MinMax}) can treat both subclasses uniformly via `instanceof Measurement`.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class Measurement {
|
|
14
|
+
abstract readonly measurementType: string;
|
|
15
|
+
readonly value: number;
|
|
16
|
+
readonly unit: MeasurementUnit;
|
|
17
|
+
protected constructor(value: number, unit: MeasurementUnit);
|
|
18
|
+
/** Non-freedom unit abbreviation (e.g. `ft`, `km`, `min`), appended without a space. */
|
|
19
|
+
protected abstract abbreviate(): string;
|
|
20
|
+
/** Returns a new measurement converted to the given system (optionally forcing a unit). */
|
|
21
|
+
abstract toMeasurementSystem(system: string, unitName?: string): Measurement;
|
|
22
|
+
/**
|
|
23
|
+
* Renders the value and (by default) its unit. Imperial/Metric/Standard units are
|
|
24
|
+
* abbreviated with no space; Freedom units use their full name with a leading space.
|
|
25
|
+
* Pass `showUnitName = false` to render the value only (used by {@link MinMax}).
|
|
26
|
+
*/
|
|
27
|
+
toString(showUnitName?: boolean): string;
|
|
28
|
+
toJSON(): {
|
|
29
|
+
value: number;
|
|
30
|
+
measurementType: string;
|
|
31
|
+
unit: MeasurementUnit;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=measurement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurement.d.ts","sourceRoot":"","sources":["../../../src/models/measurements/measurement.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,eAAO,MAAM,0BAA0B,YAAY,CAAC;AAEpD,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,8BAAsB,WAAW;IAC7B,QAAQ,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,SAAS,aAAa,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe;IAK1D,wFAAwF;IACxF,SAAS,CAAC,QAAQ,CAAC,UAAU,IAAI,MAAM;IAEvC,2FAA2F;IAC3F,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW;IAE5E;;;;OAIG;IACH,QAAQ,CAAC,YAAY,UAAO,GAAG,MAAM;IAWrC,MAAM,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE;CAU9E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Measurement = exports.FREEDOM_MEASUREMENT_SYSTEM = void 0;
|
|
4
|
+
const measurementValue_1 = require("./measurementValue");
|
|
5
|
+
/** Marker for the "best" measurement system; freedom units render/behave specially. */
|
|
6
|
+
exports.FREEDOM_MEASUREMENT_SYSTEM = 'Freedom';
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base for {@link LengthMeasurement} and {@link TimeMeasurement}. Holds a numeric
|
|
9
|
+
* `value` and a `unit` descriptor, and centralizes value formatting + freedom spacing so a
|
|
10
|
+
* range wrapper ({@link MinMax}) can treat both subclasses uniformly via `instanceof Measurement`.
|
|
11
|
+
*/
|
|
12
|
+
class Measurement {
|
|
13
|
+
constructor(value, unit) {
|
|
14
|
+
this.value = value;
|
|
15
|
+
this.unit = unit;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Renders the value and (by default) its unit. Imperial/Metric/Standard units are
|
|
19
|
+
* abbreviated with no space; Freedom units use their full name with a leading space.
|
|
20
|
+
* Pass `showUnitName = false` to render the value only (used by {@link MinMax}).
|
|
21
|
+
*/
|
|
22
|
+
toString(showUnitName = true) {
|
|
23
|
+
const formatted = (0, measurementValue_1.formatMeasurementValue)(this.value);
|
|
24
|
+
if (!showUnitName) {
|
|
25
|
+
return formatted;
|
|
26
|
+
}
|
|
27
|
+
if (this.unit.measurementSystem === exports.FREEDOM_MEASUREMENT_SYSTEM) {
|
|
28
|
+
return `${formatted} ${this.unit.name}`;
|
|
29
|
+
}
|
|
30
|
+
return `${formatted}${this.abbreviate()}`;
|
|
31
|
+
}
|
|
32
|
+
toJSON() {
|
|
33
|
+
return {
|
|
34
|
+
value: this.value,
|
|
35
|
+
measurementType: this.measurementType,
|
|
36
|
+
unit: {
|
|
37
|
+
measurementSystem: this.unit.measurementSystem,
|
|
38
|
+
name: this.unit.name,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Measurement = Measurement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared display formatter for measurement values, used by {@link Measurement.toString}.
|
|
3
|
+
*
|
|
4
|
+
* Rules (applied to the magnitude, sign preserved; exact 0 renders as "0"):
|
|
5
|
+
* - |value| > 9999 -> scientific notation, 2 decimal places
|
|
6
|
+
* - 1 <= |value| <= 9999 -> rounded to the nearest 0.1, no scientific notation
|
|
7
|
+
* - 0.001 <= |value| < 1 -> rounded to the nearest 0.001, no scientific notation
|
|
8
|
+
* - |value| < 0.001 -> scientific notation, 2 decimal places
|
|
9
|
+
*
|
|
10
|
+
* Rounding drops trailing zeros (e.g. `200`, `5.1`, `0.083`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatMeasurementValue(value: number): string;
|
|
13
|
+
//# sourceMappingURL=measurementValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurementValue.d.ts","sourceRoot":"","sources":["../../../src/models/measurements/measurementValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoB5D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatMeasurementValue = formatMeasurementValue;
|
|
4
|
+
/**
|
|
5
|
+
* Shared display formatter for measurement values, used by {@link Measurement.toString}.
|
|
6
|
+
*
|
|
7
|
+
* Rules (applied to the magnitude, sign preserved; exact 0 renders as "0"):
|
|
8
|
+
* - |value| > 9999 -> scientific notation, 2 decimal places
|
|
9
|
+
* - 1 <= |value| <= 9999 -> rounded to the nearest 0.1, no scientific notation
|
|
10
|
+
* - 0.001 <= |value| < 1 -> rounded to the nearest 0.001, no scientific notation
|
|
11
|
+
* - |value| < 0.001 -> scientific notation, 2 decimal places
|
|
12
|
+
*
|
|
13
|
+
* Rounding drops trailing zeros (e.g. `200`, `5.1`, `0.083`).
|
|
14
|
+
*/
|
|
15
|
+
function formatMeasurementValue(value) {
|
|
16
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
17
|
+
throw new Error(`formatMeasurementValue: value must be a finite number, got: ${value}`);
|
|
18
|
+
}
|
|
19
|
+
if (value === 0) {
|
|
20
|
+
return '0';
|
|
21
|
+
}
|
|
22
|
+
const magnitude = Math.abs(value);
|
|
23
|
+
if (magnitude > 9999) {
|
|
24
|
+
return value.toExponential(2);
|
|
25
|
+
}
|
|
26
|
+
if (magnitude >= 1) {
|
|
27
|
+
return String(roundTo(value, 1));
|
|
28
|
+
}
|
|
29
|
+
if (magnitude >= 0.001) {
|
|
30
|
+
return String(roundTo(value, 3));
|
|
31
|
+
}
|
|
32
|
+
return value.toExponential(2);
|
|
33
|
+
}
|
|
34
|
+
function roundTo(value, decimals) {
|
|
35
|
+
const factor = 10 ** decimals;
|
|
36
|
+
return Math.round(value * factor) / factor;
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Measurement } from './measurement';
|
|
2
|
+
/**
|
|
3
|
+
* A min/max pair, generic over the endpoint type. Used for range-valued fields such as
|
|
4
|
+
* `rappelCount` (`MinMax<number>`) and time estimates (`MinMax<TimeMeasurement>`).
|
|
5
|
+
*/
|
|
6
|
+
export declare class MinMax<T> {
|
|
7
|
+
readonly min: T;
|
|
8
|
+
readonly max: T;
|
|
9
|
+
constructor(min: T, max: T);
|
|
10
|
+
/** Applies `fn` to both endpoints, returning a new pair. */
|
|
11
|
+
map<U>(fn: (value: T) => U): MinMax<U>;
|
|
12
|
+
/**
|
|
13
|
+
* Renders the range as `min-max`. When the endpoints are {@link Measurement}s, the unit is
|
|
14
|
+
* shown only on `max`, so a range reads e.g. `3-6h` or `400-500 Walmart Supercenters`.
|
|
15
|
+
* Non-measurement endpoints (e.g. numbers) render plainly (`1-2`).
|
|
16
|
+
*/
|
|
17
|
+
toString(showUnitName?: boolean): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a measurement range to the given system. `min` is converted first (choosing a
|
|
20
|
+
* random Freedom unit when applicable), then `max` is forced onto the same unit by reusing
|
|
21
|
+
* `min`'s resulting unit name, guaranteeing both endpoints share a unit.
|
|
22
|
+
*/
|
|
23
|
+
toMeasurementSystem<M extends Measurement>(this: MinMax<M>, system: string, unitName?: string): MinMax<M>;
|
|
24
|
+
toJSON(): {
|
|
25
|
+
min: T;
|
|
26
|
+
max: T;
|
|
27
|
+
};
|
|
28
|
+
static fromResult<T>(json: unknown, parseItem: (value: unknown) => T): MinMax<T>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=minMax.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minMax.d.ts","sourceRoot":"","sources":["../../../src/models/measurements/minMax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,MAAM,CAAC,CAAC;IACjB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;gBAEJ,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IAK1B,4DAA4D;IAC5D,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAItC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,UAAO,GAAG,MAAM;IAUrC;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,SAAS,WAAW,EACrC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,GAClB,MAAM,CAAC,CAAC,CAAC;IASZ,MAAM,IAAI;QAAE,GAAG,EAAE,CAAC,CAAC;QAAC,GAAG,EAAE,CAAC,CAAA;KAAE;IAI5B,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;CAUnF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MinMax = void 0;
|
|
4
|
+
const measurement_1 = require("./measurement");
|
|
5
|
+
/**
|
|
6
|
+
* A min/max pair, generic over the endpoint type. Used for range-valued fields such as
|
|
7
|
+
* `rappelCount` (`MinMax<number>`) and time estimates (`MinMax<TimeMeasurement>`).
|
|
8
|
+
*/
|
|
9
|
+
class MinMax {
|
|
10
|
+
constructor(min, max) {
|
|
11
|
+
this.min = min;
|
|
12
|
+
this.max = max;
|
|
13
|
+
}
|
|
14
|
+
/** Applies `fn` to both endpoints, returning a new pair. */
|
|
15
|
+
map(fn) {
|
|
16
|
+
return new MinMax(fn(this.min), fn(this.max));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Renders the range as `min-max`. When the endpoints are {@link Measurement}s, the unit is
|
|
20
|
+
* shown only on `max`, so a range reads e.g. `3-6h` or `400-500 Walmart Supercenters`.
|
|
21
|
+
* Non-measurement endpoints (e.g. numbers) render plainly (`1-2`).
|
|
22
|
+
*/
|
|
23
|
+
toString(showUnitName = true) {
|
|
24
|
+
const minStr = this.min instanceof measurement_1.Measurement ? this.min.toString(false) : String(this.min);
|
|
25
|
+
const maxStr = this.max instanceof measurement_1.Measurement
|
|
26
|
+
? this.max.toString(showUnitName)
|
|
27
|
+
: String(this.max);
|
|
28
|
+
return `${minStr}-${maxStr}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts a measurement range to the given system. `min` is converted first (choosing a
|
|
32
|
+
* random Freedom unit when applicable), then `max` is forced onto the same unit by reusing
|
|
33
|
+
* `min`'s resulting unit name, guaranteeing both endpoints share a unit.
|
|
34
|
+
*/
|
|
35
|
+
toMeasurementSystem(system, unitName) {
|
|
36
|
+
const convertedMin = this.min.toMeasurementSystem(system, unitName);
|
|
37
|
+
const convertedMax = this.max.toMeasurementSystem(system, convertedMin.unit.name);
|
|
38
|
+
return new MinMax(convertedMin, convertedMax);
|
|
39
|
+
}
|
|
40
|
+
toJSON() {
|
|
41
|
+
return { min: this.min, max: this.max };
|
|
42
|
+
}
|
|
43
|
+
static fromResult(json, parseItem) {
|
|
44
|
+
if (json == null || typeof json !== 'object') {
|
|
45
|
+
throw new Error('MinMax result must be an object with min and max');
|
|
46
|
+
}
|
|
47
|
+
const o = json;
|
|
48
|
+
if (!('min' in o) || !('max' in o)) {
|
|
49
|
+
throw new Error('MinMax result must include both min and max');
|
|
50
|
+
}
|
|
51
|
+
return new MinMax(parseItem(o.min), parseItem(o.max));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.MinMax = MinMax;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Measurement } from './measurement';
|
|
2
|
+
import type { FreedomSystem } from './lengthMeasurement';
|
|
3
|
+
export type StandardSystem = {
|
|
4
|
+
measurementSystem: 'Standard';
|
|
5
|
+
name: 'minutes' | 'hours' | 'days';
|
|
6
|
+
};
|
|
7
|
+
export type TimeMeasurementUnit = StandardSystem | FreedomSystem;
|
|
8
|
+
export type TimeMeasurementSystem = 'Standard' | 'Freedom';
|
|
9
|
+
/** Convenience unit descriptors for the units RopeWiki stores times in. */
|
|
10
|
+
export declare const MINUTES: StandardSystem;
|
|
11
|
+
export declare const HOURS: StandardSystem;
|
|
12
|
+
export declare const DAYS: StandardSystem;
|
|
13
|
+
/** A duration with an explicit unit, convertible between Standard and Freedom systems. */
|
|
14
|
+
export declare class TimeMeasurement extends Measurement {
|
|
15
|
+
readonly measurementType: "time";
|
|
16
|
+
readonly unit: TimeMeasurementUnit;
|
|
17
|
+
constructor(value: number, unit: TimeMeasurementUnit);
|
|
18
|
+
toMeasurementSystem(system: TimeMeasurementSystem, unitName?: string): TimeMeasurement;
|
|
19
|
+
protected abbreviate(): string;
|
|
20
|
+
private toFreedom;
|
|
21
|
+
static fromResult(json: unknown): TimeMeasurement;
|
|
22
|
+
static coerce(value: unknown, defaultUnit: TimeMeasurementUnit): TimeMeasurement | null;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=timeMeasurement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeMeasurement.d.ts","sourceRoot":"","sources":["../../../src/models/measurements/timeMeasurement.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IACzB,iBAAiB,EAAE,UAAU,CAAC;IAC9B,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;CACtC,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,aAAa,CAAC;AACjE,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,SAAS,CAAC;AAE3D,2EAA2E;AAC3E,eAAO,MAAM,OAAO,EAAE,cAAmE,CAAC;AAC1F,eAAO,MAAM,KAAK,EAAE,cAAiE,CAAC;AACtF,eAAO,MAAM,IAAI,EAAE,cAAgE,CAAC;AA8CpF,0FAA0F;AAC1F,qBAAa,eAAgB,SAAQ,WAAW;IAC5C,QAAQ,CAAC,eAAe,EAAG,MAAM,CAAU;IAC3C,SAAiB,IAAI,EAAE,mBAAmB,CAAC;gBAE/B,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB;IAIpD,mBAAmB,CAAC,MAAM,EAAE,qBAAqB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe;IAgBtF,SAAS,CAAC,UAAU,IAAI,MAAM;IAa9B,OAAO,CAAC,SAAS;IAcjB,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe;IAkBjD,MAAM,CAAC,MAAM,CACT,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,mBAAmB,GACjC,eAAe,GAAG,IAAI;CAiB5B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeMeasurement = exports.DAYS = exports.HOURS = exports.MINUTES = void 0;
|
|
4
|
+
const measurement_1 = require("./measurement");
|
|
5
|
+
/** Convenience unit descriptors for the units RopeWiki stores times in. */
|
|
6
|
+
exports.MINUTES = { measurementSystem: 'Standard', name: 'minutes' };
|
|
7
|
+
exports.HOURS = { measurementSystem: 'Standard', name: 'hours' };
|
|
8
|
+
exports.DAYS = { measurementSystem: 'Standard', name: 'days' };
|
|
9
|
+
/** Duration of one unit of each Standard name, expressed in seconds. */
|
|
10
|
+
const SECONDS_PER_UNIT = {
|
|
11
|
+
minutes: 60,
|
|
12
|
+
hours: 3600,
|
|
13
|
+
days: 86400,
|
|
14
|
+
};
|
|
15
|
+
const STANDARD_NAMES = ['minutes', 'hours', 'days'];
|
|
16
|
+
function fixed(seconds) {
|
|
17
|
+
return { minSeconds: seconds, maxSeconds: seconds };
|
|
18
|
+
}
|
|
19
|
+
/** Duration of each freedom unit in seconds. Ranges pick a random value within the interval. */
|
|
20
|
+
const FREEDOM_TIME_UNITS = {
|
|
21
|
+
'Star-Spangled Banners': fixed(79),
|
|
22
|
+
'Saving Private Ryans': fixed(169 * 60),
|
|
23
|
+
Jiffies: fixed(0.02),
|
|
24
|
+
Moments: fixed(90),
|
|
25
|
+
'Dog years': fixed(52 * 86400),
|
|
26
|
+
Fortnights: fixed(14 * 86400),
|
|
27
|
+
Scaramuccis: fixed(11 * 86400),
|
|
28
|
+
'Basketball quarters': fixed(12 * 60),
|
|
29
|
+
'Hockey periods': fixed(20 * 60),
|
|
30
|
+
'Football quarters': fixed(15 * 60),
|
|
31
|
+
Microcenturies: fixed(52 * 60 + 35.7),
|
|
32
|
+
'DMV wait times': { minSeconds: 60 * 60, maxSeconds: 90 * 60 },
|
|
33
|
+
'Green light honks': { minSeconds: 0.003, maxSeconds: 0.015 },
|
|
34
|
+
};
|
|
35
|
+
function randomInRange(min, max) {
|
|
36
|
+
if (min === max)
|
|
37
|
+
return min;
|
|
38
|
+
return min + Math.random() * (max - min);
|
|
39
|
+
}
|
|
40
|
+
function pickRandomKey(record) {
|
|
41
|
+
const keys = Object.keys(record);
|
|
42
|
+
return keys[Math.floor(Math.random() * keys.length)];
|
|
43
|
+
}
|
|
44
|
+
/** A duration with an explicit unit, convertible between Standard and Freedom systems. */
|
|
45
|
+
class TimeMeasurement extends measurement_1.Measurement {
|
|
46
|
+
constructor(value, unit) {
|
|
47
|
+
super(value, unit);
|
|
48
|
+
this.measurementType = 'time';
|
|
49
|
+
}
|
|
50
|
+
toMeasurementSystem(system, unitName) {
|
|
51
|
+
const unit = this.unit;
|
|
52
|
+
if (unit.measurementSystem === measurement_1.FREEDOM_MEASUREMENT_SYSTEM) {
|
|
53
|
+
throw new Error('Freedom units cannot be converted to any other system because they are the best units.');
|
|
54
|
+
}
|
|
55
|
+
if (system === 'Freedom') {
|
|
56
|
+
return this.toFreedom(unit, unitName);
|
|
57
|
+
}
|
|
58
|
+
const targetName = unitName != null ? assertStandardUnit(unitName) : unit.name;
|
|
59
|
+
const seconds = this.value * SECONDS_PER_UNIT[unit.name];
|
|
60
|
+
const value = seconds / SECONDS_PER_UNIT[targetName];
|
|
61
|
+
return new TimeMeasurement(value, { measurementSystem: 'Standard', name: targetName });
|
|
62
|
+
}
|
|
63
|
+
abbreviate() {
|
|
64
|
+
switch (this.unit.name) {
|
|
65
|
+
case 'minutes':
|
|
66
|
+
return 'min';
|
|
67
|
+
case 'hours':
|
|
68
|
+
return 'h';
|
|
69
|
+
case 'days':
|
|
70
|
+
return 'd';
|
|
71
|
+
default:
|
|
72
|
+
return this.unit.name;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
toFreedom(unit, unitName) {
|
|
76
|
+
const seconds = this.value * SECONDS_PER_UNIT[unit.name];
|
|
77
|
+
const name = unitName ?? pickRandomKey(FREEDOM_TIME_UNITS);
|
|
78
|
+
const entry = FREEDOM_TIME_UNITS[name];
|
|
79
|
+
if (entry == null) {
|
|
80
|
+
throw new Error(`TimeMeasurement: "${name}" is not a known Freedom unit`);
|
|
81
|
+
}
|
|
82
|
+
const unitSeconds = randomInRange(entry.minSeconds, entry.maxSeconds);
|
|
83
|
+
return new TimeMeasurement(seconds / unitSeconds, {
|
|
84
|
+
measurementSystem: 'Freedom',
|
|
85
|
+
name,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
static fromResult(json) {
|
|
89
|
+
if (json == null || typeof json !== 'object') {
|
|
90
|
+
throw new Error('TimeMeasurement result must be an object');
|
|
91
|
+
}
|
|
92
|
+
const r = json;
|
|
93
|
+
if (r.measurementType !== 'time') {
|
|
94
|
+
throw new Error(`TimeMeasurement.measurementType must be "time", got: ${JSON.stringify(r.measurementType)}`);
|
|
95
|
+
}
|
|
96
|
+
if (typeof r.value !== 'number' || !Number.isFinite(r.value)) {
|
|
97
|
+
throw new Error(`TimeMeasurement.value must be a finite number, got: ${JSON.stringify(r.value)}`);
|
|
98
|
+
}
|
|
99
|
+
return new TimeMeasurement(r.value, parseTimeUnit(r.unit));
|
|
100
|
+
}
|
|
101
|
+
static coerce(value, defaultUnit) {
|
|
102
|
+
if (value == null) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
if (value instanceof TimeMeasurement) {
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
if (typeof value === 'number') {
|
|
109
|
+
if (!Number.isFinite(value)) {
|
|
110
|
+
throw new Error(`TimeMeasurement.coerce: numeric value must be finite, got: ${value}`);
|
|
111
|
+
}
|
|
112
|
+
return new TimeMeasurement(value, defaultUnit);
|
|
113
|
+
}
|
|
114
|
+
return TimeMeasurement.fromResult(value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.TimeMeasurement = TimeMeasurement;
|
|
118
|
+
function assertStandardUnit(name) {
|
|
119
|
+
if (!STANDARD_NAMES.includes(name)) {
|
|
120
|
+
throw new Error(`TimeMeasurement: "${name}" is not a valid Standard unit (expected one of [${STANDARD_NAMES.join(', ')}])`);
|
|
121
|
+
}
|
|
122
|
+
return name;
|
|
123
|
+
}
|
|
124
|
+
function parseTimeUnit(u) {
|
|
125
|
+
if (u == null || typeof u !== 'object') {
|
|
126
|
+
throw new Error('TimeMeasurement.unit must be an object');
|
|
127
|
+
}
|
|
128
|
+
const o = u;
|
|
129
|
+
const { measurementSystem, name } = o;
|
|
130
|
+
if (typeof name !== 'string') {
|
|
131
|
+
throw new Error('TimeMeasurement.unit.name must be a string');
|
|
132
|
+
}
|
|
133
|
+
if (measurementSystem === 'Standard') {
|
|
134
|
+
return { measurementSystem: 'Standard', name: assertStandardUnit(name) };
|
|
135
|
+
}
|
|
136
|
+
if (measurementSystem === 'Freedom') {
|
|
137
|
+
return { measurementSystem: 'Freedom', name };
|
|
138
|
+
}
|
|
139
|
+
throw new Error(`TimeMeasurement.unit.measurementSystem must be Standard or Freedom, got: ${JSON.stringify(measurementSystem)}`);
|
|
140
|
+
}
|
|
@@ -7,6 +7,9 @@ import { OfflinePageView } from './offlinePageView';
|
|
|
7
7
|
import { RopewikiPageView } from './ropewikiPageView';
|
|
8
8
|
import { RouteType } from '../routes/routeType';
|
|
9
9
|
import { RopewikiVehicleType } from '../ropewikiVehicleType';
|
|
10
|
+
import { MinMax } from '../measurements/minMax';
|
|
11
|
+
import { LengthMeasurement } from '../measurements/lengthMeasurement';
|
|
12
|
+
import { TimeMeasurement } from '../measurements/timeMeasurement';
|
|
10
13
|
export declare class OfflineRopewikiPageView extends RopewikiPageView implements OfflinePageView {
|
|
11
14
|
readonly fetchType: "offline";
|
|
12
15
|
bannerImage: OfflineBetaSectionImage | null;
|
|
@@ -15,22 +18,7 @@ export declare class OfflineRopewikiPageView extends RopewikiPageView implements
|
|
|
15
18
|
constructor(id: string, routeType: RouteType, name: string, aka: string[], url: string, quality: number, userVotes: number, regions: {
|
|
16
19
|
name: string;
|
|
17
20
|
id: string;
|
|
18
|
-
}[], difficultyRating: import('../difficulty/difficultyRating').DifficultyRating, permit: import('../permitStatus').PermitStatus | null, rappelCount: {
|
|
19
|
-
min: number;
|
|
20
|
-
max: number;
|
|
21
|
-
} | number | null, jumps: number | null, vehicle: RopewikiVehicleType | null, rappelLongest: number | null, shuttleTime: number | null, overallLength: number | null, descentLength: number | null, exitLength: number | null, approachLength: number | null, overallTime: {
|
|
22
|
-
min: number;
|
|
23
|
-
max: number;
|
|
24
|
-
} | number | null, approachTime: {
|
|
25
|
-
min: number;
|
|
26
|
-
max: number;
|
|
27
|
-
} | number | null, descentTime: {
|
|
28
|
-
min: number;
|
|
29
|
-
max: number;
|
|
30
|
-
} | number | null, exitTime: {
|
|
31
|
-
min: number;
|
|
32
|
-
max: number;
|
|
33
|
-
} | number | null, approachElevGain: number | null, descentElevGain: number | null, exitElevGain: number | null, months: string[], latestRevisionDate: Date, bannerImage: OfflineBetaSectionImage | null, betaSections: OfflineBetaSection[], miniMap: OfflinePageMiniMap | OfflineCenteredRegionMiniMap | null, coordinates: {
|
|
21
|
+
}[], difficultyRating: import('../difficulty/difficultyRating').DifficultyRating, permit: import('../permitStatus').PermitStatus | null, rappelCount: MinMax<number> | number | null, jumps: number | null, vehicle: RopewikiVehicleType | null, rappelLongest: LengthMeasurement | null, shuttleTime: TimeMeasurement | null, overallLength: LengthMeasurement | null, descentLength: LengthMeasurement | null, exitLength: LengthMeasurement | null, approachLength: LengthMeasurement | null, overallTime: TimeMeasurement | MinMax<TimeMeasurement> | null, approachTime: TimeMeasurement | MinMax<TimeMeasurement> | null, descentTime: TimeMeasurement | MinMax<TimeMeasurement> | null, exitTime: TimeMeasurement | MinMax<TimeMeasurement> | null, approachElevGain: LengthMeasurement | null, descentElevGain: LengthMeasurement | null, exitElevGain: LengthMeasurement | null, months: string[], latestRevisionDate: Date, bannerImage: OfflineBetaSectionImage | null, betaSections: OfflineBetaSection[], miniMap: OfflinePageMiniMap | OfflineCenteredRegionMiniMap | null, coordinates: {
|
|
34
22
|
lat: number;
|
|
35
23
|
lon: number;
|
|
36
24
|
} | null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offlineRopewikiPageView.d.ts","sourceRoot":"","sources":["../../../src/models/pageViews/offlineRopewikiPageView.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,OAAO,EAAE,4BAA4B,EAAE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AM,EAAE,EAChB,kBAAkB,EAAE,IAAI,EACxB,WAAW,EAAE,uBAAuB,GAAG,IAAI,EAC3C,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,EAAE,kBAAkB,GAAG,4BAA4B,GAAG,IAAI,EACjE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAsCpD,aAAa,IAAI,kBAAkB;IAqBnC,mBAAmB,IAAI,OAAO,mBAAmB,EAAE,MAAM,GAAG,IAAI;IAOhE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,uBAAuB;CA2CxF"}
|
|
@@ -28,19 +28,19 @@ export declare class OnlineRopewikiPageView extends RopewikiPageView implements
|
|
|
28
28
|
}[], difficultyRating: import('../difficulty/difficultyRating').DifficultyRating, permit: import('../permitStatus').PermitStatus | null, rappelCount: {
|
|
29
29
|
min: number;
|
|
30
30
|
max: number;
|
|
31
|
-
} | number | null, jumps: number | null, vehicle: RopewikiVehicleType | null,
|
|
31
|
+
} | number | null, jumps: number | null, vehicle: RopewikiVehicleType | null, rappelLongestFeet: number | null, shuttleTimeMinutes: number | null, overallLengthMiles: number | null, descentLengthMiles: number | null, exitLengthMiles: number | null, approachLengthMiles: number | null, overallTimeHours: {
|
|
32
32
|
min: number;
|
|
33
33
|
max: number;
|
|
34
|
-
} | number | null,
|
|
34
|
+
} | number | null, approachTimeHours: {
|
|
35
35
|
min: number;
|
|
36
36
|
max: number;
|
|
37
|
-
} | number | null,
|
|
37
|
+
} | number | null, descentTimeHours: {
|
|
38
38
|
min: number;
|
|
39
39
|
max: number;
|
|
40
|
-
} | number | null,
|
|
40
|
+
} | number | null, exitTimeHours: {
|
|
41
41
|
min: number;
|
|
42
42
|
max: number;
|
|
43
|
-
} | number | null,
|
|
43
|
+
} | number | null, approachElevGainFeet: number | null, descentElevGainFeet: number | null, exitElevGainFeet: number | null, months: string[], latestRevisionDate: Date, bannerImage: OnlineBetaSectionImage | null, betaSections: OnlineBetaSection[], miniMap: OnlinePageMiniMap | OnlineCenteredRegionMiniMap | null, coordinates: {
|
|
44
44
|
lat: number;
|
|
45
45
|
lon: number;
|
|
46
46
|
} | null, downloadFolder?: string | null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onlineRopewikiPageView.d.ts","sourceRoot":"","sources":["../../../src/models/pageViews/onlineRopewikiPageView.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAgB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAkC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"onlineRopewikiPageView.d.ts","sourceRoot":"","sources":["../../../src/models/pageViews/onlineRopewikiPageView.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,C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const offlineRopewikiPageView_1 = require("./offlineRopewikiPageView");
|
|
|
15
15
|
const pageView_1 = require("./pageView");
|
|
16
16
|
const ropewikiPageView_1 = require("./ropewikiPageView");
|
|
17
17
|
const pageViewType_1 = require("./pageViewType");
|
|
18
|
+
const lengthMeasurement_1 = require("../measurements/lengthMeasurement");
|
|
19
|
+
const timeMeasurement_1 = require("../measurements/timeMeasurement");
|
|
18
20
|
const downloadPhaseTitles_1 = require("../../download/helpers/downloadPhaseTitles");
|
|
19
21
|
const downloadJob_1 = require("../../download/downloadJob");
|
|
20
22
|
const downloadPhase_1 = require("../../download/downloadPhase");
|
|
@@ -35,8 +37,8 @@ const saveOfflinePageViewTaskDependency_1 = require("../../download/dependencies
|
|
|
35
37
|
const downloadConstants_1 = require("../../download/helpers/downloadConstants");
|
|
36
38
|
const offlinePageBundlePaths_1 = require("../../helpers/offlinePageBundlePaths");
|
|
37
39
|
class OnlineRopewikiPageView extends ropewikiPageView_1.RopewikiPageView {
|
|
38
|
-
constructor(id, routeType, name, aka, url, quality, userVotes, regions, difficultyRating, permit, rappelCount, jumps, vehicle,
|
|
39
|
-
super(id, routeType, name, aka, url, quality, userVotes, regions, difficultyRating, permit, rappelCount, jumps, vehicle,
|
|
40
|
+
constructor(id, routeType, name, aka, url, quality, userVotes, regions, difficultyRating, permit, rappelCount, jumps, vehicle, rappelLongestFeet, shuttleTimeMinutes, overallLengthMiles, descentLengthMiles, exitLengthMiles, approachLengthMiles, overallTimeHours, approachTimeHours, descentTimeHours, exitTimeHours, approachElevGainFeet, descentElevGainFeet, exitElevGainFeet, months, latestRevisionDate, bannerImage, betaSections, miniMap, coordinates, downloadFolder = null) {
|
|
41
|
+
super(id, routeType, name, aka, url, quality, userVotes, regions, difficultyRating, permit, ropewikiPageView_1.RopewikiPageView.coerceRappelCount(rappelCount), jumps, vehicle, lengthMeasurement_1.LengthMeasurement.coerce(rappelLongestFeet, lengthMeasurement_1.FEET), timeMeasurement_1.TimeMeasurement.coerce(shuttleTimeMinutes, timeMeasurement_1.MINUTES), lengthMeasurement_1.LengthMeasurement.coerce(overallLengthMiles, lengthMeasurement_1.MILES), lengthMeasurement_1.LengthMeasurement.coerce(descentLengthMiles, lengthMeasurement_1.MILES), lengthMeasurement_1.LengthMeasurement.coerce(exitLengthMiles, lengthMeasurement_1.MILES), lengthMeasurement_1.LengthMeasurement.coerce(approachLengthMiles, lengthMeasurement_1.MILES), ropewikiPageView_1.RopewikiPageView.coerceTimeOrRange(overallTimeHours, timeMeasurement_1.HOURS), ropewikiPageView_1.RopewikiPageView.coerceTimeOrRange(approachTimeHours, timeMeasurement_1.HOURS), ropewikiPageView_1.RopewikiPageView.coerceTimeOrRange(descentTimeHours, timeMeasurement_1.HOURS), ropewikiPageView_1.RopewikiPageView.coerceTimeOrRange(exitTimeHours, timeMeasurement_1.HOURS), lengthMeasurement_1.LengthMeasurement.coerce(approachElevGainFeet, lengthMeasurement_1.FEET), lengthMeasurement_1.LengthMeasurement.coerce(descentElevGainFeet, lengthMeasurement_1.FEET), lengthMeasurement_1.LengthMeasurement.coerce(exitElevGainFeet, lengthMeasurement_1.FEET), months, latestRevisionDate, coordinates);
|
|
40
42
|
this.fetchType = 'online';
|
|
41
43
|
this.bannerImage = bannerImage;
|
|
42
44
|
this.betaSections = betaSections;
|
|
@@ -5,10 +5,9 @@ import { RopewikiVehicleType } from '../ropewikiVehicleType';
|
|
|
5
5
|
import { FetchType } from '../fetchType';
|
|
6
6
|
import { RouteType } from '../routes/routeType';
|
|
7
7
|
import { PageViewType } from './pageViewType';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
8
|
+
import { MinMax } from '../measurements/minMax';
|
|
9
|
+
import { LengthMeasurement } from '../measurements/lengthMeasurement';
|
|
10
|
+
import { TimeMeasurement, TimeMeasurementUnit } from '../measurements/timeMeasurement';
|
|
12
11
|
export declare function registerRopewikiPageViewParser(fetchType: FetchType, parse: (result: unknown) => RopewikiPageView): void;
|
|
13
12
|
export declare abstract class RopewikiPageView {
|
|
14
13
|
abstract readonly fetchType: FetchType;
|
|
@@ -26,22 +25,22 @@ export declare abstract class RopewikiPageView {
|
|
|
26
25
|
}[];
|
|
27
26
|
difficultyRating: DifficultyRating;
|
|
28
27
|
permit: PermitStatus | null;
|
|
29
|
-
rappelCount: MinMax | number | null;
|
|
28
|
+
rappelCount: MinMax<number> | number | null;
|
|
30
29
|
jumps: number | null;
|
|
31
30
|
vehicle: RopewikiVehicleType | null;
|
|
32
|
-
rappelLongest:
|
|
33
|
-
shuttleTime:
|
|
34
|
-
overallLength:
|
|
35
|
-
descentLength:
|
|
36
|
-
exitLength:
|
|
37
|
-
approachLength:
|
|
38
|
-
overallTime:
|
|
39
|
-
approachTime:
|
|
40
|
-
descentTime:
|
|
41
|
-
exitTime:
|
|
42
|
-
approachElevGain:
|
|
43
|
-
descentElevGain:
|
|
44
|
-
exitElevGain:
|
|
31
|
+
rappelLongest: LengthMeasurement | null;
|
|
32
|
+
shuttleTime: TimeMeasurement | null;
|
|
33
|
+
overallLength: LengthMeasurement | null;
|
|
34
|
+
descentLength: LengthMeasurement | null;
|
|
35
|
+
exitLength: LengthMeasurement | null;
|
|
36
|
+
approachLength: LengthMeasurement | null;
|
|
37
|
+
overallTime: TimeMeasurement | MinMax<TimeMeasurement> | null;
|
|
38
|
+
approachTime: TimeMeasurement | MinMax<TimeMeasurement> | null;
|
|
39
|
+
descentTime: TimeMeasurement | MinMax<TimeMeasurement> | null;
|
|
40
|
+
exitTime: TimeMeasurement | MinMax<TimeMeasurement> | null;
|
|
41
|
+
approachElevGain: LengthMeasurement | null;
|
|
42
|
+
descentElevGain: LengthMeasurement | null;
|
|
43
|
+
exitElevGain: LengthMeasurement | null;
|
|
45
44
|
months: string[];
|
|
46
45
|
latestRevisionDate: Date;
|
|
47
46
|
coordinates: {
|
|
@@ -51,12 +50,21 @@ export declare abstract class RopewikiPageView {
|
|
|
51
50
|
protected constructor(id: string, routeType: RouteType, name: string, aka: string[], url: string, quality: number, userVotes: number, regions: {
|
|
52
51
|
name: string;
|
|
53
52
|
id: string;
|
|
54
|
-
}[], difficultyRating: DifficultyRating, permit: PermitStatus | null, rappelCount: MinMax | number | null, jumps: number | null, vehicle: RopewikiVehicleType | null, rappelLongest:
|
|
53
|
+
}[], difficultyRating: DifficultyRating, permit: PermitStatus | null, rappelCount: MinMax<number> | number | null, jumps: number | null, vehicle: RopewikiVehicleType | null, rappelLongest: LengthMeasurement | null, shuttleTime: TimeMeasurement | null, overallLength: LengthMeasurement | null, descentLength: LengthMeasurement | null, exitLength: LengthMeasurement | null, approachLength: LengthMeasurement | null, overallTime: TimeMeasurement | MinMax<TimeMeasurement> | null, approachTime: TimeMeasurement | MinMax<TimeMeasurement> | null, descentTime: TimeMeasurement | MinMax<TimeMeasurement> | null, exitTime: TimeMeasurement | MinMax<TimeMeasurement> | null, approachElevGain: LengthMeasurement | null, descentElevGain: LengthMeasurement | null, exitElevGain: LengthMeasurement | null, months: string[], latestRevisionDate: Date, coordinates: {
|
|
55
54
|
lat: number;
|
|
56
55
|
lon: number;
|
|
57
56
|
} | null);
|
|
58
57
|
static fromResult(result: unknown, fetchType?: FetchType): RopewikiPageView;
|
|
59
58
|
protected static validateCommonFields(r: Record<string, unknown>, expectedFetchType: FetchType, context: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Converts the raw length/time fields on a wire record into {@link LengthMeasurement} /
|
|
61
|
+
* {@link TimeMeasurement} (and {@link MinMax}) instances in place. Accepts legacy bare numbers
|
|
62
|
+
* and `{ min, max }` ranges (tagged with each field's canonical source unit) as well as the
|
|
63
|
+
* serialized measurement object shapes, so parsing round-trips through {@link Measurement#toJSON}.
|
|
64
|
+
*/
|
|
65
|
+
private static hydrateMeasurementFields;
|
|
66
|
+
protected static coerceRappelCount(value: unknown): MinMax<number> | number | null;
|
|
67
|
+
protected static coerceTimeOrRange(value: unknown, defaultUnit: TimeMeasurementUnit): TimeMeasurement | MinMax<TimeMeasurement> | null;
|
|
60
68
|
private static assertPageViewType;
|
|
61
69
|
private static assertRouteType;
|
|
62
70
|
protected static assertString(obj: Record<string, unknown>, key: string): void;
|
|
@@ -72,8 +80,6 @@ export declare abstract class RopewikiPageView {
|
|
|
72
80
|
protected static assertVehicle(obj: Record<string, unknown>, key: string): void;
|
|
73
81
|
protected static assertPermit(obj: Record<string, unknown>, key: string): void;
|
|
74
82
|
protected static assertRappelCount(obj: Record<string, unknown>, key: string): void;
|
|
75
|
-
protected static assertMinMaxOrNumber(obj: Record<string, unknown>, key: string): void;
|
|
76
83
|
protected static assertIso8601DateString(obj: Record<string, unknown>, key: string): void;
|
|
77
84
|
}
|
|
78
|
-
export {};
|
|
79
85
|
//# sourceMappingURL=ropewikiPageView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ropewikiPageView.d.ts","sourceRoot":"","sources":["../../../src/models/pageViews/ropewikiPageView.ts"],"names":[],"mappings":"AAAA,OAAO,+CAA+C,CAAC;AACvD,OAAO,EACH,gBAAgB,EAEnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ropewikiPageView.d.ts","sourceRoot":"","sources":["../../../src/models/pageViews/ropewikiPageView.ts"],"names":[],"mappings":"AAAA,OAAO,+CAA+C,CAAC;AACvD,OAAO,EACH,gBAAgB,EAEnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAA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AO,CAAC,EAC5B,GAAG,EAAE,MAAM,GACZ,IAAI;IAoBP,SAAS,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IA4BzE,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAgB/E,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAgB9E,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,GACZ,IAAI;IAwBP,SAAS,CAAC,MAAM,CAAC,uBAAuB,CACpC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,GACZ,IAAI;CAcV"}
|
|
@@ -8,6 +8,9 @@ const permitStatus_1 = require("../permitStatus");
|
|
|
8
8
|
const ropewikiVehicleType_1 = require("../ropewikiVehicleType");
|
|
9
9
|
const routeType_1 = require("../routes/routeType");
|
|
10
10
|
const pageViewType_1 = require("./pageViewType");
|
|
11
|
+
const minMax_1 = require("../measurements/minMax");
|
|
12
|
+
const lengthMeasurement_1 = require("../measurements/lengthMeasurement");
|
|
13
|
+
const timeMeasurement_1 = require("../measurements/timeMeasurement");
|
|
11
14
|
const ropewikiPageViewParsers = new Map();
|
|
12
15
|
function registerRopewikiPageViewParser(fetchType, parse) {
|
|
13
16
|
ropewikiPageViewParsers.set(fetchType, parse);
|
|
@@ -78,19 +81,6 @@ class RopewikiPageView {
|
|
|
78
81
|
RopewikiPageView.assertRappelCount(r, 'rappelCount');
|
|
79
82
|
RopewikiPageView.assertNullableNumber(r, 'jumps');
|
|
80
83
|
RopewikiPageView.assertVehicle(r, 'vehicle');
|
|
81
|
-
RopewikiPageView.assertNullableNumber(r, 'rappelLongest');
|
|
82
|
-
RopewikiPageView.assertNullableNumber(r, 'shuttleTime');
|
|
83
|
-
RopewikiPageView.assertNullableNumber(r, 'overallLength');
|
|
84
|
-
RopewikiPageView.assertNullableNumber(r, 'descentLength');
|
|
85
|
-
RopewikiPageView.assertNullableNumber(r, 'exitLength');
|
|
86
|
-
RopewikiPageView.assertNullableNumber(r, 'approachLength');
|
|
87
|
-
RopewikiPageView.assertMinMaxOrNumber(r, 'overallTime');
|
|
88
|
-
RopewikiPageView.assertMinMaxOrNumber(r, 'approachTime');
|
|
89
|
-
RopewikiPageView.assertMinMaxOrNumber(r, 'descentTime');
|
|
90
|
-
RopewikiPageView.assertMinMaxOrNumber(r, 'exitTime');
|
|
91
|
-
RopewikiPageView.assertNullableNumber(r, 'approachElevGain');
|
|
92
|
-
RopewikiPageView.assertNullableNumber(r, 'descentElevGain');
|
|
93
|
-
RopewikiPageView.assertNullableNumber(r, 'exitElevGain');
|
|
94
84
|
RopewikiPageView.assertStringArray(r, 'months');
|
|
95
85
|
RopewikiPageView.assertIso8601DateString(r, 'latestRevisionDate');
|
|
96
86
|
RopewikiPageView.assertNullableCoordinates(r, 'coordinates');
|
|
@@ -99,6 +89,68 @@ class RopewikiPageView {
|
|
|
99
89
|
}
|
|
100
90
|
r.latestRevisionDate = new Date(r.latestRevisionDate);
|
|
101
91
|
r.difficultyRating = difficultyRating_1.DifficultyRating.fromResult((0, difficultyRating_1.resolveDifficultyRatingFromRecord)(r));
|
|
92
|
+
RopewikiPageView.hydrateMeasurementFields(r);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Converts the raw length/time fields on a wire record into {@link LengthMeasurement} /
|
|
96
|
+
* {@link TimeMeasurement} (and {@link MinMax}) instances in place. Accepts legacy bare numbers
|
|
97
|
+
* and `{ min, max }` ranges (tagged with each field's canonical source unit) as well as the
|
|
98
|
+
* serialized measurement object shapes, so parsing round-trips through {@link Measurement#toJSON}.
|
|
99
|
+
*/
|
|
100
|
+
static hydrateMeasurementFields(r) {
|
|
101
|
+
r.rappelCount = RopewikiPageView.coerceRappelCount(r.rappelCount);
|
|
102
|
+
r.rappelLongest = lengthMeasurement_1.LengthMeasurement.coerce(r.rappelLongest, lengthMeasurement_1.FEET);
|
|
103
|
+
r.overallLength = lengthMeasurement_1.LengthMeasurement.coerce(r.overallLength, lengthMeasurement_1.MILES);
|
|
104
|
+
r.descentLength = lengthMeasurement_1.LengthMeasurement.coerce(r.descentLength, lengthMeasurement_1.MILES);
|
|
105
|
+
r.exitLength = lengthMeasurement_1.LengthMeasurement.coerce(r.exitLength, lengthMeasurement_1.MILES);
|
|
106
|
+
r.approachLength = lengthMeasurement_1.LengthMeasurement.coerce(r.approachLength, lengthMeasurement_1.MILES);
|
|
107
|
+
r.approachElevGain = lengthMeasurement_1.LengthMeasurement.coerce(r.approachElevGain, lengthMeasurement_1.FEET);
|
|
108
|
+
r.descentElevGain = lengthMeasurement_1.LengthMeasurement.coerce(r.descentElevGain, lengthMeasurement_1.FEET);
|
|
109
|
+
r.exitElevGain = lengthMeasurement_1.LengthMeasurement.coerce(r.exitElevGain, lengthMeasurement_1.FEET);
|
|
110
|
+
r.shuttleTime = timeMeasurement_1.TimeMeasurement.coerce(r.shuttleTime, timeMeasurement_1.MINUTES);
|
|
111
|
+
r.overallTime = RopewikiPageView.coerceTimeOrRange(r.overallTime, timeMeasurement_1.HOURS);
|
|
112
|
+
r.approachTime = RopewikiPageView.coerceTimeOrRange(r.approachTime, timeMeasurement_1.HOURS);
|
|
113
|
+
r.descentTime = RopewikiPageView.coerceTimeOrRange(r.descentTime, timeMeasurement_1.HOURS);
|
|
114
|
+
r.exitTime = RopewikiPageView.coerceTimeOrRange(r.exitTime, timeMeasurement_1.HOURS);
|
|
115
|
+
}
|
|
116
|
+
static coerceRappelCount(value) {
|
|
117
|
+
if (value == null)
|
|
118
|
+
return null;
|
|
119
|
+
if (value instanceof minMax_1.MinMax)
|
|
120
|
+
return value;
|
|
121
|
+
if (typeof value === 'number')
|
|
122
|
+
return value;
|
|
123
|
+
if (typeof value === 'object') {
|
|
124
|
+
const o = value;
|
|
125
|
+
if (typeof o.min === 'number' && typeof o.max === 'number') {
|
|
126
|
+
return new minMax_1.MinMax(o.min, o.max);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
throw new Error('RopewikiPageView.rappelCount must be a number, { min, max }, or null');
|
|
130
|
+
}
|
|
131
|
+
static coerceTimeOrRange(value, defaultUnit) {
|
|
132
|
+
if (value == null)
|
|
133
|
+
return null;
|
|
134
|
+
if (value instanceof timeMeasurement_1.TimeMeasurement)
|
|
135
|
+
return value;
|
|
136
|
+
if (value instanceof minMax_1.MinMax)
|
|
137
|
+
return value;
|
|
138
|
+
if (typeof value === 'number') {
|
|
139
|
+
return timeMeasurement_1.TimeMeasurement.coerce(value, defaultUnit);
|
|
140
|
+
}
|
|
141
|
+
if (typeof value === 'object') {
|
|
142
|
+
const o = value;
|
|
143
|
+
if ('min' in o && 'max' in o) {
|
|
144
|
+
const min = timeMeasurement_1.TimeMeasurement.coerce(o.min, defaultUnit);
|
|
145
|
+
const max = timeMeasurement_1.TimeMeasurement.coerce(o.max, defaultUnit);
|
|
146
|
+
if (min == null || max == null) {
|
|
147
|
+
throw new Error('RopewikiPageView time range min/max must not be null');
|
|
148
|
+
}
|
|
149
|
+
return new minMax_1.MinMax(min, max);
|
|
150
|
+
}
|
|
151
|
+
return timeMeasurement_1.TimeMeasurement.fromResult(value);
|
|
152
|
+
}
|
|
153
|
+
throw new Error('RopewikiPageView time field must be a number, { min, max }, measurement object, or null');
|
|
102
154
|
}
|
|
103
155
|
static assertPageViewType(obj, key) {
|
|
104
156
|
const v = obj[key];
|
|
@@ -269,9 +321,6 @@ class RopewikiPageView {
|
|
|
269
321
|
}
|
|
270
322
|
throw new Error(`RopewikiPageView.${key} must be number or { min, max } or null, got: ${typeof v}`);
|
|
271
323
|
}
|
|
272
|
-
static assertMinMaxOrNumber(obj, key) {
|
|
273
|
-
RopewikiPageView.assertRappelCount(obj, key);
|
|
274
|
-
}
|
|
275
324
|
static assertIso8601DateString(obj, key) {
|
|
276
325
|
const v = obj[key];
|
|
277
326
|
if (typeof v !== 'string') {
|