@mailwoman/timezone-lookup 9.2.0 → 9.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.
- package/{build.ts → lib/build.ts} +13 -12
- package/{cli.ts → lib/cli.ts} +7 -9
- package/{index.ts → lib/index.ts} +32 -13
- package/lib/schema.ts +27 -0
- package/out/build.d.ts +8 -2
- package/out/build.d.ts.map +1 -1
- package/out/build.js +7 -7
- package/out/build.js.map +1 -1
- package/out/cli.d.ts.map +1 -1
- package/out/cli.js +7 -8
- package/out/cli.js.map +1 -1
- package/out/index.d.ts +6 -5
- package/out/index.d.ts.map +1 -1
- package/out/index.js +24 -8
- package/out/index.js.map +1 -1
- package/out/schema.d.ts +26 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +10 -0
- package/out/schema.js.map +1 -0
- package/package.json +36 -2
|
@@ -9,23 +9,25 @@
|
|
|
9
9
|
* prefilter), and the geometry normalized to MultiPolygon coordinates as JSON.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
13
|
+
import type { GeoFeature, InferGeoFeatureCollection, MultiPolygonLiteral, PolygonLiteral } from "@mailwoman/spatial"
|
|
14
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
14
15
|
|
|
15
|
-
import type { MultiPolygonCoords } from "
|
|
16
|
+
import type { MultiPolygonCoords } from "#index"
|
|
17
|
+
import type { TimezoneDatabase } from "#schema"
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
properties: { tzid: string }
|
|
19
|
-
geometry: { type: "Polygon" | "MultiPolygon"; coordinates: number[][][] | number[][][][] }
|
|
20
|
-
}
|
|
19
|
+
export type TimezoneFeature = GeoFeature<PolygonLiteral | MultiPolygonLiteral, { tzid: string }>
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Read the GeoJSON at `geojsonPath` and write the polygon DB to `dbPath` (overwriting its table).
|
|
23
|
+
*
|
|
24
|
+
* @returns The number of features written to the DB.
|
|
24
25
|
*/
|
|
25
|
-
export function buildTimezoneDB(geojsonPath: string, dbPath: string): { features: number } {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export async function buildTimezoneDB(geojsonPath: string, dbPath: string): Promise<{ features: number }> {
|
|
27
|
+
const data = await readLocalJSONFile<InferGeoFeatureCollection<TimezoneFeature>>(geojsonPath)
|
|
28
|
+
|
|
29
|
+
using db = new DatabaseClient<TimezoneDatabase>(dbPath)
|
|
30
|
+
|
|
29
31
|
db.exec("DROP TABLE IF EXISTS timezone_polygons")
|
|
30
32
|
|
|
31
33
|
db.exec(
|
|
@@ -79,7 +81,6 @@ export function buildTimezoneDB(geojsonPath: string, dbPath: string): { features
|
|
|
79
81
|
|
|
80
82
|
db.exec("COMMIT")
|
|
81
83
|
db.exec("CREATE INDEX idx_tz_bbox ON timezone_polygons (minLat, maxLat, minLon, maxLon)")
|
|
82
|
-
db.close()
|
|
83
84
|
|
|
84
85
|
return { features: data.features.length }
|
|
85
86
|
}
|
package/{cli.ts → lib/cli.ts}
RENAMED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* The `--` separates flags from coordinates so negative longitudes parse as positionals.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { parseArguments } from "@mailwoman/core/scripting/arguments"
|
|
18
18
|
|
|
19
|
-
import { buildTimezoneDB } from "
|
|
20
|
-
import { offsetSecForTimezone, TimezoneLookup } from "
|
|
19
|
+
import { buildTimezoneDB } from "#build"
|
|
20
|
+
import { offsetSecForTimezone, TimezoneLookup } from "#index"
|
|
21
21
|
|
|
22
|
-
const { values, positionals } =
|
|
22
|
+
const { values, positionals } = parseArguments({
|
|
23
23
|
options: {
|
|
24
24
|
geojson: { type: "string" },
|
|
25
25
|
out: { type: "string" },
|
|
@@ -35,7 +35,7 @@ if (positionals[0] === "build") {
|
|
|
35
35
|
process.exit(1)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const { features } = buildTimezoneDB(values.geojson, values.out)
|
|
38
|
+
const { features } = await buildTimezoneDB(values.geojson, values.out)
|
|
39
39
|
|
|
40
40
|
console.error(`built ${values.out} (${features} features)`)
|
|
41
41
|
} else {
|
|
@@ -48,11 +48,9 @@ if (positionals[0] === "build") {
|
|
|
48
48
|
process.exit(1)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
using lookup = new TimezoneLookup({ databasePath: values.db })
|
|
52
52
|
// oxlint-disable-next-line unicorn/no-array-method-this-argument -- `lookup.find(lat, lon)` is a two-argument gazetteer probe, not Array#find
|
|
53
|
-
const tzid = lookup.
|
|
53
|
+
const tzid = lookup.explore(lat, lon)
|
|
54
54
|
|
|
55
55
|
console.log(JSON.stringify({ timezone: tzid, offsetSec: tzid ? offsetSecForTimezone(tzid) : null }))
|
|
56
|
-
|
|
57
|
-
lookup.close()
|
|
58
56
|
}
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
* database dependency. Build the DB with `mailwoman-timezone build` (see `./build.ts`).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { DatabaseSync } from "node:sqlite"
|
|
13
|
-
|
|
14
12
|
import type { AnnotationSet, Annotator } from "@mailwoman/annotations"
|
|
13
|
+
import { parseJSONStrict } from "@mailwoman/core/json"
|
|
14
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client"
|
|
15
|
+
|
|
16
|
+
import type { TimezoneDatabase } from "#schema"
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Normalized geometry: an array of polygons, each `[outerRing, ...holes]`, each ring `[[lon,lat],…]`.
|
|
@@ -26,6 +28,9 @@ export type MultiPolygonCoords = number[][][][]
|
|
|
26
28
|
* `@mailwoman/core` with it, whose published tarball carries ~11 MB of libpostal/WOF/chromium-i18n data. Eleven
|
|
27
29
|
* megabytes for fifteen lines is the wrong trade for a leaf lookup package. If this package ever gains a real spatial
|
|
28
30
|
* dependency, delete these and import them.
|
|
31
|
+
*
|
|
32
|
+
* Repo-health-ignore private-name-shadows-export -- kept local so a leaf lookup package stays off @mailwoman/core's ~11
|
|
33
|
+
* MB of shipped data; see the docstring
|
|
29
34
|
*/
|
|
30
35
|
function pointInRing(lon: number, lat: number, ring: number[][]): boolean {
|
|
31
36
|
let inside = false
|
|
@@ -46,6 +51,9 @@ function pointInRing(lon: number, lat: number, ring: number[][]): boolean {
|
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* Inside the outer ring and outside every hole.
|
|
54
|
+
*
|
|
55
|
+
* Repo-health-ignore private-name-shadows-export -- kept local so a leaf lookup package stays off @mailwoman/core's ~11
|
|
56
|
+
* MB of shipped data; see the docstring
|
|
49
57
|
*/
|
|
50
58
|
function pointInPolygon(lon: number, lat: number, polygon: number[][][]): boolean {
|
|
51
59
|
if (!polygon[0] || !pointInRing(lon, lat, polygon[0])) return false
|
|
@@ -86,12 +94,20 @@ export function offsetSecForTimezone(tzid: string, date: Date = new Date()): num
|
|
|
86
94
|
/**
|
|
87
95
|
* A timezone lookup over a built `node:sqlite` polygon DB.
|
|
88
96
|
*/
|
|
89
|
-
export class TimezoneLookup {
|
|
90
|
-
#db:
|
|
91
|
-
|
|
97
|
+
export class TimezoneLookup implements Disposable {
|
|
98
|
+
#db: DatabaseClient<TimezoneDatabase>
|
|
99
|
+
/**
|
|
100
|
+
* Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
|
|
101
|
+
* ownership is membership rather than a flag a later branch has to check.
|
|
102
|
+
*/
|
|
103
|
+
readonly #resources = new DisposableStack()
|
|
104
|
+
#stmt: ReturnType<DatabaseClient["prepare"]>
|
|
92
105
|
|
|
93
|
-
constructor(opts: { databasePath: string } | { database:
|
|
94
|
-
this.#db =
|
|
106
|
+
constructor(opts: { databasePath: string } | { database: DatabaseClient<TimezoneDatabase> }) {
|
|
107
|
+
this.#db =
|
|
108
|
+
"database" in opts
|
|
109
|
+
? opts.database
|
|
110
|
+
: this.#resources.use(new DatabaseClient<TimezoneDatabase>(opts.databasePath, { readOnly: true }))
|
|
95
111
|
|
|
96
112
|
// Candidate features whose bbox contains the point; PIP picks the exact one.
|
|
97
113
|
this.#stmt = this.#db.prepare(
|
|
@@ -103,19 +119,22 @@ export class TimezoneLookup {
|
|
|
103
119
|
/**
|
|
104
120
|
* The IANA timezone id containing `(lat, lon)`, or `null` if none (shouldn't happen with oceans).
|
|
105
121
|
*/
|
|
106
|
-
|
|
122
|
+
explore(lat: number, lon: number): string | null {
|
|
107
123
|
const rows = this.#stmt.all(lat, lat, lon, lon) as Array<{ tzid: string; geom: string }>
|
|
108
124
|
|
|
109
125
|
for (const row of rows) {
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
const multiPolygonCoords = parseJSONStrict<MultiPolygonCoords>(row.geom)
|
|
127
|
+
|
|
128
|
+
if (pointInMultiPolygon(lon, lat, multiPolygonCoords)) {
|
|
129
|
+
return row.tzid
|
|
130
|
+
}
|
|
112
131
|
}
|
|
113
132
|
|
|
114
133
|
return null
|
|
115
134
|
}
|
|
116
135
|
|
|
117
|
-
|
|
118
|
-
this.#
|
|
136
|
+
[Symbol.dispose](): void {
|
|
137
|
+
this.#resources[Symbol.dispose]()
|
|
119
138
|
}
|
|
120
139
|
}
|
|
121
140
|
|
|
@@ -125,7 +144,7 @@ export class TimezoneLookup {
|
|
|
125
144
|
export function makeTimezoneAnnotator(lookup: TimezoneLookup): Annotator {
|
|
126
145
|
return ({ lat, lon, date }): Partial<AnnotationSet> => {
|
|
127
146
|
// oxlint-disable-next-line unicorn/no-array-method-this-argument -- `lookup.find(lat, lon)` is a two-argument gazetteer probe, not Array#find
|
|
128
|
-
const name = lookup.
|
|
147
|
+
const name = lookup.explore(lat, lon)
|
|
129
148
|
|
|
130
149
|
if (!name) return {}
|
|
131
150
|
const offsetSec = offsetSecForTimezone(name, date)
|
package/lib/schema.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The `timezone.db` read contract. Declared beside the reader and the builder that writes it, so a column added to
|
|
7
|
+
* one is a compile error against the other.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* One timezone polygon: its IANA identifier, bounding box, and encoded geometry.
|
|
12
|
+
*/
|
|
13
|
+
export interface TimezonePolygonTable {
|
|
14
|
+
tzid: string
|
|
15
|
+
minLat: number | null
|
|
16
|
+
maxLat: number | null
|
|
17
|
+
minLon: number | null
|
|
18
|
+
maxLon: number | null
|
|
19
|
+
geom: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The tables `timezone.db` carries.
|
|
24
|
+
*/
|
|
25
|
+
export interface TimezoneDatabase {
|
|
26
|
+
timezone_polygons: TimezonePolygonTable
|
|
27
|
+
}
|
package/out/build.d.ts
CHANGED
|
@@ -8,10 +8,16 @@
|
|
|
8
8
|
* Polygon|MultiPolygon }`). One row per feature: the tzid, a bounding box (for the lookup's
|
|
9
9
|
* prefilter), and the geometry normalized to MultiPolygon coordinates as JSON.
|
|
10
10
|
*/
|
|
11
|
+
import type { GeoFeature, MultiPolygonLiteral, PolygonLiteral } from "@mailwoman/spatial";
|
|
12
|
+
export type TimezoneFeature = GeoFeature<PolygonLiteral | MultiPolygonLiteral, {
|
|
13
|
+
tzid: string;
|
|
14
|
+
}>;
|
|
11
15
|
/**
|
|
12
16
|
* Read the GeoJSON at `geojsonPath` and write the polygon DB to `dbPath` (overwriting its table).
|
|
17
|
+
*
|
|
18
|
+
* @returns The number of features written to the DB.
|
|
13
19
|
*/
|
|
14
|
-
export declare function buildTimezoneDB(geojsonPath: string, dbPath: string): {
|
|
20
|
+
export declare function buildTimezoneDB(geojsonPath: string, dbPath: string): Promise<{
|
|
15
21
|
features: number;
|
|
16
|
-
}
|
|
22
|
+
}>;
|
|
17
23
|
//# sourceMappingURL=build.d.ts.map
|
package/out/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../lib/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAA6B,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMpH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,cAAc,GAAG,mBAAmB,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEhG;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA4DxG"}
|
package/out/build.js
CHANGED
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
* Polygon|MultiPolygon }`). One row per feature: the tzid, a bounding box (for the lookup's
|
|
9
9
|
* prefilter), and the geometry normalized to MultiPolygon coordinates as JSON.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { readLocalJSONFile } from "@mailwoman/core/fs/readers";
|
|
12
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
13
13
|
/**
|
|
14
14
|
* Read the GeoJSON at `geojsonPath` and write the polygon DB to `dbPath` (overwriting its table).
|
|
15
|
+
*
|
|
16
|
+
* @returns The number of features written to the DB.
|
|
15
17
|
*/
|
|
16
|
-
export function buildTimezoneDB(geojsonPath, dbPath) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const db = new DatabaseSync(dbPath);
|
|
18
|
+
export async function buildTimezoneDB(geojsonPath, dbPath) {
|
|
19
|
+
const data = await readLocalJSONFile(geojsonPath);
|
|
20
|
+
using db = new DatabaseClient(dbPath);
|
|
20
21
|
db.exec("DROP TABLE IF EXISTS timezone_polygons");
|
|
21
22
|
db.exec(`CREATE TABLE timezone_polygons (tzid TEXT NOT NULL, minLat REAL, maxLat REAL, minLon REAL, maxLon REAL, geom TEXT NOT NULL)`);
|
|
22
23
|
const insert = db.prepare("INSERT INTO timezone_polygons (tzid, minLat, maxLat, minLon, maxLon, geom) VALUES (?,?,?,?,?,?)");
|
|
@@ -53,7 +54,6 @@ export function buildTimezoneDB(geojsonPath, dbPath) {
|
|
|
53
54
|
}
|
|
54
55
|
db.exec("COMMIT");
|
|
55
56
|
db.exec("CREATE INDEX idx_tz_bbox ON timezone_polygons (minLat, maxLat, minLon, maxLon)");
|
|
56
|
-
db.close();
|
|
57
57
|
return { features: data.features.length };
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=build.js.map
|
package/out/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../lib/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAOzD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAAmB,EAAE,MAAc;IACxE,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAA6C,WAAW,CAAC,CAAA;IAE7F,MAAM,EAAE,GAAG,IAAI,cAAc,CAAmB,MAAM,CAAC,CAAA;IAEvD,EAAE,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAA;IAEjD,EAAE,CAAC,IAAI,CACN,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IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC9F,CAAC;IAED,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACjB,EAAE,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAA;IAEzF,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;AAC1C,CAAC"}
|
package/out/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG"}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../lib/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG"}
|
package/out/cli.js
CHANGED
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
*
|
|
14
14
|
* The `--` separates flags from coordinates so negative longitudes parse as positionals.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import { buildTimezoneDB } from "
|
|
18
|
-
import { offsetSecForTimezone, TimezoneLookup } from "
|
|
19
|
-
const { values, positionals } =
|
|
16
|
+
import { parseArguments } from "@mailwoman/core/scripting/arguments";
|
|
17
|
+
import { buildTimezoneDB } from "#build";
|
|
18
|
+
import { offsetSecForTimezone, TimezoneLookup } from "#index";
|
|
19
|
+
const { values, positionals } = parseArguments({
|
|
20
20
|
options: {
|
|
21
21
|
geojson: { type: "string" },
|
|
22
22
|
out: { type: "string" },
|
|
@@ -29,7 +29,7 @@ if (positionals[0] === "build") {
|
|
|
29
29
|
console.error("Usage: mailwoman-timezone build --geojson <path> --out <db>");
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
|
32
|
-
const { features } = buildTimezoneDB(values.geojson, values.out);
|
|
32
|
+
const { features } = await buildTimezoneDB(values.geojson, values.out);
|
|
33
33
|
console.error(`built ${values.out} (${features} features)`);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
@@ -39,10 +39,9 @@ else {
|
|
|
39
39
|
console.error("Usage: mailwoman-timezone --db <db> -- <lat> <lon>");
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
using lookup = new TimezoneLookup({ databasePath: values.db });
|
|
43
43
|
// oxlint-disable-next-line unicorn/no-array-method-this-argument -- `lookup.find(lat, lon)` is a two-argument gazetteer probe, not Array#find
|
|
44
|
-
const tzid = lookup.
|
|
44
|
+
const tzid = lookup.explore(lat, lon);
|
|
45
45
|
console.log(JSON.stringify({ timezone: tzid, offsetSec: tzid ? offsetSecForTimezone(tzid) : null }));
|
|
46
|
-
lookup.close();
|
|
47
46
|
}
|
|
48
47
|
//# sourceMappingURL=cli.js.map
|
package/out/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../lib/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAE7D,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC;IAC9C,OAAO,EAAE;QACR,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACtB;IACD,gBAAgB,EAAE,IAAI;CACtB,CAAC,CAAA;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I,EAAE,CAAC,CAAC,CAAA;AACrG,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* mirroring the resolver's PIP pattern. The UTC offset comes from `Intl.DateTimeFormat` — no tz
|
|
9
9
|
* database dependency. Build the DB with `mailwoman-timezone build` (see `./build.ts`).
|
|
10
10
|
*/
|
|
11
|
-
import { DatabaseSync } from "node:sqlite";
|
|
12
11
|
import type { Annotator } from "@mailwoman/annotations";
|
|
12
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
13
|
+
import type { TimezoneDatabase } from "#schema";
|
|
13
14
|
/**
|
|
14
15
|
* Normalized geometry: an array of polygons, each `[outerRing, ...holes]`, each ring `[[lon,lat],…]`.
|
|
15
16
|
*/
|
|
@@ -26,18 +27,18 @@ export declare function offsetSecForTimezone(tzid: string, date?: Date): number
|
|
|
26
27
|
/**
|
|
27
28
|
* A timezone lookup over a built `node:sqlite` polygon DB.
|
|
28
29
|
*/
|
|
29
|
-
export declare class TimezoneLookup {
|
|
30
|
+
export declare class TimezoneLookup implements Disposable {
|
|
30
31
|
#private;
|
|
31
32
|
constructor(opts: {
|
|
32
33
|
databasePath: string;
|
|
33
34
|
} | {
|
|
34
|
-
database:
|
|
35
|
+
database: DatabaseClient<TimezoneDatabase>;
|
|
35
36
|
});
|
|
36
37
|
/**
|
|
37
38
|
* The IANA timezone id containing `(lat, lon)`, or `null` if none (shouldn't happen with oceans).
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
explore(lat: number, lon: number): string | null;
|
|
41
|
+
[Symbol.dispose](): void;
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Build an `Annotator` that fills `AnnotationSet.timezone` (name + current offset) from a lookup.
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,CAAA;AA6C/C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAEnG;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAiB,GAAG,MAAM,GAAG,SAAS,CAe9F;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,UAAU;;gBASpC,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAA;KAAE;IAa3F;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAchD,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGxB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAUvE"}
|
package/out/index.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* mirroring the resolver's PIP pattern. The UTC offset comes from `Intl.DateTimeFormat` — no tz
|
|
9
9
|
* database dependency. Build the DB with `mailwoman-timezone build` (see `./build.ts`).
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { parseJSONStrict } from "@mailwoman/core/json";
|
|
12
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
12
13
|
/**
|
|
13
14
|
* Ray-cast point-in-ring (even-odd rule). `ring` is `[[lon, lat], …]`.
|
|
14
15
|
*
|
|
@@ -17,6 +18,9 @@ import { DatabaseSync } from "node:sqlite";
|
|
|
17
18
|
* `@mailwoman/core` with it, whose published tarball carries ~11 MB of libpostal/WOF/chromium-i18n data. Eleven
|
|
18
19
|
* megabytes for fifteen lines is the wrong trade for a leaf lookup package. If this package ever gains a real spatial
|
|
19
20
|
* dependency, delete these and import them.
|
|
21
|
+
*
|
|
22
|
+
* Repo-health-ignore private-name-shadows-export -- kept local so a leaf lookup package stays off @mailwoman/core's ~11
|
|
23
|
+
* MB of shipped data; see the docstring
|
|
20
24
|
*/
|
|
21
25
|
function pointInRing(lon, lat, ring) {
|
|
22
26
|
let inside = false;
|
|
@@ -33,6 +37,9 @@ function pointInRing(lon, lat, ring) {
|
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Inside the outer ring and outside every hole.
|
|
40
|
+
*
|
|
41
|
+
* Repo-health-ignore private-name-shadows-export -- kept local so a leaf lookup package stays off @mailwoman/core's ~11
|
|
42
|
+
* MB of shipped data; see the docstring
|
|
36
43
|
*/
|
|
37
44
|
function pointInPolygon(lon, lat, polygon) {
|
|
38
45
|
if (!polygon[0] || !pointInRing(lon, lat, polygon[0]))
|
|
@@ -73,9 +80,17 @@ export function offsetSecForTimezone(tzid, date = new Date()) {
|
|
|
73
80
|
*/
|
|
74
81
|
export class TimezoneLookup {
|
|
75
82
|
#db;
|
|
83
|
+
/**
|
|
84
|
+
* Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
|
|
85
|
+
* ownership is membership rather than a flag a later branch has to check.
|
|
86
|
+
*/
|
|
87
|
+
#resources = new DisposableStack();
|
|
76
88
|
#stmt;
|
|
77
89
|
constructor(opts) {
|
|
78
|
-
this.#db =
|
|
90
|
+
this.#db =
|
|
91
|
+
"database" in opts
|
|
92
|
+
? opts.database
|
|
93
|
+
: this.#resources.use(new DatabaseClient(opts.databasePath, { readOnly: true }));
|
|
79
94
|
// Candidate features whose bbox contains the point; PIP picks the exact one.
|
|
80
95
|
this.#stmt = this.#db.prepare(`SELECT tzid, geom FROM timezone_polygons
|
|
81
96
|
WHERE minLat <= ? AND maxLat >= ? AND minLon <= ? AND maxLon >= ?`);
|
|
@@ -83,17 +98,18 @@ export class TimezoneLookup {
|
|
|
83
98
|
/**
|
|
84
99
|
* The IANA timezone id containing `(lat, lon)`, or `null` if none (shouldn't happen with oceans).
|
|
85
100
|
*/
|
|
86
|
-
|
|
101
|
+
explore(lat, lon) {
|
|
87
102
|
const rows = this.#stmt.all(lat, lat, lon, lon);
|
|
88
103
|
for (const row of rows) {
|
|
89
|
-
|
|
90
|
-
if (pointInMultiPolygon(lon, lat,
|
|
104
|
+
const multiPolygonCoords = parseJSONStrict(row.geom);
|
|
105
|
+
if (pointInMultiPolygon(lon, lat, multiPolygonCoords)) {
|
|
91
106
|
return row.tzid;
|
|
107
|
+
}
|
|
92
108
|
}
|
|
93
109
|
return null;
|
|
94
110
|
}
|
|
95
|
-
|
|
96
|
-
this.#
|
|
111
|
+
[Symbol.dispose]() {
|
|
112
|
+
this.#resources[Symbol.dispose]();
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
115
|
/**
|
|
@@ -102,7 +118,7 @@ export class TimezoneLookup {
|
|
|
102
118
|
export function makeTimezoneAnnotator(lookup) {
|
|
103
119
|
return ({ lat, lon, date }) => {
|
|
104
120
|
// oxlint-disable-next-line unicorn/no-array-method-this-argument -- `lookup.find(lat, lon)` is a two-argument gazetteer probe, not Array#find
|
|
105
|
-
const name = lookup.
|
|
121
|
+
const name = lookup.explore(lat, lon);
|
|
106
122
|
if (!name)
|
|
107
123
|
return {};
|
|
108
124
|
const offsetSec = offsetSecForTimezone(name, date);
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AASzD;;;;;;;;;;;GAWG;AACH,SAAS,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,IAAgB;IAC9D,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QAC/D,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAA;QACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAA;QACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAA;QACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAA;QAEvB,IAAI,EAAE,GAAG,GAAG,KAAK,EAAE,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9E,MAAM,GAAG,CAAC,MAAM,CAAA;QACjB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAW,EAAE,GAAW,EAAE,OAAqB;IACtE,IAAI,CAAC,OAA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GAAG,CAAC,IAAI,CAAA;YAChB,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;IAClC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IAC3D,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAA0B,EAAE;QACrD,8IAA8I;QAC9I,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAErC,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAA;QACpB,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAElD,OAAO,EAAE,QAAQ,EAAE,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAA;IACxE,CAAC,CAAA;AACF,CAAC"}
|
package/out/schema.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The `timezone.db` read contract. Declared beside the reader and the builder that writes it, so a column added to
|
|
7
|
+
* one is a compile error against the other.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* One timezone polygon: its IANA identifier, bounding box, and encoded geometry.
|
|
11
|
+
*/
|
|
12
|
+
export interface TimezonePolygonTable {
|
|
13
|
+
tzid: string;
|
|
14
|
+
minLat: number | null;
|
|
15
|
+
maxLat: number | null;
|
|
16
|
+
minLon: number | null;
|
|
17
|
+
maxLon: number | null;
|
|
18
|
+
geom: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The tables `timezone.db` carries.
|
|
22
|
+
*/
|
|
23
|
+
export interface TimezoneDatabase {
|
|
24
|
+
timezone_polygons: TimezonePolygonTable;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../lib/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,iBAAiB,EAAE,oBAAoB,CAAA;CACvC"}
|
package/out/schema.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The `timezone.db` read contract. Declared beside the reader and the builder that writes it, so a column added to
|
|
7
|
+
* one is a compile error against the other.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../lib/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/timezone-lookup",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Coordinate → IANA timezone, server-side. Point-in-polygon over timezone-boundary-builder polygons in a node:sqlite DB; UTC offset via Intl (no tz-db dependency). An @mailwoman/annotations Annotator.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -26,15 +26,30 @@
|
|
|
26
26
|
"!test/**"
|
|
27
27
|
],
|
|
28
28
|
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"imports": {
|
|
31
|
+
"#*": {
|
|
32
|
+
"types": "./out/*.d.ts",
|
|
33
|
+
"node": "./out/*.js",
|
|
34
|
+
"default": "./out/*.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
29
37
|
"exports": {
|
|
30
38
|
"./package.json": "./package.json",
|
|
31
39
|
".": {
|
|
32
40
|
"types": "./out/index.d.ts",
|
|
41
|
+
"node": "./out/index.js",
|
|
33
42
|
"default": "./out/index.js"
|
|
34
43
|
},
|
|
35
44
|
"./build": {
|
|
36
45
|
"types": "./out/build.d.ts",
|
|
46
|
+
"node": "./out/build.js",
|
|
37
47
|
"default": "./out/build.js"
|
|
48
|
+
},
|
|
49
|
+
"./schema": {
|
|
50
|
+
"types": "./out/schema.d.ts",
|
|
51
|
+
"node": "./out/schema.js",
|
|
52
|
+
"default": "./out/schema.js"
|
|
38
53
|
}
|
|
39
54
|
},
|
|
40
55
|
"publishConfig": {
|
|
@@ -43,15 +58,34 @@
|
|
|
43
58
|
"./package.json": "./package.json",
|
|
44
59
|
".": {
|
|
45
60
|
"types": "./out/index.d.ts",
|
|
61
|
+
"node": "./out/index.js",
|
|
46
62
|
"default": "./out/index.js"
|
|
47
63
|
},
|
|
48
64
|
"./build": {
|
|
49
65
|
"types": "./out/build.d.ts",
|
|
66
|
+
"node": "./out/build.js",
|
|
50
67
|
"default": "./out/build.js"
|
|
68
|
+
},
|
|
69
|
+
"./schema": {
|
|
70
|
+
"types": "./out/schema.d.ts",
|
|
71
|
+
"node": "./out/schema.js",
|
|
72
|
+
"default": "./out/schema.js"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"imports": {
|
|
76
|
+
"#*": {
|
|
77
|
+
"types": "./out/*.d.ts",
|
|
78
|
+
"node": "./out/*.js",
|
|
79
|
+
"default": "./out/*.js"
|
|
51
80
|
}
|
|
52
81
|
}
|
|
53
82
|
},
|
|
54
83
|
"dependencies": {
|
|
55
|
-
"@mailwoman/annotations": "9.
|
|
84
|
+
"@mailwoman/annotations": "9.3.0",
|
|
85
|
+
"@mailwoman/core": "9.3.0",
|
|
86
|
+
"@mailwoman/sqlite": "9.3.0"
|
|
87
|
+
},
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@mailwoman/spatial": "9.3.0"
|
|
56
90
|
}
|
|
57
91
|
}
|