@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 +1 @@
1
- {"version":"7.0.2","root":["../lib/bbox.test.ts","../lib/distance.test.ts","../lib/open-location-code.test.ts","../lib/osgb36.test.ts","../lib/point-query.test.ts","../lib/position.test.ts","../lib/well-known-text.test.ts","../lib/coordinate/coordinate-formats.test.ts","../lib/gb/codepoint.test.ts","../lib/geometries/point.test.ts","../lib/geometries/polygon.test.ts","../lib/geometries/round.test.ts","../lib/geometries/simplify.test.ts","../lib/geometries/point/distance.test.ts","../lib/google/place-id.test.ts","../lib/h3/cell.test.ts","../lib/h3/expand-short-cell-int.test.ts"],"packageJsons":["../../../node_modules/@sister.software/h3/package.json","../../../node_modules/@types/chai/package.json","../../../node_modules/@types/deep-eql/package.json","../../../node_modules/@types/node/package.json","../../../node_modules/@vitest/browser-playwright/package.json","../../../node_modules/@vitest/coverage-v8/package.json","../../../node_modules/@vitest/mocker/package.json","../../../node_modules/@vitest/ui/package.json","../../../node_modules/assertion-error/package.json","../../../node_modules/buffer/package.json","../../../node_modules/chai/package.json","../../../node_modules/deep-eql/package.json","../../../node_modules/esbuild/package.json","../../../node_modules/events/package.json","../../../node_modules/expect-type/package.json","../../../node_modules/jiti/package.json","../../../node_modules/jsdom/package.json","../../../node_modules/path-ts/package.json","../../../node_modules/punycode/package.json","../../../node_modules/string_decoder/package.json","../../../node_modules/tagged-tag/package.json","../../../node_modules/terser/package.json","../../../node_modules/tinybench/package.json","../../../node_modules/type-fest/package.json","../../../node_modules/undici-types/package.json","../../../node_modules/vite/package.json","../../../node_modules/vitest/package.json","../../../node_modules/wkx/package.json","../../../node_modules/yaml/package.json","../../annotations/package.json","../../core/package.json","../package.json"],"missingPackageJsons":["../../../node_modules/@edge-runtime/vm/package.json","../../../node_modules/@mailwoman/core/fs/temporary/package.json","../../../node_modules/@mailwoman/core/fs/writers/package.json","../../../node_modules/@opentelemetry/api/package.json","../../../node_modules/@sister.software/h3/out/lib/api/package.json","../../../node_modules/@sister.software/h3/out/lib/package.json","../../../node_modules/@sister.software/h3/out/lib/runtime/package.json","../../../node_modules/@sister.software/h3/out/package.json","../../../node_modules/@types/assert/package.json","../../../node_modules/@types/assert/strict/package.json","../../../node_modules/@types/async_hooks/package.json","../../../node_modules/@types/child_process/package.json","../../../node_modules/@types/cluster/package.json","../../../node_modules/@types/console/package.json","../../../node_modules/@types/constants/package.json","../../../node_modules/@types/crypto/package.json","../../../node_modules/@types/dgram/package.json","../../../node_modules/@types/diagnostics_channel/package.json","../../../node_modules/@types/dns/package.json","../../../node_modules/@types/dns/promises/package.json","../../../node_modules/@types/domain/package.json","../../../node_modules/@types/events/package.json","../../../node_modules/@types/fs/package.json","../../../node_modules/@types/fs/promises/package.json","../../../node_modules/@types/http/package.json","../../../node_modules/@types/http2/package.json","../../../node_modules/@types/https/package.json","../../../node_modules/@types/inspector/package.json","../../../node_modules/@types/inspector/promises/package.json","../../../node_modules/@types/module/package.json","../../../node_modules/@types/net/package.json","../../../node_modules/@types/node/assert/package.json","../../../node_modules/@types/node/dns/package.json","../../../node_modules/@types/node/fs/package.json","../../../node_modules/@types/node/inspector/package.json","../../../node_modules/@types/node/path/package.json","../../../node_modules/@types/node/readline/package.json","../../../node_modules/@types/node/stream/package.json","../../../node_modules/@types/node/test/package.json","../../../node_modules/@types/node/timers/package.json","../../../node_modules/@types/node/util/package.json","../../../node_modules/@types/node/web-globals/package.json","../../../node_modules/@types/node/zlib/package.json","../../../node_modules/@types/os/package.json","../../../node_modules/@types/path/package.json","../../../node_modules/@types/path/posix/package.json","../../../node_modules/@types/path/win32/package.json","../../../node_modules/@types/perf_hooks/package.json","../../../node_modules/@types/process/package.json","../../../node_modules/@types/punycode/package.json","../../../node_modules/@types/querystring/package.json","../../../node_modules/@types/readline/package.json","../../../node_modules/@types/readline/promises/package.json","../../../node_modules/@types/repl/package.json","../../../node_modules/@types/stream/consumers/package.json","../../../node_modules/@types/stream/iter/package.json","../../../node_modules/@types/stream/package.json","../../../node_modules/@types/stream/promises/package.json","../../../node_modules/@types/stream/web/package.json","../../../node_modules/@types/string_decoder/package.json","../../../node_modules/@types/timers/package.json","../../../node_modules/@types/timers/promises/package.json","../../../node_modules/@types/tls/package.json","../../../node_modules/@types/trace_events/package.json","../../../node_modules/@types/tty/package.json","../../../node_modules/@types/url/package.json","../../../node_modules/@types/util/package.json","../../../node_modules/@types/util/types/package.json","../../../node_modules/@types/v8/package.json","../../../node_modules/@types/vm/package.json","../../../node_modules/@types/wasi/package.json","../../../node_modules/@types/worker_threads/package.json","../../../node_modules/@types/zlib/package.json","../../../node_modules/@vitejs/devtools/package.json","../../../node_modules/@vitest/browser-preview/package.json","../../../node_modules/@vitest/browser-webdriverio/package.json","../../../node_modules/@vitest/coverage-istanbul/package.json","../../../node_modules/@vitest/mocker/dist/package.json","../../../node_modules/assert/package.json","../../../node_modules/assert/strict/package.json","../../../node_modules/async_hooks/package.json","../../../node_modules/child_process/package.json","../../../node_modules/cluster/package.json","../../../node_modules/console/package.json","../../../node_modules/constants/package.json","../../../node_modules/crypto/package.json","../../../node_modules/dgram/package.json","../../../node_modules/diagnostics_channel/package.json","../../../node_modules/dns/package.json","../../../node_modules/dns/promises/package.json","../../../node_modules/domain/package.json","../../../node_modules/expect-type/dist/package.json","../../../node_modules/fs/package.json","../../../node_modules/fs/promises/package.json","../../../node_modules/happy-dom/package.json","../../../node_modules/http/package.json","../../../node_modules/http2/package.json","../../../node_modules/https/package.json","../../../node_modules/inspector/package.json","../../../node_modules/inspector/promises/package.json","../../../node_modules/less/package.json","../../../node_modules/module/package.json","../../../node_modules/msw/package.json","../../../node_modules/net/package.json","../../../node_modules/os/package.json","../../../node_modules/path-ts/out/lib/package.json","../../../node_modules/path-ts/out/package.json","../../../node_modules/path/package.json","../../../node_modules/path/posix/package.json","../../../node_modules/path/win32/package.json","../../../node_modules/perf_hooks/package.json","../../../node_modules/process/package.json","../../../node_modules/querystring/package.json","../../../node_modules/readline/package.json","../../../node_modules/readline/promises/package.json","../../../node_modules/repl/package.json","../../../node_modules/sass-embedded/package.json","../../../node_modules/sass/package.json","../../../node_modules/stream/consumers/package.json","../../../node_modules/stream/iter/package.json","../../../node_modules/stream/package.json","../../../node_modules/stream/promises/package.json","../../../node_modules/stream/web/package.json","../../../node_modules/stylus/package.json","../../../node_modules/sugarss/package.json","../../../node_modules/timers/package.json","../../../node_modules/timers/promises/package.json","../../../node_modules/tinybench/dist/package.json","../../../node_modules/tls/package.json","../../../node_modules/trace_events/package.json","../../../node_modules/tsx/package.json","../../../node_modules/tty/package.json","../../../node_modules/type-fest/source/internal/package.json","../../../node_modules/type-fest/source/package.json","../../../node_modules/url/package.json","../../../node_modules/util/package.json","../../../node_modules/util/types/package.json","../../../node_modules/v8/package.json","../../../node_modules/vite/dist/node/chunks/package.json","../../../node_modules/vite/dist/node/package.json","../../../node_modules/vite/dist/package.json","../../../node_modules/vite/module-runner/package.json","../../../node_modules/vite/types/package.json","../../../node_modules/vitest/dist/chunks/package.json","../../../node_modules/vitest/dist/package.json","../../../node_modules/vm/package.json","../../../node_modules/wasi/package.json","../../../node_modules/wkx/lib/package.json","../../../node_modules/worker_threads/package.json","../../../node_modules/zlib/package.json"]}
1
+ {"version":"7.0.2","root":["../lib/bbox.test.ts","../lib/digipin.test.ts","../lib/distance.test.ts","../lib/open-location-code.test.ts","../lib/osgb36.test.ts","../lib/position.test.ts","../lib/well-known-text.test.ts","../lib/coordinate/coordinate-formats.test.ts","../lib/gb/codepoint.test.ts","../lib/geometries/point.test.ts","../lib/geometries/polygon.test.ts","../lib/geometries/round.test.ts","../lib/geometries/simplify.test.ts","../lib/geometries/point/distance.test.ts","../lib/google/place-id.test.ts","../lib/h3/cell.test.ts","../lib/h3/expand-short-cell-int.test.ts","../lib/point/reading.test.ts"],"packageJsons":["../../../node_modules/@sister.software/h3/package.json","../../../node_modules/@types/chai/package.json","../../../node_modules/@types/deep-eql/package.json","../../../node_modules/@types/node/package.json","../../../node_modules/@vitest/browser-playwright/package.json","../../../node_modules/@vitest/coverage-v8/package.json","../../../node_modules/@vitest/mocker/package.json","../../../node_modules/@vitest/ui/package.json","../../../node_modules/assertion-error/package.json","../../../node_modules/buffer/package.json","../../../node_modules/chai/package.json","../../../node_modules/deep-eql/package.json","../../../node_modules/esbuild/package.json","../../../node_modules/events/package.json","../../../node_modules/expect-type/package.json","../../../node_modules/jiti/package.json","../../../node_modules/jsdom/package.json","../../../node_modules/path-ts/package.json","../../../node_modules/punycode/package.json","../../../node_modules/string_decoder/package.json","../../../node_modules/tagged-tag/package.json","../../../node_modules/terser/package.json","../../../node_modules/tinybench/package.json","../../../node_modules/type-fest/package.json","../../../node_modules/undici-types/package.json","../../../node_modules/vite/package.json","../../../node_modules/vitest/package.json","../../../node_modules/wkx/package.json","../../../node_modules/yaml/package.json","../../annotations/package.json","../../core/package.json","../../recognizer/package.json","../../registry/package.json","../package.json"],"missingPackageJsons":["../../../node_modules/@edge-runtime/vm/package.json","../../../node_modules/@mailwoman/core/fs/readers/package.json","../../../node_modules/@mailwoman/core/fs/temporary/package.json","../../../node_modules/@mailwoman/core/fs/writers/package.json","../../../node_modules/@mailwoman/core/paths/package.json","../../../node_modules/@mailwoman/core/values/json/package.json","../../../node_modules/@mailwoman/recognizer/coordinates.generated/package.json","../../../node_modules/@mailwoman/recognizer/coordinates/package.json","../../../node_modules/@mailwoman/recognizer/identifiers.generated/package.json","../../../node_modules/@mailwoman/recognizer/identifiers/package.json","../../../node_modules/@mailwoman/recognizer/spatial.generated/package.json","../../../node_modules/@mailwoman/recognizer/spatial/package.json","../../../node_modules/@mailwoman/recognizer/types/package.json","../../../node_modules/@mailwoman/registry/types/package.json","../../../node_modules/@opentelemetry/api/package.json","../../../node_modules/@sister.software/h3/out/lib/api/package.json","../../../node_modules/@sister.software/h3/out/lib/package.json","../../../node_modules/@sister.software/h3/out/lib/runtime/package.json","../../../node_modules/@sister.software/h3/out/package.json","../../../node_modules/@types/assert/package.json","../../../node_modules/@types/assert/strict/package.json","../../../node_modules/@types/async_hooks/package.json","../../../node_modules/@types/child_process/package.json","../../../node_modules/@types/cluster/package.json","../../../node_modules/@types/console/package.json","../../../node_modules/@types/constants/package.json","../../../node_modules/@types/crypto/package.json","../../../node_modules/@types/dgram/package.json","../../../node_modules/@types/diagnostics_channel/package.json","../../../node_modules/@types/dns/package.json","../../../node_modules/@types/dns/promises/package.json","../../../node_modules/@types/domain/package.json","../../../node_modules/@types/events/package.json","../../../node_modules/@types/fs/package.json","../../../node_modules/@types/fs/promises/package.json","../../../node_modules/@types/http/package.json","../../../node_modules/@types/http2/package.json","../../../node_modules/@types/https/package.json","../../../node_modules/@types/inspector/package.json","../../../node_modules/@types/inspector/promises/package.json","../../../node_modules/@types/module/package.json","../../../node_modules/@types/net/package.json","../../../node_modules/@types/node/assert/package.json","../../../node_modules/@types/node/dns/package.json","../../../node_modules/@types/node/fs/package.json","../../../node_modules/@types/node/inspector/package.json","../../../node_modules/@types/node/path/package.json","../../../node_modules/@types/node/readline/package.json","../../../node_modules/@types/node/stream/package.json","../../../node_modules/@types/node/test/package.json","../../../node_modules/@types/node/timers/package.json","../../../node_modules/@types/node/util/package.json","../../../node_modules/@types/node/web-globals/package.json","../../../node_modules/@types/node/zlib/package.json","../../../node_modules/@types/os/package.json","../../../node_modules/@types/path/package.json","../../../node_modules/@types/path/posix/package.json","../../../node_modules/@types/path/win32/package.json","../../../node_modules/@types/perf_hooks/package.json","../../../node_modules/@types/process/package.json","../../../node_modules/@types/punycode/package.json","../../../node_modules/@types/querystring/package.json","../../../node_modules/@types/readline/package.json","../../../node_modules/@types/readline/promises/package.json","../../../node_modules/@types/repl/package.json","../../../node_modules/@types/stream/consumers/package.json","../../../node_modules/@types/stream/iter/package.json","../../../node_modules/@types/stream/package.json","../../../node_modules/@types/stream/promises/package.json","../../../node_modules/@types/stream/web/package.json","../../../node_modules/@types/string_decoder/package.json","../../../node_modules/@types/timers/package.json","../../../node_modules/@types/timers/promises/package.json","../../../node_modules/@types/tls/package.json","../../../node_modules/@types/trace_events/package.json","../../../node_modules/@types/tty/package.json","../../../node_modules/@types/url/package.json","../../../node_modules/@types/util/package.json","../../../node_modules/@types/util/types/package.json","../../../node_modules/@types/v8/package.json","../../../node_modules/@types/vm/package.json","../../../node_modules/@types/wasi/package.json","../../../node_modules/@types/worker_threads/package.json","../../../node_modules/@types/zlib/package.json","../../../node_modules/@vitejs/devtools/package.json","../../../node_modules/@vitest/browser-preview/package.json","../../../node_modules/@vitest/browser-webdriverio/package.json","../../../node_modules/@vitest/coverage-istanbul/package.json","../../../node_modules/@vitest/mocker/dist/package.json","../../../node_modules/assert/package.json","../../../node_modules/assert/strict/package.json","../../../node_modules/async_hooks/package.json","../../../node_modules/child_process/package.json","../../../node_modules/cluster/package.json","../../../node_modules/console/package.json","../../../node_modules/constants/package.json","../../../node_modules/crypto/package.json","../../../node_modules/dgram/package.json","../../../node_modules/diagnostics_channel/package.json","../../../node_modules/dns/package.json","../../../node_modules/dns/promises/package.json","../../../node_modules/domain/package.json","../../../node_modules/expect-type/dist/package.json","../../../node_modules/fs/package.json","../../../node_modules/fs/promises/package.json","../../../node_modules/happy-dom/package.json","../../../node_modules/http/package.json","../../../node_modules/http2/package.json","../../../node_modules/https/package.json","../../../node_modules/inspector/package.json","../../../node_modules/inspector/promises/package.json","../../../node_modules/less/package.json","../../../node_modules/module/package.json","../../../node_modules/msw/package.json","../../../node_modules/net/package.json","../../../node_modules/os/package.json","../../../node_modules/path-ts/out/lib/package.json","../../../node_modules/path-ts/out/package.json","../../../node_modules/path/package.json","../../../node_modules/path/posix/package.json","../../../node_modules/path/win32/package.json","../../../node_modules/perf_hooks/package.json","../../../node_modules/process/package.json","../../../node_modules/querystring/package.json","../../../node_modules/readline/package.json","../../../node_modules/readline/promises/package.json","../../../node_modules/repl/package.json","../../../node_modules/sass-embedded/package.json","../../../node_modules/sass/package.json","../../../node_modules/stream/consumers/package.json","../../../node_modules/stream/iter/package.json","../../../node_modules/stream/package.json","../../../node_modules/stream/promises/package.json","../../../node_modules/stream/web/package.json","../../../node_modules/stylus/package.json","../../../node_modules/sugarss/package.json","../../../node_modules/timers/package.json","../../../node_modules/timers/promises/package.json","../../../node_modules/tinybench/dist/package.json","../../../node_modules/tls/package.json","../../../node_modules/trace_events/package.json","../../../node_modules/tsx/package.json","../../../node_modules/tty/package.json","../../../node_modules/type-fest/source/internal/package.json","../../../node_modules/type-fest/source/package.json","../../../node_modules/url/package.json","../../../node_modules/util/package.json","../../../node_modules/util/types/package.json","../../../node_modules/v8/package.json","../../../node_modules/vite/dist/node/chunks/package.json","../../../node_modules/vite/dist/node/package.json","../../../node_modules/vite/dist/package.json","../../../node_modules/vite/module-runner/package.json","../../../node_modules/vite/types/package.json","../../../node_modules/vitest/dist/chunks/package.json","../../../node_modules/vitest/dist/package.json","../../../node_modules/vm/package.json","../../../node_modules/wasi/package.json","../../../node_modules/wkx/lib/package.json","../../../node_modules/worker_threads/package.json","../../../node_modules/zlib/package.json"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/spatial",
3
- "version": "11.1.0",
3
+ "version": "11.3.0",
4
4
  "description": "Spatial analysis, geocoding, and other geo-related utilities.",
5
5
  "keywords": [
6
6
  "geo",
@@ -93,8 +93,9 @@
93
93
  }
94
94
  },
95
95
  "dependencies": {
96
- "@mailwoman/core": "11.1.0",
97
- "@mailwoman/postcode": "11.1.0",
96
+ "@mailwoman/core": "11.3.0",
97
+ "@mailwoman/postcode": "11.3.0",
98
+ "@mailwoman/recognizer": "11.3.0",
98
99
  "@sister.software/h3": "^1.1.0",
99
100
  "@types/google.maps": "^3.66.9",
100
101
  "geo-coordinates-parser": "^1.7.4",
@@ -103,10 +104,10 @@
103
104
  "wkx": "^0.5.0"
104
105
  },
105
106
  "devDependencies": {
106
- "@mailwoman/annotations": "11.1.0",
107
+ "@mailwoman/annotations": "11.3.0",
107
108
  "type-fest": "^5.10.0"
108
109
  },
109
110
  "engines": {
110
- "node": "^24.22.1 || >=26.12.1"
111
+ "node": "^24.22.3 || >=26.13.1"
111
112
  }
112
113
  }
@@ -5,8 +5,8 @@
5
5
  * @file One ogr2ogr harness for every streaming extraction.
6
6
  */
7
7
 
8
- import { tryParsingJSON } from "@mailwoman/core/json"
9
- import { spawnProcess } from "@mailwoman/core/process"
8
+ import { spawnProcess } from "@mailwoman/core/scripting/process"
9
+ import { tryParsingJSON } from "@mailwoman/core/values/json"
10
10
  import type { PathBuilderLike } from "path-ts"
11
11
  import { TextSpliterator } from "spliterator"
12
12
 
package/tools/ogr.ts CHANGED
@@ -5,15 +5,15 @@
5
5
  * What an OGR-readable source declares about itself, read before any feature is —
6
6
  * the identity check every polygon-layer ingest opens with.
7
7
  *
8
- * OGR is build tooling, never A serve dependency (scope invariant 6).
8
+ * OGR is build tooling, never a serving dependency (scope invariant 6).
9
9
  * The check refuses a source whose declared authority code isn't the one the ingest was written for,
10
10
  * because reading one projection's coordinates as another's is silent — and it runs the
11
11
  * datum-transformation guard even where no shift is needed, because skipping it on the reasoning
12
12
  * that a source needs no shift makes the guard fire on the day a source arrives that does.
13
13
  */
14
14
 
15
- import { parseJSONStrict, stringifyJSON } from "@mailwoman/core/json"
16
- import { runFile } from "@mailwoman/core/process"
15
+ import { runFile } from "@mailwoman/core/scripting/process"
16
+ import { parseJSONStrict, stringifyJSON } from "@mailwoman/core/values/json"
17
17
 
18
18
  import { assertDatumTransformationAvailable } from "#projection/transform"
19
19
 
@@ -1,294 +0,0 @@
1
- // SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
2
- // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
3
-
4
- /**
5
- * @file The shapes a typed query takes when it is a point rather than an address, and the one parser for them.
6
- *
7
- * A search field receives coordinates in a dozen spellings, a plus code, an H3 cell, a geohash or a
8
- * Who's On First id beside ordinary addresses. {@link parsePointQuery} reads the whole text as one of those shapes or
9
- * answers `null`, so a caller sends only an address to the classifier. It reads text and decodes no cell: decoding a cell
10
- * to a coordinate belongs to the module that owns the format, and the H3 reader loads a WebAssembly binary
11
- * that a text test mustn't pay for.
12
- */
13
-
14
- import { isValidLatitude, isValidLongitude } from "#coordinate/bounds"
15
- import { isFullPlusCode, isShortPlusCode } from "#open-location-code"
16
-
17
- /**
18
- * The axis order a coordinate pair was read in.
19
- *
20
- * `lat_lon` is the order people write and the order inside a Google Maps link.
21
- * `lon_lat` is reported when the first number is out of latitude range, so it can only be a longitude.
22
- */
23
- export type CoordinateOrder = "lat_lon" | "lon_lat"
24
-
25
- export type PointQuery =
26
- | {
27
- kind: "coordinates"
28
- lat: number
29
- lon: number
30
- order: CoordinateOrder
31
- }
32
- | {
33
- /**
34
- * An Open Location Code, upper-cased.
35
- *
36
- * A short code (`VFQ6+92P`) decodes only beside a reference position.
37
- * The caller supplies that position.
38
- */
39
- kind: "plus_code"
40
- code: string
41
- full: boolean
42
- }
43
- | {
44
- /**
45
- * An H3 cell index in its hexadecimal form, lower-cased.
46
- *
47
- * Only the shape is checked here: the H3 library decides validity when it decodes the cell.
48
- */
49
- kind: "h3"
50
- cell: string
51
- }
52
- | {
53
- /**
54
- * A geohash, lower-cased.
55
- *
56
- * It is accepted only behind a `geohash:` or `gh:` prefix, because a bare hash is also a word.
57
- */
58
- kind: "geohash"
59
- hash: string
60
- }
61
- | {
62
- /**
63
- * A Who's On First id, from `wof:85633793`, `wof 85633793` or a Spelunker link.
64
- */
65
- kind: "wof"
66
- id: number
67
- }
68
-
69
- /**
70
- * `wof:85633793`, `wof 85633793`, `whosonfirst:85633793`.
71
- */
72
- const WOF_REFERENCE = /^(?:wof|whosonfirst)[\s:]+(\d{1,16})$/iu
73
-
74
- /**
75
- * A Spelunker place page, with or without the trailing slash.
76
- */
77
- const SPELUNKER_URL = /^https?:\/\/spelunker\.whosonfirst\.org\/id\/(\d{1,16})\/?$/iu
78
-
79
- /**
80
- * The hexadecimal form of an H3 cell: mode 1 in the high nibble, then fourteen more digits.
81
- */
82
- const H3_CELL = /^(?:h3:)?(8[0-9a-f]{14})$/iu
83
-
84
- /**
85
- * A geohash behind its prefix, in the base-32 alphabet that omits `a`, `i`, `l` and `o`.
86
- */
87
- const GEOHASH_REFERENCE = /^(?:geohash|gh):\s*([0-9b-hjkmnp-z]{1,12})$/iu
88
-
89
- /**
90
- * A `geo:` URI, `geo:48.8584,2.2945` with an optional altitude and parameters.
91
- */
92
- const GEO_URI = /^geo:(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)(?:,-?\d+(?:\.\d+)?)?(?:;.*)?$/iu
93
-
94
- /**
95
- * Google Maps' path segment, `@48.8584,2.2945,17z`, with the zoom optional.
96
- */
97
- const MAPS_SEGMENT = /^@(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)(?:,[\d.]+z)?$/iu
98
-
99
- /**
100
- * A labeled pair in either order: `lat 48.85 lon 2.29`, `lng=2.29, lat=48.85`.
101
- */
102
- const LABELED_PAIR =
103
- /^(lat(?:itude)?|lon(?:gitude)?|lng)\s*[:=]?\s*(-?\d+(?:\.\d+)?)\s*[,;\s]\s*(lat(?:itude)?|lon(?:gitude)?|lng)\s*[:=]?\s*(-?\d+(?:\.\d+)?)$/iu
104
-
105
- /**
106
- * One angle: a signed decimal, or degrees with optional minutes and seconds,
107
- * each with its mark, and an optional hemisphere letter after it.
108
- */
109
- const ANGLE =
110
- /^([+-])?\s*(\d+(?:\.\d+)?)\s*(?:°|º|d\b)?\s*(?:(\d+(?:\.\d+)?)\s*(?:'|′|’|m\b)\s*)?(?:(\d+(?:\.\d+)?)\s*(?:"|″|”|''|s\b)\s*)?([NSEW])?$/iu
111
-
112
- /**
113
- * A pair of angles is split at the comma or semicolon, or after the first hemisphere letter,
114
- * or between two decimal numbers at the whitespace between them.
115
- */
116
- const PAIR_AT_HEMISPHERE = /^(.+?[NSEW])\s+(.+)$/iu
117
- const PAIR_AT_SPACE = /^(\S+)\s+(\S+)$/u
118
-
119
- interface Angle {
120
- degrees: number
121
- hemisphere: "N" | "S" | "E" | "W" | null
122
- }
123
-
124
- function parseAngle(text: string): Angle | null {
125
- const match = ANGLE.exec(text.trim())
126
-
127
- if (!match) return null
128
-
129
- const [, sign, degrees, minutes = "0", seconds = "0", letter] = match
130
- const magnitude = Number(degrees) + Number(minutes) / 60 + Number(seconds) / 3600
131
-
132
- if (!Number.isFinite(magnitude)) return null
133
-
134
- const hemisphere = letter ? (letter.toUpperCase() as Angle["hemisphere"]) : null
135
- const negative = sign === "-" || hemisphere === "S" || hemisphere === "W"
136
-
137
- return { degrees: negative ? -magnitude : magnitude, hemisphere }
138
- }
139
-
140
- /**
141
- * A pair of angles as the point they name, or `null` when the pair is out of range in both orders.
142
- *
143
- * Hemisphere letters decide the axis.
144
- * Without them the first number is the latitude, as in a Google Maps link,
145
- * unless only the other order is in range.
146
- */
147
- function pairToPoint(first: Angle, second: Angle): PointQuery | null {
148
- const latLetters = new Set(["N", "S"])
149
- const lonLetters = new Set(["E", "W"])
150
-
151
- if (first.hemisphere && second.hemisphere) {
152
- if (latLetters.has(first.hemisphere) && lonLetters.has(second.hemisphere)) {
153
- return coordinates(first.degrees, second.degrees, "lat_lon")
154
- }
155
-
156
- if (lonLetters.has(first.hemisphere) && latLetters.has(second.hemisphere)) {
157
- return coordinates(second.degrees, first.degrees, "lon_lat")
158
- }
159
-
160
- return null
161
- }
162
-
163
- if (first.hemisphere) {
164
- return latLetters.has(first.hemisphere)
165
- ? coordinates(first.degrees, second.degrees, "lat_lon")
166
- : coordinates(second.degrees, first.degrees, "lon_lat")
167
- }
168
-
169
- if (second.hemisphere) {
170
- return lonLetters.has(second.hemisphere)
171
- ? coordinates(first.degrees, second.degrees, "lat_lon")
172
- : coordinates(second.degrees, first.degrees, "lon_lat")
173
- }
174
-
175
- return coordinates(first.degrees, second.degrees, "lat_lon") ?? coordinates(second.degrees, first.degrees, "lon_lat")
176
- }
177
-
178
- function coordinates(lat: number, lon: number, order: CoordinateOrder): PointQuery | null {
179
- if (!isValidLatitude(lat) || !isValidLongitude(lon)) return null
180
-
181
- return { kind: "coordinates", lat, lon, order }
182
- }
183
-
184
- /**
185
- * Whether a bare pair of numbers reads as a coordinate rather than two counts.
186
- *
187
- * `12 34` reads as a house number beside a postcode and as a position, so a bare pair
188
- * needs a comma, a decimal point, a degree mark or a hemisphere letter.
189
- */
190
- const COORDINATE_MARK = /[,;.°º'′"″NSEW]/iu
191
-
192
- function parseCoordinatePair(text: string): PointQuery | null {
193
- if (!COORDINATE_MARK.test(text)) return null
194
-
195
- const halves =
196
- (/[,;]/u.test(text) ? text.split(/[,;]/u, 2) : null) ??
197
- PAIR_AT_HEMISPHERE.exec(text)?.slice(1, 3) ??
198
- PAIR_AT_SPACE.exec(text)?.slice(1, 3)
199
-
200
- if (!halves || halves.length !== 2) return null
201
-
202
- const first = parseAngle(halves[0]!)
203
- const second = parseAngle(halves[1]!)
204
-
205
- if (!first || !second) return null
206
-
207
- return pairToPoint(first, second)
208
- }
209
-
210
- /**
211
- * Reads a whole query as the point it names: a coordinate pair in decimal,
212
- * degrees-minutes-seconds, `geo:` or Google Maps form, a full or short plus code,
213
- * an H3 cell, a prefixed geohash, or a Who's On First id.
214
- *
215
- * Returns `null` for text that's none of these.
216
- * Every address is such a text.
217
- *
218
- * A coordinate outside the valid range in both axis orders is also `null`, never clamped.
219
- */
220
- export function parsePointQuery(text: string): PointQuery | null {
221
- const trimmed = text.trim()
222
-
223
- if (!trimmed) return null
224
-
225
- const wof = WOF_REFERENCE.exec(trimmed) ?? SPELUNKER_URL.exec(trimmed)
226
-
227
- if (wof) {
228
- const id = Number(wof[1])
229
-
230
- return Number.isSafeInteger(id) && id > 0 ? { kind: "wof", id } : null
231
- }
232
-
233
- const h3 = H3_CELL.exec(trimmed)
234
-
235
- if (h3) return { kind: "h3", cell: h3[1]!.toLowerCase() }
236
-
237
- const geohash = GEOHASH_REFERENCE.exec(trimmed)
238
-
239
- if (geohash) return { kind: "geohash", hash: geohash[1]!.toLowerCase() }
240
-
241
- if (isFullPlusCode(trimmed)) return { kind: "plus_code", code: trimmed.toUpperCase(), full: true }
242
-
243
- if (isShortPlusCode(trimmed)) return { kind: "plus_code", code: trimmed.toUpperCase(), full: false }
244
-
245
- const uri = GEO_URI.exec(trimmed) ?? MAPS_SEGMENT.exec(trimmed)
246
-
247
- if (uri) return coordinates(Number(uri[1]), Number(uri[2]), "lat_lon")
248
-
249
- const labeled = LABELED_PAIR.exec(trimmed)
250
-
251
- if (labeled) {
252
- const [, firstLabel, firstValue, secondLabel, secondValue] = labeled
253
- const firstIsLat = /^lat/iu.test(firstLabel!)
254
-
255
- if (firstIsLat === /^lat/iu.test(secondLabel!)) return null
256
-
257
- return firstIsLat
258
- ? coordinates(Number(firstValue), Number(secondValue), "lat_lon")
259
- : coordinates(Number(secondValue), Number(firstValue), "lon_lat")
260
- }
261
-
262
- return parseCoordinatePair(trimmed)
263
- }
264
-
265
- /**
266
- * A coordinate pair as text, latitude first, in the form {@link parsePointQuery} reads back.
267
- *
268
- * Six decimals place a point within about 11 cm.
269
- */
270
- export function coordinatePairText(lat: number, lon: number, decimals = 6): string {
271
- return `${lat.toFixed(decimals)}, ${lon.toFixed(decimals)}`
272
- }
273
-
274
- /**
275
- * The label a point query is shown under, such as the tag column of a parse.
276
- */
277
- export const POINT_QUERY_LABEL: Record<PointQuery["kind"], string> = {
278
- coordinates: "coordinates",
279
- plus_code: "plus code",
280
- h3: "H3 cell",
281
- geohash: "geohash",
282
- wof: "Who's On First id",
283
- }
284
-
285
- /**
286
- * The same shapes as a noun phrase with its article, for a sentence: "this is a plus code".
287
- */
288
- export const POINT_QUERY_PHRASE: Record<PointQuery["kind"], string> = {
289
- coordinates: "a coordinate pair",
290
- plus_code: "a plus code",
291
- h3: "an H3 cell",
292
- geohash: "a geohash",
293
- wof: "a Who's On First id",
294
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * The axis order a coordinate pair was read in.
3
- *
4
- * `lat_lon` is the order people write and the order inside a Google Maps link.
5
- * `lon_lat` is reported when the first number is out of latitude range, so it can only be a longitude.
6
- */
7
- export type CoordinateOrder = "lat_lon" | "lon_lat";
8
- export type PointQuery = {
9
- kind: "coordinates";
10
- lat: number;
11
- lon: number;
12
- order: CoordinateOrder;
13
- } | {
14
- /**
15
- * An Open Location Code, upper-cased.
16
- *
17
- * A short code (`VFQ6+92P`) decodes only beside a reference position.
18
- * The caller supplies that position.
19
- */
20
- kind: "plus_code";
21
- code: string;
22
- full: boolean;
23
- } | {
24
- /**
25
- * An H3 cell index in its hexadecimal form, lower-cased.
26
- *
27
- * Only the shape is checked here: the H3 library decides validity when it decodes the cell.
28
- */
29
- kind: "h3";
30
- cell: string;
31
- } | {
32
- /**
33
- * A geohash, lower-cased.
34
- *
35
- * It is accepted only behind a `geohash:` or `gh:` prefix, because a bare hash is also a word.
36
- */
37
- kind: "geohash";
38
- hash: string;
39
- } | {
40
- /**
41
- * A Who's On First id, from `wof:85633793`, `wof 85633793` or a Spelunker link.
42
- */
43
- kind: "wof";
44
- id: number;
45
- };
46
- /**
47
- * Reads a whole query as the point it names: a coordinate pair in decimal,
48
- * degrees-minutes-seconds, `geo:` or Google Maps form, a full or short plus code,
49
- * an H3 cell, a prefixed geohash, or a Who's On First id.
50
- *
51
- * Returns `null` for text that's none of these.
52
- * Every address is such a text.
53
- *
54
- * A coordinate outside the valid range in both axis orders is also `null`, never clamped.
55
- */
56
- export declare function parsePointQuery(text: string): PointQuery | null;
57
- /**
58
- * A coordinate pair as text, latitude first, in the form {@link parsePointQuery} reads back.
59
- *
60
- * Six decimals place a point within about 11 cm.
61
- */
62
- export declare function coordinatePairText(lat: number, lon: number, decimals?: number): string;
63
- /**
64
- * The label a point query is shown under, such as the tag column of a parse.
65
- */
66
- export declare const POINT_QUERY_LABEL: Record<PointQuery["kind"], string>;
67
- /**
68
- * The same shapes as a noun phrase with its article, for a sentence: "this is a plus code".
69
- */
70
- export declare const POINT_QUERY_PHRASE: Record<PointQuery["kind"], string>;
71
- //# sourceMappingURL=point-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"point-query.d.ts","sourceRoot":"","sources":["../lib/point-query.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAA;AAEnD,MAAM,MAAM,UAAU,GACnB;IACA,IAAI,EAAE,aAAa,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,eAAe,CAAA;CACrB,GACD;IACA;;;;;OAKG;IACH,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;CACZ,GACD;IACA;;;;OAIG;IACH,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACX,GACD;IACA;;;;OAIG;IACH,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACX,GACD;IACA;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;CACT,CAAA;AA+IJ;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CA2C/D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,CAEjF;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAMhE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAMjE,CAAA"}