@honua/app-platform 0.1.0-beta.0 → 0.1.2-beta.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/contract/discovery.d.ts +231 -0
- package/contract/discovery.d.ts.map +1 -0
- package/contract/discovery.js +554 -0
- package/contract/edit-sketch.d.ts +8 -0
- package/contract/edit-sketch.d.ts.map +1 -1
- package/contract/edit-sketch.js +15 -0
- package/contract/edit-snapping.d.ts +160 -0
- package/contract/edit-snapping.d.ts.map +1 -0
- package/contract/edit-snapping.js +675 -0
- package/contract/generated/projjson-v0.7-crs-validator.d.ts +35 -0
- package/contract/generated/projjson-v0.7-crs-validator.d.ts.map +1 -0
- package/contract/generated/projjson-v0.7-crs-validator.js +3941 -0
- package/contract/index.d.ts +11 -2
- package/contract/index.d.ts.map +1 -1
- package/contract/index.js +4 -1
- package/contract/pmtiles.d.ts +31 -0
- package/contract/pmtiles.d.ts.map +1 -1
- package/contract/pmtiles.js +60 -20
- package/contract/protocol-module.d.ts +70 -0
- package/contract/protocol-module.d.ts.map +1 -0
- package/contract/protocol-module.js +1 -0
- package/contract/schema-envelope.d.ts +26 -0
- package/contract/schema-envelope.d.ts.map +1 -0
- package/contract/schema-envelope.js +25 -0
- package/contract/schema.d.ts +582 -0
- package/contract/schema.d.ts.map +1 -0
- package/contract/schema.js +2483 -0
- package/contract/source-capability-support.d.ts +6 -0
- package/contract/source-capability-support.d.ts.map +1 -0
- package/contract/source-capability-support.js +154 -0
- package/contract/source.d.ts +35 -17
- package/contract/source.d.ts.map +1 -1
- package/contract/source.js +267 -71
- package/contract/types.d.ts +140 -4
- package/contract/types.d.ts.map +1 -1
- package/contract/types.js +6 -14
- package/core/bounded-json.d.ts +4 -0
- package/core/bounded-json.d.ts.map +1 -0
- package/core/bounded-json.js +38 -0
- package/core/cache-state.d.ts +9 -0
- package/core/cache-state.d.ts.map +1 -1
- package/core/cache-state.js +10 -0
- package/core/capabilities-xml.d.ts +33 -0
- package/core/capabilities-xml.d.ts.map +1 -0
- package/core/capabilities-xml.js +331 -0
- package/core/client.d.ts +4 -1
- package/core/client.d.ts.map +1 -1
- package/core/client.js +115 -29
- package/core/error-classifications.d.ts +153 -0
- package/core/error-classifications.d.ts.map +1 -0
- package/core/error-classifications.js +140 -0
- package/core/error-code-registry.d.ts +158 -0
- package/core/error-code-registry.d.ts.map +1 -0
- package/core/error-code-registry.js +143 -0
- package/core/error-envelope.d.ts +68 -0
- package/core/error-envelope.d.ts.map +1 -0
- package/core/error-envelope.js +357 -0
- package/core/errors.d.ts +45 -29
- package/core/errors.d.ts.map +1 -1
- package/core/errors.js +97 -50
- package/core/geoparquet-sql.d.ts +30 -2
- package/core/geoparquet-sql.d.ts.map +1 -1
- package/core/geoparquet-sql.js +38 -3
- package/core/odata-key-path.d.ts +12 -0
- package/core/odata-key-path.d.ts.map +1 -0
- package/core/odata-key-path.js +28 -0
- package/core/odata-write-codec.d.ts +66 -0
- package/core/odata-write-codec.d.ts.map +1 -0
- package/core/odata-write-codec.js +1083 -0
- package/core/odata.d.ts +59 -7
- package/core/odata.d.ts.map +1 -1
- package/core/odata.js +431 -99
- package/core/ogc-features.d.ts.map +1 -1
- package/core/ogc-features.js +3 -0
- package/core/ogc-maps.d.ts +7 -0
- package/core/ogc-maps.d.ts.map +1 -1
- package/core/ogc-maps.js +46 -7
- package/core/ogc-processes.d.ts +2 -1
- package/core/ogc-processes.d.ts.map +1 -1
- package/core/ogc-processes.js +33 -5
- package/core/ogc-records.d.ts +9 -0
- package/core/ogc-records.d.ts.map +1 -1
- package/core/ogc-records.js +78 -29
- package/core/ogc-tiles.d.ts +10 -1
- package/core/ogc-tiles.d.ts.map +1 -1
- package/core/ogc-tiles.js +56 -17
- package/core/path-utils.d.ts +9 -0
- package/core/path-utils.d.ts.map +1 -1
- package/core/path-utils.js +19 -0
- package/core/protocol-transport.d.ts +1 -0
- package/core/protocol-transport.d.ts.map +1 -1
- package/core/request-pipeline.d.ts.map +1 -1
- package/core/request-pipeline.js +1 -1
- package/core/spatial-filter.d.ts +8 -4
- package/core/spatial-filter.d.ts.map +1 -1
- package/core/spatial-filter.js +206 -16
- package/core/stac-static.d.ts +6 -2
- package/core/stac-static.d.ts.map +1 -1
- package/core/stac-static.js +260 -69
- package/core/surfaces.d.ts.map +1 -1
- package/core/surfaces.js +69 -5
- package/core/types.d.ts +125 -7
- package/core/types.d.ts.map +1 -1
- package/core/wfs-capabilities.d.ts +2 -0
- package/core/wfs-capabilities.d.ts.map +1 -1
- package/core/wfs-capabilities.js +8 -1
- package/core/wfs.d.ts.map +1 -1
- package/core/wfs.js +10 -0
- package/core/wms-capabilities.d.ts +56 -84
- package/core/wms-capabilities.d.ts.map +1 -1
- package/core/wms-capabilities.js +212 -509
- package/core/wmts-capabilities.d.ts +62 -62
- package/core/wmts-capabilities.d.ts.map +1 -1
- package/core/wmts-capabilities.js +224 -371
- package/esri-compat/editor.d.ts +8 -0
- package/esri-compat/editor.d.ts.map +1 -1
- package/esri-compat/editor.js +13 -0
- package/esri-compat/feature-layer.d.ts +2 -0
- package/esri-compat/feature-layer.d.ts.map +1 -1
- package/esri-compat/feature-layer.js +1 -0
- package/esri-compat/layer-list.d.ts +11 -0
- package/esri-compat/layer-list.d.ts.map +1 -1
- package/esri-compat/layer-list.js +49 -0
- package/esri-compat/legend.d.ts +10 -0
- package/esri-compat/legend.d.ts.map +1 -1
- package/esri-compat/legend.js +27 -0
- package/esri-compat/portal.d.ts +197 -0
- package/esri-compat/portal.d.ts.map +1 -0
- package/esri-compat/portal.js +251 -0
- package/esri-compat/renderer-objects.d.ts +40 -0
- package/esri-compat/renderer-objects.d.ts.map +1 -0
- package/esri-compat/renderer-objects.js +62 -0
- package/esri-compat/sketch.d.ts +43 -0
- package/esri-compat/sketch.d.ts.map +1 -1
- package/esri-compat/sketch.js +46 -0
- package/esri-compat/snapping.d.ts +43 -0
- package/esri-compat/snapping.d.ts.map +1 -0
- package/esri-compat/snapping.js +45 -0
- package/esri-compat/url.d.ts.map +1 -1
- package/esri-compat/url.js +1 -1
- package/esri-compat/widget-host.d.ts +84 -0
- package/esri-compat/widget-host.d.ts.map +1 -0
- package/esri-compat/widget-host.js +159 -0
- package/generated-app/errors.d.ts +18 -2
- package/generated-app/errors.d.ts.map +1 -1
- package/generated-app/errors.js +44 -11
- package/geocoding/index.d.ts +7 -0
- package/geocoding/index.d.ts.map +1 -1
- package/geocoding/index.js +5 -0
- package/geocoding/provider-http.d.ts +37 -0
- package/geocoding/provider-http.d.ts.map +1 -0
- package/geocoding/provider-http.js +91 -0
- package/geocoding/provider.d.ts +145 -0
- package/geocoding/provider.d.ts.map +1 -0
- package/geocoding/provider.js +41 -0
- package/geocoding/providers/honua.d.ts +28 -0
- package/geocoding/providers/honua.d.ts.map +1 -0
- package/geocoding/providers/honua.js +68 -0
- package/geocoding/providers/nominatim.d.ts +47 -0
- package/geocoding/providers/nominatim.d.ts.map +1 -0
- package/geocoding/providers/nominatim.js +105 -0
- package/geocoding/providers/pelias.d.ts +40 -0
- package/geocoding/providers/pelias.d.ts.map +1 -0
- package/geocoding/providers/pelias.js +115 -0
- package/geocoding/providers/photon.d.ts +39 -0
- package/geocoding/providers/photon.d.ts.map +1 -0
- package/geocoding/providers/photon.js +107 -0
- package/geometry/convert.d.ts +13 -0
- package/geometry/convert.d.ts.map +1 -0
- package/geometry/convert.js +12 -0
- package/geometry/index.d.ts +17 -0
- package/geometry/index.d.ts.map +1 -0
- package/geometry/index.js +15 -0
- package/geometry/internal.d.ts +25 -0
- package/geometry/internal.d.ts.map +1 -0
- package/geometry/internal.js +40 -0
- package/geometry/ops.d.ts +71 -0
- package/geometry/ops.d.ts.map +1 -0
- package/geometry/ops.js +147 -0
- package/geometry/project.d.ts +40 -0
- package/geometry/project.d.ts.map +1 -0
- package/geometry/project.js +88 -0
- package/geometry/types.d.ts +36 -0
- package/geometry/types.d.ts.map +1 -0
- package/geometry/types.js +12 -0
- package/map/automatic-mount-integration.d.ts +134 -0
- package/map/automatic-mount-integration.d.ts.map +1 -0
- package/map/automatic-mount-integration.js +305 -0
- package/map/automatic-source-strategy.d.ts +125 -0
- package/map/automatic-source-strategy.d.ts.map +1 -0
- package/map/automatic-source-strategy.js +494 -0
- package/map/data-to-map-bridge.d.ts +293 -0
- package/map/data-to-map-bridge.d.ts.map +1 -0
- package/map/data-to-map-bridge.js +817 -0
- package/map/geojson-projection.d.ts +33 -0
- package/map/geojson-projection.d.ts.map +1 -0
- package/map/geojson-projection.js +118 -0
- package/map/index.d.ts +14 -0
- package/map/index.d.ts.map +1 -1
- package/map/index.js +8 -0
- package/map/raster-source-spec.d.ts +30 -0
- package/map/raster-source-spec.d.ts.map +1 -0
- package/map/raster-source-spec.js +190 -0
- package/map/raster-source-strategy.d.ts +65 -0
- package/map/raster-source-strategy.d.ts.map +1 -0
- package/map/raster-source-strategy.js +232 -0
- package/map/source-to-maplibre.d.ts +91 -0
- package/map/source-to-maplibre.d.ts.map +1 -0
- package/map/source-to-maplibre.js +454 -0
- package/map/temporal-playback.d.ts +139 -0
- package/map/temporal-playback.d.ts.map +1 -0
- package/map/temporal-playback.js +247 -0
- package/package.json +28 -2
- package/query-planner/canonical.d.ts +7 -0
- package/query-planner/canonical.d.ts.map +1 -0
- package/query-planner/canonical.js +145 -0
- package/query-planner/cql2-json.d.ts +17 -0
- package/query-planner/cql2-json.d.ts.map +1 -0
- package/query-planner/cql2-json.js +646 -0
- package/query-planner/diagnostics.d.ts +35 -0
- package/query-planner/diagnostics.d.ts.map +1 -0
- package/query-planner/diagnostics.js +373 -0
- package/query-planner/duckdb.d.ts +79 -0
- package/query-planner/duckdb.d.ts.map +1 -0
- package/query-planner/duckdb.js +758 -0
- package/query-planner/execution-context.d.ts +5 -0
- package/query-planner/execution-context.d.ts.map +1 -0
- package/query-planner/execution-context.js +50 -0
- package/query-planner/executor.d.ts +5 -0
- package/query-planner/executor.d.ts.map +1 -0
- package/query-planner/executor.js +223 -0
- package/query-planner/geoservices.d.ts +91 -0
- package/query-planner/geoservices.d.ts.map +1 -0
- package/query-planner/geoservices.js +667 -0
- package/query-planner/grpc.d.ts +100 -0
- package/query-planner/grpc.d.ts.map +1 -0
- package/query-planner/grpc.js +736 -0
- package/query-planner/index.d.ts +44 -0
- package/query-planner/index.d.ts.map +1 -0
- package/query-planner/index.js +30 -0
- package/query-planner/ir.d.ts +20 -0
- package/query-planner/ir.d.ts.map +1 -0
- package/query-planner/ir.js +417 -0
- package/query-planner/local-aggregate.d.ts +5 -0
- package/query-planner/local-aggregate.d.ts.map +1 -0
- package/query-planner/local-aggregate.js +126 -0
- package/query-planner/odata.d.ts +48 -0
- package/query-planner/odata.d.ts.map +1 -0
- package/query-planner/odata.js +662 -0
- package/query-planner/ogc-compiler.d.ts +55 -0
- package/query-planner/ogc-compiler.d.ts.map +1 -0
- package/query-planner/ogc-compiler.js +480 -0
- package/query-planner/ogc-features.d.ts +53 -0
- package/query-planner/ogc-features.d.ts.map +1 -0
- package/query-planner/ogc-features.js +617 -0
- package/query-planner/planner.d.ts +17 -0
- package/query-planner/planner.d.ts.map +1 -0
- package/query-planner/planner.js +818 -0
- package/query-planner/resource.d.ts +94 -0
- package/query-planner/resource.d.ts.map +1 -0
- package/query-planner/resource.js +526 -0
- package/query-planner/semantic-canonical.d.ts +15 -0
- package/query-planner/semantic-canonical.d.ts.map +1 -0
- package/query-planner/semantic-canonical.js +62 -0
- package/query-planner/semantic-compat.d.ts +10 -0
- package/query-planner/semantic-compat.d.ts.map +1 -0
- package/query-planner/semantic-compat.js +35 -0
- package/query-planner/semantic-compiler.d.ts +64 -0
- package/query-planner/semantic-compiler.d.ts.map +1 -0
- package/query-planner/semantic-compiler.js +81 -0
- package/query-planner/semantic-literals.d.ts +30 -0
- package/query-planner/semantic-literals.d.ts.map +1 -0
- package/query-planner/semantic-literals.js +133 -0
- package/query-planner/semantic-types.d.ts +265 -0
- package/query-planner/semantic-types.d.ts.map +1 -0
- package/query-planner/semantic-types.js +1 -0
- package/query-planner/semantic.d.ts +54 -0
- package/query-planner/semantic.d.ts.map +1 -0
- package/query-planner/semantic.js +1421 -0
- package/query-planner/types.d.ts +560 -0
- package/query-planner/types.d.ts.map +1 -0
- package/query-planner/types.js +49 -0
- package/query-planner/wfs-semantic.d.ts +58 -0
- package/query-planner/wfs-semantic.d.ts.map +1 -0
- package/query-planner/wfs-semantic.js +547 -0
- package/query-planner/wfs.d.ts +6 -0
- package/query-planner/wfs.d.ts.map +1 -0
- package/query-planner/wfs.js +71 -0
- package/realtime/contract.d.ts +142 -0
- package/realtime/contract.d.ts.map +1 -0
- package/realtime/contract.js +154 -0
- package/realtime/honua-server.d.ts.map +1 -1
- package/realtime/honua-server.js +13 -8
- package/realtime/index.d.ts +19 -4
- package/realtime/index.d.ts.map +1 -1
- package/realtime/index.js +14 -4
- package/realtime/odata-delta.d.ts +114 -0
- package/realtime/odata-delta.d.ts.map +1 -0
- package/realtime/odata-delta.js +483 -0
- package/realtime/resumable-transport.d.ts +111 -0
- package/realtime/resumable-transport.d.ts.map +1 -0
- package/realtime/resumable-transport.js +406 -0
- package/realtime/resumable.d.ts +104 -0
- package/realtime/resumable.d.ts.map +1 -0
- package/realtime/resumable.js +632 -0
- package/realtime/sse.d.ts.map +1 -1
- package/realtime/sse.js +27 -23
- package/realtime/websocket.d.ts +60 -0
- package/realtime/websocket.d.ts.map +1 -0
- package/realtime/websocket.js +157 -0
- package/realtime/wire.d.ts +27 -0
- package/realtime/wire.d.ts.map +1 -0
- package/realtime/wire.js +57 -0
- package/replica-sync/errors.d.ts +2 -1
- package/replica-sync/errors.d.ts.map +1 -1
- package/replica-sync/errors.js +33 -2
- package/runtime/edit-snapping.d.ts +107 -0
- package/runtime/edit-snapping.d.ts.map +1 -0
- package/runtime/edit-snapping.js +190 -0
- package/runtime/errors.d.ts +3 -2
- package/runtime/errors.d.ts.map +1 -1
- package/runtime/errors.js +19 -2
- package/runtime/index.d.ts +6 -0
- package/runtime/index.d.ts.map +1 -1
- package/runtime/index.js +3 -0
- package/runtime/maplibre-renderer.d.ts +41 -0
- package/runtime/maplibre-renderer.d.ts.map +1 -0
- package/runtime/maplibre-renderer.js +322 -0
- package/runtime/query-tiles.d.ts +2 -1
- package/runtime/query-tiles.d.ts.map +1 -1
- package/runtime/query-tiles.js +6 -2
- package/runtime/source-bridge.d.ts +4 -4
- package/runtime/source-bridge.d.ts.map +1 -1
- package/runtime/source-bridge.js +9 -56
- package/runtime/style-interactions.d.ts +3 -2
- package/runtime/style-interactions.d.ts.map +1 -1
- package/runtime/style-interactions.js +11 -3
- package/runtime/terra-draw-sketch.d.ts +275 -0
- package/runtime/terra-draw-sketch.d.ts.map +1 -0
- package/runtime/terra-draw-sketch.js +404 -0
- package/scene-workspace/index.d.ts +4 -0
- package/scene-workspace/index.d.ts.map +1 -1
- package/scene-workspace/index.js +2 -0
- package/scene-workspace/source-to-cesium.d.ts +116 -0
- package/scene-workspace/source-to-cesium.d.ts.map +1 -0
- package/scene-workspace/source-to-cesium.js +791 -0
- package/scene-workspace/state-sync.d.ts +147 -0
- package/scene-workspace/state-sync.d.ts.map +1 -0
- package/scene-workspace/state-sync.js +1123 -0
- package/source-capability-registry.d.ts +1 -0
- package/source-capability-registry.js +1 -0
- package/source-capability-types.d.ts +186 -0
- package/source-capability-types.js +7 -0
- package/style/index.d.ts +2 -0
- package/style/index.d.ts.map +1 -1
- package/style/index.js +2 -0
- package/style/renderers.d.ts +326 -0
- package/style/renderers.d.ts.map +1 -0
- package/style/renderers.js +517 -0
- package/web-components/controller.d.ts +2 -0
- package/web-components/controller.d.ts.map +1 -1
- package/web-components/controller.js +49 -8
- package/web-components/elements.d.ts +95 -1
- package/web-components/elements.d.ts.map +1 -1
- package/web-components/elements.js +458 -19
- package/web-components/index.d.ts +8 -1
- package/web-components/index.d.ts.map +1 -1
- package/web-components/index.js +7 -0
- package/web-components/maplibre-renderer.d.ts.map +1 -1
- package/web-components/maplibre-renderer.js +87 -0
- package/web-components/measurement.d.ts +69 -0
- package/web-components/measurement.d.ts.map +1 -0
- package/web-components/measurement.js +523 -0
- package/web-components/types.d.ts +109 -0
- package/web-components/types.d.ts.map +1 -1
- package/webmap/convert-renderer.d.ts +24 -3
- package/webmap/convert-renderer.d.ts.map +1 -1
- package/webmap/convert-renderer.js +93 -112
- package/webmap/index.d.ts +1 -1
- package/webmap/index.d.ts.map +1 -1
- package/webmap/index.js +1 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-pluggable geocoding contract: `GeocodingProvider` plus the
|
|
3
|
+
* normalized result shapes every adapter maps into. The Honua facade
|
|
4
|
+
* (`honuaGeocodingProvider`) and the open-source adapters (Nominatim, Photon,
|
|
5
|
+
* Pelias) all implement this one interface so hosts can swap providers with
|
|
6
|
+
* configuration only.
|
|
7
|
+
*
|
|
8
|
+
* Capability differences between providers are declared up front via
|
|
9
|
+
* {@link GeocodingProvider.capabilities} and enforced with the SDK's existing
|
|
10
|
+
* capability policy: an unsupported operation throws
|
|
11
|
+
* `HonuaCapabilityNotSupportedError` under the default `"strict"` policy and
|
|
12
|
+
* degrades to an empty result under `"degraded"`.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
import type { CapabilityPolicy } from "../contract/types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Operations a {@link GeocodingProvider} may support.
|
|
19
|
+
*
|
|
20
|
+
* @experimental
|
|
21
|
+
*/
|
|
22
|
+
export type GeocodingCapability = "geocode" | "reverse" | "suggest";
|
|
23
|
+
/**
|
|
24
|
+
* Identifies which provider produced a result and carries that provider's
|
|
25
|
+
* attribution / usage-policy obligations so hosts can surface them (for
|
|
26
|
+
* example in a map attribution control).
|
|
27
|
+
*
|
|
28
|
+
* @experimental
|
|
29
|
+
*/
|
|
30
|
+
export interface GeocodingProvenance {
|
|
31
|
+
/** Provider identifier, e.g. `"nominatim"`, `"photon"`, `"pelias"`, `"honua"`. */
|
|
32
|
+
readonly provider: string;
|
|
33
|
+
/** Human-readable data attribution the host is obliged to display. */
|
|
34
|
+
readonly attribution: string;
|
|
35
|
+
/** Usage/acceptable-use policy for the configured endpoint, when known. */
|
|
36
|
+
readonly usagePolicyUrl?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Normalized forward-geocode candidate. Mirrors the contract shape of
|
|
40
|
+
* `GeocodeResult` with provider provenance stamped on every result.
|
|
41
|
+
*
|
|
42
|
+
* @experimental
|
|
43
|
+
*/
|
|
44
|
+
export interface ProviderGeocodeMatch {
|
|
45
|
+
/** Formatted address / place label. */
|
|
46
|
+
address: string;
|
|
47
|
+
latitude: number;
|
|
48
|
+
longitude: number;
|
|
49
|
+
/**
|
|
50
|
+
* Provider-reported match quality when available (Nominatim `importance`,
|
|
51
|
+
* Pelias `confidence`, Honua locator `score`). Scale is provider-specific.
|
|
52
|
+
*/
|
|
53
|
+
score?: number;
|
|
54
|
+
/** Provider-specific attributes, stringified to the contract shape. */
|
|
55
|
+
attributes: Record<string, string | null>;
|
|
56
|
+
provenance: GeocodingProvenance;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Normalized reverse-geocode result.
|
|
60
|
+
*
|
|
61
|
+
* @experimental
|
|
62
|
+
*/
|
|
63
|
+
export interface ProviderReverseMatch {
|
|
64
|
+
address: string;
|
|
65
|
+
latitude: number;
|
|
66
|
+
longitude: number;
|
|
67
|
+
attributes: Record<string, string | null>;
|
|
68
|
+
provenance: GeocodingProvenance;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Normalized typeahead suggestion.
|
|
72
|
+
*
|
|
73
|
+
* @experimental
|
|
74
|
+
*/
|
|
75
|
+
export interface ProviderSuggestion {
|
|
76
|
+
text: string;
|
|
77
|
+
provenance: GeocodingProvenance;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Options for {@link GeocodingProvider.geocode}.
|
|
81
|
+
*
|
|
82
|
+
* @experimental
|
|
83
|
+
*/
|
|
84
|
+
export interface ProviderGeocodeOptions {
|
|
85
|
+
/** Maximum number of candidates to return. */
|
|
86
|
+
limit?: number;
|
|
87
|
+
/** Comma-separated ISO 3166-1 alpha-2 country codes, e.g. `"us,ca"`. */
|
|
88
|
+
countryCodes?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Options for {@link GeocodingProvider.suggest}.
|
|
92
|
+
*
|
|
93
|
+
* @experimental
|
|
94
|
+
*/
|
|
95
|
+
export interface ProviderSuggestOptions {
|
|
96
|
+
/** Maximum number of suggestions to return. */
|
|
97
|
+
limit?: number;
|
|
98
|
+
/** Comma-separated ISO 3166-1 alpha-2 country codes, e.g. `"us,ca"`. */
|
|
99
|
+
countryCodes?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Provider-pluggable geocoding contract. All adapters normalize into the same
|
|
103
|
+
* typed result shapes; capability differences are declared, not discovered at
|
|
104
|
+
* runtime.
|
|
105
|
+
*
|
|
106
|
+
* Operations outside {@link capabilities} throw
|
|
107
|
+
* `HonuaCapabilityNotSupportedError` under the `"strict"` capability policy
|
|
108
|
+
* (the default) and resolve to an empty result under `"degraded"`.
|
|
109
|
+
*
|
|
110
|
+
* @experimental
|
|
111
|
+
*/
|
|
112
|
+
export interface GeocodingProvider {
|
|
113
|
+
/** Stable provider identifier, e.g. `"nominatim"`. */
|
|
114
|
+
readonly id: string;
|
|
115
|
+
/** Operations this provider supports. */
|
|
116
|
+
readonly capabilities: ReadonlyArray<GeocodingCapability>;
|
|
117
|
+
/** Human-readable data attribution the host is obliged to display. */
|
|
118
|
+
readonly attribution: string;
|
|
119
|
+
/** Usage/acceptable-use policy for the configured endpoint, when known. */
|
|
120
|
+
readonly usagePolicyUrl?: string;
|
|
121
|
+
/** Forward-geocode a free-text query into candidate locations. */
|
|
122
|
+
geocode(query: string, options?: ProviderGeocodeOptions): Promise<ProviderGeocodeMatch[]>;
|
|
123
|
+
/** Reverse-geocode a latitude/longitude pair; `null` when nothing is found. */
|
|
124
|
+
reverse(latitude: number, longitude: number): Promise<ProviderReverseMatch | null>;
|
|
125
|
+
/** Typeahead suggestions for a partial query. */
|
|
126
|
+
suggest(text: string, options?: ProviderSuggestOptions): Promise<ProviderSuggestion[]>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* `true` when `provider` declares `capability`.
|
|
130
|
+
*
|
|
131
|
+
* @experimental
|
|
132
|
+
*/
|
|
133
|
+
export declare function supportsGeocodingCapability(provider: GeocodingProvider, capability: GeocodingCapability): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Enforce a capability declaration against the active capability policy.
|
|
136
|
+
* Returns `true` when the capability is supported. When it is missing, throws
|
|
137
|
+
* `HonuaCapabilityNotSupportedError` under `"strict"` (the default) or returns
|
|
138
|
+
* `false` under `"degraded"` so callers can resolve to an empty result.
|
|
139
|
+
*
|
|
140
|
+
* @experimental
|
|
141
|
+
*/
|
|
142
|
+
export declare function assertGeocodingCapability(provider: Pick<GeocodingProvider, "id" | "capabilities">, capability: GeocodingCapability, policy?: CapabilityPolicy): boolean;
|
|
143
|
+
/** Re-exported so provider hosts can type their policy without importing `/contract`. */
|
|
144
|
+
export type { CapabilityPolicy };
|
|
145
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/geocoding/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC1D,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC,kEAAkE;IAClE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC1F,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IACnF,iDAAiD;IACjD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CACxF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAEjH;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,GAAG,cAAc,CAAC,EACxD,UAAU,EAAE,mBAAmB,EAC/B,MAAM,GAAE,gBAA2B,GAClC,OAAO,CAQT;AAED,yFAAyF;AACzF,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-pluggable geocoding contract: `GeocodingProvider` plus the
|
|
3
|
+
* normalized result shapes every adapter maps into. The Honua facade
|
|
4
|
+
* (`honuaGeocodingProvider`) and the open-source adapters (Nominatim, Photon,
|
|
5
|
+
* Pelias) all implement this one interface so hosts can swap providers with
|
|
6
|
+
* configuration only.
|
|
7
|
+
*
|
|
8
|
+
* Capability differences between providers are declared up front via
|
|
9
|
+
* {@link GeocodingProvider.capabilities} and enforced with the SDK's existing
|
|
10
|
+
* capability policy: an unsupported operation throws
|
|
11
|
+
* `HonuaCapabilityNotSupportedError` under the default `"strict"` policy and
|
|
12
|
+
* degrades to an empty result under `"degraded"`.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
import { HonuaCapabilityNotSupportedError } from "../core/errors.js";
|
|
17
|
+
/**
|
|
18
|
+
* `true` when `provider` declares `capability`.
|
|
19
|
+
*
|
|
20
|
+
* @experimental
|
|
21
|
+
*/
|
|
22
|
+
export function supportsGeocodingCapability(provider, capability) {
|
|
23
|
+
return provider.capabilities.includes(capability);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Enforce a capability declaration against the active capability policy.
|
|
27
|
+
* Returns `true` when the capability is supported. When it is missing, throws
|
|
28
|
+
* `HonuaCapabilityNotSupportedError` under `"strict"` (the default) or returns
|
|
29
|
+
* `false` under `"degraded"` so callers can resolve to an empty result.
|
|
30
|
+
*
|
|
31
|
+
* @experimental
|
|
32
|
+
*/
|
|
33
|
+
export function assertGeocodingCapability(provider, capability, policy = "strict") {
|
|
34
|
+
if (provider.capabilities.includes(capability)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (policy === "strict") {
|
|
38
|
+
throw new HonuaCapabilityNotSupportedError(capability, provider.id);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Honua facade adapter: wraps the existing {@link HonuaGeocodingClient}
|
|
3
|
+
* (Honua-hosted GeocodeServer locator) in the provider-pluggable
|
|
4
|
+
* {@link GeocodingProvider} contract, making the Honua facade one provider
|
|
5
|
+
* among several.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { CapabilityPolicy } from "../../contract/types.js";
|
|
10
|
+
import type { HonuaGeocodingClient } from "../index.js";
|
|
11
|
+
import { type GeocodingProvider } from "../provider.js";
|
|
12
|
+
/** Options for {@link honuaGeocodingProvider}. @experimental */
|
|
13
|
+
export interface HonuaGeocodingProviderOptions {
|
|
14
|
+
/** Capability policy; the Honua locator supports all declared operations. */
|
|
15
|
+
capabilityPolicy?: CapabilityPolicy;
|
|
16
|
+
/** Override the default attribution string for your deployment's data. */
|
|
17
|
+
attribution?: string;
|
|
18
|
+
/** Usage-policy URL for your deployment, when applicable. */
|
|
19
|
+
usagePolicyUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wrap a {@link HonuaGeocodingClient} in the {@link GeocodingProvider}
|
|
23
|
+
* contract.
|
|
24
|
+
*
|
|
25
|
+
* @experimental
|
|
26
|
+
*/
|
|
27
|
+
export declare function honuaGeocodingProvider(client: HonuaGeocodingClient, options?: HonuaGeocodingProviderOptions): GeocodingProvider;
|
|
28
|
+
//# sourceMappingURL=honua.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honua.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/honua.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,gBAAgB,CAAC;AAExB,gEAAgE;AAChE,MAAM,WAAW,6BAA6B;IAC5C,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,GAAE,6BAAkC,GAC1C,iBAAiB,CAsDnB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Honua facade adapter: wraps the existing {@link HonuaGeocodingClient}
|
|
3
|
+
* (Honua-hosted GeocodeServer locator) in the provider-pluggable
|
|
4
|
+
* {@link GeocodingProvider} contract, making the Honua facade one provider
|
|
5
|
+
* among several.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { assertGeocodingCapability, } from "../provider.js";
|
|
10
|
+
const HONUA_ATTRIBUTION = "Honua-hosted locator service";
|
|
11
|
+
const HONUA_CAPABILITIES = ["geocode", "reverse", "suggest"];
|
|
12
|
+
/**
|
|
13
|
+
* Wrap a {@link HonuaGeocodingClient} in the {@link GeocodingProvider}
|
|
14
|
+
* contract.
|
|
15
|
+
*
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
export function honuaGeocodingProvider(client, options = {}) {
|
|
19
|
+
const policy = options.capabilityPolicy ?? "strict";
|
|
20
|
+
const provenance = Object.freeze({
|
|
21
|
+
provider: "honua",
|
|
22
|
+
attribution: options.attribution ?? HONUA_ATTRIBUTION,
|
|
23
|
+
...(options.usagePolicyUrl !== undefined ? { usagePolicyUrl: options.usagePolicyUrl } : {}),
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
id: "honua",
|
|
27
|
+
capabilities: HONUA_CAPABILITIES,
|
|
28
|
+
attribution: provenance.attribution,
|
|
29
|
+
usagePolicyUrl: provenance.usagePolicyUrl,
|
|
30
|
+
async geocode(query, geocodeOptions) {
|
|
31
|
+
assertGeocodingCapability({ id: "honua", capabilities: HONUA_CAPABILITIES }, "geocode", policy);
|
|
32
|
+
const results = await client.forwardGeocode(query, {
|
|
33
|
+
maxResults: geocodeOptions?.limit,
|
|
34
|
+
countryCodes: geocodeOptions?.countryCodes,
|
|
35
|
+
});
|
|
36
|
+
return results.map((result) => ({
|
|
37
|
+
address: result.address,
|
|
38
|
+
latitude: result.latitude,
|
|
39
|
+
longitude: result.longitude,
|
|
40
|
+
score: result.score,
|
|
41
|
+
attributes: result.attributes,
|
|
42
|
+
provenance,
|
|
43
|
+
}));
|
|
44
|
+
},
|
|
45
|
+
async reverse(latitude, longitude) {
|
|
46
|
+
assertGeocodingCapability({ id: "honua", capabilities: HONUA_CAPABILITIES }, "reverse", policy);
|
|
47
|
+
const result = await client.reverseGeocode(latitude, longitude);
|
|
48
|
+
if (!result) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
address: result.address,
|
|
53
|
+
latitude: result.latitude,
|
|
54
|
+
longitude: result.longitude,
|
|
55
|
+
attributes: result.attributes,
|
|
56
|
+
provenance,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
async suggest(text, suggestOptions) {
|
|
60
|
+
assertGeocodingCapability({ id: "honua", capabilities: HONUA_CAPABILITIES }, "suggest", policy);
|
|
61
|
+
const suggestions = await client.suggest(text, {
|
|
62
|
+
maxSuggestions: suggestOptions?.limit,
|
|
63
|
+
countryCodes: suggestOptions?.countryCodes,
|
|
64
|
+
});
|
|
65
|
+
return suggestions.map((suggestion) => ({ text: suggestion.text, provenance }));
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nominatim adapter for the {@link GeocodingProvider} contract.
|
|
3
|
+
*
|
|
4
|
+
* Supports `geocode` and `reverse`; Nominatim has no typeahead endpoint, so
|
|
5
|
+
* `suggest` is declared unsupported and throws
|
|
6
|
+
* `HonuaCapabilityNotSupportedError` under the strict capability policy.
|
|
7
|
+
*
|
|
8
|
+
* There is no default endpoint: pass the `baseUrl` of an instance you are
|
|
9
|
+
* entitled to use. If you point at the public
|
|
10
|
+
* `https://nominatim.openstreetmap.org` service you MUST follow the OSMF
|
|
11
|
+
* Nominatim usage policy — at most 1 request/second, a real `userAgent`
|
|
12
|
+
* identifying your application, and no heavy typeahead-style traffic.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
import type { CapabilityPolicy } from "../../contract/types.js";
|
|
17
|
+
import { type ProviderTransportOptions } from "../provider-http.js";
|
|
18
|
+
import { type GeocodingProvider } from "../provider.js";
|
|
19
|
+
/** Options for {@link nominatimGeocodingProvider}. @experimental */
|
|
20
|
+
export interface NominatimProviderOptions extends ProviderTransportOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Base URL of the Nominatim instance, e.g. `https://nominatim.example.org`.
|
|
23
|
+
* Required — no third-party default is baked in (usage-policy safety).
|
|
24
|
+
*/
|
|
25
|
+
baseUrl: string;
|
|
26
|
+
/**
|
|
27
|
+
* Value for the `User-Agent` header. The OSMF usage policy requires a real
|
|
28
|
+
* application identifier when using the public instance. Only settable in
|
|
29
|
+
* non-browser runtimes; browsers control their own `User-Agent`.
|
|
30
|
+
*/
|
|
31
|
+
userAgent?: string;
|
|
32
|
+
/** Contact email forwarded as the `email` query parameter (public-instance etiquette). */
|
|
33
|
+
email?: string;
|
|
34
|
+
/** Capability policy; `"strict"` (default) throws on `suggest`. */
|
|
35
|
+
capabilityPolicy?: CapabilityPolicy;
|
|
36
|
+
/** Override the default attribution string (self-hosted instances). */
|
|
37
|
+
attribution?: string;
|
|
38
|
+
/** Override the default usage-policy URL (self-hosted instances). */
|
|
39
|
+
usagePolicyUrl?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a {@link GeocodingProvider} backed by a Nominatim instance.
|
|
43
|
+
*
|
|
44
|
+
* @experimental
|
|
45
|
+
*/
|
|
46
|
+
export declare function nominatimGeocodingProvider(options: NominatimProviderOptions): GeocodingProvider;
|
|
47
|
+
//# sourceMappingURL=nominatim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nominatim.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/nominatim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,iBAAiB,EAMvB,MAAM,gBAAgB,CAAC;AAExB,oEAAoE;AACpE,MAAM,WAAW,wBAAyB,SAAQ,wBAAwB;IACxE;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAmBD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAqF/F"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nominatim adapter for the {@link GeocodingProvider} contract.
|
|
3
|
+
*
|
|
4
|
+
* Supports `geocode` and `reverse`; Nominatim has no typeahead endpoint, so
|
|
5
|
+
* `suggest` is declared unsupported and throws
|
|
6
|
+
* `HonuaCapabilityNotSupportedError` under the strict capability policy.
|
|
7
|
+
*
|
|
8
|
+
* There is no default endpoint: pass the `baseUrl` of an instance you are
|
|
9
|
+
* entitled to use. If you point at the public
|
|
10
|
+
* `https://nominatim.openstreetmap.org` service you MUST follow the OSMF
|
|
11
|
+
* Nominatim usage policy — at most 1 request/second, a real `userAgent`
|
|
12
|
+
* identifying your application, and no heavy typeahead-style traffic.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
import { providerGetJson, stringifyProviderAttributes, trimProviderBaseUrl, } from "../provider-http.js";
|
|
17
|
+
import { assertGeocodingCapability, } from "../provider.js";
|
|
18
|
+
const NOMINATIM_ATTRIBUTION = "Data © OpenStreetMap contributors, ODbL 1.0";
|
|
19
|
+
const NOMINATIM_USAGE_POLICY_URL = "https://operations.osmfoundation.org/policies/nominatim/";
|
|
20
|
+
const NOMINATIM_CAPABILITIES = ["geocode", "reverse"];
|
|
21
|
+
/**
|
|
22
|
+
* Create a {@link GeocodingProvider} backed by a Nominatim instance.
|
|
23
|
+
*
|
|
24
|
+
* @experimental
|
|
25
|
+
*/
|
|
26
|
+
export function nominatimGeocodingProvider(options) {
|
|
27
|
+
const baseUrl = trimProviderBaseUrl(options.baseUrl);
|
|
28
|
+
const policy = options.capabilityPolicy ?? "strict";
|
|
29
|
+
const headers = {};
|
|
30
|
+
if (options.userAgent) {
|
|
31
|
+
headers["User-Agent"] = options.userAgent;
|
|
32
|
+
}
|
|
33
|
+
const provenance = Object.freeze({
|
|
34
|
+
provider: "nominatim",
|
|
35
|
+
attribution: options.attribution ?? NOMINATIM_ATTRIBUTION,
|
|
36
|
+
usagePolicyUrl: options.usagePolicyUrl ?? NOMINATIM_USAGE_POLICY_URL,
|
|
37
|
+
});
|
|
38
|
+
const request = (path, params, label) => {
|
|
39
|
+
params.set("format", "jsonv2");
|
|
40
|
+
if (options.email) {
|
|
41
|
+
params.set("email", options.email);
|
|
42
|
+
}
|
|
43
|
+
return providerGetJson(`${baseUrl}${path}?${params.toString()}`, {
|
|
44
|
+
fetchFn: options.fetchFn,
|
|
45
|
+
timeoutMs: options.timeoutMs,
|
|
46
|
+
headers,
|
|
47
|
+
label,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const toMatch = (place) => ({
|
|
51
|
+
address: place.display_name ?? "",
|
|
52
|
+
latitude: Number(place.lat),
|
|
53
|
+
longitude: Number(place.lon),
|
|
54
|
+
score: place.importance,
|
|
55
|
+
attributes: stringifyProviderAttributes({
|
|
56
|
+
place_id: place.place_id,
|
|
57
|
+
osm_type: place.osm_type,
|
|
58
|
+
osm_id: place.osm_id,
|
|
59
|
+
category: place.category,
|
|
60
|
+
type: place.type,
|
|
61
|
+
}),
|
|
62
|
+
provenance,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
id: "nominatim",
|
|
66
|
+
capabilities: NOMINATIM_CAPABILITIES,
|
|
67
|
+
attribution: provenance.attribution,
|
|
68
|
+
usagePolicyUrl: provenance.usagePolicyUrl,
|
|
69
|
+
async geocode(query, geocodeOptions) {
|
|
70
|
+
assertGeocodingCapability({ id: "nominatim", capabilities: NOMINATIM_CAPABILITIES }, "geocode", policy);
|
|
71
|
+
const params = new URLSearchParams({ q: query });
|
|
72
|
+
if (geocodeOptions?.limit !== undefined) {
|
|
73
|
+
params.set("limit", String(geocodeOptions.limit));
|
|
74
|
+
}
|
|
75
|
+
if (geocodeOptions?.countryCodes !== undefined) {
|
|
76
|
+
params.set("countrycodes", geocodeOptions.countryCodes);
|
|
77
|
+
}
|
|
78
|
+
const places = await request("/search", params, "nominatim geocode");
|
|
79
|
+
return (places ?? []).map(toMatch);
|
|
80
|
+
},
|
|
81
|
+
async reverse(latitude, longitude) {
|
|
82
|
+
assertGeocodingCapability({ id: "nominatim", capabilities: NOMINATIM_CAPABILITIES }, "reverse", policy);
|
|
83
|
+
const params = new URLSearchParams({ lat: String(latitude), lon: String(longitude) });
|
|
84
|
+
const place = await request("/reverse", params, "nominatim reverse");
|
|
85
|
+
// Nominatim reports "no result" as `{ "error": "Unable to geocode" }`.
|
|
86
|
+
if (!place || place.error !== undefined || place.lat === undefined) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const match = toMatch(place);
|
|
90
|
+
return {
|
|
91
|
+
address: match.address,
|
|
92
|
+
latitude: match.latitude,
|
|
93
|
+
longitude: match.longitude,
|
|
94
|
+
attributes: match.attributes,
|
|
95
|
+
provenance,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
async suggest() {
|
|
99
|
+
// Declared capability miss: Nominatim's usage policy forbids
|
|
100
|
+
// autocomplete-style traffic and it exposes no suggest endpoint.
|
|
101
|
+
assertGeocodingCapability({ id: "nominatim", capabilities: NOMINATIM_CAPABILITIES }, "suggest", policy);
|
|
102
|
+
return [];
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pelias adapter for the {@link GeocodingProvider} contract.
|
|
3
|
+
*
|
|
4
|
+
* Supports `geocode` (`/v1/search`), `reverse` (`/v1/reverse`), and `suggest`
|
|
5
|
+
* via the dedicated `/v1/autocomplete` endpoint.
|
|
6
|
+
*
|
|
7
|
+
* There is no default endpoint: pass the `baseUrl` of an instance you are
|
|
8
|
+
* entitled to use (self-hosted Pelias or a hosted service such as
|
|
9
|
+
* geocode.earth, whose terms and API key requirements you must follow).
|
|
10
|
+
* Attribution depends on the datasets the instance is built from — override
|
|
11
|
+
* `attribution` to match your instance's obligations.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import type { CapabilityPolicy } from "../../contract/types.js";
|
|
16
|
+
import { type ProviderTransportOptions } from "../provider-http.js";
|
|
17
|
+
import { type GeocodingProvider } from "../provider.js";
|
|
18
|
+
/** Options for {@link peliasGeocodingProvider}. @experimental */
|
|
19
|
+
export interface PeliasProviderOptions extends ProviderTransportOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Base URL of the Pelias instance, e.g. `https://pelias.example.org`.
|
|
22
|
+
* Required — no third-party default is baked in (usage-policy safety).
|
|
23
|
+
*/
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
/** API key forwarded as the `api_key` query parameter (hosted instances). */
|
|
26
|
+
apiKey?: string;
|
|
27
|
+
/** Capability policy; Pelias supports all declared operations. */
|
|
28
|
+
capabilityPolicy?: CapabilityPolicy;
|
|
29
|
+
/** Override the default attribution string to match your instance's datasets. */
|
|
30
|
+
attribution?: string;
|
|
31
|
+
/** Override the default usage-policy URL (hosted/self-hosted instances). */
|
|
32
|
+
usagePolicyUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a {@link GeocodingProvider} backed by a Pelias instance.
|
|
36
|
+
*
|
|
37
|
+
* @experimental
|
|
38
|
+
*/
|
|
39
|
+
export declare function peliasGeocodingProvider(options: PeliasProviderOptions): GeocodingProvider;
|
|
40
|
+
//# sourceMappingURL=pelias.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pelias.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/pelias.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,gBAAgB,CAAC;AAExB,iEAAiE;AACjE,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAwBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAiGzF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pelias adapter for the {@link GeocodingProvider} contract.
|
|
3
|
+
*
|
|
4
|
+
* Supports `geocode` (`/v1/search`), `reverse` (`/v1/reverse`), and `suggest`
|
|
5
|
+
* via the dedicated `/v1/autocomplete` endpoint.
|
|
6
|
+
*
|
|
7
|
+
* There is no default endpoint: pass the `baseUrl` of an instance you are
|
|
8
|
+
* entitled to use (self-hosted Pelias or a hosted service such as
|
|
9
|
+
* geocode.earth, whose terms and API key requirements you must follow).
|
|
10
|
+
* Attribution depends on the datasets the instance is built from — override
|
|
11
|
+
* `attribution` to match your instance's obligations.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import { providerGetJson, stringifyProviderAttributes, trimProviderBaseUrl, } from "../provider-http.js";
|
|
16
|
+
import { assertGeocodingCapability, } from "../provider.js";
|
|
17
|
+
const PELIAS_ATTRIBUTION = "Geocoding by Pelias; data © OpenStreetMap contributors and other dataset licensors";
|
|
18
|
+
const PELIAS_USAGE_POLICY_URL = "https://github.com/pelias/documentation/blob/master/data-licenses.md";
|
|
19
|
+
const PELIAS_CAPABILITIES = ["geocode", "reverse", "suggest"];
|
|
20
|
+
/**
|
|
21
|
+
* Create a {@link GeocodingProvider} backed by a Pelias instance.
|
|
22
|
+
*
|
|
23
|
+
* @experimental
|
|
24
|
+
*/
|
|
25
|
+
export function peliasGeocodingProvider(options) {
|
|
26
|
+
const baseUrl = trimProviderBaseUrl(options.baseUrl);
|
|
27
|
+
const policy = options.capabilityPolicy ?? "strict";
|
|
28
|
+
const provenance = Object.freeze({
|
|
29
|
+
provider: "pelias",
|
|
30
|
+
attribution: options.attribution ?? PELIAS_ATTRIBUTION,
|
|
31
|
+
usagePolicyUrl: options.usagePolicyUrl ?? PELIAS_USAGE_POLICY_URL,
|
|
32
|
+
});
|
|
33
|
+
const request = (path, params, label) => {
|
|
34
|
+
if (options.apiKey) {
|
|
35
|
+
params.set("api_key", options.apiKey);
|
|
36
|
+
}
|
|
37
|
+
return providerGetJson(`${baseUrl}${path}?${params.toString()}`, {
|
|
38
|
+
fetchFn: options.fetchFn,
|
|
39
|
+
timeoutMs: options.timeoutMs,
|
|
40
|
+
label,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const toMatch = (feature) => {
|
|
44
|
+
const [longitude, latitude] = feature.geometry?.coordinates ?? [Number.NaN, Number.NaN];
|
|
45
|
+
const p = feature.properties ?? {};
|
|
46
|
+
return {
|
|
47
|
+
address: p.label ?? p.name ?? "",
|
|
48
|
+
latitude,
|
|
49
|
+
longitude,
|
|
50
|
+
score: p.confidence,
|
|
51
|
+
attributes: stringifyProviderAttributes({
|
|
52
|
+
gid: p.gid,
|
|
53
|
+
layer: p.layer,
|
|
54
|
+
source: p.source,
|
|
55
|
+
country_code: p.country_code,
|
|
56
|
+
postalcode: p.postalcode,
|
|
57
|
+
}),
|
|
58
|
+
provenance,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const applyCountryFilter = (params, countryCodes) => {
|
|
62
|
+
if (countryCodes !== undefined) {
|
|
63
|
+
params.set("boundary.country", countryCodes);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
id: "pelias",
|
|
68
|
+
capabilities: PELIAS_CAPABILITIES,
|
|
69
|
+
attribution: provenance.attribution,
|
|
70
|
+
usagePolicyUrl: provenance.usagePolicyUrl,
|
|
71
|
+
async geocode(query, geocodeOptions) {
|
|
72
|
+
assertGeocodingCapability({ id: "pelias", capabilities: PELIAS_CAPABILITIES }, "geocode", policy);
|
|
73
|
+
const params = new URLSearchParams({ text: query });
|
|
74
|
+
if (geocodeOptions?.limit !== undefined) {
|
|
75
|
+
params.set("size", String(geocodeOptions.limit));
|
|
76
|
+
}
|
|
77
|
+
applyCountryFilter(params, geocodeOptions?.countryCodes);
|
|
78
|
+
const data = await request("/v1/search", params, "pelias geocode");
|
|
79
|
+
return (data.features ?? []).map(toMatch);
|
|
80
|
+
},
|
|
81
|
+
async reverse(latitude, longitude) {
|
|
82
|
+
assertGeocodingCapability({ id: "pelias", capabilities: PELIAS_CAPABILITIES }, "reverse", policy);
|
|
83
|
+
const params = new URLSearchParams({
|
|
84
|
+
"point.lat": String(latitude),
|
|
85
|
+
"point.lon": String(longitude),
|
|
86
|
+
});
|
|
87
|
+
const data = await request("/v1/reverse", params, "pelias reverse");
|
|
88
|
+
const feature = data.features?.[0];
|
|
89
|
+
if (!feature) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const match = toMatch(feature);
|
|
93
|
+
return {
|
|
94
|
+
address: match.address,
|
|
95
|
+
latitude: match.latitude,
|
|
96
|
+
longitude: match.longitude,
|
|
97
|
+
attributes: match.attributes,
|
|
98
|
+
provenance,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
async suggest(text, suggestOptions) {
|
|
102
|
+
assertGeocodingCapability({ id: "pelias", capabilities: PELIAS_CAPABILITIES }, "suggest", policy);
|
|
103
|
+
const params = new URLSearchParams({ text });
|
|
104
|
+
if (suggestOptions?.limit !== undefined) {
|
|
105
|
+
params.set("size", String(suggestOptions.limit));
|
|
106
|
+
}
|
|
107
|
+
applyCountryFilter(params, suggestOptions?.countryCodes);
|
|
108
|
+
const data = await request("/v1/autocomplete", params, "pelias suggest");
|
|
109
|
+
return (data.features ?? []).map((feature) => ({
|
|
110
|
+
text: feature.properties?.label ?? feature.properties?.name ?? "",
|
|
111
|
+
provenance,
|
|
112
|
+
}));
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Photon adapter for the {@link GeocodingProvider} contract.
|
|
3
|
+
*
|
|
4
|
+
* Photon (komoot) is typeahead-first, so it supports all three operations:
|
|
5
|
+
* `geocode`, `reverse`, and `suggest` (suggest reuses the search endpoint,
|
|
6
|
+
* which is designed for as-you-type queries).
|
|
7
|
+
*
|
|
8
|
+
* There is no default endpoint: pass the `baseUrl` of an instance you are
|
|
9
|
+
* entitled to use (e.g. a self-hosted Photon, or `https://photon.komoot.io`
|
|
10
|
+
* within its fair-use terms).
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import type { CapabilityPolicy } from "../../contract/types.js";
|
|
15
|
+
import { type ProviderTransportOptions } from "../provider-http.js";
|
|
16
|
+
import { type GeocodingProvider } from "../provider.js";
|
|
17
|
+
/** Options for {@link photonGeocodingProvider}. @experimental */
|
|
18
|
+
export interface PhotonProviderOptions extends ProviderTransportOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Base URL of the Photon instance, e.g. `https://photon.example.org`.
|
|
21
|
+
* Required — no third-party default is baked in (usage-policy safety).
|
|
22
|
+
*/
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
/** BCP-47 language for results, forwarded as `lang` when set. */
|
|
25
|
+
language?: string;
|
|
26
|
+
/** Capability policy; Photon supports all declared operations. */
|
|
27
|
+
capabilityPolicy?: CapabilityPolicy;
|
|
28
|
+
/** Override the default attribution string (self-hosted instances). */
|
|
29
|
+
attribution?: string;
|
|
30
|
+
/** Override the default usage-policy URL (self-hosted instances). */
|
|
31
|
+
usagePolicyUrl?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a {@link GeocodingProvider} backed by a Photon instance.
|
|
35
|
+
*
|
|
36
|
+
* @experimental
|
|
37
|
+
*/
|
|
38
|
+
export declare function photonGeocodingProvider(options: PhotonProviderOptions): GeocodingProvider;
|
|
39
|
+
//# sourceMappingURL=photon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"photon.d.ts","sourceRoot":"","sources":["../../../../src/geocoding/providers/photon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,iBAAiB,EAOvB,MAAM,gBAAgB,CAAC;AAExB,iEAAiE;AACjE,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAsCD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAmFzF"}
|