@meridian-ts/photon 0.0.0-stage → 1.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/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # @meridian-ts/photon
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 21c5e38: Meridian 1.0: maps and locations for Ember.
8
+
9
+ - `@meridian-ts/ember`: a declarative MapLibre map, a port of `@vis.gl/react-maplibre`. Sources,
10
+ layers, markers, popups, all the controls, clusters, place autocomplete, a geocoder control
11
+ and directions.
12
+ - `@meridian-ts/core`: the provider interfaces for geocoding, places, routing, elevation, time
13
+ zone, static maps and IP location, and `defineMeridian`.
14
+ - Eleven provider adapters: Nominatim, Photon, Pelias, Valhalla, Stadia Maps, MapTiler, Mapbox,
15
+ Google, HERE, Esri and AWS.
16
+ - `@meridian-ts/draw`: draw and edit tools on terra-draw.
17
+ - `@meridian-ts/deck`: deck.gl layers and H3 hexagon clusters.
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [21c5e38]
22
+ - @meridian-ts/core@1.0.0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joe Gaudet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ Meridian
2
+ Copyright (c) 2026 Joe Gaudet. MIT licensed; see LICENSE.md.
3
+
4
+ Meridian is a port of the component API of @vis.gl/react-maplibre (vis.gl contributors, MIT) to
5
+ Ember. It copies the names and the behaviour of that API, and no code.
6
+
7
+ Meridian renders maps with MapLibre GL JS (BSD-3-Clause), which the application installs.
8
+ Each provider adapter calls the public HTTP API of its provider. Meridian depends on no provider
9
+ SDK. The terms of each provider apply to the data that its API returns.
package/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # Temporary Holding Version
1
+ # @meridian-ts/photon
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Meridian adapter for Photon. See the [guide](https://joegaudet.com/meridian/).
4
+
5
+ ```ts
6
+ import { defineMeridian } from '@meridian-ts/core'
7
+ import { photon } from '@meridian-ts/photon'
8
+
9
+ export const meridian = defineMeridian({ geocoding: photon() })
10
+
11
+ const places = await meridian.geocoding.forward('Stanley Park, Vancouver')
12
+ ```
13
+
14
+ The provider needs no key. To use your own server or a proxy, pass `baseUrl`.
@@ -0,0 +1,8 @@
1
+ import { type AdapterOptions, type Provider } from '@meridian-ts/core';
2
+ /** Photon needs no key. `baseUrl` is your own Photon server, or your proxy. */
3
+ export type PhotonOptions = AdapterOptions;
4
+ /**
5
+ * The Photon adapter: forward geocoding, reverse geocoding and autocomplete. Photon is made
6
+ * for search-as-you-type, so `autocomplete` and `forward` are the same request.
7
+ */
8
+ export declare function photon(options?: PhotonOptions): Provider;
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ import { createHttp, toLngLat } from '@meridian-ts/core';
2
+
3
+ // src/index.ts
4
+ function toPlace(feature) {
5
+ const p = feature.properties;
6
+ const [lng, lat] = feature.geometry.coordinates;
7
+ const street = [p.housenumber, p.street].filter(Boolean).join(" ");
8
+ const name = p.name ?? (street || p.city || p.country || "");
9
+ const label = [.../* @__PURE__ */ new Set([name, street, p.district, p.city, p.state, p.country])].filter(Boolean).join(", ");
10
+ const place = {
11
+ id: `${p.osm_type ?? ""}${p.osm_id ?? `${lng},${lat}`}`,
12
+ name,
13
+ label,
14
+ location: { lat, lng },
15
+ address: {
16
+ houseNumber: p.housenumber,
17
+ street: p.street,
18
+ district: p.district,
19
+ city: p.city,
20
+ county: p.county,
21
+ region: p.state,
22
+ postcode: p.postcode,
23
+ country: p.country,
24
+ countryCode: p.countrycode?.toUpperCase()
25
+ },
26
+ raw: feature
27
+ };
28
+ if (p.extent) {
29
+ const [west, north, east, south] = p.extent;
30
+ place.bbox = [west, south, east, north];
31
+ }
32
+ if (p.osm_key) place.categories = [`${p.osm_key}:${p.osm_value}`];
33
+ return place;
34
+ }
35
+ function photon(options = {}) {
36
+ const http = createHttp({
37
+ provider: "photon",
38
+ defaultBaseUrl: "https://photon.komoot.io",
39
+ options
40
+ });
41
+ const search = async (query, o = {}) => {
42
+ const [lon, lat] = o.proximity ? toLngLat(o.proximity) : [];
43
+ const body = await http.get(
44
+ "/api",
45
+ { q: query, limit: o.limit, lang: o.language, lon, lat, bbox: o.bbox?.join(",") },
46
+ o
47
+ );
48
+ const places = body.features.map(toPlace);
49
+ const countries = o.countries?.map((code) => code.toUpperCase());
50
+ return countries ? places.filter((place) => countries.includes(place.address?.countryCode ?? "")) : places;
51
+ };
52
+ return {
53
+ name: "photon",
54
+ geocoding: {
55
+ forward: search,
56
+ autocomplete: search,
57
+ reverse: async (lngLat, o = {}) => {
58
+ const [lon, lat] = toLngLat(lngLat);
59
+ const body = await http.get(
60
+ "/reverse",
61
+ { lon, lat, limit: o.limit, lang: o.language },
62
+ o
63
+ );
64
+ return body.features.map(toPlace);
65
+ }
66
+ }
67
+ };
68
+ }
69
+
70
+ export { photon };
71
+ //# sourceMappingURL=index.js.map
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAoCA,SAAS,QAAQ,OAAA,EAA+B;AAC9C,EAAA,MAAM,IAAI,OAAA,CAAQ,UAAA;AAClB,EAAA,MAAM,CAAC,GAAA,EAAK,GAAG,CAAA,GAAI,QAAQ,QAAA,CAAS,WAAA;AACpC,EAAA,MAAM,MAAA,GAAS,CAAC,CAAA,CAAE,WAAA,EAAa,CAAA,CAAE,MAAM,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACjE,EAAA,MAAM,OAAO,CAAA,CAAE,IAAA,KAAS,UAAU,CAAA,CAAE,IAAA,IAAQ,EAAE,OAAA,IAAW,EAAA,CAAA;AACzD,EAAA,MAAM,KAAA,GAAQ,CAAC,mBAAG,IAAI,IAAI,CAAC,IAAA,EAAM,MAAA,EAAQ,CAAA,CAAE,QAAA,EAAU,CAAA,CAAE,MAAM,CAAA,CAAE,KAAA,EAAO,CAAA,CAAE,OAAO,CAAC,CAAC,EAC9E,MAAA,CAAO,OAAO,CAAA,CACd,IAAA,CAAK,IAAI,CAAA;AACZ,EAAA,MAAM,KAAA,GAAe;AAAA,IACnB,EAAA,EAAI,CAAA,EAAG,CAAA,CAAE,QAAA,IAAY,EAAE,CAAA,EAAG,CAAA,CAAE,MAAA,IAAU,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAA,CAAA;AAAA,IACrD,IAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA,EAAU,EAAE,GAAA,EAAK,GAAA,EAAI;AAAA,IACrB,OAAA,EAAS;AAAA,MACP,aAAa,CAAA,CAAE,WAAA;AAAA,MACf,QAAQ,CAAA,C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A,CAAE,OAAO,IAAA,EAAM,CAAA,CAAE,QAAA,EAAU,GAAA,EAAK,KAAK,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,MAChF;AAAA,KACF;AACA,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAExC,IAAA,MAAM,YAAY,CAAA,CAAE,SAAA,EAAW,IAAI,CAAA,IAAA,KAAQ,IAAA,CAAK,aAAa,CAAA;AAC7D,IAAA,OAAO,SAAA,GACH,MAAA,CAAO,MAAA,CAAO,CAAA,KAAA,KAAS,SAAA,CAAU,QAAA,CAAS,KAAA,CAAM,OAAA,EAAS,WAAA,IAAe,EAAE,CAAC,CAAA,GAC3E,MAAA;AAAA,EACN,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,QAAA;AAAA,IACN,SAAA,EAAW;AAAA,MACT,OAAA,EAAS,MAAA;AAAA,MACT,YAAA,EAAc,MAAA;AAAA,MACd,OAAA,EAAS,OAAO,MAAA,EAAQ,CAAA,GAAI,EAAC,KAAM;AACjC,QAAA,MAAM,CAAC,GAAA,EAAK,GAAG,CAAA,GAAI,SAAS,MAAM,CAAA;AAClC,QAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,GAAA;AAAA,UACtB,UAAA;AAAA,UACA,EAAE,KAAK,GAAA,EAAK,KAAA,EAAO,EAAE,KAAA,EAAO,IAAA,EAAM,EAAE,QAAA,EAAS;AAAA,UAC7C;AAAA,SACF;AACA,QAAA,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAClC;AAAA;AACF,GACF;AACF","file":"index.js","sourcesContent":["// Photon API: https://photon.komoot.io/ and https://github.com/komoot/photon#search-api\nimport {\n createHttp,\n toLngLat,\n type AdapterOptions,\n type BBox,\n type GeocodeOptions,\n type Place,\n type Provider,\n} from '@meridian-ts/core'\n\n/** Photon needs no key. `baseUrl` is your own Photon server, or your proxy. */\nexport type PhotonOptions = AdapterOptions\n\ninterface PhotonFeature {\n geometry: { coordinates: [number, number] }\n properties: {\n osm_type?: string\n osm_id?: number\n osm_key?: string\n osm_value?: string\n name?: string\n housenumber?: string\n street?: string\n district?: string\n city?: string\n county?: string\n state?: string\n country?: string\n countrycode?: string\n postcode?: string\n /** `[minLon, maxLat, maxLon, minLat]` */\n extent?: [number, number, number, number]\n }\n}\n\nfunction toPlace(feature: PhotonFeature): Place {\n const p = feature.properties\n const [lng, lat] = feature.geometry.coordinates\n const street = [p.housenumber, p.street].filter(Boolean).join(' ')\n const name = p.name ?? (street || p.city || p.country || '')\n const label = [...new Set([name, street, p.district, p.city, p.state, p.country])]\n .filter(Boolean)\n .join(', ')\n const place: Place = {\n id: `${p.osm_type ?? ''}${p.osm_id ?? `${lng},${lat}`}`,\n name,\n label,\n location: { lat, lng },\n address: {\n houseNumber: p.housenumber,\n street: p.street,\n district: p.district,\n city: p.city,\n county: p.county,\n region: p.state,\n postcode: p.postcode,\n country: p.country,\n countryCode: p.countrycode?.toUpperCase(),\n },\n raw: feature,\n }\n if (p.extent) {\n const [west, north, east, south] = p.extent\n place.bbox = [west, south, east, north] as BBox\n }\n if (p.osm_key) place.categories = [`${p.osm_key}:${p.osm_value}`]\n return place\n}\n\n/**\n * The Photon adapter: forward geocoding, reverse geocoding and autocomplete. Photon is made\n * for search-as-you-type, so `autocomplete` and `forward` are the same request.\n */\nexport function photon(options: PhotonOptions = {}): Provider {\n const http = createHttp({\n provider: 'photon',\n defaultBaseUrl: 'https://photon.komoot.io',\n options,\n })\n\n const search = async (query: string, o: GeocodeOptions = {}): Promise<Place[]> => {\n const [lon, lat] = o.proximity ? toLngLat(o.proximity) : []\n const body = await http.get<{ features: PhotonFeature[] }>(\n '/api',\n { q: query, limit: o.limit, lang: o.language, lon, lat, bbox: o.bbox?.join(',') },\n o,\n )\n const places = body.features.map(toPlace)\n // Photon has no country filter, so filter the results.\n const countries = o.countries?.map(code => code.toUpperCase())\n return countries\n ? places.filter(place => countries.includes(place.address?.countryCode ?? ''))\n : places\n }\n\n return {\n name: 'photon',\n geocoding: {\n forward: search,\n autocomplete: search,\n reverse: async (lngLat, o = {}) => {\n const [lon, lat] = toLngLat(lngLat)\n const body = await http.get<{ features: PhotonFeature[] }>(\n '/reverse',\n { lon, lat, limit: o.limit, lang: o.language },\n o,\n )\n return body.features.map(toPlace)\n },\n },\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@meridian-ts/photon",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Meridian adapter for Photon (Komoot): geocoding and autocomplete on OpenStreetMap data.",
5
+ "keywords": [
6
+ "meridian",
7
+ "photon",
8
+ "geocoding autocomplete openstreetmap",
9
+ "gis"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Joe Gaudet joe@joegaudet.com",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/joegaudet/meridian.git",
16
+ "directory": "packages/photon"
17
+ },
18
+ "homepage": "https://joegaudet.com/meridian/",
19
+ "bugs": "https://github.com/joegaudet/meridian/issues",
20
+ "type": "module",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "CHANGELOG.md",
32
+ "README.md",
33
+ "LICENSE.md",
34
+ "NOTICE"
35
+ ],
36
+ "sideEffects": false,
37
+ "dependencies": {
38
+ "@meridian-ts/core": "^1.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@meridian-ts/conformance": "0.0.0"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.12.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup"
51
+ }
6
52
  }