@mailwoman/photon 5.10.0 → 6.0.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/README.md +22 -12
- package/out/app.d.ts +30 -0
- package/out/app.d.ts.map +1 -0
- package/out/app.js +56 -0
- package/out/app.js.map +1 -0
- package/out/cli.js +79 -13
- package/out/cli.js.map +1 -1
- package/out/engine.d.ts +80 -0
- package/out/engine.d.ts.map +1 -0
- package/out/engine.js +19 -0
- package/out/engine.js.map +1 -0
- package/out/index.d.ts +11 -150
- package/out/index.d.ts.map +1 -1
- package/out/index.js +11 -250
- package/out/index.js.map +1 -1
- package/out/projection.d.ts +97 -0
- package/out/projection.d.ts.map +1 -0
- package/out/projection.js +143 -0
- package/out/projection.js.map +1 -0
- package/out/routes.d.ts +14 -0
- package/out/routes.d.ts.map +1 -0
- package/out/routes.js +174 -0
- package/out/routes.js.map +1 -0
- package/out/schema.d.ts +229 -0
- package/out/schema.d.ts.map +1 -0
- package/out/schema.js +120 -0
- package/out/schema.js.map +1 -0
- package/package.json +13 -8
package/out/index.js
CHANGED
|
@@ -9,256 +9,17 @@
|
|
|
9
9
|
* prefixes. It maps onto Mailwoman's shipped FST autocomplete tier (#190/#587) + parse →
|
|
10
10
|
* resolve.
|
|
11
11
|
*
|
|
12
|
-
* Like its
|
|
12
|
+
* Like its siblings, the package is engine-agnostic: {@link createPhotonApp} takes a
|
|
13
13
|
* {@link PhotonEngine}; the CLI wires the real engine. Implementation is staged on the epic (#801
|
|
14
14
|
* / the Photon child); routes whose engine method is absent answer `501`.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return s ? [s] : undefined;
|
|
26
|
-
}
|
|
27
|
-
const EMPTY = { type: "FeatureCollection", features: [] };
|
|
28
|
-
/**
|
|
29
|
-
* Permissive CORS, matching upstream Photon: `Access-Control-Allow-Origin: *` on every response, plus a `204` answer to
|
|
30
|
-
* preflight `OPTIONS`. `ACAO: *` is anonymous (no credentials), so a wildcard `Allow-Headers` is valid.
|
|
31
|
-
*/
|
|
32
|
-
const applyCors = (req, res, next) => {
|
|
33
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
34
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
35
|
-
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
36
|
-
if (req.method === "OPTIONS") {
|
|
37
|
-
res.setHeader("Access-Control-Max-Age", "86400");
|
|
38
|
-
res.status(204).end();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
next();
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* A friendly HTML landing page for `GET /` (#1022). Upstream komoot/photon serves no root page, so there's no wire
|
|
45
|
-
* contract to match — this is pure courtesy: a browser visitor (or an evaluator kicking the tires) who pastes the bare
|
|
46
|
-
* host in gets a one-glance orientation with clickable example queries instead of Express's `Cannot GET /` 404, which
|
|
47
|
-
* reads as "the service is broken". Relative example URLs so they resolve against whatever host/port serves this.
|
|
48
|
-
*/
|
|
49
|
-
const ROOT_HTML = `<!doctype html>
|
|
50
|
-
<html lang="en">
|
|
51
|
-
<head>
|
|
52
|
-
<meta charset="utf-8">
|
|
53
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
54
|
-
<title>@mailwoman/photon</title>
|
|
55
|
-
<style>
|
|
56
|
-
:root { color-scheme: light dark }
|
|
57
|
-
body { font: 16px/1.6 system-ui, -apple-system, sans-serif; max-width: 42rem; margin: 3rem auto; padding: 0 1.25rem }
|
|
58
|
-
h1 { font-size: 1.3rem; margin: 0 0 .5rem }
|
|
59
|
-
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace }
|
|
60
|
-
ul { padding-left: 1.2rem }
|
|
61
|
-
li { margin: .4rem 0 }
|
|
62
|
-
a { color: #2563eb }
|
|
63
|
-
.q { font-family: ui-monospace, SFMono-Regular, Menlo, monospace }
|
|
64
|
-
footer { margin-top: 2rem; font-size: .9rem; opacity: .8 }
|
|
65
|
-
</style>
|
|
66
|
-
</head>
|
|
67
|
-
<body>
|
|
68
|
-
<h1>@mailwoman/photon</h1>
|
|
69
|
-
<p>A Photon-compatible autocomplete geocoding API — the same <code>/api</code> and <code>/reverse</code> contract, served from a SQLite gazetteer instead of an Elasticsearch cluster.</p>
|
|
70
|
-
<p>Try a query:</p>
|
|
71
|
-
<ul>
|
|
72
|
-
<li><a class="q" href="/api?q=berlin&limit=3">/api?q=berlin&limit=3</a></li>
|
|
73
|
-
<li><a class="q" href="/api?q=1600+pennsylvania+ave&limit=1">/api?q=1600+pennsylvania+ave&limit=1</a></li>
|
|
74
|
-
<li><a class="q" href="/reverse?lat=52.52&lon=13.405">/reverse?lat=52.52&lon=13.405</a></li>
|
|
75
|
-
</ul>
|
|
76
|
-
<footer><a href="https://mailwoman.sister.software/docs/concepts/switching-from-photon">Switching from Photon</a> · <a href="https://mailwoman.sister.software/demo">Live demo</a></footer>
|
|
77
|
-
</body>
|
|
78
|
-
</html>
|
|
79
|
-
`;
|
|
80
|
-
/**
|
|
81
|
-
* Build the Photon-compatible router around an injected {@link PhotonEngine}. Param parsing lives here; the feature
|
|
82
|
-
* _projection_ (resolved place → {@link PhotonProperties}) is the staged work.
|
|
83
|
-
*/
|
|
84
|
-
export function createPhotonRouter(engine, options = {}) {
|
|
85
|
-
const router = Router();
|
|
86
|
-
// Browser-embedded widgets need CORS or their cross-origin XHR is blocked before the request completes (#1017).
|
|
87
|
-
if (options.cors !== false) {
|
|
88
|
-
router.use(applyCors);
|
|
89
|
-
}
|
|
90
|
-
// A helpful root banner instead of a bare `Cannot GET /` 404 — the first thing a browser visitor hits (#1022).
|
|
91
|
-
const root = (_req, res) => {
|
|
92
|
-
res.type("html").send(ROOT_HTML);
|
|
93
|
-
};
|
|
94
|
-
const search = async (req, res) => {
|
|
95
|
-
if (!engine.search) {
|
|
96
|
-
res.status(501).json({ ...EMPTY, message: "search not implemented" });
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const q = req.query;
|
|
100
|
-
const query = asString(q["q"]);
|
|
101
|
-
if (!query) {
|
|
102
|
-
res.status(400).json({ ...EMPTY, message: "q is required" });
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const params = {
|
|
106
|
-
q: query,
|
|
107
|
-
limit: Number(q["limit"] ?? DEFAULT_LIMIT) || DEFAULT_LIMIT,
|
|
108
|
-
lang: asString(q["lang"]),
|
|
109
|
-
lat: q["lat"] != null ? Number(q["lat"]) : undefined,
|
|
110
|
-
lon: q["lon"] != null ? Number(q["lon"]) : undefined,
|
|
111
|
-
osmTag: asStringArray(q["osm_tag"]),
|
|
112
|
-
layer: asStringArray(q["layer"]),
|
|
113
|
-
};
|
|
114
|
-
res.json(await engine.search(params));
|
|
115
|
-
};
|
|
116
|
-
const reverse = async (req, res) => {
|
|
117
|
-
if (!engine.reverse) {
|
|
118
|
-
res.status(501).json({ ...EMPTY, message: "reverse not implemented" });
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const q = req.query;
|
|
122
|
-
const lat = Number(q["lat"]);
|
|
123
|
-
const lon = Number(q["lon"]);
|
|
124
|
-
if (!Number.isFinite(lat) || !Number.isFinite(lon)) {
|
|
125
|
-
res.status(400).json({ ...EMPTY, message: "lat and lon are required" });
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (lat < -90 || lat > 90 || lon < -180 || lon > 180) {
|
|
129
|
-
res.status(400).json({ ...EMPTY, message: "lat must be in [-90, 90] and lon in [-180, 180]" });
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const params = {
|
|
133
|
-
lat,
|
|
134
|
-
lon,
|
|
135
|
-
limit: Number(q["limit"] ?? DEFAULT_LIMIT) || DEFAULT_LIMIT,
|
|
136
|
-
lang: asString(q["lang"]),
|
|
137
|
-
radius: q["radius"] != null ? Number(q["radius"]) : undefined,
|
|
138
|
-
};
|
|
139
|
-
res.json(await engine.reverse(params));
|
|
140
|
-
};
|
|
141
|
-
// Safety net: malformed input or an engine fault returns an empty FeatureCollection, never a crash.
|
|
142
|
-
const safe = (fn) => async (req, res, next) => {
|
|
143
|
-
try {
|
|
144
|
-
await fn(req, res, next);
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
if (!res.headersSent) {
|
|
148
|
-
res.status(500).json({ ...EMPTY, message: "internal error" });
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
router.get("/", safe(root));
|
|
153
|
-
router.get("/api", safe(search));
|
|
154
|
-
router.get("/reverse", safe(reverse));
|
|
155
|
-
return router;
|
|
156
|
-
}
|
|
157
|
-
/** Build a Photon `Feature` from a coordinate + properties. */
|
|
158
|
-
export function photonFeature(lon, lat, properties) {
|
|
159
|
-
return { type: "Feature", geometry: { type: "Point", coordinates: [lon, lat] }, properties };
|
|
160
|
-
}
|
|
161
|
-
/** Wrap features in a Photon `FeatureCollection`. */
|
|
162
|
-
export function photonCollection(features) {
|
|
163
|
-
return { type: "FeatureCollection", features };
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* How a resolved tag projects onto Photon's schema: the property key that holds its name, plus the OSM `key`/`value`/
|
|
167
|
-
* `type` a Photon client reads. Kept close to komoot Photon's own values so client label-builders behave.
|
|
168
|
-
*/
|
|
169
|
-
const FORWARD_TAG_PROJECTION = {
|
|
170
|
-
venue: { key: "name", osmKey: "amenity", osmValue: "yes", type: "house" },
|
|
171
|
-
house: { key: "name", osmKey: "building", osmValue: "yes", type: "house" },
|
|
172
|
-
street: { key: "street", osmKey: "highway", osmValue: "residential", type: "street" },
|
|
173
|
-
neighbourhood: { key: "district", osmKey: "place", osmValue: "suburb", type: "district" },
|
|
174
|
-
dependent_locality: { key: "district", osmKey: "place", osmValue: "suburb", type: "district" },
|
|
175
|
-
borough: { key: "district", osmKey: "place", osmValue: "borough", type: "district" },
|
|
176
|
-
locality: { key: "city", osmKey: "place", osmValue: "city", type: "city" },
|
|
177
|
-
// WOF placetypes the /reverse hierarchy uses (so both endpoints derive osm tags from ONE table).
|
|
178
|
-
localadmin: { key: "city", osmKey: "place", osmValue: "city", type: "city" },
|
|
179
|
-
subregion: { key: "county", osmKey: "place", osmValue: "county", type: "county" },
|
|
180
|
-
county: { key: "county", osmKey: "place", osmValue: "county", type: "county" },
|
|
181
|
-
region: { key: "state", osmKey: "place", osmValue: "state", type: "state" },
|
|
182
|
-
macroregion: { key: "state", osmKey: "place", osmValue: "state", type: "state" },
|
|
183
|
-
country: { key: "country", osmKey: "place", osmValue: "country", type: "country" },
|
|
184
|
-
};
|
|
185
|
-
/** Fallback OSM tags — a Photon client reads `osm_key`/`osm_value`/`type` unconditionally, so they must never be absent. */
|
|
186
|
-
const DEFAULT_OSM_TAGS = { osm_key: "place", osm_value: "yes", type: "other" };
|
|
187
|
-
/**
|
|
188
|
-
* The Photon `osm_key`/`osm_value`/`type` for a resolved tag or WOF placetype (`locality`, `region`, `country`, …),
|
|
189
|
-
* falling back to a safe default so the fields are always present. Shared by the forward projection and `/reverse` so
|
|
190
|
-
* the two endpoints report a place the SAME way. #1014.
|
|
191
|
-
*/
|
|
192
|
-
export function photonOSMTags(tagOrPlacetype) {
|
|
193
|
-
const proj = FORWARD_TAG_PROJECTION[tagOrPlacetype];
|
|
194
|
-
return proj ? { osm_key: proj.osmKey, osm_value: proj.osmValue, type: proj.type } : { ...DEFAULT_OSM_TAGS };
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Project a resolved forward result into Photon properties — decorating from the RESOLVED gazetteer place (proper-cased
|
|
198
|
-
* names + ancestry + country), NOT the parsed input span, and ALWAYS emitting `osm_key`/`osm_value`/`type` so Photon
|
|
199
|
-
* client libraries (leaflet-control-geocoder, @openrunner/photon-geocoder) never dereference undefined. #1014.
|
|
200
|
-
*/
|
|
201
|
-
export function photonForwardProperties(input) {
|
|
202
|
-
// Safe defaults: a Photon client reads osm_key/osm_value/type unconditionally, so they must never be undefined.
|
|
203
|
-
const props = { ...DEFAULT_OSM_TAGS };
|
|
204
|
-
const [primary] = input.places;
|
|
205
|
-
if (primary) {
|
|
206
|
-
props.name = primary.name;
|
|
207
|
-
Object.assign(props, photonOSMTags(primary.tag));
|
|
208
|
-
}
|
|
209
|
-
for (const place of input.places) {
|
|
210
|
-
const proj = FORWARD_TAG_PROJECTION[place.tag];
|
|
211
|
-
if (proj && props[proj.key] == null) {
|
|
212
|
-
props[proj.key] = place.name;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
if (input.postcode) {
|
|
216
|
-
props.postcode = input.postcode;
|
|
217
|
-
}
|
|
218
|
-
if (input.country?.name && props.country == null) {
|
|
219
|
-
props.country = input.country.name;
|
|
220
|
-
}
|
|
221
|
-
if (input.country?.code) {
|
|
222
|
-
props.countrycode = input.country.code.toLowerCase();
|
|
223
|
-
}
|
|
224
|
-
// #1041: house-grade override. A rooftop / interpolated coordinate is a BUILDING, not the admin locality the
|
|
225
|
-
// ancestry above would label it — re-tag the schema so a Photon client renders (and zooms to) a house, and surface
|
|
226
|
-
// the parsed housenumber + street. Matches upstream komoot/photon's bare address point (osm_key:place, osm_value:
|
|
227
|
-
// house, type:house, with housenumber + street and NO name). Drop the admin-derived `name` — else the QGIS FLF label
|
|
228
|
-
// (name + housenumber + street + city + postcode) doubles the city ("Paris 8 Boulevard du Palais Paris 75001"). The
|
|
229
|
-
// city/state/postcode/country the ancestry filled stay put (upstream carries them on a house result too).
|
|
230
|
-
if (input.house) {
|
|
231
|
-
props.osm_key = "place";
|
|
232
|
-
props.osm_value = "house";
|
|
233
|
-
props.type = "house";
|
|
234
|
-
delete props.name;
|
|
235
|
-
const number = input.house.number?.trim();
|
|
236
|
-
const street = input.house.street?.trim();
|
|
237
|
-
if (number) {
|
|
238
|
-
props.housenumber = number;
|
|
239
|
-
}
|
|
240
|
-
if (street) {
|
|
241
|
-
props.street = street;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return props;
|
|
245
|
-
}
|
|
246
|
-
/** {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014. */
|
|
247
|
-
export function photonForwardFeature(input) {
|
|
248
|
-
return photonFeature(input.lon, input.lat, photonForwardProperties(input));
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Assemble a Photon `FeatureCollection` honoring `limit` (#1016): the primary feature first, then ranked alternatives,
|
|
252
|
-
* capped at `limit`. `limit` floors to 1 (Photon always returns at least the best match).
|
|
253
|
-
*/
|
|
254
|
-
export function photonForwardCollection(result, limit) {
|
|
255
|
-
const cap = Math.max(1, Math.floor(limit) || 1);
|
|
256
|
-
const features = [photonForwardFeature(result.primary)];
|
|
257
|
-
for (const alt of result.alternatives) {
|
|
258
|
-
if (features.length >= cap)
|
|
259
|
-
break;
|
|
260
|
-
features.push(photonForwardFeature(alt));
|
|
261
|
-
}
|
|
262
|
-
return photonCollection(features);
|
|
263
|
-
}
|
|
15
|
+
*
|
|
16
|
+
* The Hono app (CORS + error envelope + the emitted OpenAPI document) lives in `app.ts`; route
|
|
17
|
+
* definitions + handlers in `routes.ts`; wire types + the engine contract in `engine.ts`; the
|
|
18
|
+
* resolved-place → Photon-schema projection in `projection.ts`; the zod wire schemas in
|
|
19
|
+
* `schema.ts`.
|
|
20
|
+
*/
|
|
21
|
+
export * from "./app.js";
|
|
22
|
+
export * from "./engine.js";
|
|
23
|
+
export * from "./projection.js";
|
|
24
|
+
export * from "./schema.js";
|
|
264
25
|
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The RESOLVED-place → Photon-schema projection: decorating a resolved gazetteer place (proper-
|
|
7
|
+
* cased names + ancestry + country, house/street grade overrides) into {@link PhotonProperties},
|
|
8
|
+
* plus the `format=jsonld` schema.org re-serialization. Wire types + feature/collection
|
|
9
|
+
* construction live in `engine.ts`.
|
|
10
|
+
*/
|
|
11
|
+
import { type SchemaOrgPlace } from "@mailwoman/annotations";
|
|
12
|
+
import { type PhotonFeature, type PhotonFeatureCollection, type PhotonProperties } from "./engine.ts";
|
|
13
|
+
/**
|
|
14
|
+
* The resolved-place info a forward `/api` result carries: the admin ladder (MOST-SPECIFIC first) with GAZETTEER names,
|
|
15
|
+
* the coordinate, the resolved country, and the postcode. {@link photonForwardProperties} projects it onto Photon's
|
|
16
|
+
* schema. #1014 — decorate from the resolved place, not the parsed input span.
|
|
17
|
+
*/
|
|
18
|
+
export interface PhotonForwardInput {
|
|
19
|
+
lat: number;
|
|
20
|
+
lon: number;
|
|
21
|
+
postcode?: string | null;
|
|
22
|
+
/** The resolved country, mapped by the caller (ISO2 → canonical name via `@mailwoman/codex`). */
|
|
23
|
+
country?: {
|
|
24
|
+
name?: string;
|
|
25
|
+
code?: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/** Resolved admin ancestry, most-specific first, each carrying the gazetteer's canonical name (not the parsed span). */
|
|
28
|
+
places: ReadonlyArray<{
|
|
29
|
+
tag: string;
|
|
30
|
+
name: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* A HOUSE-GRADE result (#1041): set only when the resolver produced a specific building coordinate — the
|
|
34
|
+
* `address_point` (rooftop) or `interpolated` tier fired, NOT an admin centroid. {@link photonForwardProperties} then
|
|
35
|
+
* re-tags the schema `osm_key: place` / `osm_value: house` / `type: house` and surfaces the parsed `housenumber` +
|
|
36
|
+
* `street`, matching upstream komoot/photon's own bare-address-point shape (verified against `photon.komoot.io`: a
|
|
37
|
+
* residential rooftop returns `{osm_key:"place", osm_value:"house", type:"house", housenumber, street}` with NO
|
|
38
|
+
* `name`). Absent → the result keeps its admin-ancestry schema. Without it a rooftop reads as `type: city` and a
|
|
39
|
+
* client zooms to city scale (or paints a city marker) on a doorstep match — the #1041 regression.
|
|
40
|
+
*/
|
|
41
|
+
house?: {
|
|
42
|
+
number?: string | null;
|
|
43
|
+
street?: string | null;
|
|
44
|
+
} | null;
|
|
45
|
+
/**
|
|
46
|
+
* A STREET-GRADE result (#1050): set when the street-centroid tier (#1042/#1046) fired — a street-level coordinate,
|
|
47
|
+
* below rooftop/interp, above admin. {@link photonForwardProperties} re-tags it `osm_key: highway` / `osm_value:
|
|
48
|
+
* residential` / `type: street` with the FULL assembled street name in `name` — matching upstream komoot's street
|
|
49
|
+
* results (verified live 2026-07-10: a street primary returns `{osm_key:"highway", osm_value:<class>, type:"street",
|
|
50
|
+
* name:"Rue de la République", city, …}`; the street name rides `name`, not `street`). Without it a street centroid
|
|
51
|
+
* reads `type: city` with the city's name — the #1050 regression. `house` wins when both are set (a numbered query
|
|
52
|
+
* never street-tiers).
|
|
53
|
+
*/
|
|
54
|
+
street?: {
|
|
55
|
+
name?: string | null;
|
|
56
|
+
} | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The Photon `osm_key`/`osm_value`/`type` for a resolved tag or WOF placetype (`locality`, `region`, `country`, …),
|
|
60
|
+
* falling back to a safe default so the fields are always present. Shared by the forward projection and `/reverse` so
|
|
61
|
+
* the two endpoints report a place the SAME way. #1014.
|
|
62
|
+
*/
|
|
63
|
+
export declare function photonOSMTags(tagOrPlacetype: string): {
|
|
64
|
+
osm_key: string;
|
|
65
|
+
osm_value: string;
|
|
66
|
+
type: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Project a resolved forward result into Photon properties — decorating from the RESOLVED gazetteer place (proper-cased
|
|
70
|
+
* names + ancestry + country), NOT the parsed input span, and ALWAYS emitting `osm_key`/`osm_value`/`type` so Photon
|
|
71
|
+
* client libraries (leaflet-control-geocoder, @openrunner/photon-geocoder) never dereference undefined. #1014.
|
|
72
|
+
*/
|
|
73
|
+
export declare function photonForwardProperties(input: PhotonForwardInput): PhotonProperties;
|
|
74
|
+
/** {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014. */
|
|
75
|
+
export declare function photonForwardFeature(input: PhotonForwardInput): PhotonFeature;
|
|
76
|
+
/** The winning place plus its ranked alternatives — the input to {@link photonForwardCollection}. #1016. */
|
|
77
|
+
export interface PhotonForwardResult {
|
|
78
|
+
/** The winning place, with full admin ancestry (from the resolved hierarchy). */
|
|
79
|
+
primary: PhotonForwardInput;
|
|
80
|
+
/** Ranked alternative places (Springfield MA / IL / …), each a single-place input; excludes the primary. */
|
|
81
|
+
alternatives: PhotonForwardInput[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Assemble a Photon `FeatureCollection` honoring `limit` (#1016): the primary feature first, then ranked alternatives,
|
|
85
|
+
* capped at `limit`. `limit` floors to 1 (Photon always returns at least the best match).
|
|
86
|
+
*/
|
|
87
|
+
export declare function photonForwardCollection(result: PhotonForwardResult, limit: number): PhotonFeatureCollection;
|
|
88
|
+
/**
|
|
89
|
+
* Project a Photon `Feature` into a schema.org `Place` JSON-LD object (`format=jsonld`, #1052) — the OUTPUT-format
|
|
90
|
+
* projection. Reads the feature's already-decorated {@link PhotonProperties} (housenumber/street/city/state/postcode/
|
|
91
|
+
* countrycode + the coordinate), so it stays a pure re-serialization of the SAME resolved place the FeatureCollection
|
|
92
|
+
* carries. `streetAddress` is the plain house-number-first join (the light router has no locale formatter).
|
|
93
|
+
*/
|
|
94
|
+
export declare function photonFeatureToSchemaOrg(feature: PhotonFeature): SchemaOrgPlace;
|
|
95
|
+
/** Project a whole Photon `FeatureCollection` into an array of schema.org `Place` objects (`format=jsonld`). #1052. */
|
|
96
|
+
export declare function photonToSchemaOrg(collection: PhotonFeatureCollection): SchemaOrgPlace[];
|
|
97
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +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,iGAAiG;IACjG,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACjD,wHAAwH;IACxH,MAAM,EAAE,aAAa,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpD;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IACjE;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;CACxC;AA6BD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAI1G;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,gBAAgB,CA6DnF;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAE7E;AAED,4GAA4G;AAC5G,MAAM,WAAW,mBAAmB;IACnC,iFAAiF;IACjF,OAAO,EAAE,kBAAkB,CAAA;IAC3B,4GAA4G;IAC5G,YAAY,EAAE,kBAAkB,EAAE,CAAA;CAClC;AAED;;;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,uHAAuH;AACvH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,uBAAuB,GAAG,cAAc,EAAE,CAEvF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The RESOLVED-place → Photon-schema projection: decorating a resolved gazetteer place (proper-
|
|
7
|
+
* cased names + ancestry + country, house/street grade overrides) into {@link PhotonProperties},
|
|
8
|
+
* plus the `format=jsonld` schema.org re-serialization. Wire types + feature/collection
|
|
9
|
+
* construction live in `engine.ts`.
|
|
10
|
+
*/
|
|
11
|
+
import { composeStreetAddress, toSchemaOrg } from "@mailwoman/annotations";
|
|
12
|
+
import { photonCollection, photonFeature, } from "./engine.js";
|
|
13
|
+
/**
|
|
14
|
+
* How a resolved tag projects onto Photon's schema: the property key that holds its name, plus the OSM `key`/`value`/
|
|
15
|
+
* `type` a Photon client reads. Kept close to komoot Photon's own values so client label-builders behave.
|
|
16
|
+
*/
|
|
17
|
+
const FORWARD_TAG_PROJECTION = {
|
|
18
|
+
venue: { key: "name", osmKey: "amenity", osmValue: "yes", type: "house" },
|
|
19
|
+
house: { key: "name", osmKey: "building", osmValue: "yes", type: "house" },
|
|
20
|
+
street: { key: "street", osmKey: "highway", osmValue: "residential", type: "street" },
|
|
21
|
+
neighbourhood: { key: "district", osmKey: "place", osmValue: "suburb", type: "district" },
|
|
22
|
+
dependent_locality: { key: "district", osmKey: "place", osmValue: "suburb", type: "district" },
|
|
23
|
+
borough: { key: "district", osmKey: "place", osmValue: "borough", type: "district" },
|
|
24
|
+
locality: { key: "city", osmKey: "place", osmValue: "city", type: "city" },
|
|
25
|
+
// WOF placetypes the /reverse hierarchy uses (so both endpoints derive osm tags from ONE table).
|
|
26
|
+
localadmin: { key: "city", osmKey: "place", osmValue: "city", type: "city" },
|
|
27
|
+
subregion: { key: "county", osmKey: "place", osmValue: "county", type: "county" },
|
|
28
|
+
county: { key: "county", osmKey: "place", osmValue: "county", type: "county" },
|
|
29
|
+
region: { key: "state", osmKey: "place", osmValue: "state", type: "state" },
|
|
30
|
+
macroregion: { key: "state", osmKey: "place", osmValue: "state", type: "state" },
|
|
31
|
+
country: { key: "country", osmKey: "place", osmValue: "country", type: "country" },
|
|
32
|
+
};
|
|
33
|
+
/** Fallback OSM tags — a Photon client reads `osm_key`/`osm_value`/`type` unconditionally, so they must never be absent. */
|
|
34
|
+
const DEFAULT_OSM_TAGS = { osm_key: "place", osm_value: "yes", type: "other" };
|
|
35
|
+
/**
|
|
36
|
+
* The Photon `osm_key`/`osm_value`/`type` for a resolved tag or WOF placetype (`locality`, `region`, `country`, …),
|
|
37
|
+
* falling back to a safe default so the fields are always present. Shared by the forward projection and `/reverse` so
|
|
38
|
+
* the two endpoints report a place the SAME way. #1014.
|
|
39
|
+
*/
|
|
40
|
+
export function photonOSMTags(tagOrPlacetype) {
|
|
41
|
+
const proj = FORWARD_TAG_PROJECTION[tagOrPlacetype];
|
|
42
|
+
return proj ? { osm_key: proj.osmKey, osm_value: proj.osmValue, type: proj.type } : { ...DEFAULT_OSM_TAGS };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Project a resolved forward result into Photon properties — decorating from the RESOLVED gazetteer place (proper-cased
|
|
46
|
+
* names + ancestry + country), NOT the parsed input span, and ALWAYS emitting `osm_key`/`osm_value`/`type` so Photon
|
|
47
|
+
* client libraries (leaflet-control-geocoder, @openrunner/photon-geocoder) never dereference undefined. #1014.
|
|
48
|
+
*/
|
|
49
|
+
export function photonForwardProperties(input) {
|
|
50
|
+
// Safe defaults: a Photon client reads osm_key/osm_value/type unconditionally, so they must never be undefined.
|
|
51
|
+
const props = { ...DEFAULT_OSM_TAGS };
|
|
52
|
+
const [primary] = input.places;
|
|
53
|
+
if (primary) {
|
|
54
|
+
props.name = primary.name;
|
|
55
|
+
Object.assign(props, photonOSMTags(primary.tag));
|
|
56
|
+
}
|
|
57
|
+
for (const place of input.places) {
|
|
58
|
+
const proj = FORWARD_TAG_PROJECTION[place.tag];
|
|
59
|
+
if (proj && props[proj.key] == null) {
|
|
60
|
+
props[proj.key] = place.name;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (input.postcode) {
|
|
64
|
+
props.postcode = input.postcode;
|
|
65
|
+
}
|
|
66
|
+
if (input.country?.name && props.country == null) {
|
|
67
|
+
props.country = input.country.name;
|
|
68
|
+
}
|
|
69
|
+
if (input.country?.code) {
|
|
70
|
+
props.countrycode = input.country.code.toLowerCase();
|
|
71
|
+
}
|
|
72
|
+
// #1041: house-grade override. A rooftop / interpolated coordinate is a BUILDING, not the admin locality the
|
|
73
|
+
// ancestry above would label it — re-tag the schema so a Photon client renders (and zooms to) a house, and surface
|
|
74
|
+
// the parsed housenumber + street. Matches upstream komoot/photon's bare address point (osm_key:place, osm_value:
|
|
75
|
+
// house, type:house, with housenumber + street and NO name). Drop the admin-derived `name` — else the QGIS FLF label
|
|
76
|
+
// (name + housenumber + street + city + postcode) doubles the city ("Paris 8 Boulevard du Palais Paris 75001"). The
|
|
77
|
+
// city/state/postcode/country the ancestry filled stay put (upstream carries them on a house result too).
|
|
78
|
+
// #1050: street-grade — the street-centroid tier fired. Re-tag per upstream's street shape (full
|
|
79
|
+
// name in `name`, highway/street osm tags); the admin ancestry (city/state/…) stays as context.
|
|
80
|
+
if (input.street?.name && !input.house) {
|
|
81
|
+
props.name = input.street.name;
|
|
82
|
+
Object.assign(props, { osm_key: "highway", osm_value: "residential", type: "street" });
|
|
83
|
+
}
|
|
84
|
+
if (input.house) {
|
|
85
|
+
props.osm_key = "place";
|
|
86
|
+
props.osm_value = "house";
|
|
87
|
+
props.type = "house";
|
|
88
|
+
delete props.name;
|
|
89
|
+
const number = input.house.number?.trim();
|
|
90
|
+
const street = input.house.street?.trim();
|
|
91
|
+
if (number) {
|
|
92
|
+
props.housenumber = number;
|
|
93
|
+
}
|
|
94
|
+
if (street) {
|
|
95
|
+
props.street = street;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return props;
|
|
99
|
+
}
|
|
100
|
+
/** {@link photonForwardProperties}, wrapped as a Photon Point `Feature` at the resolved coordinate. #1014. */
|
|
101
|
+
export function photonForwardFeature(input) {
|
|
102
|
+
return photonFeature(input.lon, input.lat, photonForwardProperties(input));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Assemble a Photon `FeatureCollection` honoring `limit` (#1016): the primary feature first, then ranked alternatives,
|
|
106
|
+
* capped at `limit`. `limit` floors to 1 (Photon always returns at least the best match).
|
|
107
|
+
*/
|
|
108
|
+
export function photonForwardCollection(result, limit) {
|
|
109
|
+
const cap = Math.max(1, Math.floor(limit) || 1);
|
|
110
|
+
const features = [photonForwardFeature(result.primary)];
|
|
111
|
+
for (const alt of result.alternatives) {
|
|
112
|
+
if (features.length >= cap)
|
|
113
|
+
break;
|
|
114
|
+
features.push(photonForwardFeature(alt));
|
|
115
|
+
}
|
|
116
|
+
return photonCollection(features);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Project a Photon `Feature` into a schema.org `Place` JSON-LD object (`format=jsonld`, #1052) — the OUTPUT-format
|
|
120
|
+
* projection. Reads the feature's already-decorated {@link PhotonProperties} (housenumber/street/city/state/postcode/
|
|
121
|
+
* countrycode + the coordinate), so it stays a pure re-serialization of the SAME resolved place the FeatureCollection
|
|
122
|
+
* carries. `streetAddress` is the plain house-number-first join (the light router has no locale formatter).
|
|
123
|
+
*/
|
|
124
|
+
export function photonFeatureToSchemaOrg(feature) {
|
|
125
|
+
const p = feature.properties;
|
|
126
|
+
const [lon, lat] = feature.geometry.coordinates;
|
|
127
|
+
const streetAddress = composeStreetAddress({ houseNumber: p.housenumber, street: p.street });
|
|
128
|
+
return toSchemaOrg({
|
|
129
|
+
lat,
|
|
130
|
+
lon,
|
|
131
|
+
name: p.name,
|
|
132
|
+
streetAddress: streetAddress || undefined,
|
|
133
|
+
locality: p.city,
|
|
134
|
+
region: p.state,
|
|
135
|
+
postalCode: p.postcode,
|
|
136
|
+
countryCode: p.countrycode,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/** Project a whole Photon `FeatureCollection` into an array of schema.org `Place` objects (`format=jsonld`). #1052. */
|
|
140
|
+
export function photonToSchemaOrg(collection) {
|
|
141
|
+
return collection.features.map(photonFeatureToSchemaOrg);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +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;AAqCpB;;;GAGG;AACH,MAAM,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AAwB,CAAC,OAAsB;IAC9D,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAA;IAC5B,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAA;IAC/C,MAAM,aAAa,GAAG,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;IAE5F,OAAO,WAAW,CAAC;QAClB,GAAG;QACH,GAAG;QACH,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,aAAa,EAAE,aAAa,IAAI,SAAS;QACzC,QAAQ,EAAE,CAAC,CAAC,IAAI;QAChB,MAAM,EAAE,CAAC,CAAC,KAAK;QACf,UAAU,EAAE,CAAC,CAAC,QAAQ;QACtB,WAAW,EAAE,CAAC,CAAC,WAAW;KAC1B,CAAC,CAAA;AACH,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,iBAAiB,CAAC,UAAmC;IACpE,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AACzD,CAAC"}
|
package/out/routes.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Route definitions + handlers for the Photon-compatible surface. The OpenAPI document is
|
|
7
|
+
* emitted from these definitions — no handwritten spec. Handlers parse params from the
|
|
8
|
+
* `legacyQuery` express-shaped view; the zod query schemas drive only the emitted document.
|
|
9
|
+
*/
|
|
10
|
+
import { type OpenAPIHono } from "@hono/zod-openapi";
|
|
11
|
+
import { type PhotonEngine } from "./engine.ts";
|
|
12
|
+
/** Register the Photon-compatible routes against an injected engine. */
|
|
13
|
+
export declare function registerPhotonRoutes(app: OpenAPIHono, engine: PhotonEngine): void;
|
|
14
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +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,EACN,KAAK,YAAY,EAIjB,MAAM,aAAa,CAAA;AAwHpB,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA6DjF"}
|