@mailwoman/spatial 11.1.0 → 11.3.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.
Files changed (69) hide show
  1. package/README.md +2 -1
  2. package/lib/digipin.ts +282 -0
  3. package/lib/geometries/point/coordinates.ts +1 -1
  4. package/lib/geometries/point.ts +1 -1
  5. package/lib/geometries/ring-blob.ts +1 -1
  6. package/lib/geometries.ts +1 -1
  7. package/lib/h3/interior-cells.ts +5 -3
  8. package/lib/h3/polygon-cells.ts +4 -4
  9. package/lib/index.ts +2 -1
  10. package/lib/open-location-code.ts +45 -30
  11. package/lib/point/reading.ts +323 -0
  12. package/lib/point/text.ts +70 -0
  13. package/lib/polyline.ts +8 -6
  14. package/lib/position.ts +1 -1
  15. package/lib/projection/transform.ts +1 -1
  16. package/out/digipin.d.ts +94 -0
  17. package/out/digipin.d.ts.map +1 -0
  18. package/out/digipin.js +242 -0
  19. package/out/digipin.js.map +1 -0
  20. package/out/geometries/point/coordinates.js +1 -1
  21. package/out/geometries/point/coordinates.js.map +1 -1
  22. package/out/geometries/point.js +1 -1
  23. package/out/geometries/point.js.map +1 -1
  24. package/out/geometries/ring-blob.d.ts +1 -1
  25. package/out/geometries.d.ts +1 -1
  26. package/out/geometries.js +1 -1
  27. package/out/h3/interior-cells.d.ts.map +1 -1
  28. package/out/h3/interior-cells.js +5 -3
  29. package/out/h3/interior-cells.js.map +1 -1
  30. package/out/h3/polygon-cells.d.ts +3 -2
  31. package/out/h3/polygon-cells.d.ts.map +1 -1
  32. package/out/h3/polygon-cells.js +4 -4
  33. package/out/h3/polygon-cells.js.map +1 -1
  34. package/out/index.d.ts +2 -1
  35. package/out/index.d.ts.map +1 -1
  36. package/out/index.js +2 -1
  37. package/out/index.js.map +1 -1
  38. package/out/open-location-code.d.ts +24 -16
  39. package/out/open-location-code.d.ts.map +1 -1
  40. package/out/open-location-code.js +27 -27
  41. package/out/open-location-code.js.map +1 -1
  42. package/out/point/reading.d.ts +144 -0
  43. package/out/point/reading.d.ts.map +1 -0
  44. package/out/point/reading.js +167 -0
  45. package/out/point/reading.js.map +1 -0
  46. package/out/point/text.d.ts +117 -0
  47. package/out/point/text.d.ts.map +1 -0
  48. package/out/point/text.js +44 -0
  49. package/out/point/text.js.map +1 -0
  50. package/out/polyline.d.ts.map +1 -1
  51. package/out/polyline.js +8 -6
  52. package/out/polyline.js.map +1 -1
  53. package/out/position.d.ts +1 -1
  54. package/out/projection/transform.js +1 -1
  55. package/out/projection/transform.js.map +1 -1
  56. package/out/tools/ogr/stream.js +2 -2
  57. package/out/tools/ogr/stream.js.map +1 -1
  58. package/out/tools/ogr.js +3 -3
  59. package/out/tools/ogr.js.map +1 -1
  60. package/out/tools/tsconfig.tsbuildinfo +1 -1
  61. package/out/tsconfig.test.tsbuildinfo +1 -1
  62. package/package.json +6 -5
  63. package/tools/ogr/stream.ts +2 -2
  64. package/tools/ogr.ts +3 -3
  65. package/lib/point-query.ts +0 -294
  66. package/out/point-query.d.ts +0 -71
  67. package/out/point-query.d.ts.map +0 -1
  68. package/out/point-query.js +0 -194
  69. package/out/point-query.js.map +0 -1
@@ -1,32 +1,30 @@
1
1
  // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
2
  // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
3
  const OLC_ALPHABET = "23456789CFGHJMPQRVWX";
4
+ /**
5
+ * The digits before the separator of a full code.
6
+ *
7
+ * The validator reads eight as a full code and two, four or six as a short one.
8
+ */
9
+ const FULL_PREFIX_LENGTH = 8;
4
10
  const OLC_DIGIT_VALUE = new Map([...OLC_ALPHABET].map((c, i) => [c, i]));
5
11
  const PAIR_RESOLUTIONS = [20, 1, 1 / 20, 1 / 400, 1 / 8000];
6
12
  const GRID_COLUMNS = 4;
7
13
  const GRID_ROWS = 5;
8
14
  /**
9
- * Returns true for a full plus code of exactly 8 digits, `+`, and 2 or 3 digits.
15
+ * Decodes a full code to its cell.
10
16
  *
11
- * It rejects the padded and longer forms the spec allows, since addresses use only the 10–11 digit form.
12
- */
13
- export function isFullPlusCode(token) {
14
- return /^[23456789CFGHJMPQRVWX]{8}\+[23456789CFGHJMPQRVWX]{2,3}$/i.test(token);
15
- }
16
- /**
17
- * Returns true for a short plus code with 2, 4 or 6 digits before the `+`,
18
- * such as the `VFQ6+92P` form Google prints on place cards.
17
+ * The validator guarantees the alphabet and the digit counts, and the brand guarantees
18
+ * the eight digits before the separator, so no input to this function fails.
19
+ * A short code has its own brand and decodes through {@link recoverNearestPlusCode}.
19
20
  */
20
- export function isShortPlusCode(token) {
21
- return /^[23456789CFGHJMPQRVWX]{2,6}\+[23456789CFGHJMPQRVWX]{2,3}$/i.test(token) && token.indexOf("+") % 2 === 0;
21
+ export function decodePlusCode(code) {
22
+ return decodeDigits(code.replace("+", ""));
22
23
  }
23
24
  /**
24
- * Decodes a full plus code to its cell, returning null for anything {@link isFullPlusCode} rejects.
25
+ * Decodes the digits of a full code, 10 or 11 of them, without the separator.
25
26
  */
26
- export function decodePlusCode(code) {
27
- if (!isFullPlusCode(code))
28
- return null;
29
- const digits = code.toUpperCase().replace("+", "");
27
+ function decodeDigits(digits) {
30
28
  let latLo = -90;
31
29
  let lonLo = -180;
32
30
  let latSpan = 400;
@@ -72,34 +70,36 @@ function encodePairDigits(lat, lon, length) {
72
70
  return encodePairs(lat, lon, length).digits;
73
71
  }
74
72
  /**
75
- * Encodes a coordinate as a full plus code of 10 or 11 digits, the forms {@link isFullPlusCode} accepts.
73
+ * Encodes a coordinate as a full plus code of 10 or 11 digits, the forms an address holds.
76
74
  *
77
75
  * The eleventh digit refines the last pair's cell on the 4 × 5 grid the spec defines.
76
+ * The digits come from the specification's alphabet and the separator follows the eighth,
77
+ * so the code has the form the validator accepts and the decoders take.
78
78
  */
79
79
  export function encodePlusCode(lat, lon, length = 10) {
80
80
  const { digits, latRemainder, lonRemainder } = encodePairs(lat, lon, 10);
81
- const code = `${digits.slice(0, 8)}+${digits.slice(8)}`;
81
+ const code = `${digits.slice(0, FULL_PREFIX_LENGTH)}+${digits.slice(FULL_PREFIX_LENGTH)}`;
82
82
  if (length === 10)
83
83
  return code;
84
84
  const cell = PAIR_RESOLUTIONS[4];
85
85
  const row = Math.min(Math.floor(latRemainder / (cell / GRID_ROWS)), GRID_ROWS - 1);
86
86
  const column = Math.min(Math.floor(lonRemainder / (cell / GRID_COLUMNS)), GRID_COLUMNS - 1);
87
- return code + OLC_ALPHABET[row * GRID_COLUMNS + column];
87
+ return (code + OLC_ALPHABET[row * GRID_COLUMNS + column]);
88
88
  }
89
89
  /**
90
90
  * Recovers a short plus code to the matching cell nearest a reference coordinate,
91
91
  * following the spec's `recoverNearest`.
92
- * It returns null for an invalid short code.
92
+ *
93
+ * The brand guarantees two, four or six digits before the separator, so every short code recovers to a cell.
94
+ * The reference must be a finite coordinate.
95
+ *
96
+ * Every caller already holds one.
97
+ * A full code has its own brand and decodes through {@link decodePlusCode}.
93
98
  */
94
99
  export function recoverNearestPlusCode(shortCode, refLat, refLon) {
95
- if (!isShortPlusCode(shortCode))
96
- return null;
97
- const upper = shortCode.toUpperCase();
98
- const missing = 8 - upper.indexOf("+");
100
+ const missing = FULL_PREFIX_LENGTH - shortCode.indexOf("+");
99
101
  const prefix = encodePairDigits(refLat, refLon, missing);
100
- const candidate = decodePlusCode(prefix + upper);
101
- if (!candidate)
102
- return null;
102
+ const candidate = decodeDigits(prefix + shortCode.replace("+", ""));
103
103
  const LAT_MIN = -90;
104
104
  const LAT_MAX = 90;
105
105
  const prefixResolution = PAIR_RESOLUTIONS[missing / 2 - 1];
@@ -1 +1 @@
1
- {"version":3,"file":"open-location-code.js","sourceRoot":"","sources":["../lib/open-location-code.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAIlE,MAAM,YAAY,GAAG,sBAAsB,CAAA;AAE3C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAiB,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,C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OAAO,CAAC,CAAA;IACxD,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAA;IAEnE,MAAM,OAAO,GAAG,CAAC,EAAE,CAAA;IACnB,MAAM,OAAO,GAAG,EAAE,CAAA;IAClB,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAE,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,GAAG,SAAS,EAAE,CAAA;IAE/B,IAAI,MAAM,GAAG,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,gBAAgB,IAAI,OAAO,EAAE,CAAC;QAC5F,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAA;IAC/B,CAAC;SAAM,IAAI,MAAM,GAAG,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,gBAAgB,IAAI,OAAO,EAAE,CAAC;QACnG,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAA;IAC/B,CAAC;IAED,IAAI,MAAM,GAAG,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;QAChD,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAA;IAC/B,CAAC;SAAM,IAAI,MAAM,GAAG,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;QACvD,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAA;IAC/B,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @file What a typed query resolves to when it is a point rather than an address, read from recognitions.
3
+ *
4
+ * A search field receives coordinates in a dozen spellings, a plus code, an H3 cell, a geohash or a
5
+ * Who's On First id beside ordinary addresses. {@link recognizePointQuery} runs one recognizer over the `coordinates`,
6
+ * `spatial` and `identifiers` families of `@mailwoman/recognizer` and answers from the recognition that spans the text.
7
+ * It decodes no cell: decoding a code to a coordinate belongs to the module that owns the format,
8
+ * and the H3 reader loads a WebAssembly binary that a text test shouldn't pay for.
9
+ *
10
+ * # What makes a recognition a reading
11
+ *
12
+ * A recognition is trusted when the engine's validator accepted it and its span is the whole text.
13
+ * An embedded span or a rejected recognition never becomes a reading: `Apt 4, 12 Main St` holds the valid pair `4, 12`.
14
+ *
15
+ * The grammars admit no white space around a value, so **the caller trims** the text before it is read.
16
+ * The earth app trims where it takes the typed input.
17
+ *
18
+ * # One handler for every kind
19
+ *
20
+ * `handlers` has an entry for each kind of the three families, and the object is checked against
21
+ * `HandlerMap<typeof families>`. A kind added to any family fails the TypeScript build until it has a handler.
22
+ * A handler returns a point reading, or a {@link NotAPointQuery} with the recognized kind and the reason it isn't a point.
23
+ */
24
+ import { type KindsOf } from "@mailwoman/recognizer";
25
+ import type { AxisOrder, Validated } from "@mailwoman/recognizer/types";
26
+ /**
27
+ * The families a point query is read from, composed once.
28
+ */
29
+ declare const families: readonly [import("@mailwoman/recognizer").FamilyDeclaration<import("@mailwoman/recognizer/coordinates.generated").CoordinatesKind, import("@mailwoman/recognizer/coordinates.generated").CoordinatesPayloads, Record<never, never>, import("@mailwoman/recognizer/coordinates.generated").CoordinatesRejections>, import("@mailwoman/recognizer").FamilyDeclaration<import("@mailwoman/recognizer/spatial.generated").SpatialKind, import("@mailwoman/recognizer/spatial.generated").SpatialPayloads, Record<never, never>, import("@mailwoman/recognizer/spatial.generated").SpatialRejections>, import("@mailwoman/recognizer").FamilyDeclaration<import("@mailwoman/recognizer/identifiers.generated").IdentifiersKind, import("@mailwoman/recognizer/identifiers.generated").IdentifiersPayloads, Record<never, never>, import("@mailwoman/recognizer/identifiers.generated").IdentifiersRejections>];
30
+ /**
31
+ * Every kind of recognition a point query reads, one per shape of the three families.
32
+ */
33
+ export type PointQueryKind = KindsOf<typeof families>;
34
+ /**
35
+ * A point reading is the point a text resolves to.
36
+ *
37
+ * `recognized` is the generated kind of the recognition the reading came from.
38
+ */
39
+ export type PointReading = {
40
+ readonly recognized: PointQueryKind;
41
+ } & ({
42
+ /**
43
+ * A coordinate pair in decimal, degrees-minutes-seconds, labeled, `geo:`
44
+ * or Google Maps form, latitude and longitude as the validator branded them.
45
+ *
46
+ * `lon_lat` is reported when the first number is out of latitude range,
47
+ * so it can only be a longitude.
48
+ */
49
+ readonly kind: "coordinates";
50
+ readonly latitude: Validated.Latitude;
51
+ readonly longitude: Validated.Longitude;
52
+ readonly order: AxisOrder;
53
+ } | {
54
+ /**
55
+ * A GeoJSON `Point`.
56
+ * Its position is already latitude first in the payload.
57
+ */
58
+ readonly kind: "geojson_point";
59
+ readonly latitude: Validated.Latitude;
60
+ readonly longitude: Validated.Longitude;
61
+ } | {
62
+ /**
63
+ * A full Open Location Code, upper-cased.
64
+ * It decodes to a cell with no further input.
65
+ */
66
+ readonly kind: "plus_code";
67
+ readonly full: true;
68
+ readonly code: Validated.FullPlusCode;
69
+ } | {
70
+ /**
71
+ * A short Open Location Code, upper-cased.
72
+ * It decodes only beside a reference position.
73
+ */
74
+ readonly kind: "plus_code";
75
+ readonly full: false;
76
+ readonly code: Validated.ShortPlusCode;
77
+ } | {
78
+ /**
79
+ * A DIGIPIN, ten upper-case characters without hyphens.
80
+ */
81
+ readonly kind: "digipin";
82
+ readonly code: Validated.Digipin;
83
+ } | {
84
+ /**
85
+ * An H3 cell index in its hexadecimal form, lower-cased.
86
+ *
87
+ * The validator checks the shape, and the H3 library decides validity when it decodes the cell.
88
+ */
89
+ readonly kind: "h3";
90
+ readonly cell: string;
91
+ } | {
92
+ /**
93
+ * A geohash behind its `geohash:` or `gh:` prefix, lower-cased.
94
+ */
95
+ readonly kind: "geohash";
96
+ readonly hash: string;
97
+ } | {
98
+ /**
99
+ * A Who's On First id, from `wof:85633793`, `wof 85633793` or a Spelunker link.
100
+ */
101
+ readonly kind: "wof";
102
+ readonly id: Validated.Integer;
103
+ });
104
+ /**
105
+ * Lists why a recognized text isn't a point query.
106
+ *
107
+ * - `names_no_position`: the text is an identifier or a document with no single position,
108
+ * such as a Census GEOID, a GNIS feature id or a GeoJSON `LineString`.
109
+ * - `ambiguous_without_prefix`: the text is a valid code whose spelling is also a phone number
110
+ * or a count, so no prefix or separator makes it a position.
111
+ * - `digit_group`: the text is a well-formed code made only of digits in a grouped form.
112
+ * A phone number is written the same way.
113
+ */
114
+ export type NotAPointReason = "names_no_position" | "ambiguous_without_prefix" | "digit_group";
115
+ /**
116
+ * The text is a recognized shape and not a point query: a caller sends it to the address classifier.
117
+ */
118
+ export interface NotAPointQuery {
119
+ readonly kind: "not_a_point";
120
+ readonly recognized: PointQueryKind;
121
+ readonly reason: NotAPointReason;
122
+ }
123
+ /**
124
+ * A text that's a whole recognition resolves to a point or to a shape that isn't a point.
125
+ */
126
+ export type PointQueryReading = PointReading | NotAPointQuery;
127
+ /**
128
+ * Reads a trimmed text as a point, or as a recognized shape that isn't a point query.
129
+ *
130
+ * Returns `null` when no recognition of the three families is validated and covers the whole text.
131
+ * Every address is such a text.
132
+ *
133
+ * A coordinate out of range in both axis orders is a rejected recognition,
134
+ * so it reads as `null`, never clamped.
135
+ *
136
+ * @param text The text the caller already trimmed, because the grammars admit no outer white space.
137
+ */
138
+ export declare function recognizePointQuery(text: string): PointQueryReading | null;
139
+ /**
140
+ * Reads a trimmed text as a point, or `null` when it is an address or a recognized shape with no position.
141
+ */
142
+ export declare function pointFromText(text: string): PointReading | null;
143
+ export {};
144
+ //# sourceMappingURL=reading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../../lib/point/reading.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAGN,KAAK,OAAO,EAGZ,MAAM,uBAAuB,CAAA;AAK9B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AA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,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACpB,GACD;IACA;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;IACpB,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,OAAO,CAAA;CAC7B,CACH,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,aAAa,CAAA;AAE9F;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,cAAc,CAAA;AA+H7D;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAmB1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAI/D"}
@@ -0,0 +1,167 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * @file What a typed query resolves to when it is a point rather than an address, read from recognitions.
5
+ *
6
+ * A search field receives coordinates in a dozen spellings, a plus code, an H3 cell, a geohash or a
7
+ * Who's On First id beside ordinary addresses. {@link recognizePointQuery} runs one recognizer over the `coordinates`,
8
+ * `spatial` and `identifiers` families of `@mailwoman/recognizer` and answers from the recognition that spans the text.
9
+ * It decodes no cell: decoding a code to a coordinate belongs to the module that owns the format,
10
+ * and the H3 reader loads a WebAssembly binary that a text test shouldn't pay for.
11
+ *
12
+ * # What makes a recognition a reading
13
+ *
14
+ * A recognition is trusted when the engine's validator accepted it and its span is the whole text.
15
+ * An embedded span or a rejected recognition never becomes a reading: `Apt 4, 12 Main St` holds the valid pair `4, 12`.
16
+ *
17
+ * The grammars admit no white space around a value, so **the caller trims** the text before it is read.
18
+ * The earth app trims where it takes the typed input.
19
+ *
20
+ * # One handler for every kind
21
+ *
22
+ * `handlers` has an entry for each kind of the three families, and the object is checked against
23
+ * `HandlerMap<typeof families>`. A kind added to any family fails the TypeScript build until it has a handler.
24
+ * A handler returns a point reading, or a {@link NotAPointQuery} with the recognized kind and the reason it isn't a point.
25
+ */
26
+ import { createRecognizer, } from "@mailwoman/recognizer";
27
+ import { coordinates } from "@mailwoman/recognizer/coordinates";
28
+ import { isDeterministicSpatial } from "@mailwoman/recognizer/deterministic/spatial";
29
+ import { identifiers } from "@mailwoman/recognizer/identifiers";
30
+ import { spatial } from "@mailwoman/recognizer/spatial";
31
+ /**
32
+ * The families a point query is read from, composed once.
33
+ */
34
+ const families = [coordinates, spatial, identifiers];
35
+ const recognizer = createRecognizer(families);
36
+ /**
37
+ * The payload of a recognition the reader has already checked is validated.
38
+ *
39
+ * A recognition without one is a defect in the reader, so it throws rather than answering with an absence.
40
+ */
41
+ function payloadOf(recognition) {
42
+ const { validation } = recognition;
43
+ if (validation.status !== "validated") {
44
+ throw new RangeError(`${recognition.kind} reached its point handler without a validated payload`);
45
+ }
46
+ return validation.payload;
47
+ }
48
+ function coordinatePair(recognition) {
49
+ const { latitude, longitude, order } = payloadOf(recognition);
50
+ return { kind: "coordinates", recognized: recognition.kind, latitude, longitude, order };
51
+ }
52
+ function noPosition(recognition) {
53
+ return { kind: "not_a_point", recognized: recognition.kind, reason: "names_no_position" };
54
+ }
55
+ function wofID(recognition) {
56
+ return { kind: "wof", recognized: recognition.kind, id: payloadOf(recognition).id };
57
+ }
58
+ function h3Cell(recognition) {
59
+ return { kind: "h3", recognized: recognition.kind, cell: payloadOf(recognition).cell.toLowerCase() };
60
+ }
61
+ /**
62
+ * One handler per kind.
63
+ *
64
+ * A new kind in any composed family fails this object's `satisfies` clause.
65
+ *
66
+ * The second clause fixes each handler's return type.
67
+ * `HandlerMap` leaves it open.
68
+ */
69
+ const handlers = {
70
+ "coordinate.decimal_pair": coordinatePair,
71
+ "coordinate.decimal_pair_spaced": coordinatePair,
72
+ "coordinate.dms_pair": coordinatePair,
73
+ "coordinate.dms_pair_spaced": coordinatePair,
74
+ "coordinate.labeled_pair": coordinatePair,
75
+ "coordinate.maps_segment": coordinatePair,
76
+ // RFC 5870 fixes the order as latitude, longitude, altitude, and the payload has no order of its own.
77
+ "coordinate.geo_uri": (recognition) => {
78
+ const { latitude, longitude } = payloadOf(recognition);
79
+ return { kind: "coordinates", recognized: recognition.kind, latitude, longitude, order: "lat_lon" };
80
+ },
81
+ "plus_code.token": (recognition) => {
82
+ const { full_code, short_code } = payloadOf(recognition);
83
+ if (full_code != null)
84
+ return { kind: "plus_code", recognized: recognition.kind, full: true, code: full_code };
85
+ if (short_code != null)
86
+ return { kind: "plus_code", recognized: recognition.kind, full: false, code: short_code };
87
+ // The validator fills exactly one of the two fields, so a validated payload with neither is a defect in the engine.
88
+ throw new RangeError(`${recognition.kind} validated with neither a full code nor a short code`);
89
+ },
90
+ // The validator accepts the all-digit form.
91
+ // A phone number is written the same way.
92
+ // The trust rule decides.
93
+ "digipin.display": (recognition) => isDeterministicSpatial(recognition, recognition.text)
94
+ ? { kind: "digipin", recognized: recognition.kind, code: payloadOf(recognition).code }
95
+ : { kind: "not_a_point", recognized: recognition.kind, reason: "digit_group" },
96
+ // Ten characters from `2` to `9` and `C F J K L M P T` are also a phone number, a count or a postcode.
97
+ "digipin.compact": (recognition) => ({
98
+ kind: "not_a_point",
99
+ recognized: recognition.kind,
100
+ reason: "ambiguous_without_prefix",
101
+ }),
102
+ // A GeoJSON `Point` is the point.
103
+ // Every other GeoJSON type is a document with no single position.
104
+ "geojson.object": (recognition) => {
105
+ const { type, latitude, longitude } = payloadOf(recognition);
106
+ if (type === "Point" && latitude != null && longitude != null) {
107
+ return { kind: "geojson_point", recognized: recognition.kind, latitude, longitude };
108
+ }
109
+ return noPosition(recognition);
110
+ },
111
+ // A Census GEOID is a run of digits, and the state code is the only part the validator can check.
112
+ "census.geoid_block": noPosition,
113
+ "census.geoid_block_group": noPosition,
114
+ "census.geoid_county": noPosition,
115
+ "census.geoid_state": noPosition,
116
+ "census.geoid_tract": noPosition,
117
+ "gnis.reference": noPosition,
118
+ "gnis.summary_url": noPosition,
119
+ "geohash.prefixed": (recognition) => ({
120
+ kind: "geohash",
121
+ recognized: recognition.kind,
122
+ hash: payloadOf(recognition).hash.toLowerCase(),
123
+ }),
124
+ // A bare H3 cell is read as a point here: the map's copy menu writes one,
125
+ // and a search field that reads back what the map copied is the contract.
126
+ // `isDeterministicIdentifier` withholds a bare cell from an address parse,
127
+ // because 15 hexadecimal digits are also a count.
128
+ "h3.cell": h3Cell,
129
+ "h3.prefixed_cell": h3Cell,
130
+ "wof.reference": wofID,
131
+ "wof.spelunker_url": wofID,
132
+ };
133
+ /**
134
+ * Reads a trimmed text as a point, or as a recognized shape that isn't a point query.
135
+ *
136
+ * Returns `null` when no recognition of the three families is validated and covers the whole text.
137
+ * Every address is such a text.
138
+ *
139
+ * A coordinate out of range in both axis orders is a rejected recognition,
140
+ * so it reads as `null`, never clamped.
141
+ *
142
+ * @param text The text the caller already trimmed, because the grammars admit no outer white space.
143
+ */
144
+ export function recognizePointQuery(text) {
145
+ let notAPoint = null;
146
+ for (const recognition of recognizer.recognize(text).recognitions) {
147
+ if (recognition.validation.status !== "validated" || recognition.start !== 0 || recognition.end !== text.length) {
148
+ continue;
149
+ }
150
+ const handler = handlers[recognition.kind];
151
+ const reading = handler(recognition);
152
+ // Two shapes may cover one text, such as a Census GEOID and an H3 cell.
153
+ // The point wins.
154
+ if (reading.kind !== "not_a_point")
155
+ return reading;
156
+ notAPoint ??= reading;
157
+ }
158
+ return notAPoint;
159
+ }
160
+ /**
161
+ * Reads a trimmed text as a point, or `null` when it is an address or a recognized shape with no position.
162
+ */
163
+ export function pointFromText(text) {
164
+ const reading = recognizePointQuery(text);
165
+ return reading && reading.kind !== "not_a_point" ? reading : null;
166
+ }
167
+ //# sourceMappingURL=reading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reading.js","sourceRoot":"","sources":["../../lib/point/reading.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACN,gBAAgB,GAKhB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAA;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAA;AAGvD;;GAEG;AACH,MAAM,QAAQ,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAU,CAAA;AAO7D,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;AA4G7C;;;;GAIG;AACH,SAAS,SAAS,CAAU,WAK3B;IACA,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAA;IAElC,IAAI,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CAAC,GAAG,WAAW,CAAC,IAAI,wDAAwD,CAAC,CAAA;IAClG,CAAC;IAED,OAAO,UAAU,CAAC,OAAO,CAAA;AAC1B,CAAC;AAQD,SAAS,cAAc,CAAC,WAA6D;IACpF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;IAE7D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AACzF,CAAC;AAED,SAAS,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aAAa;YAAE,OAAO,OAAO,CAAA;QAElD,SAAS,KAAK,OAAO,CAAA;IACtB,CAAC;IAED,OAAO,SAAS,CAAA;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAEzC,OAAO,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;AAClE,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * A coordinate pair as text, latitude first, in the form `pointFromText` reads back.
3
+ *
4
+ * Six decimals place a point within about 11 cm.
5
+ */
6
+ export declare function coordinatePairText(lat: number, lon: number, decimals?: number): string;
7
+ /**
8
+ * Labels a recognized shape in a result panel and in a sentence.
9
+ */
10
+ export interface PointQueryDescription {
11
+ /**
12
+ * The name a result is shown under, such as the tag column of a parse.
13
+ */
14
+ readonly label: string;
15
+ /**
16
+ * The same name as a noun phrase with its article: "this is a plus code".
17
+ */
18
+ readonly phrase: string;
19
+ }
20
+ /**
21
+ * The description of every kind, so a new kind in any composed family fails the build until it has one.
22
+ */
23
+ export declare const POINT_QUERY_DESCRIPTIONS: {
24
+ "coordinate.decimal_pair": {
25
+ readonly label: "coordinates";
26
+ readonly phrase: "a coordinate pair";
27
+ };
28
+ "coordinate.decimal_pair_spaced": {
29
+ readonly label: "coordinates";
30
+ readonly phrase: "a coordinate pair";
31
+ };
32
+ "coordinate.dms_pair": {
33
+ readonly label: "coordinates";
34
+ readonly phrase: "a coordinate pair";
35
+ };
36
+ "coordinate.dms_pair_spaced": {
37
+ readonly label: "coordinates";
38
+ readonly phrase: "a coordinate pair";
39
+ };
40
+ "coordinate.geo_uri": {
41
+ readonly label: "coordinates";
42
+ readonly phrase: "a coordinate pair";
43
+ };
44
+ "coordinate.labeled_pair": {
45
+ readonly label: "coordinates";
46
+ readonly phrase: "a coordinate pair";
47
+ };
48
+ "coordinate.maps_segment": {
49
+ readonly label: "coordinates";
50
+ readonly phrase: "a coordinate pair";
51
+ };
52
+ "plus_code.token": {
53
+ label: string;
54
+ phrase: string;
55
+ };
56
+ "digipin.compact": {
57
+ label: string;
58
+ phrase: string;
59
+ };
60
+ "digipin.display": {
61
+ label: string;
62
+ phrase: string;
63
+ };
64
+ "geojson.object": {
65
+ label: string;
66
+ phrase: string;
67
+ };
68
+ "census.geoid_block": {
69
+ readonly label: "Census GEOID";
70
+ readonly phrase: "a Census GEOID";
71
+ };
72
+ "census.geoid_block_group": {
73
+ readonly label: "Census GEOID";
74
+ readonly phrase: "a Census GEOID";
75
+ };
76
+ "census.geoid_county": {
77
+ readonly label: "Census GEOID";
78
+ readonly phrase: "a Census GEOID";
79
+ };
80
+ "census.geoid_state": {
81
+ readonly label: "Census GEOID";
82
+ readonly phrase: "a Census GEOID";
83
+ };
84
+ "census.geoid_tract": {
85
+ readonly label: "Census GEOID";
86
+ readonly phrase: "a Census GEOID";
87
+ };
88
+ "geohash.prefixed": {
89
+ label: string;
90
+ phrase: string;
91
+ };
92
+ "gnis.reference": {
93
+ readonly label: "GNIS id";
94
+ readonly phrase: "a GNIS feature id";
95
+ };
96
+ "gnis.summary_url": {
97
+ readonly label: "GNIS id";
98
+ readonly phrase: "a GNIS feature id";
99
+ };
100
+ "h3.cell": {
101
+ readonly label: "H3 cell";
102
+ readonly phrase: "an H3 cell";
103
+ };
104
+ "h3.prefixed_cell": {
105
+ readonly label: "H3 cell";
106
+ readonly phrase: "an H3 cell";
107
+ };
108
+ "wof.reference": {
109
+ readonly label: "Who's On First id";
110
+ readonly phrase: "a Who's On First id";
111
+ };
112
+ "wof.spelunker_url": {
113
+ readonly label: "Who's On First id";
114
+ readonly phrase: "a Who's On First id";
115
+ };
116
+ };
117
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../lib/point/text.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAEjF;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACvB;AAQD;;GAEG;AACH,eAAO,MAAM,wBAAwB;;wBATJ,aAAa;yBAAU,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;QAiBrD,KAAK;QAAe,MAAM;;;QAC1B,KAAK;QAAa,MAAM;;;QACxB,KAAK;QAAa,MAAM;;;QACzB,KAAK;QAAa,MAAM;;;wBAnBf,cAAc;yBAAU,gBAAgB;;;;;;;;;;;;;;;;;;;QAyB/C,KAAK;QAAa,MAAM;;;wBAxBtB,SAAS;yBAAU,mBAAmB;;;;;;;wBACtC,SAAS;yBAAU,YAAY;;;;;;;wBAChC,mBAAmB;yBAAU,qBAAqB;;;;;;CA6BP,CAAA"}
@@ -0,0 +1,44 @@
1
+ // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
+ // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
+ /**
4
+ * A coordinate pair as text, latitude first, in the form `pointFromText` reads back.
5
+ *
6
+ * Six decimals place a point within about 11 cm.
7
+ */
8
+ export function coordinatePairText(lat, lon, decimals = 6) {
9
+ return `${lat.toFixed(decimals)}, ${lon.toFixed(decimals)}`;
10
+ }
11
+ const COORDINATE_PAIR = { label: "coordinates", phrase: "a coordinate pair" };
12
+ const CENSUS_GEOID = { label: "Census GEOID", phrase: "a Census GEOID" };
13
+ const GNIS_ID = { label: "GNIS id", phrase: "a GNIS feature id" };
14
+ const H3_CELL = { label: "H3 cell", phrase: "an H3 cell" };
15
+ const WOF_ID = { label: "Who's On First id", phrase: "a Who's On First id" };
16
+ /**
17
+ * The description of every kind, so a new kind in any composed family fails the build until it has one.
18
+ */
19
+ export const POINT_QUERY_DESCRIPTIONS = {
20
+ "coordinate.decimal_pair": COORDINATE_PAIR,
21
+ "coordinate.decimal_pair_spaced": COORDINATE_PAIR,
22
+ "coordinate.dms_pair": COORDINATE_PAIR,
23
+ "coordinate.dms_pair_spaced": COORDINATE_PAIR,
24
+ "coordinate.geo_uri": COORDINATE_PAIR,
25
+ "coordinate.labeled_pair": COORDINATE_PAIR,
26
+ "coordinate.maps_segment": COORDINATE_PAIR,
27
+ "plus_code.token": { label: "plus code", phrase: "a plus code" },
28
+ "digipin.compact": { label: "DIGIPIN", phrase: "a DIGIPIN" },
29
+ "digipin.display": { label: "DIGIPIN", phrase: "a DIGIPIN" },
30
+ "geojson.object": { label: "GeoJSON", phrase: "a GeoJSON object" },
31
+ "census.geoid_block": CENSUS_GEOID,
32
+ "census.geoid_block_group": CENSUS_GEOID,
33
+ "census.geoid_county": CENSUS_GEOID,
34
+ "census.geoid_state": CENSUS_GEOID,
35
+ "census.geoid_tract": CENSUS_GEOID,
36
+ "geohash.prefixed": { label: "geohash", phrase: "a geohash" },
37
+ "gnis.reference": GNIS_ID,
38
+ "gnis.summary_url": GNIS_ID,
39
+ "h3.cell": H3_CELL,
40
+ "h3.prefixed_cell": H3_CELL,
41
+ "wof.reference": WOF_ID,
42
+ "wof.spelunker_url": WOF_ID,
43
+ };
44
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../lib/point/text.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAYlE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,GAAW,EAAE,QAAQ,GAAG,CAAC;IACxE,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC5D,CAAC;AAg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AAO;IAC3B,SAAS,EAAE,OAAO;IAClB,kBAAkB,EAAE,OAAO;IAC3B,eAAe,EAAE,MAAM;IACvB,mBAAmB,EAAE,MAAM;CACuC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"polyline.d.ts","sourceRoot":"","sources":["../lib/polyline.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EACrC,CAAC,EAAE,MAAM,GACP,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAqC9C"}
1
+ {"version":3,"file":"polyline.d.ts","sourceRoot":"","sources":["../lib/polyline.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EACrC,CAAC,EAAE,MAAM,GACP,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAqC9C"}
package/out/polyline.js CHANGED
@@ -1,13 +1,15 @@
1
1
  // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
2
  // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
3
  /**
4
- * Position along a polyline, by arc length.
4
+ * This module finds a position along a polyline by arc length.
5
5
  *
6
- * This is what house-number interpolation stands on: given a street segment's geometry
7
- * and how far along its house-number range an address sits, it answers where that's on the ground.
8
- * The node reader (`resolver-wof-sqlite/interpolation.ts`) and the browser twin
9
- * (`resolver-wof-wasm/httpvfs/street.ts`) both call it: the geometry never
10
- * differs between them, only the I/O around it does.
6
+ * House-number interpolation supplies a street segment's geometry and an address's
7
+ * fraction along the segment's house-number range.
8
+ * This module returns the corresponding position on the ground.
9
+ *
10
+ * The node reader (`resolver-wof-sqlite/labels/street/interpolation.ts`)
11
+ * and the browser reader (`resolver-wof-wasm/httpvfs/street.ts`) both call it,
12
+ * so they share the geometry calculation while their surrounding I/O differs.
11
13
  */
12
14
  import { centralAngle, EARTH_RADII } from "#distance";
13
15
  /**