@mailwoman/photon 8.0.0 → 8.2.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/app.ts +7 -3
- package/cli.ts +18 -4
- package/engine.ts +21 -7
- package/out/app.d.ts +6 -2
- package/out/app.d.ts.map +1 -1
- package/out/app.js +4 -2
- package/out/app.js.map +1 -1
- package/out/cli.js +10 -4
- package/out/cli.js.map +1 -1
- package/out/engine.d.ts +21 -7
- package/out/engine.d.ts.map +1 -1
- package/out/engine.js +6 -2
- package/out/engine.js.map +1 -1
- package/out/projection.d.ts +21 -7
- package/out/projection.d.ts.map +1 -1
- package/out/projection.js +9 -3
- package/out/projection.js.map +1 -1
- package/out/routes.d.ts +4 -2
- package/out/routes.d.ts.map +1 -1
- package/out/routes.js +21 -4
- package/out/routes.js.map +1 -1
- package/out/schema.d.ts +21 -5
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +21 -5
- package/out/schema.js.map +1 -1
- package/package.json +10 -10
- package/projection.ts +24 -8
- package/routes.ts +30 -9
- package/schema.ts +21 -5
package/app.ts
CHANGED
|
@@ -15,7 +15,9 @@ import { cors } from "hono/cors"
|
|
|
15
15
|
import type { PhotonEngine } from "./engine.ts"
|
|
16
16
|
import { registerPhotonRoutes } from "./routes.ts"
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Options for {@link createPhotonApp}.
|
|
20
|
+
*/
|
|
19
21
|
export interface PhotonAppOptions {
|
|
20
22
|
/**
|
|
21
23
|
* Emit permissive CORS headers (`Access-Control-Allow-Origin: *`) on every response and answer preflight `OPTIONS`
|
|
@@ -54,14 +56,16 @@ export const PHOTON_DOC_INFO: OpenAPIDocInfo = {
|
|
|
54
56
|
],
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Build the Photon-compatible app around an injected {@link PhotonEngine}.
|
|
61
|
+
*/
|
|
58
62
|
export function createPhotonApp(engine: PhotonEngine, options: PhotonAppOptions = {}): OpenAPIHono {
|
|
59
63
|
const app = new OpenAPIHono()
|
|
60
64
|
|
|
61
65
|
// Browser-embedded widgets need CORS or their cross-origin XHR is blocked before the request completes (#1017).
|
|
62
66
|
// GET-only — photon has no mutating routes, so unlike libpostal's CORS there is no POST in the methods list.
|
|
63
67
|
if (options.cors !== false) {
|
|
64
|
-
app.use(cors({ origin: "*", allowMethods: ["GET", "OPTIONS"], allowHeaders: ["*"], maxAge:
|
|
68
|
+
app.use(cors({ origin: "*", allowMethods: ["GET", "OPTIONS"], allowHeaders: ["*"], maxAge: 86_400 }))
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
// Safety net: malformed input or an engine fault returns an empty FeatureCollection, never a crash (photon's
|
package/cli.ts
CHANGED
|
@@ -42,7 +42,9 @@ import {
|
|
|
42
42
|
type PhotonProperties,
|
|
43
43
|
} from "./index.ts"
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* WOF placetype → Photon property key.
|
|
47
|
+
*/
|
|
46
48
|
const PLACETYPE_TO_KEY: Record<string, keyof PhotonProperties> = {
|
|
47
49
|
street: "street",
|
|
48
50
|
locality: "city",
|
|
@@ -52,7 +54,9 @@ const PLACETYPE_TO_KEY: Record<string, keyof PhotonProperties> = {
|
|
|
52
54
|
country: "country",
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* A real address fits comfortably; longer is malformed input (and would exceed the model's window).
|
|
59
|
+
*/
|
|
56
60
|
const MAX_QUERY_LEN = 512
|
|
57
61
|
|
|
58
62
|
async function serve(): Promise<void> {
|
|
@@ -85,8 +89,10 @@ async function serve(): Promise<void> {
|
|
|
85
89
|
// wrong gazetteer without a word).
|
|
86
90
|
if (values["candidate-db"] && !existsSync(values["candidate-db"])) {
|
|
87
91
|
console.error(`✗ --candidate-db not found: ${values["candidate-db"]}`)
|
|
92
|
+
|
|
88
93
|
process.exit(1)
|
|
89
94
|
}
|
|
95
|
+
|
|
90
96
|
const candidateDb =
|
|
91
97
|
resolveCandidateDBPath(values["candidate-db"]) ??
|
|
92
98
|
(existsSync(conventionCandidate) ? conventionCandidate : undefined)
|
|
@@ -95,7 +101,7 @@ async function serve(): Promise<void> {
|
|
|
95
101
|
// is required" — a stranger's first `npx @mailwoman/photon serve` must say exactly what data is
|
|
96
102
|
// missing and the one command that fixes it. Kept in sync with the docs' hosted-artifact layout
|
|
97
103
|
// (mailwoman.sister.software/docs/switching/photon — the maintained pointer).
|
|
98
|
-
if (!candidateDb && wofPaths.length
|
|
104
|
+
if (!candidateDb && !wofPaths.length) {
|
|
99
105
|
console.error(
|
|
100
106
|
[
|
|
101
107
|
"✗ no gazetteer data found — the endpoint needs a resolver database to answer queries.",
|
|
@@ -112,6 +118,7 @@ async function serve(): Promise<void> {
|
|
|
112
118
|
" Docs: https://mailwoman.sister.software/docs/switching/photon",
|
|
113
119
|
].join("\n")
|
|
114
120
|
)
|
|
121
|
+
|
|
115
122
|
process.exit(1)
|
|
116
123
|
}
|
|
117
124
|
|
|
@@ -134,6 +141,7 @@ async function serve(): Promise<void> {
|
|
|
134
141
|
// #1016: forward the client's viewport/user location as a proximity bias — a SOFT re-rank the resolver
|
|
135
142
|
// folds into candidate scoring (Springfield near the map center wins). Only when both coords are present.
|
|
136
143
|
const bias = params.lat != null && params.lon != null ? [{ lat: params.lat, lon: params.lon }] : undefined
|
|
144
|
+
|
|
137
145
|
// No country constraint: the default-on #244 placer routes the query's country (Berlin→DE,
|
|
138
146
|
// Boston→US). Forcing "US" here is a HARD override (geocode-core.ts:102) that resolved every
|
|
139
147
|
// non-US query to its US namesake — wrong for a global autocomplete front.
|
|
@@ -143,6 +151,8 @@ async function serve(): Promise<void> {
|
|
|
143
151
|
shards: shards.for,
|
|
144
152
|
nationalShards: banShards.for,
|
|
145
153
|
bias,
|
|
154
|
+
// Decision A endpoint default: Photon is an autocomplete front — a human typing fragments.
|
|
155
|
+
inputMode: "fragmented",
|
|
146
156
|
})
|
|
147
157
|
|
|
148
158
|
if (result.lat == null || result.lon == null) return photonCollection([])
|
|
@@ -158,6 +168,7 @@ async function serve(): Promise<void> {
|
|
|
158
168
|
// #1050: the street-centroid tier is STREET-GRADE — full assembled street name in `name`,
|
|
159
169
|
// highway/street osm tags (the parallel of the #1041 house treatment).
|
|
160
170
|
const streetGrade = result.resolution_tier === "street"
|
|
171
|
+
|
|
161
172
|
const primary: PhotonForwardInput = {
|
|
162
173
|
lat: result.lat,
|
|
163
174
|
lon: result.lon,
|
|
@@ -167,6 +178,7 @@ async function serve(): Promise<void> {
|
|
|
167
178
|
...(houseGrade ? { house: { number: result.house_number, street: result.street } } : {}),
|
|
168
179
|
...(streetGrade ? { street: { name: result.street } } : {}),
|
|
169
180
|
}
|
|
181
|
+
|
|
170
182
|
// #1016: candidates[0] is the primary itself; its ranked alternatives (Springfield MA/IL/…) become the
|
|
171
183
|
// extra features, up to the requested `limit`. Each alternative is a single resolved place.
|
|
172
184
|
const alternatives = result.candidates.slice(1).map((c) => {
|
|
@@ -187,8 +199,9 @@ async function serve(): Promise<void> {
|
|
|
187
199
|
if (!reverseGeo) return photonCollection([])
|
|
188
200
|
const { hierarchy } = await reverseGeo.reverseGeocode(params.lat, params.lon)
|
|
189
201
|
|
|
190
|
-
if (hierarchy.length
|
|
202
|
+
if (!hierarchy.length) return photonCollection([])
|
|
191
203
|
const deepest = hierarchy[0]!
|
|
204
|
+
|
|
192
205
|
// #1014: carry osm_key/osm_value/type (from the deepest placetype) so /reverse matches /api's schema —
|
|
193
206
|
// no Photon client should dereference an undefined osm_key on a reverse result either.
|
|
194
207
|
const properties: PhotonProperties = {
|
|
@@ -248,6 +261,7 @@ function openapi(): void {
|
|
|
248
261
|
if (values.flavor !== "3.1" && values.flavor !== "3.0") {
|
|
249
262
|
console.error(`✗ --flavor must be "3.1" or "3.0" (got "${values.flavor}")`)
|
|
250
263
|
console.error("Usage: mailwoman-photon openapi [--flavor 3.1|3.0] [--out <path>]")
|
|
264
|
+
|
|
251
265
|
process.exit(1)
|
|
252
266
|
}
|
|
253
267
|
|
package/engine.ts
CHANGED
|
@@ -33,7 +33,9 @@ export interface PhotonProperties {
|
|
|
33
33
|
[key: string]: unknown
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* A Photon result feature: a GeoJSON Point with {@link PhotonProperties}.
|
|
38
|
+
*/
|
|
37
39
|
export interface PhotonFeature {
|
|
38
40
|
type: "Feature"
|
|
39
41
|
geometry: {
|
|
@@ -43,18 +45,24 @@ export interface PhotonFeature {
|
|
|
43
45
|
properties: PhotonProperties
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The Photon response envelope — a GeoJSON FeatureCollection.
|
|
50
|
+
*/
|
|
47
51
|
export interface PhotonFeatureCollection {
|
|
48
52
|
type: "FeatureCollection"
|
|
49
53
|
features: PhotonFeature[]
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Parsed `/api` (forward / autocomplete) parameters.
|
|
58
|
+
*/
|
|
53
59
|
export interface PhotonSearchParams {
|
|
54
60
|
q: string
|
|
55
61
|
limit: number
|
|
56
62
|
lang?: string
|
|
57
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Location bias.
|
|
65
|
+
*/
|
|
58
66
|
lat?: number
|
|
59
67
|
lon?: number
|
|
60
68
|
bbox?: [number, number, number, number]
|
|
@@ -62,7 +70,9 @@ export interface PhotonSearchParams {
|
|
|
62
70
|
layer?: string[]
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Parsed `/reverse` parameters.
|
|
75
|
+
*/
|
|
66
76
|
export interface PhotonReverseParams {
|
|
67
77
|
lat: number
|
|
68
78
|
lon: number
|
|
@@ -80,12 +90,16 @@ export interface PhotonEngine {
|
|
|
80
90
|
reverse?(params: PhotonReverseParams): Promise<PhotonFeatureCollection>
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Build a Photon `Feature` from a coordinate + properties.
|
|
95
|
+
*/
|
|
84
96
|
export function photonFeature(lon: number, lat: number, properties: PhotonProperties): PhotonFeature {
|
|
85
97
|
return { type: "Feature", geometry: { type: "Point", coordinates: [lon, lat] }, properties }
|
|
86
98
|
}
|
|
87
99
|
|
|
88
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Wrap features in a Photon `FeatureCollection`.
|
|
102
|
+
*/
|
|
89
103
|
export function photonCollection(features: PhotonFeature[]): PhotonFeatureCollection {
|
|
90
104
|
return { type: "FeatureCollection", features }
|
|
91
105
|
}
|
package/out/app.d.ts
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
10
10
|
import { type OpenAPIDocInfo } from "@mailwoman/api-kit";
|
|
11
11
|
import type { PhotonEngine } from "./engine.ts";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Options for {@link createPhotonApp}.
|
|
14
|
+
*/
|
|
13
15
|
export interface PhotonAppOptions {
|
|
14
16
|
/**
|
|
15
17
|
* Emit permissive CORS headers (`Access-Control-Allow-Origin: *`) on every response and answer preflight `OPTIONS`
|
|
@@ -25,6 +27,8 @@ export interface PhotonAppOptions {
|
|
|
25
27
|
* {@link attachOpenAPIDocs}) uses — one source of truth, no risk of the two drifting.
|
|
26
28
|
*/
|
|
27
29
|
export declare const PHOTON_DOC_INFO: OpenAPIDocInfo;
|
|
28
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Build the Photon-compatible app around an injected {@link PhotonEngine}.
|
|
32
|
+
*/
|
|
29
33
|
export declare function createPhotonApp(engine: PhotonEngine, options?: PhotonAppOptions): OpenAPIHono;
|
|
30
34
|
//# sourceMappingURL=app.d.ts.map
|
package/out/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAI3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAI3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,cAqB7B,CAAA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,WAAW,CAiBjG"}
|
package/out/app.js
CHANGED
|
@@ -38,13 +38,15 @@ export const PHOTON_DOC_INFO = {
|
|
|
38
38
|
{ name: "meta", description: "Health and deploy-time operations." },
|
|
39
39
|
],
|
|
40
40
|
};
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Build the Photon-compatible app around an injected {@link PhotonEngine}.
|
|
43
|
+
*/
|
|
42
44
|
export function createPhotonApp(engine, options = {}) {
|
|
43
45
|
const app = new OpenAPIHono();
|
|
44
46
|
// Browser-embedded widgets need CORS or their cross-origin XHR is blocked before the request completes (#1017).
|
|
45
47
|
// GET-only — photon has no mutating routes, so unlike libpostal's CORS there is no POST in the methods list.
|
|
46
48
|
if (options.cors !== false) {
|
|
47
|
-
app.use(cors({ origin: "*", allowMethods: ["GET", "OPTIONS"], allowHeaders: ["*"], maxAge:
|
|
49
|
+
app.use(cors({ origin: "*", allowMethods: ["GET", "OPTIONS"], allowHeaders: ["*"], maxAge: 86_400 }));
|
|
48
50
|
}
|
|
49
51
|
// Safety net: malformed input or an engine fault returns an empty FeatureCollection, never a crash (photon's
|
|
50
52
|
// envelope — NOT `{error}`, which is the libpostal/nominatim shape).
|
package/out/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAuB,MAAM,oBAAoB,CAAA;AAC3E,OAAO,WAAW,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAuB,MAAM,oBAAoB,CAAA;AAC3E,OAAO,WAAW,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAelD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC9C,KAAK,EAAE,WAAW,CAAC,IAAI;IACvB,OAAO,EAAE,WAAW,CAAC,OAAO;IAC5B,WAAW,EAAE,WAA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E,GAAG,CAAC,CAAC,CAAA;IAE/G,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACjC,iBAAiB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;IAEvC,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/out/cli.js
CHANGED
|
@@ -23,7 +23,9 @@ import { createWOFResolver } from "@mailwoman/resolver";
|
|
|
23
23
|
import { geocodeAddress, ShardProvider } from "mailwoman/geocode-core";
|
|
24
24
|
import { createResolverBackend, mailwomanDataRoot, resolveCandidateDBPath, wofShardPaths, } from "mailwoman/resolver-backend";
|
|
25
25
|
import { createPhotonApp, PHOTON_DOC_INFO, photonCollection, photonFeature, photonForwardCollection, photonOSMTags, } from "./index.js";
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* WOF placetype → Photon property key.
|
|
28
|
+
*/
|
|
27
29
|
const PLACETYPE_TO_KEY = {
|
|
28
30
|
street: "street",
|
|
29
31
|
locality: "city",
|
|
@@ -32,7 +34,9 @@ const PLACETYPE_TO_KEY = {
|
|
|
32
34
|
region: "state",
|
|
33
35
|
country: "country",
|
|
34
36
|
};
|
|
35
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* A real address fits comfortably; longer is malformed input (and would exceed the model's window).
|
|
39
|
+
*/
|
|
36
40
|
const MAX_QUERY_LEN = 512;
|
|
37
41
|
async function serve() {
|
|
38
42
|
const { values } = parseArgs({
|
|
@@ -68,7 +72,7 @@ async function serve() {
|
|
|
68
72
|
// is required" — a stranger's first `npx @mailwoman/photon serve` must say exactly what data is
|
|
69
73
|
// missing and the one command that fixes it. Kept in sync with the docs' hosted-artifact layout
|
|
70
74
|
// (mailwoman.sister.software/docs/switching/photon — the maintained pointer).
|
|
71
|
-
if (!candidateDb && wofPaths.length
|
|
75
|
+
if (!candidateDb && !wofPaths.length) {
|
|
72
76
|
console.error([
|
|
73
77
|
"✗ no gazetteer data found — the endpoint needs a resolver database to answer queries.",
|
|
74
78
|
"",
|
|
@@ -112,6 +116,8 @@ async function serve() {
|
|
|
112
116
|
shards: shards.for,
|
|
113
117
|
nationalShards: banShards.for,
|
|
114
118
|
bias,
|
|
119
|
+
// Decision A endpoint default: Photon is an autocomplete front — a human typing fragments.
|
|
120
|
+
inputMode: "fragmented",
|
|
115
121
|
});
|
|
116
122
|
if (result.lat == null || result.lon == null)
|
|
117
123
|
return photonCollection([]);
|
|
@@ -153,7 +159,7 @@ async function serve() {
|
|
|
153
159
|
if (!reverseGeo)
|
|
154
160
|
return photonCollection([]);
|
|
155
161
|
const { hierarchy } = await reverseGeo.reverseGeocode(params.lat, params.lon);
|
|
156
|
-
if (hierarchy.length
|
|
162
|
+
if (!hierarchy.length)
|
|
157
163
|
return photonCollection([]);
|
|
158
164
|
const deepest = hierarchy[0];
|
|
159
165
|
// #1014: carry osm_key/osm_value/type (from the deepest placetype) so /reverse matches /api's schema —
|
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,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GACb,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EACN,e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AC,EAAE,CAAC,CAAA;IAE/B,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,CAAC,CAAA;AACnD,CAAC;AAED,8FAA8F;AAC9F,MAAM,OAAO,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AAEnF,QAAQ,OAAO,EAAE,CAAC;IACjB,KAAK,OAAO;QACX,MAAM,KAAK,EAAE,CAAA;QACb,MAAK;IACN,KAAK,SAAS;QACb,OAAO,EAAE,CAAA;QACT,MAAK;IACN;QACC,OAAO,CAAC,KAAK,CACZ;YACC,mCAAmC;YACnC,4EAA4E;YAC5E,6CAA6C;SAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CACZ,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/B,CAAC"}
|
package/out/engine.d.ts
CHANGED
|
@@ -31,7 +31,9 @@ export interface PhotonProperties {
|
|
|
31
31
|
extent?: [number, number, number, number];
|
|
32
32
|
[key: string]: unknown;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* A Photon result feature: a GeoJSON Point with {@link PhotonProperties}.
|
|
36
|
+
*/
|
|
35
37
|
export interface PhotonFeature {
|
|
36
38
|
type: "Feature";
|
|
37
39
|
geometry: {
|
|
@@ -40,24 +42,32 @@ export interface PhotonFeature {
|
|
|
40
42
|
};
|
|
41
43
|
properties: PhotonProperties;
|
|
42
44
|
}
|
|
43
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The Photon response envelope — a GeoJSON FeatureCollection.
|
|
47
|
+
*/
|
|
44
48
|
export interface PhotonFeatureCollection {
|
|
45
49
|
type: "FeatureCollection";
|
|
46
50
|
features: PhotonFeature[];
|
|
47
51
|
}
|
|
48
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Parsed `/api` (forward / autocomplete) parameters.
|
|
54
|
+
*/
|
|
49
55
|
export interface PhotonSearchParams {
|
|
50
56
|
q: string;
|
|
51
57
|
limit: number;
|
|
52
58
|
lang?: string;
|
|
53
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Location bias.
|
|
61
|
+
*/
|
|
54
62
|
lat?: number;
|
|
55
63
|
lon?: number;
|
|
56
64
|
bbox?: [number, number, number, number];
|
|
57
65
|
osmTag?: string[];
|
|
58
66
|
layer?: string[];
|
|
59
67
|
}
|
|
60
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Parsed `/reverse` parameters.
|
|
70
|
+
*/
|
|
61
71
|
export interface PhotonReverseParams {
|
|
62
72
|
lat: number;
|
|
63
73
|
lon: number;
|
|
@@ -73,8 +83,12 @@ export interface PhotonEngine {
|
|
|
73
83
|
search?(params: PhotonSearchParams): Promise<PhotonFeatureCollection>;
|
|
74
84
|
reverse?(params: PhotonReverseParams): Promise<PhotonFeatureCollection>;
|
|
75
85
|
}
|
|
76
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Build a Photon `Feature` from a coordinate + properties.
|
|
88
|
+
*/
|
|
77
89
|
export declare function photonFeature(lon: number, lat: number, properties: PhotonProperties): PhotonFeature;
|
|
78
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Wrap features in a Photon `FeatureCollection`.
|
|
92
|
+
*/
|
|
79
93
|
export declare function photonCollection(features: PhotonFeature[]): PhotonFeatureCollection;
|
|
80
94
|
//# sourceMappingURL=engine.d.ts.map
|
package/out/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAA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CAAC,CAAA;IACrE,OAAO,CAAC,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;CACvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,aAAa,CAEnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,uBAAuB,CAEnF"}
|
package/out/engine.js
CHANGED
|
@@ -8,11 +8,15 @@
|
|
|
8
8
|
* builds on them; the RESOLVED-place → {@link PhotonProperties} projection itself lives in
|
|
9
9
|
* `projection.ts`.
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Build a Photon `Feature` from a coordinate + properties.
|
|
13
|
+
*/
|
|
12
14
|
export function photonFeature(lon, lat, properties) {
|
|
13
15
|
return { type: "Feature", geometry: { type: "Point", coordinates: [lon, lat] }, properties };
|
|
14
16
|
}
|
|
15
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Wrap features in a Photon `FeatureCollection`.
|
|
19
|
+
*/
|
|
16
20
|
export function photonCollection(features) {
|
|
17
21
|
return { type: "FeatureCollection", features };
|
|
18
22
|
}
|
package/out/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmFH;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,GAAW,EAAE,UAA4B;IACnF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,CAAA;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAyB;IACzD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAA;AAC/C,CAAC"}
|
package/out/projection.d.ts
CHANGED
|
@@ -19,12 +19,16 @@ export interface PhotonForwardInput {
|
|
|
19
19
|
lat: number;
|
|
20
20
|
lon: number;
|
|
21
21
|
postcode?: string | null;
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The resolved country, mapped by the caller (ISO2 → canonical name via `@mailwoman/codex`).
|
|
24
|
+
*/
|
|
23
25
|
country?: {
|
|
24
26
|
name?: string;
|
|
25
27
|
code?: string;
|
|
26
28
|
} | null;
|
|
27
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Resolved admin ancestry, most-specific first, each carrying the gazetteer's canonical name (not the parsed span).
|
|
31
|
+
*/
|
|
28
32
|
places: ReadonlyArray<{
|
|
29
33
|
tag: string;
|
|
30
34
|
name: string;
|
|
@@ -71,13 +75,21 @@ export declare function photonOSMTags(tagOrPlacetype: string): {
|
|
|
71
75
|
* client libraries (leaflet-control-geocoder, @openrunner/photon-geocoder) never dereference undefined. #1014.
|
|
72
76
|
*/
|
|
73
77
|
export declare function photonForwardProperties(input: PhotonForwardInput): PhotonProperties;
|
|
74
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014.
|
|
80
|
+
*/
|
|
75
81
|
export declare function photonForwardFeature(input: PhotonForwardInput): PhotonFeature;
|
|
76
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* The winning place plus its ranked alternatives — the input to {@link photonForwardCollection}. #1016.
|
|
84
|
+
*/
|
|
77
85
|
export interface PhotonForwardResult {
|
|
78
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* The winning place, with full admin ancestry (from the resolved hierarchy).
|
|
88
|
+
*/
|
|
79
89
|
primary: PhotonForwardInput;
|
|
80
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Ranked alternative places (Springfield MA / IL / …), each a single-place input; excludes the primary.
|
|
92
|
+
*/
|
|
81
93
|
alternatives: PhotonForwardInput[];
|
|
82
94
|
}
|
|
83
95
|
/**
|
|
@@ -92,6 +104,8 @@ export declare function photonForwardCollection(result: PhotonForwardResult, lim
|
|
|
92
104
|
* carries. `streetAddress` is the plain house-number-first join (the light router has no locale formatter).
|
|
93
105
|
*/
|
|
94
106
|
export declare function photonFeatureToSchemaOrg(feature: PhotonFeature): SchemaOrgPlace;
|
|
95
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Project a whole Photon `FeatureCollection` into an array of schema.org `Place` objects (`format=jsonld`). #1052.
|
|
109
|
+
*/
|
|
96
110
|
export declare function photonToSchemaOrg(collection: PhotonFeatureCollection): SchemaOrgPlace[];
|
|
97
111
|
//# sourceMappingURL=projection.d.ts.map
|
package/out/projection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAwB,KAAK,cAAc,EAAe,MAAM,wBAAwB,CAAA;AAE/F,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAG5B,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAA;AAEpB;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAwB,KAAK,cAAc,EAAe,MAAM,wBAAwB,CAAA;AAE/F,OAAO,EACN,KAAK,aAAa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;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,uBAAuB,CAU3G;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAe/E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,uBAAuB,GAAG,cAAc,EAAE,CAEvF"}
|
package/out/projection.js
CHANGED
|
@@ -33,7 +33,9 @@ const FORWARD_TAG_PROJECTION = {
|
|
|
33
33
|
macroregion: { key: "state", osmKey: "place", osmValue: "state", type: "state" },
|
|
34
34
|
country: { key: "country", osmKey: "place", osmValue: "country", type: "country" },
|
|
35
35
|
};
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Fallback OSM tags — a Photon client reads `osm_key`/`osm_value`/`type` unconditionally, so they must never be absent.
|
|
38
|
+
*/
|
|
37
39
|
const DEFAULT_OSM_TAGS = { osm_key: "place", osm_value: "yes", type: "other" };
|
|
38
40
|
/**
|
|
39
41
|
* The Photon `osm_key`/`osm_value`/`type` for a resolved tag or WOF placetype (`locality`, `region`, `country`, …),
|
|
@@ -100,7 +102,9 @@ export function photonForwardProperties(input) {
|
|
|
100
102
|
}
|
|
101
103
|
return props;
|
|
102
104
|
}
|
|
103
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014.
|
|
107
|
+
*/
|
|
104
108
|
export function photonForwardFeature(input) {
|
|
105
109
|
return photonFeature(input.lon, input.lat, photonForwardProperties(input));
|
|
106
110
|
}
|
|
@@ -139,7 +143,9 @@ export function photonFeatureToSchemaOrg(feature) {
|
|
|
139
143
|
countryCode: p.countrycode,
|
|
140
144
|
});
|
|
141
145
|
}
|
|
142
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Project a whole Photon `FeatureCollection` into an array of schema.org `Place` objects (`format=jsonld`). #1052.
|
|
148
|
+
*/
|
|
143
149
|
export function photonToSchemaOrg(collection) {
|
|
144
150
|
return collection.features.map(photonFeatureToSchemaOrg);
|
|
145
151
|
}
|
package/out/projection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAuB,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAE/F,OAAO,EAGN,gBAAgB,EAChB,aAAa,GAEb,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAuB,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAE/F,OAAO,EAGN,gBAAgB,EAChB,aAAa,GAEb,MAAM,aAAa,CAAA;AAyCpB;;;GAGG;AACH,MAAM,sBAAsB,GAGxB;IACH,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IACzE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC1E,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE;IACrF,aAAa,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;IACzF,+GAA+G;IAC/G,0GAA0G;IAC1G,SAAS,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,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AC,KAAK;QACf,UAAU,EAAE,CAAC,CAAC,QAAQ;QACtB,WAAW,EAAE,CAAC,CAAC,WAAW;KAC1B,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAmC;IACpE,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AACzD,CAAC"}
|
package/out/routes.d.ts
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
* `legacyQuery` express-shaped view; the zod query schemas drive only the emitted document.
|
|
9
9
|
*/
|
|
10
10
|
import { type OpenAPIHono } from "@hono/zod-openapi";
|
|
11
|
-
import {
|
|
12
|
-
/**
|
|
11
|
+
import type { PhotonEngine } from "./engine.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Register the Photon-compatible routes against an injected engine.
|
|
14
|
+
*/
|
|
13
15
|
export declare function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): void;
|
|
14
16
|
//# sourceMappingURL=routes.d.ts.map
|
package/out/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAe,KAAK,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAGpE,OAAO,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAe,KAAK,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAoE,MAAM,aAAa,CAAA;AA4IjH;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAiEjF"}
|
package/out/routes.js
CHANGED
|
@@ -8,13 +8,28 @@
|
|
|
8
8
|
* `legacyQuery` express-shaped view; the zod query schemas drive only the emitted document.
|
|
9
9
|
*/
|
|
10
10
|
import { createRoute, z } from "@hono/zod-openapi";
|
|
11
|
-
import {} from "./engine.js";
|
|
12
11
|
import { photonToSchemaOrg } from "./projection.js";
|
|
13
12
|
import { PhotonMessageCollectionSchema, PhotonResponseSchema, reverseQueryParams, searchQueryParams } from "./schema.js";
|
|
13
|
+
/**
|
|
14
|
+
* Southern limit of latitude in WGS-84 degrees.
|
|
15
|
+
*/
|
|
16
|
+
const MIN_LATITUDE = -90;
|
|
17
|
+
/**
|
|
18
|
+
* Northern limit of latitude in WGS-84 degrees.
|
|
19
|
+
*/
|
|
20
|
+
const MAX_LATITUDE = 90;
|
|
21
|
+
/**
|
|
22
|
+
* Western limit of longitude in WGS-84 degrees.
|
|
23
|
+
*/
|
|
24
|
+
const MIN_LONGITUDE = -180;
|
|
25
|
+
/**
|
|
26
|
+
* Eastern limit of longitude in WGS-84 degrees.
|
|
27
|
+
*/
|
|
28
|
+
const MAX_LONGITUDE = 180;
|
|
14
29
|
const DEFAULT_LIMIT = 15;
|
|
15
30
|
const EMPTY = { type: "FeatureCollection", features: [] };
|
|
16
31
|
function asString(raw) {
|
|
17
|
-
return typeof raw === "string" && raw.length
|
|
32
|
+
return typeof raw === "string" && raw.length ? raw : undefined;
|
|
18
33
|
}
|
|
19
34
|
function asStringArray(raw) {
|
|
20
35
|
if (Array.isArray(raw))
|
|
@@ -114,7 +129,9 @@ const reverseRoute = createRoute({
|
|
|
114
129
|
request: { query: reverseQueryParams },
|
|
115
130
|
responses: collectionResponses,
|
|
116
131
|
});
|
|
117
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Register the Photon-compatible routes against an injected engine.
|
|
134
|
+
*/
|
|
118
135
|
export function registerPhotonRoutes(app, engine) {
|
|
119
136
|
app.openapi(rootRoute, (c) => c.html(ROOT_HTML));
|
|
120
137
|
app.openapi(searchRoute, async (c) => {
|
|
@@ -152,7 +169,7 @@ export function registerPhotonRoutes(app, engine) {
|
|
|
152
169
|
if (!Number.isFinite(lat) || !Number.isFinite(lon)) {
|
|
153
170
|
return c.json({ ...EMPTY, message: "lat and lon are required" }, 400);
|
|
154
171
|
}
|
|
155
|
-
if (lat <
|
|
172
|
+
if (lat < MIN_LATITUDE || lat > MAX_LATITUDE || lon < MIN_LONGITUDE || lon > MAX_LONGITUDE) {
|
|
156
173
|
return c.json({ ...EMPTY, message: "lat must be in [-90, 90] and lon in [-180, 180]" }, 400);
|
|
157
174
|
}
|
|
158
175
|
const params = {
|
package/out/routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAoB,CAAC,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAoB,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAIpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAExH;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,EAAE,CAAA;AAExB;;GAEG;AACH,MAAM,YAAY,GAAG,EAAE,CAAA;AAEvB;;GAEG;AACH,MAAM,aAAa,GAAG,CAAC,GAAG,CAAA;AAE1B;;GAEG;AACH,MAAM,aAAa,GAAG,GAAG,CAAA;AAEzB,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,MAAM,KAAK,GAA4B,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AAElF,SAAS,QAAQ,CAAC,GAAY;IAC7B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,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AAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,IAAI,aAAa;YAC3D,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACzB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SAC7D,CAAA;QAED,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE/C,0GAA0G;QAC1G,+FAA+F;QAC/F,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAU,EAAE,GAAG,CAAC,CAAA;QAC3D,CAAC;QAED,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;AACH,CAAC"}
|
package/out/schema.d.ts
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* and every wire decision stays in the handlers (see routes.ts's legacyQuery adapter).
|
|
10
10
|
*/
|
|
11
11
|
import { z } from "@hono/zod-openapi";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Photon feature properties — OSM-derived keys; tolerant of extras (`[key: string]: unknown` on the wire type).
|
|
14
|
+
*/
|
|
13
15
|
export declare const PhotonPropertiesSchema: z.ZodObject<{
|
|
14
16
|
osm_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
15
17
|
osm_type: z.ZodOptional<z.ZodString>;
|
|
@@ -28,6 +30,9 @@ export declare const PhotonPropertiesSchema: z.ZodObject<{
|
|
|
28
30
|
countrycode: z.ZodOptional<z.ZodString>;
|
|
29
31
|
extent: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
30
32
|
}, z.core.$loose>;
|
|
33
|
+
/**
|
|
34
|
+
* One Photon result feature — GeoJSON geometry plus Photon's property block.
|
|
35
|
+
*/
|
|
31
36
|
export declare const PhotonFeatureSchema: z.ZodObject<{
|
|
32
37
|
type: z.ZodLiteral<"Feature">;
|
|
33
38
|
geometry: z.ZodObject<{
|
|
@@ -53,6 +58,9 @@ export declare const PhotonFeatureSchema: z.ZodObject<{
|
|
|
53
58
|
extent: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
54
59
|
}, z.core.$loose>;
|
|
55
60
|
}, z.core.$strip>;
|
|
61
|
+
/**
|
|
62
|
+
* Response body of `/api`, a GeoJSON FeatureCollection as Photon returns it.
|
|
63
|
+
*/
|
|
56
64
|
export declare const PhotonFeatureCollectionSchema: z.ZodObject<{
|
|
57
65
|
type: z.ZodLiteral<"FeatureCollection">;
|
|
58
66
|
features: z.ZodArray<z.ZodObject<{
|
|
@@ -81,7 +89,9 @@ export declare const PhotonFeatureCollectionSchema: z.ZodObject<{
|
|
|
81
89
|
}, z.core.$loose>;
|
|
82
90
|
}, z.core.$strip>>;
|
|
83
91
|
}, z.core.$strip>;
|
|
84
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* The error/degenerate envelope: an EMPTY FeatureCollection carrying a message. Never `{error}` on this surface.
|
|
94
|
+
*/
|
|
85
95
|
export declare const PhotonMessageCollectionSchema: z.ZodObject<{
|
|
86
96
|
type: z.ZodLiteral<"FeatureCollection">;
|
|
87
97
|
features: z.ZodArray<z.ZodObject<{
|
|
@@ -122,7 +132,9 @@ export declare const SchemaOrgGeoCoordinatesSchema: z.ZodObject<{
|
|
|
122
132
|
latitude: z.ZodNumber;
|
|
123
133
|
longitude: z.ZodNumber;
|
|
124
134
|
}, z.core.$strip>;
|
|
125
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* The schema.org [`PostalAddress`](https://schema.org/PostalAddress) node — mirrors `SchemaOrgPostalAddress`.
|
|
137
|
+
*/
|
|
126
138
|
export declare const SchemaOrgPostalAddressSchema: z.ZodObject<{
|
|
127
139
|
"@type": z.ZodLiteral<"PostalAddress">;
|
|
128
140
|
streetAddress: z.ZodOptional<z.ZodString>;
|
|
@@ -206,7 +218,9 @@ export declare const PhotonResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
206
218
|
addressCountry: z.ZodOptional<z.ZodString>;
|
|
207
219
|
}, z.core.$strip>>;
|
|
208
220
|
}, z.core.$strip>>]>;
|
|
209
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* `GET /api` query — documented shape; presence/parsing enforced in-handler.
|
|
223
|
+
*/
|
|
210
224
|
export declare const searchQueryParams: z.ZodObject<{
|
|
211
225
|
q: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
212
226
|
limit: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
@@ -217,7 +231,9 @@ export declare const searchQueryParams: z.ZodObject<{
|
|
|
217
231
|
layer: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
218
232
|
format: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
219
233
|
}, z.core.$strip>;
|
|
220
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* `GET /reverse` query.
|
|
236
|
+
*/
|
|
221
237
|
export declare const reverseQueryParams: z.ZodObject<{
|
|
222
238
|
lat: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
223
239
|
lon: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
package/out/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAGrC
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAGrC;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;iBAoBN,CAAA;AAE7B;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;iBAAiE,CAAA;AAEjG;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBACsC,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMN,CAAA;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;iBAMN,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;iBAUN,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAQN,CAAA;AAE3B;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEN,CAAA;AAQ3B;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;iBAa5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;iBAO7B,CAAA"}
|
package/out/schema.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { z } from "@hono/zod-openapi";
|
|
12
12
|
import { featureCollectionSchema, featureSchema } from "@mailwoman/api-kit";
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Photon feature properties — OSM-derived keys; tolerant of extras (`[key: string]: unknown` on the wire type).
|
|
15
|
+
*/
|
|
14
16
|
export const PhotonPropertiesSchema = z
|
|
15
17
|
.object({
|
|
16
18
|
osm_id: z.union([z.number(), z.string()]).optional(),
|
|
@@ -32,9 +34,17 @@ export const PhotonPropertiesSchema = z
|
|
|
32
34
|
})
|
|
33
35
|
.loose()
|
|
34
36
|
.openapi("PhotonProperties");
|
|
37
|
+
/**
|
|
38
|
+
* One Photon result feature — GeoJSON geometry plus Photon's property block.
|
|
39
|
+
*/
|
|
35
40
|
export const PhotonFeatureSchema = featureSchema(PhotonPropertiesSchema).openapi("PhotonFeature");
|
|
41
|
+
/**
|
|
42
|
+
* Response body of `/api`, a GeoJSON FeatureCollection as Photon returns it.
|
|
43
|
+
*/
|
|
36
44
|
export const PhotonFeatureCollectionSchema = featureCollectionSchema(PhotonFeatureSchema).openapi("PhotonFeatureCollection");
|
|
37
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The error/degenerate envelope: an EMPTY FeatureCollection carrying a message. Never `{error}` on this surface.
|
|
47
|
+
*/
|
|
38
48
|
export const PhotonMessageCollectionSchema = z
|
|
39
49
|
.object({
|
|
40
50
|
type: z.literal("FeatureCollection"),
|
|
@@ -55,7 +65,9 @@ export const SchemaOrgGeoCoordinatesSchema = z
|
|
|
55
65
|
longitude: z.number(),
|
|
56
66
|
})
|
|
57
67
|
.openapi("SchemaOrgGeoCoordinates");
|
|
58
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* The schema.org [`PostalAddress`](https://schema.org/PostalAddress) node — mirrors `SchemaOrgPostalAddress`.
|
|
70
|
+
*/
|
|
59
71
|
export const SchemaOrgPostalAddressSchema = z
|
|
60
72
|
.object({
|
|
61
73
|
"@type": z.literal("PostalAddress"),
|
|
@@ -93,7 +105,9 @@ export const PhotonResponseSchema = z
|
|
|
93
105
|
* us). Validator-proof: accepts one value or many; the doc override keeps the emitted parameter schema exact.
|
|
94
106
|
*/
|
|
95
107
|
const tolerantParam = z.union([z.string(), z.array(z.string())]).optional();
|
|
96
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* `GET /api` query — documented shape; presence/parsing enforced in-handler.
|
|
110
|
+
*/
|
|
97
111
|
export const searchQueryParams = z.object({
|
|
98
112
|
q: tolerantParam.openapi({ type: "string", description: "The query string to search for." }),
|
|
99
113
|
limit: tolerantParam.openapi({ type: "integer", description: "Maximum results (default 15)." }),
|
|
@@ -108,7 +122,9 @@ export const searchQueryParams = z.object({
|
|
|
108
122
|
layer: tolerantParam.openapi({ type: "array", items: { type: "string" }, description: "Layer filter; repeatable." }),
|
|
109
123
|
format: tolerantParam.openapi({ type: "string", enum: ["geojson", "jsonld"], description: "Output format." }),
|
|
110
124
|
});
|
|
111
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* `GET /reverse` query.
|
|
127
|
+
*/
|
|
112
128
|
export const reverseQueryParams = z.object({
|
|
113
129
|
lat: tolerantParam.openapi({ type: "number", description: "Latitude." }),
|
|
114
130
|
lon: tolerantParam.openapi({ type: "number", description: "Longitude." }),
|
package/out/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE3E
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE3E;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC;KACrC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAA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EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACtF,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;CAC7G,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/photon",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Photon drop-in — a Photon-compatible autocomplete/type-ahead geocoding API (GeoJSON FeatureCollection over /api + /reverse) on the Mailwoman engine. Run it with `npx @mailwoman/photon serve`.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@hono/zod-openapi": "^1.5.1",
|
|
47
|
-
"@mailwoman/annotations": "8.
|
|
48
|
-
"@mailwoman/api-kit": "8.
|
|
49
|
-
"@mailwoman/ban": "8.
|
|
50
|
-
"@mailwoman/codex": "8.
|
|
51
|
-
"@mailwoman/neural": "8.
|
|
52
|
-
"@mailwoman/neural-weights-en-us": "8.
|
|
53
|
-
"@mailwoman/resolver": "8.
|
|
54
|
-
"@mailwoman/resolver-wof-sqlite": "8.
|
|
47
|
+
"@mailwoman/annotations": "8.2.0",
|
|
48
|
+
"@mailwoman/api-kit": "8.2.0",
|
|
49
|
+
"@mailwoman/ban": "8.2.0",
|
|
50
|
+
"@mailwoman/codex": "8.2.0",
|
|
51
|
+
"@mailwoman/neural": "8.2.0",
|
|
52
|
+
"@mailwoman/neural-weights-en-us": "8.2.0",
|
|
53
|
+
"@mailwoman/resolver": "8.2.0",
|
|
54
|
+
"@mailwoman/resolver-wof-sqlite": "8.2.0",
|
|
55
55
|
"hono": "^4.12.32",
|
|
56
|
-
"mailwoman": "8.
|
|
56
|
+
"mailwoman": "8.2.0",
|
|
57
57
|
"zod": "^4.4.3"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/projection.ts
CHANGED
|
@@ -28,9 +28,13 @@ export interface PhotonForwardInput {
|
|
|
28
28
|
lat: number
|
|
29
29
|
lon: number
|
|
30
30
|
postcode?: string | null
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The resolved country, mapped by the caller (ISO2 → canonical name via `@mailwoman/codex`).
|
|
33
|
+
*/
|
|
32
34
|
country?: { name?: string; code?: string } | null
|
|
33
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Resolved admin ancestry, most-specific first, each carrying the gazetteer's canonical name (not the parsed span).
|
|
37
|
+
*/
|
|
34
38
|
places: ReadonlyArray<{ tag: string; name: string }>
|
|
35
39
|
/**
|
|
36
40
|
* A HOUSE-GRADE result (#1041): set only when the resolver produced a specific building coordinate — the
|
|
@@ -81,7 +85,9 @@ const FORWARD_TAG_PROJECTION: Record<
|
|
|
81
85
|
country: { key: "country", osmKey: "place", osmValue: "country", type: "country" },
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Fallback OSM tags — a Photon client reads `osm_key`/`osm_value`/`type` unconditionally, so they must never be absent.
|
|
90
|
+
*/
|
|
85
91
|
const DEFAULT_OSM_TAGS = { osm_key: "place", osm_value: "yes", type: "other" } as const
|
|
86
92
|
|
|
87
93
|
/**
|
|
@@ -163,16 +169,24 @@ export function photonForwardProperties(input: PhotonForwardInput): PhotonProper
|
|
|
163
169
|
return props
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014.
|
|
174
|
+
*/
|
|
167
175
|
export function photonForwardFeature(input: PhotonForwardInput): PhotonFeature {
|
|
168
176
|
return photonFeature(input.lon, input.lat, photonForwardProperties(input))
|
|
169
177
|
}
|
|
170
178
|
|
|
171
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* The winning place plus its ranked alternatives — the input to {@link photonForwardCollection}. #1016.
|
|
181
|
+
*/
|
|
172
182
|
export interface PhotonForwardResult {
|
|
173
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* The winning place, with full admin ancestry (from the resolved hierarchy).
|
|
185
|
+
*/
|
|
174
186
|
primary: PhotonForwardInput
|
|
175
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Ranked alternative places (Springfield MA / IL / …), each a single-place input; excludes the primary.
|
|
189
|
+
*/
|
|
176
190
|
alternatives: PhotonForwardInput[]
|
|
177
191
|
}
|
|
178
192
|
|
|
@@ -215,7 +229,9 @@ export function photonFeatureToSchemaOrg(feature: PhotonFeature): SchemaOrgPlace
|
|
|
215
229
|
})
|
|
216
230
|
}
|
|
217
231
|
|
|
218
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* Project a whole Photon `FeatureCollection` into an array of schema.org `Place` objects (`format=jsonld`). #1052.
|
|
234
|
+
*/
|
|
219
235
|
export function photonToSchemaOrg(collection: PhotonFeatureCollection): SchemaOrgPlace[] {
|
|
220
236
|
return collection.features.map(photonFeatureToSchemaOrg)
|
|
221
237
|
}
|
package/routes.ts
CHANGED
|
@@ -11,21 +11,36 @@
|
|
|
11
11
|
import { createRoute, type OpenAPIHono, z } from "@hono/zod-openapi"
|
|
12
12
|
import type { Context } from "hono"
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
type PhotonEngine,
|
|
16
|
-
type PhotonFeatureCollection,
|
|
17
|
-
type PhotonReverseParams,
|
|
18
|
-
type PhotonSearchParams,
|
|
19
|
-
} from "./engine.ts"
|
|
14
|
+
import type { PhotonEngine, PhotonFeatureCollection, PhotonReverseParams, PhotonSearchParams } from "./engine.ts"
|
|
20
15
|
import { photonToSchemaOrg } from "./projection.ts"
|
|
21
16
|
import { PhotonMessageCollectionSchema, PhotonResponseSchema, reverseQueryParams, searchQueryParams } from "./schema.ts"
|
|
22
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Southern limit of latitude in WGS-84 degrees.
|
|
20
|
+
*/
|
|
21
|
+
const MIN_LATITUDE = -90
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Northern limit of latitude in WGS-84 degrees.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_LATITUDE = 90
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Western limit of longitude in WGS-84 degrees.
|
|
30
|
+
*/
|
|
31
|
+
const MIN_LONGITUDE = -180
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Eastern limit of longitude in WGS-84 degrees.
|
|
35
|
+
*/
|
|
36
|
+
const MAX_LONGITUDE = 180
|
|
37
|
+
|
|
23
38
|
const DEFAULT_LIMIT = 15
|
|
24
39
|
|
|
25
40
|
const EMPTY: PhotonFeatureCollection = { type: "FeatureCollection", features: [] }
|
|
26
41
|
|
|
27
42
|
function asString(raw: unknown): string | undefined {
|
|
28
|
-
return typeof raw === "string" && raw.length
|
|
43
|
+
return typeof raw === "string" && raw.length ? raw : undefined
|
|
29
44
|
}
|
|
30
45
|
|
|
31
46
|
function asStringArray(raw: unknown): string[] | undefined {
|
|
@@ -136,7 +151,9 @@ const reverseRoute = createRoute({
|
|
|
136
151
|
responses: collectionResponses,
|
|
137
152
|
})
|
|
138
153
|
|
|
139
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Register the Photon-compatible routes against an injected engine.
|
|
156
|
+
*/
|
|
140
157
|
export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): void {
|
|
141
158
|
app.openapi(rootRoute, (c) => c.html(ROOT_HTML))
|
|
142
159
|
|
|
@@ -146,6 +163,7 @@ export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): vo
|
|
|
146
163
|
const query = asString(q["q"])
|
|
147
164
|
|
|
148
165
|
if (!query) return c.json({ ...EMPTY, message: "q is required" }, 400)
|
|
166
|
+
|
|
149
167
|
const params: PhotonSearchParams = {
|
|
150
168
|
q: query,
|
|
151
169
|
limit: Number(q["limit"] ?? DEFAULT_LIMIT) || DEFAULT_LIMIT,
|
|
@@ -155,6 +173,7 @@ export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): vo
|
|
|
155
173
|
osmTag: asStringArray(q["osm_tag"]),
|
|
156
174
|
layer: asStringArray(q["layer"]),
|
|
157
175
|
}
|
|
176
|
+
|
|
158
177
|
const collection = await engine.search(params)
|
|
159
178
|
|
|
160
179
|
// #1052: `format=jsonld` re-serializes the SAME FeatureCollection as schema.org `Place[]` JSON-LD. The
|
|
@@ -178,9 +197,10 @@ export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): vo
|
|
|
178
197
|
return c.json({ ...EMPTY, message: "lat and lon are required" }, 400)
|
|
179
198
|
}
|
|
180
199
|
|
|
181
|
-
if (lat <
|
|
200
|
+
if (lat < MIN_LATITUDE || lat > MAX_LATITUDE || lon < MIN_LONGITUDE || lon > MAX_LONGITUDE) {
|
|
182
201
|
return c.json({ ...EMPTY, message: "lat must be in [-90, 90] and lon in [-180, 180]" }, 400)
|
|
183
202
|
}
|
|
203
|
+
|
|
184
204
|
const params: PhotonReverseParams = {
|
|
185
205
|
lat,
|
|
186
206
|
lon,
|
|
@@ -188,6 +208,7 @@ export function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): vo
|
|
|
188
208
|
lang: asString(q["lang"]),
|
|
189
209
|
radius: q["radius"] != null ? Number(q["radius"]) : undefined,
|
|
190
210
|
}
|
|
211
|
+
|
|
191
212
|
const collection = await engine.reverse(params)
|
|
192
213
|
|
|
193
214
|
// #1052: `format=jsonld` re-serializes the reverse FeatureCollection as schema.org `Place[]` JSON-LD. See
|
package/schema.ts
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
import { z } from "@hono/zod-openapi"
|
|
13
13
|
import { featureCollectionSchema, featureSchema } from "@mailwoman/api-kit"
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Photon feature properties — OSM-derived keys; tolerant of extras (`[key: string]: unknown` on the wire type).
|
|
17
|
+
*/
|
|
16
18
|
export const PhotonPropertiesSchema = z
|
|
17
19
|
.object({
|
|
18
20
|
osm_id: z.union([z.number(), z.string()]).optional(),
|
|
@@ -35,12 +37,20 @@ export const PhotonPropertiesSchema = z
|
|
|
35
37
|
.loose()
|
|
36
38
|
.openapi("PhotonProperties")
|
|
37
39
|
|
|
40
|
+
/**
|
|
41
|
+
* One Photon result feature — GeoJSON geometry plus Photon's property block.
|
|
42
|
+
*/
|
|
38
43
|
export const PhotonFeatureSchema = featureSchema(PhotonPropertiesSchema).openapi("PhotonFeature")
|
|
39
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Response body of `/api`, a GeoJSON FeatureCollection as Photon returns it.
|
|
47
|
+
*/
|
|
40
48
|
export const PhotonFeatureCollectionSchema =
|
|
41
49
|
featureCollectionSchema(PhotonFeatureSchema).openapi("PhotonFeatureCollection")
|
|
42
50
|
|
|
43
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The error/degenerate envelope: an EMPTY FeatureCollection carrying a message. Never `{error}` on this surface.
|
|
53
|
+
*/
|
|
44
54
|
export const PhotonMessageCollectionSchema = z
|
|
45
55
|
.object({
|
|
46
56
|
type: z.literal("FeatureCollection"),
|
|
@@ -63,7 +73,9 @@ export const SchemaOrgGeoCoordinatesSchema = z
|
|
|
63
73
|
})
|
|
64
74
|
.openapi("SchemaOrgGeoCoordinates")
|
|
65
75
|
|
|
66
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* The schema.org [`PostalAddress`](https://schema.org/PostalAddress) node — mirrors `SchemaOrgPostalAddress`.
|
|
78
|
+
*/
|
|
67
79
|
export const SchemaOrgPostalAddressSchema = z
|
|
68
80
|
.object({
|
|
69
81
|
"@type": z.literal("PostalAddress"),
|
|
@@ -105,7 +117,9 @@ export const PhotonResponseSchema = z
|
|
|
105
117
|
*/
|
|
106
118
|
const tolerantParam = z.union([z.string(), z.array(z.string())]).optional()
|
|
107
119
|
|
|
108
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* `GET /api` query — documented shape; presence/parsing enforced in-handler.
|
|
122
|
+
*/
|
|
109
123
|
export const searchQueryParams = z.object({
|
|
110
124
|
q: tolerantParam.openapi({ type: "string", description: "The query string to search for." }),
|
|
111
125
|
limit: tolerantParam.openapi({ type: "integer", description: "Maximum results (default 15)." }),
|
|
@@ -121,7 +135,9 @@ export const searchQueryParams = z.object({
|
|
|
121
135
|
format: tolerantParam.openapi({ type: "string", enum: ["geojson", "jsonld"], description: "Output format." }),
|
|
122
136
|
})
|
|
123
137
|
|
|
124
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* `GET /reverse` query.
|
|
140
|
+
*/
|
|
125
141
|
export const reverseQueryParams = z.object({
|
|
126
142
|
lat: tolerantParam.openapi({ type: "number", description: "Latitude." }),
|
|
127
143
|
lon: tolerantParam.openapi({ type: "number", description: "Longitude." }),
|