@honua/app-platform 0.1.0-beta.0 → 0.1.1-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.
Files changed (381) hide show
  1. package/contract/discovery.d.ts +231 -0
  2. package/contract/discovery.d.ts.map +1 -0
  3. package/contract/discovery.js +554 -0
  4. package/contract/edit-sketch.d.ts +8 -0
  5. package/contract/edit-sketch.d.ts.map +1 -1
  6. package/contract/edit-sketch.js +15 -0
  7. package/contract/edit-snapping.d.ts +160 -0
  8. package/contract/edit-snapping.d.ts.map +1 -0
  9. package/contract/edit-snapping.js +675 -0
  10. package/contract/generated/projjson-v0.7-crs-validator.d.ts +35 -0
  11. package/contract/generated/projjson-v0.7-crs-validator.d.ts.map +1 -0
  12. package/contract/generated/projjson-v0.7-crs-validator.js +3941 -0
  13. package/contract/index.d.ts +11 -2
  14. package/contract/index.d.ts.map +1 -1
  15. package/contract/index.js +4 -1
  16. package/contract/pmtiles.d.ts +31 -0
  17. package/contract/pmtiles.d.ts.map +1 -1
  18. package/contract/pmtiles.js +60 -20
  19. package/contract/protocol-module.d.ts +70 -0
  20. package/contract/protocol-module.d.ts.map +1 -0
  21. package/contract/protocol-module.js +1 -0
  22. package/contract/schema-envelope.d.ts +26 -0
  23. package/contract/schema-envelope.d.ts.map +1 -0
  24. package/contract/schema-envelope.js +25 -0
  25. package/contract/schema.d.ts +582 -0
  26. package/contract/schema.d.ts.map +1 -0
  27. package/contract/schema.js +2483 -0
  28. package/contract/source-capability-support.d.ts +6 -0
  29. package/contract/source-capability-support.d.ts.map +1 -0
  30. package/contract/source-capability-support.js +154 -0
  31. package/contract/source.d.ts +35 -17
  32. package/contract/source.d.ts.map +1 -1
  33. package/contract/source.js +267 -71
  34. package/contract/types.d.ts +140 -4
  35. package/contract/types.d.ts.map +1 -1
  36. package/contract/types.js +6 -14
  37. package/core/bounded-json.d.ts +4 -0
  38. package/core/bounded-json.d.ts.map +1 -0
  39. package/core/bounded-json.js +38 -0
  40. package/core/cache-state.d.ts +9 -0
  41. package/core/cache-state.d.ts.map +1 -1
  42. package/core/cache-state.js +10 -0
  43. package/core/capabilities-xml.d.ts +33 -0
  44. package/core/capabilities-xml.d.ts.map +1 -0
  45. package/core/capabilities-xml.js +331 -0
  46. package/core/client.d.ts +4 -1
  47. package/core/client.d.ts.map +1 -1
  48. package/core/client.js +115 -29
  49. package/core/error-classifications.d.ts +153 -0
  50. package/core/error-classifications.d.ts.map +1 -0
  51. package/core/error-classifications.js +140 -0
  52. package/core/error-code-registry.d.ts +158 -0
  53. package/core/error-code-registry.d.ts.map +1 -0
  54. package/core/error-code-registry.js +143 -0
  55. package/core/error-envelope.d.ts +68 -0
  56. package/core/error-envelope.d.ts.map +1 -0
  57. package/core/error-envelope.js +357 -0
  58. package/core/errors.d.ts +45 -29
  59. package/core/errors.d.ts.map +1 -1
  60. package/core/errors.js +97 -50
  61. package/core/geoparquet-sql.d.ts +30 -2
  62. package/core/geoparquet-sql.d.ts.map +1 -1
  63. package/core/geoparquet-sql.js +38 -3
  64. package/core/odata-key-path.d.ts +12 -0
  65. package/core/odata-key-path.d.ts.map +1 -0
  66. package/core/odata-key-path.js +28 -0
  67. package/core/odata-write-codec.d.ts +66 -0
  68. package/core/odata-write-codec.d.ts.map +1 -0
  69. package/core/odata-write-codec.js +1083 -0
  70. package/core/odata.d.ts +59 -7
  71. package/core/odata.d.ts.map +1 -1
  72. package/core/odata.js +431 -99
  73. package/core/ogc-features.d.ts.map +1 -1
  74. package/core/ogc-features.js +3 -0
  75. package/core/ogc-maps.d.ts +7 -0
  76. package/core/ogc-maps.d.ts.map +1 -1
  77. package/core/ogc-maps.js +46 -7
  78. package/core/ogc-processes.d.ts +2 -1
  79. package/core/ogc-processes.d.ts.map +1 -1
  80. package/core/ogc-processes.js +33 -5
  81. package/core/ogc-records.d.ts +9 -0
  82. package/core/ogc-records.d.ts.map +1 -1
  83. package/core/ogc-records.js +78 -29
  84. package/core/ogc-tiles.d.ts +10 -1
  85. package/core/ogc-tiles.d.ts.map +1 -1
  86. package/core/ogc-tiles.js +56 -17
  87. package/core/path-utils.d.ts +9 -0
  88. package/core/path-utils.d.ts.map +1 -1
  89. package/core/path-utils.js +19 -0
  90. package/core/protocol-transport.d.ts +1 -0
  91. package/core/protocol-transport.d.ts.map +1 -1
  92. package/core/request-pipeline.d.ts.map +1 -1
  93. package/core/request-pipeline.js +1 -1
  94. package/core/spatial-filter.d.ts +8 -4
  95. package/core/spatial-filter.d.ts.map +1 -1
  96. package/core/spatial-filter.js +206 -16
  97. package/core/stac-static.d.ts +6 -2
  98. package/core/stac-static.d.ts.map +1 -1
  99. package/core/stac-static.js +260 -69
  100. package/core/surfaces.d.ts.map +1 -1
  101. package/core/surfaces.js +69 -5
  102. package/core/types.d.ts +125 -7
  103. package/core/types.d.ts.map +1 -1
  104. package/core/wfs-capabilities.d.ts +2 -0
  105. package/core/wfs-capabilities.d.ts.map +1 -1
  106. package/core/wfs-capabilities.js +8 -1
  107. package/core/wfs.d.ts.map +1 -1
  108. package/core/wfs.js +10 -0
  109. package/core/wms-capabilities.d.ts +56 -84
  110. package/core/wms-capabilities.d.ts.map +1 -1
  111. package/core/wms-capabilities.js +212 -509
  112. package/core/wmts-capabilities.d.ts +62 -62
  113. package/core/wmts-capabilities.d.ts.map +1 -1
  114. package/core/wmts-capabilities.js +224 -371
  115. package/esri-compat/editor.d.ts +8 -0
  116. package/esri-compat/editor.d.ts.map +1 -1
  117. package/esri-compat/editor.js +13 -0
  118. package/esri-compat/feature-layer.d.ts +2 -0
  119. package/esri-compat/feature-layer.d.ts.map +1 -1
  120. package/esri-compat/feature-layer.js +1 -0
  121. package/esri-compat/layer-list.d.ts +11 -0
  122. package/esri-compat/layer-list.d.ts.map +1 -1
  123. package/esri-compat/layer-list.js +49 -0
  124. package/esri-compat/legend.d.ts +10 -0
  125. package/esri-compat/legend.d.ts.map +1 -1
  126. package/esri-compat/legend.js +27 -0
  127. package/esri-compat/portal.d.ts +197 -0
  128. package/esri-compat/portal.d.ts.map +1 -0
  129. package/esri-compat/portal.js +251 -0
  130. package/esri-compat/renderer-objects.d.ts +40 -0
  131. package/esri-compat/renderer-objects.d.ts.map +1 -0
  132. package/esri-compat/renderer-objects.js +62 -0
  133. package/esri-compat/sketch.d.ts +43 -0
  134. package/esri-compat/sketch.d.ts.map +1 -1
  135. package/esri-compat/sketch.js +46 -0
  136. package/esri-compat/snapping.d.ts +43 -0
  137. package/esri-compat/snapping.d.ts.map +1 -0
  138. package/esri-compat/snapping.js +45 -0
  139. package/esri-compat/url.d.ts.map +1 -1
  140. package/esri-compat/url.js +1 -1
  141. package/esri-compat/widget-host.d.ts +84 -0
  142. package/esri-compat/widget-host.d.ts.map +1 -0
  143. package/esri-compat/widget-host.js +159 -0
  144. package/generated-app/errors.d.ts +18 -2
  145. package/generated-app/errors.d.ts.map +1 -1
  146. package/generated-app/errors.js +44 -11
  147. package/geocoding/index.d.ts +7 -0
  148. package/geocoding/index.d.ts.map +1 -1
  149. package/geocoding/index.js +5 -0
  150. package/geocoding/provider-http.d.ts +37 -0
  151. package/geocoding/provider-http.d.ts.map +1 -0
  152. package/geocoding/provider-http.js +91 -0
  153. package/geocoding/provider.d.ts +145 -0
  154. package/geocoding/provider.d.ts.map +1 -0
  155. package/geocoding/provider.js +41 -0
  156. package/geocoding/providers/honua.d.ts +28 -0
  157. package/geocoding/providers/honua.d.ts.map +1 -0
  158. package/geocoding/providers/honua.js +68 -0
  159. package/geocoding/providers/nominatim.d.ts +47 -0
  160. package/geocoding/providers/nominatim.d.ts.map +1 -0
  161. package/geocoding/providers/nominatim.js +105 -0
  162. package/geocoding/providers/pelias.d.ts +40 -0
  163. package/geocoding/providers/pelias.d.ts.map +1 -0
  164. package/geocoding/providers/pelias.js +115 -0
  165. package/geocoding/providers/photon.d.ts +39 -0
  166. package/geocoding/providers/photon.d.ts.map +1 -0
  167. package/geocoding/providers/photon.js +107 -0
  168. package/geometry/convert.d.ts +13 -0
  169. package/geometry/convert.d.ts.map +1 -0
  170. package/geometry/convert.js +12 -0
  171. package/geometry/index.d.ts +17 -0
  172. package/geometry/index.d.ts.map +1 -0
  173. package/geometry/index.js +15 -0
  174. package/geometry/internal.d.ts +25 -0
  175. package/geometry/internal.d.ts.map +1 -0
  176. package/geometry/internal.js +40 -0
  177. package/geometry/ops.d.ts +71 -0
  178. package/geometry/ops.d.ts.map +1 -0
  179. package/geometry/ops.js +147 -0
  180. package/geometry/project.d.ts +40 -0
  181. package/geometry/project.d.ts.map +1 -0
  182. package/geometry/project.js +88 -0
  183. package/geometry/types.d.ts +36 -0
  184. package/geometry/types.d.ts.map +1 -0
  185. package/geometry/types.js +12 -0
  186. package/map/automatic-mount-integration.d.ts +134 -0
  187. package/map/automatic-mount-integration.d.ts.map +1 -0
  188. package/map/automatic-mount-integration.js +305 -0
  189. package/map/automatic-source-strategy.d.ts +125 -0
  190. package/map/automatic-source-strategy.d.ts.map +1 -0
  191. package/map/automatic-source-strategy.js +494 -0
  192. package/map/data-to-map-bridge.d.ts +293 -0
  193. package/map/data-to-map-bridge.d.ts.map +1 -0
  194. package/map/data-to-map-bridge.js +817 -0
  195. package/map/geojson-projection.d.ts +33 -0
  196. package/map/geojson-projection.d.ts.map +1 -0
  197. package/map/geojson-projection.js +118 -0
  198. package/map/index.d.ts +14 -0
  199. package/map/index.d.ts.map +1 -1
  200. package/map/index.js +8 -0
  201. package/map/raster-source-spec.d.ts +30 -0
  202. package/map/raster-source-spec.d.ts.map +1 -0
  203. package/map/raster-source-spec.js +190 -0
  204. package/map/raster-source-strategy.d.ts +65 -0
  205. package/map/raster-source-strategy.d.ts.map +1 -0
  206. package/map/raster-source-strategy.js +232 -0
  207. package/map/source-to-maplibre.d.ts +91 -0
  208. package/map/source-to-maplibre.d.ts.map +1 -0
  209. package/map/source-to-maplibre.js +454 -0
  210. package/map/temporal-playback.d.ts +139 -0
  211. package/map/temporal-playback.d.ts.map +1 -0
  212. package/map/temporal-playback.js +247 -0
  213. package/package.json +28 -2
  214. package/query-planner/canonical.d.ts +7 -0
  215. package/query-planner/canonical.d.ts.map +1 -0
  216. package/query-planner/canonical.js +145 -0
  217. package/query-planner/cql2-json.d.ts +17 -0
  218. package/query-planner/cql2-json.d.ts.map +1 -0
  219. package/query-planner/cql2-json.js +646 -0
  220. package/query-planner/diagnostics.d.ts +35 -0
  221. package/query-planner/diagnostics.d.ts.map +1 -0
  222. package/query-planner/diagnostics.js +373 -0
  223. package/query-planner/duckdb.d.ts +79 -0
  224. package/query-planner/duckdb.d.ts.map +1 -0
  225. package/query-planner/duckdb.js +758 -0
  226. package/query-planner/execution-context.d.ts +5 -0
  227. package/query-planner/execution-context.d.ts.map +1 -0
  228. package/query-planner/execution-context.js +50 -0
  229. package/query-planner/executor.d.ts +5 -0
  230. package/query-planner/executor.d.ts.map +1 -0
  231. package/query-planner/executor.js +223 -0
  232. package/query-planner/geoservices.d.ts +91 -0
  233. package/query-planner/geoservices.d.ts.map +1 -0
  234. package/query-planner/geoservices.js +667 -0
  235. package/query-planner/grpc.d.ts +100 -0
  236. package/query-planner/grpc.d.ts.map +1 -0
  237. package/query-planner/grpc.js +736 -0
  238. package/query-planner/index.d.ts +44 -0
  239. package/query-planner/index.d.ts.map +1 -0
  240. package/query-planner/index.js +30 -0
  241. package/query-planner/ir.d.ts +20 -0
  242. package/query-planner/ir.d.ts.map +1 -0
  243. package/query-planner/ir.js +417 -0
  244. package/query-planner/local-aggregate.d.ts +5 -0
  245. package/query-planner/local-aggregate.d.ts.map +1 -0
  246. package/query-planner/local-aggregate.js +126 -0
  247. package/query-planner/odata.d.ts +48 -0
  248. package/query-planner/odata.d.ts.map +1 -0
  249. package/query-planner/odata.js +662 -0
  250. package/query-planner/ogc-compiler.d.ts +55 -0
  251. package/query-planner/ogc-compiler.d.ts.map +1 -0
  252. package/query-planner/ogc-compiler.js +480 -0
  253. package/query-planner/ogc-features.d.ts +53 -0
  254. package/query-planner/ogc-features.d.ts.map +1 -0
  255. package/query-planner/ogc-features.js +617 -0
  256. package/query-planner/planner.d.ts +17 -0
  257. package/query-planner/planner.d.ts.map +1 -0
  258. package/query-planner/planner.js +818 -0
  259. package/query-planner/resource.d.ts +94 -0
  260. package/query-planner/resource.d.ts.map +1 -0
  261. package/query-planner/resource.js +526 -0
  262. package/query-planner/semantic-canonical.d.ts +15 -0
  263. package/query-planner/semantic-canonical.d.ts.map +1 -0
  264. package/query-planner/semantic-canonical.js +62 -0
  265. package/query-planner/semantic-compat.d.ts +10 -0
  266. package/query-planner/semantic-compat.d.ts.map +1 -0
  267. package/query-planner/semantic-compat.js +35 -0
  268. package/query-planner/semantic-compiler.d.ts +64 -0
  269. package/query-planner/semantic-compiler.d.ts.map +1 -0
  270. package/query-planner/semantic-compiler.js +81 -0
  271. package/query-planner/semantic-literals.d.ts +30 -0
  272. package/query-planner/semantic-literals.d.ts.map +1 -0
  273. package/query-planner/semantic-literals.js +133 -0
  274. package/query-planner/semantic-types.d.ts +265 -0
  275. package/query-planner/semantic-types.d.ts.map +1 -0
  276. package/query-planner/semantic-types.js +1 -0
  277. package/query-planner/semantic.d.ts +54 -0
  278. package/query-planner/semantic.d.ts.map +1 -0
  279. package/query-planner/semantic.js +1421 -0
  280. package/query-planner/types.d.ts +560 -0
  281. package/query-planner/types.d.ts.map +1 -0
  282. package/query-planner/types.js +49 -0
  283. package/query-planner/wfs-semantic.d.ts +58 -0
  284. package/query-planner/wfs-semantic.d.ts.map +1 -0
  285. package/query-planner/wfs-semantic.js +547 -0
  286. package/query-planner/wfs.d.ts +6 -0
  287. package/query-planner/wfs.d.ts.map +1 -0
  288. package/query-planner/wfs.js +71 -0
  289. package/realtime/contract.d.ts +142 -0
  290. package/realtime/contract.d.ts.map +1 -0
  291. package/realtime/contract.js +154 -0
  292. package/realtime/honua-server.d.ts.map +1 -1
  293. package/realtime/honua-server.js +13 -8
  294. package/realtime/index.d.ts +19 -4
  295. package/realtime/index.d.ts.map +1 -1
  296. package/realtime/index.js +14 -4
  297. package/realtime/odata-delta.d.ts +114 -0
  298. package/realtime/odata-delta.d.ts.map +1 -0
  299. package/realtime/odata-delta.js +483 -0
  300. package/realtime/resumable-transport.d.ts +111 -0
  301. package/realtime/resumable-transport.d.ts.map +1 -0
  302. package/realtime/resumable-transport.js +406 -0
  303. package/realtime/resumable.d.ts +104 -0
  304. package/realtime/resumable.d.ts.map +1 -0
  305. package/realtime/resumable.js +632 -0
  306. package/realtime/sse.d.ts.map +1 -1
  307. package/realtime/sse.js +27 -23
  308. package/realtime/websocket.d.ts +60 -0
  309. package/realtime/websocket.d.ts.map +1 -0
  310. package/realtime/websocket.js +157 -0
  311. package/realtime/wire.d.ts +27 -0
  312. package/realtime/wire.d.ts.map +1 -0
  313. package/realtime/wire.js +57 -0
  314. package/replica-sync/errors.d.ts +2 -1
  315. package/replica-sync/errors.d.ts.map +1 -1
  316. package/replica-sync/errors.js +33 -2
  317. package/runtime/edit-snapping.d.ts +107 -0
  318. package/runtime/edit-snapping.d.ts.map +1 -0
  319. package/runtime/edit-snapping.js +190 -0
  320. package/runtime/errors.d.ts +3 -2
  321. package/runtime/errors.d.ts.map +1 -1
  322. package/runtime/errors.js +19 -2
  323. package/runtime/index.d.ts +6 -0
  324. package/runtime/index.d.ts.map +1 -1
  325. package/runtime/index.js +3 -0
  326. package/runtime/maplibre-renderer.d.ts +41 -0
  327. package/runtime/maplibre-renderer.d.ts.map +1 -0
  328. package/runtime/maplibre-renderer.js +322 -0
  329. package/runtime/query-tiles.d.ts +2 -1
  330. package/runtime/query-tiles.d.ts.map +1 -1
  331. package/runtime/query-tiles.js +6 -2
  332. package/runtime/source-bridge.d.ts +4 -4
  333. package/runtime/source-bridge.d.ts.map +1 -1
  334. package/runtime/source-bridge.js +9 -56
  335. package/runtime/style-interactions.d.ts +3 -2
  336. package/runtime/style-interactions.d.ts.map +1 -1
  337. package/runtime/style-interactions.js +11 -3
  338. package/runtime/terra-draw-sketch.d.ts +275 -0
  339. package/runtime/terra-draw-sketch.d.ts.map +1 -0
  340. package/runtime/terra-draw-sketch.js +404 -0
  341. package/scene-workspace/index.d.ts +4 -0
  342. package/scene-workspace/index.d.ts.map +1 -1
  343. package/scene-workspace/index.js +2 -0
  344. package/scene-workspace/source-to-cesium.d.ts +116 -0
  345. package/scene-workspace/source-to-cesium.d.ts.map +1 -0
  346. package/scene-workspace/source-to-cesium.js +791 -0
  347. package/scene-workspace/state-sync.d.ts +147 -0
  348. package/scene-workspace/state-sync.d.ts.map +1 -0
  349. package/scene-workspace/state-sync.js +1123 -0
  350. package/source-capability-registry.d.ts +1 -0
  351. package/source-capability-registry.js +1 -0
  352. package/source-capability-types.d.ts +186 -0
  353. package/source-capability-types.js +7 -0
  354. package/style/index.d.ts +2 -0
  355. package/style/index.d.ts.map +1 -1
  356. package/style/index.js +2 -0
  357. package/style/renderers.d.ts +326 -0
  358. package/style/renderers.d.ts.map +1 -0
  359. package/style/renderers.js +517 -0
  360. package/web-components/controller.d.ts +2 -0
  361. package/web-components/controller.d.ts.map +1 -1
  362. package/web-components/controller.js +49 -8
  363. package/web-components/elements.d.ts +95 -1
  364. package/web-components/elements.d.ts.map +1 -1
  365. package/web-components/elements.js +458 -19
  366. package/web-components/index.d.ts +8 -1
  367. package/web-components/index.d.ts.map +1 -1
  368. package/web-components/index.js +7 -0
  369. package/web-components/maplibre-renderer.d.ts.map +1 -1
  370. package/web-components/maplibre-renderer.js +87 -0
  371. package/web-components/measurement.d.ts +69 -0
  372. package/web-components/measurement.d.ts.map +1 -0
  373. package/web-components/measurement.js +523 -0
  374. package/web-components/types.d.ts +109 -0
  375. package/web-components/types.d.ts.map +1 -1
  376. package/webmap/convert-renderer.d.ts +24 -3
  377. package/webmap/convert-renderer.d.ts.map +1 -1
  378. package/webmap/convert-renderer.js +93 -112
  379. package/webmap/index.d.ts +1 -1
  380. package/webmap/index.d.ts.map +1 -1
  381. package/webmap/index.js +1 -1
@@ -0,0 +1,107 @@
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 { providerGetJson, stringifyProviderAttributes, trimProviderBaseUrl, } from "../provider-http.js";
15
+ import { assertGeocodingCapability, } from "../provider.js";
16
+ const PHOTON_ATTRIBUTION = "Data © OpenStreetMap contributors, ODbL 1.0";
17
+ const PHOTON_USAGE_POLICY_URL = "https://photon.komoot.io/";
18
+ const PHOTON_CAPABILITIES = ["geocode", "reverse", "suggest"];
19
+ function photonLabel(feature) {
20
+ const p = feature.properties ?? {};
21
+ const streetLine = p.housenumber && p.street ? `${p.street} ${p.housenumber}` : p.street;
22
+ const parts = [p.name, streetLine, p.city, p.state, p.country].filter((part) => typeof part === "string" && part.length > 0);
23
+ // Photon repeats `name` for street-level results; drop consecutive duplicates.
24
+ return parts.filter((part, index) => part !== parts[index - 1]).join(", ");
25
+ }
26
+ /**
27
+ * Create a {@link GeocodingProvider} backed by a Photon instance.
28
+ *
29
+ * @experimental
30
+ */
31
+ export function photonGeocodingProvider(options) {
32
+ const baseUrl = trimProviderBaseUrl(options.baseUrl);
33
+ const policy = options.capabilityPolicy ?? "strict";
34
+ const provenance = Object.freeze({
35
+ provider: "photon",
36
+ attribution: options.attribution ?? PHOTON_ATTRIBUTION,
37
+ usagePolicyUrl: options.usagePolicyUrl ?? PHOTON_USAGE_POLICY_URL,
38
+ });
39
+ const request = (path, params, label) => {
40
+ if (options.language) {
41
+ params.set("lang", options.language);
42
+ }
43
+ return providerGetJson(`${baseUrl}${path}?${params.toString()}`, {
44
+ fetchFn: options.fetchFn,
45
+ timeoutMs: options.timeoutMs,
46
+ label,
47
+ });
48
+ };
49
+ const toMatch = (feature) => {
50
+ const [longitude, latitude] = feature.geometry?.coordinates ?? [Number.NaN, Number.NaN];
51
+ const p = feature.properties ?? {};
52
+ return {
53
+ address: photonLabel(feature),
54
+ latitude,
55
+ longitude,
56
+ attributes: stringifyProviderAttributes({
57
+ osm_id: p.osm_id,
58
+ osm_type: p.osm_type,
59
+ osm_key: p.osm_key,
60
+ osm_value: p.osm_value,
61
+ postcode: p.postcode,
62
+ type: p.type,
63
+ }),
64
+ provenance,
65
+ };
66
+ };
67
+ const search = async (query, limit, label) => {
68
+ const params = new URLSearchParams({ q: query });
69
+ if (limit !== undefined) {
70
+ params.set("limit", String(limit));
71
+ }
72
+ const data = await request("/api", params, label);
73
+ return (data.features ?? []).map(toMatch);
74
+ };
75
+ return {
76
+ id: "photon",
77
+ capabilities: PHOTON_CAPABILITIES,
78
+ attribution: provenance.attribution,
79
+ usagePolicyUrl: provenance.usagePolicyUrl,
80
+ async geocode(query, geocodeOptions) {
81
+ assertGeocodingCapability({ id: "photon", capabilities: PHOTON_CAPABILITIES }, "geocode", policy);
82
+ return search(query, geocodeOptions?.limit, "photon geocode");
83
+ },
84
+ async reverse(latitude, longitude) {
85
+ assertGeocodingCapability({ id: "photon", capabilities: PHOTON_CAPABILITIES }, "reverse", policy);
86
+ const params = new URLSearchParams({ lat: String(latitude), lon: String(longitude) });
87
+ const data = await request("/reverse", params, "photon 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: "photon", capabilities: PHOTON_CAPABILITIES }, "suggest", policy);
103
+ const matches = await search(text, suggestOptions?.limit, "photon suggest");
104
+ return matches.map((match) => ({ text: match.address, provenance }));
105
+ },
106
+ };
107
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Esri-JSON ↔ GeoJSON conversion for the geometry package.
3
+ *
4
+ * These are re-exports of the single canonical converter utility in
5
+ * `src/core/esri-geojson.ts` (heritage of issue #264) — the geometry package
6
+ * deliberately does not fork its own Esri conversion logic. `esriToGeoJson` /
7
+ * `geoJsonToEsri` are the ergonomic aliases used by `@honua/geometry` and the
8
+ * `geometryEngine` compat shim.
9
+ *
10
+ * @module
11
+ */
12
+ export { esriGeometryToGeoJSON as esriToGeoJson, esriFeatureToGeoJSON as esriFeatureToGeoJson, geoJsonToEsriGeometry as geoJsonToEsri, } from "../core/esri-geojson.js";
13
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/geometry/convert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,qBAAqB,IAAI,aAAa,EACtC,oBAAoB,IAAI,oBAAoB,EAC5C,qBAAqB,IAAI,aAAa,GACvC,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Esri-JSON ↔ GeoJSON conversion for the geometry package.
3
+ *
4
+ * These are re-exports of the single canonical converter utility in
5
+ * `src/core/esri-geojson.ts` (heritage of issue #264) — the geometry package
6
+ * deliberately does not fork its own Esri conversion logic. `esriToGeoJson` /
7
+ * `geoJsonToEsri` are the ergonomic aliases used by `@honua/geometry` and the
8
+ * `geometryEngine` compat shim.
9
+ *
10
+ * @module
11
+ */
12
+ export { esriGeometryToGeoJSON as esriToGeoJson, esriFeatureToGeoJSON as esriFeatureToGeoJson, geoJsonToEsriGeometry as geoJsonToEsri, } from "../core/esri-geojson.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `@honua/geometry` — curated, tree-shakeable client-side geometry operations
3
+ * for the Honua SDK.
4
+ *
5
+ * This subpath (`@honua/sdk-js/geometry`, split-packaged as `@honua/geometry`)
6
+ * wraps the individual `@turf/*` packages and `proj4`, typed against the SDK's
7
+ * own GeoJSON contract. Importing a single op only pulls that op's turf backing
8
+ * into a consumer bundle; the core SDK never imports this module, so core-only
9
+ * consumers never pay for turf/proj4.
10
+ *
11
+ * @module
12
+ */
13
+ export { area, bbox, booleanContains, booleanIntersects, booleanWithin, buffer, centroid, convex, difference, intersect, length, nearestPoint, simplify, union, } from "./ops.js";
14
+ export { defineProjection, normalizeCrs, project, toWebMercator, toWgs84 } from "./project.js";
15
+ export { esriFeatureToGeoJson, esriToGeoJson, geoJsonToEsri } from "./convert.js";
16
+ export type { GeoJsonFeature, GeoJsonFeatureCollection, GeoJsonGeometry, GeoJsonLineString, GeoJsonMultiLineString, GeoJsonMultiPoint, GeoJsonMultiPolygon, GeoJsonPoint, GeoJsonPolygon, GeometryInput, LinearUnit, } from "./types.js";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/geometry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,QAAQ,EACR,MAAM,EACN,UAAU,EACV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,KAAK,GACN,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElF,YAAY,EACV,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@honua/geometry` — curated, tree-shakeable client-side geometry operations
3
+ * for the Honua SDK.
4
+ *
5
+ * This subpath (`@honua/sdk-js/geometry`, split-packaged as `@honua/geometry`)
6
+ * wraps the individual `@turf/*` packages and `proj4`, typed against the SDK's
7
+ * own GeoJSON contract. Importing a single op only pulls that op's turf backing
8
+ * into a consumer bundle; the core SDK never imports this module, so core-only
9
+ * consumers never pay for turf/proj4.
10
+ *
11
+ * @module
12
+ */
13
+ export { area, bbox, booleanContains, booleanIntersects, booleanWithin, buffer, centroid, convex, difference, intersect, length, nearestPoint, simplify, union, } from "./ops.js";
14
+ export { defineProjection, normalizeCrs, project, toWebMercator, toWgs84 } from "./project.js";
15
+ export { esriFeatureToGeoJson, esriToGeoJson, geoJsonToEsri } from "./convert.js";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Internal bridge between the SDK's GeoJSON contract types and the `geojson`
3
+ * declarations that the `@turf/*` packages are typed against. The two are
4
+ * structurally identical for the primitive geometry types the geometry package
5
+ * supports, so the conversions are erased casts — kept in one place so the ops
6
+ * modules stay free of scattered `as unknown as` noise.
7
+ *
8
+ * @internal
9
+ * @module
10
+ */
11
+ import type { Feature as TurfFeature, FeatureCollection as TurfFeatureCollection, Geometry as TurfGeometry } from "geojson";
12
+ import type { GeoJsonFeature } from "../core/types.js";
13
+ import type { GeoJsonGeometry } from "../expr/expression.js";
14
+ import type { GeometryInput } from "./types.js";
15
+ /** Narrow an input to its bare geometry, unwrapping a `Feature` if needed. */
16
+ export declare function inputToGeometry(input: GeometryInput): GeoJsonGeometry;
17
+ /** Present an SDK geometry to turf as a `geojson` geometry. */
18
+ export declare function toTurfGeometry(geometry: GeoJsonGeometry): TurfGeometry;
19
+ /** Present an SDK geometry input to turf as a `geojson` value. */
20
+ export declare function toTurfInput(input: GeometryInput): TurfFeature | TurfFeatureCollection | TurfGeometry;
21
+ /** Convert a turf geometry back into an SDK geometry. */
22
+ export declare function fromTurfGeometry(geometry: TurfGeometry): GeoJsonGeometry;
23
+ /** Convert a turf feature back into an SDK feature. */
24
+ export declare function fromTurfFeature(feature: TurfFeature): GeoJsonFeature;
25
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/geometry/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,OAAO,IAAI,WAAW,EACtB,iBAAiB,IAAI,qBAAqB,EAC1C,QAAQ,IAAI,YAAY,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,eAAe,CAYrE;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,YAAY,CAEtE;AAED,kEAAkE;AAClE,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,GAAG,qBAAqB,GAAG,YAAY,CAEpG;AAED,yDAAyD;AACzD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,eAAe,CAExE;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAEpE"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Internal bridge between the SDK's GeoJSON contract types and the `geojson`
3
+ * declarations that the `@turf/*` packages are typed against. The two are
4
+ * structurally identical for the primitive geometry types the geometry package
5
+ * supports, so the conversions are erased casts — kept in one place so the ops
6
+ * modules stay free of scattered `as unknown as` noise.
7
+ *
8
+ * @internal
9
+ * @module
10
+ */
11
+ /** Narrow an input to its bare geometry, unwrapping a `Feature` if needed. */
12
+ export function inputToGeometry(input) {
13
+ if (input.type === "Feature") {
14
+ const geometry = input.geometry;
15
+ if (!geometry) {
16
+ throw new TypeError("@honua/geometry: feature has no geometry");
17
+ }
18
+ return geometry;
19
+ }
20
+ if (input.type === "FeatureCollection") {
21
+ throw new TypeError("@honua/geometry: expected a geometry or Feature, received a FeatureCollection");
22
+ }
23
+ return input;
24
+ }
25
+ /** Present an SDK geometry to turf as a `geojson` geometry. */
26
+ export function toTurfGeometry(geometry) {
27
+ return geometry;
28
+ }
29
+ /** Present an SDK geometry input to turf as a `geojson` value. */
30
+ export function toTurfInput(input) {
31
+ return input;
32
+ }
33
+ /** Convert a turf geometry back into an SDK geometry. */
34
+ export function fromTurfGeometry(geometry) {
35
+ return geometry;
36
+ }
37
+ /** Convert a turf feature back into an SDK feature. */
38
+ export function fromTurfFeature(feature) {
39
+ return feature;
40
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Curated, tree-shakeable wrappers over the individual `@turf/*` packages,
3
+ * typed against the SDK's GeoJSON contract.
4
+ *
5
+ * Each function wraps exactly one turf package so a consumer importing a single
6
+ * op (e.g. `import { buffer } from "@honua/geometry"`) only pulls that op's turf
7
+ * dependency into their bundle. Nothing here is reimplemented — the algorithms
8
+ * live in turf; this module only adapts types and defaults.
9
+ *
10
+ * All turf area/length/buffer math is **geodesic** (great-circle on a sphere)
11
+ * and assumes coordinates are WGS84 longitude/latitude degrees, matching turf's
12
+ * contract. See `docs/geometry.md` for the planar-vs-geodesic caveats that
13
+ * matter when bridging Esri geometries.
14
+ *
15
+ * @module
16
+ */
17
+ import type { GeoJsonFeature } from "../core/types.js";
18
+ import type { GeoJsonGeometry, GeoJsonPoint } from "../expr/expression.js";
19
+ import type { GeometryInput, LinearUnit } from "./types.js";
20
+ /**
21
+ * Buffer a geometry by `radius` (default unit: meters). Wraps `@turf/buffer`.
22
+ * Returns `null` when turf cannot produce a buffer (e.g. an empty geometry).
23
+ */
24
+ export declare function buffer(input: GeometryInput, radius: number, unit?: LinearUnit): GeoJsonGeometry | null;
25
+ /** Geodesic area of a polygonal geometry in square meters. Wraps `@turf/area`. */
26
+ export declare function area(input: GeometryInput): number;
27
+ /**
28
+ * Geodesic length of a line (or polygon perimeter) in `unit` (default meters).
29
+ * Wraps `@turf/length`.
30
+ */
31
+ export declare function length(input: GeometryInput, unit?: LinearUnit): number;
32
+ /** Centroid of a geometry as a GeoJSON `Point`. Wraps `@turf/centroid`. */
33
+ export declare function centroid(input: GeometryInput): GeoJsonPoint;
34
+ /** Bounding box `[minX, minY, maxX, maxY]` of a geometry. Wraps `@turf/bbox`. */
35
+ export declare function bbox(input: GeometryInput): [number, number, number, number];
36
+ /**
37
+ * Ramer–Douglas–Peucker simplification. `tolerance` is in the geometry's
38
+ * coordinate units; `highQuality` trades speed for fidelity. Wraps
39
+ * `@turf/simplify`.
40
+ */
41
+ export declare function simplify(input: GeometryInput, tolerance: number, highQuality?: boolean): GeoJsonGeometry;
42
+ /** True if `a` and `b` share any point. Wraps `@turf/boolean-intersects`. */
43
+ export declare function booleanIntersects(a: GeometryInput, b: GeometryInput): boolean;
44
+ /** True if `a` completely contains `b`. Wraps `@turf/boolean-contains`. */
45
+ export declare function booleanContains(a: GeometryInput, b: GeometryInput): boolean;
46
+ /** True if `a` is completely within `b`. Wraps `@turf/boolean-within`. */
47
+ export declare function booleanWithin(a: GeometryInput, b: GeometryInput): boolean;
48
+ /**
49
+ * Polygon union of two or more polygonal geometries. Wraps `@turf/union`.
50
+ * Returns `null` when the inputs do not combine into a polygon.
51
+ */
52
+ export declare function union(...polygons: readonly GeometryInput[]): GeoJsonGeometry | null;
53
+ /**
54
+ * Polygon intersection of two polygonal geometries. Wraps `@turf/intersect`.
55
+ * Returns `null` when the polygons do not overlap.
56
+ */
57
+ export declare function intersect(a: GeometryInput, b: GeometryInput): GeoJsonGeometry | null;
58
+ /**
59
+ * Polygon difference `a − b`. Wraps `@turf/difference`. Returns `null` when the
60
+ * subtraction removes the whole polygon.
61
+ */
62
+ export declare function difference(a: GeometryInput, b: GeometryInput): GeoJsonGeometry | null;
63
+ /** Convex hull of a geometry. Wraps `@turf/convex`. Returns `null` if undefined. */
64
+ export declare function convex(input: GeometryInput): GeoJsonGeometry | null;
65
+ /**
66
+ * Nearest point in `points` to `target`, as a GeoJSON `Feature<Point>` carrying
67
+ * turf's `featureIndex` / `distanceToPoint` properties. Wraps
68
+ * `@turf/nearest-point`.
69
+ */
70
+ export declare function nearestPoint(target: GeoJsonPoint, points: readonly GeoJsonPoint[]): GeoJsonFeature;
71
+ //# sourceMappingURL=ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../../src/geometry/ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAmB5D;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,UAAqB,GAAG,eAAe,GAAG,IAAI,CAUhH;AAED,kFAAkF;AAClF,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAEjD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,GAAE,UAAqB,GAAG,MAAM,CAEhF;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,CAE3D;AAED,iFAAiF;AACjF,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAG3E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,eAAe,CAItG;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAE7E;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAE3E;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAEzE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,eAAe,GAAG,IAAI,CAMnF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI,CAGpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI,CAGrF;AAED,oFAAoF;AACpF,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,cAAc,CAWlG"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Curated, tree-shakeable wrappers over the individual `@turf/*` packages,
3
+ * typed against the SDK's GeoJSON contract.
4
+ *
5
+ * Each function wraps exactly one turf package so a consumer importing a single
6
+ * op (e.g. `import { buffer } from "@honua/geometry"`) only pulls that op's turf
7
+ * dependency into their bundle. Nothing here is reimplemented — the algorithms
8
+ * live in turf; this module only adapts types and defaults.
9
+ *
10
+ * All turf area/length/buffer math is **geodesic** (great-circle on a sphere)
11
+ * and assumes coordinates are WGS84 longitude/latitude degrees, matching turf's
12
+ * contract. See `docs/geometry.md` for the planar-vs-geodesic caveats that
13
+ * matter when bridging Esri geometries.
14
+ *
15
+ * @module
16
+ */
17
+ import { area as turfArea } from "@turf/area";
18
+ import { bbox as turfBbox } from "@turf/bbox";
19
+ import { booleanContains as turfBooleanContains } from "@turf/boolean-contains";
20
+ import { booleanIntersects as turfBooleanIntersects } from "@turf/boolean-intersects";
21
+ import { booleanWithin as turfBooleanWithin } from "@turf/boolean-within";
22
+ import { buffer as turfBuffer } from "@turf/buffer";
23
+ import { centroid as turfCentroid } from "@turf/centroid";
24
+ import { convex as turfConvex } from "@turf/convex";
25
+ import { difference as turfDifference } from "@turf/difference";
26
+ import { intersect as turfIntersect } from "@turf/intersect";
27
+ import { length as turfLength } from "@turf/length";
28
+ import { nearestPoint as turfNearestPoint } from "@turf/nearest-point";
29
+ import { simplify as turfSimplify } from "@turf/simplify";
30
+ import { union as turfUnion } from "@turf/union";
31
+ import { fromTurfFeature, fromTurfGeometry, inputToGeometry, toTurfGeometry, toTurfInput } from "./internal.js";
32
+ function toPolygonFeatureCollection(inputs) {
33
+ return {
34
+ type: "FeatureCollection",
35
+ features: inputs.map((input) => ({
36
+ type: "Feature",
37
+ properties: {},
38
+ geometry: toTurfGeometry(inputToGeometry(input)),
39
+ })),
40
+ };
41
+ }
42
+ /**
43
+ * Buffer a geometry by `radius` (default unit: meters). Wraps `@turf/buffer`.
44
+ * Returns `null` when turf cannot produce a buffer (e.g. an empty geometry).
45
+ */
46
+ export function buffer(input, radius, unit = "meters") {
47
+ // A single Feature/Geometry input yields a single buffered Feature (never a
48
+ // collection), so the return narrows to `Feature | undefined`.
49
+ const feature = {
50
+ type: "Feature",
51
+ properties: {},
52
+ geometry: toTurfGeometry(inputToGeometry(input)),
53
+ };
54
+ const result = turfBuffer(feature, radius, { units: unit });
55
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
56
+ }
57
+ /** Geodesic area of a polygonal geometry in square meters. Wraps `@turf/area`. */
58
+ export function area(input) {
59
+ return turfArea(toTurfInput(input));
60
+ }
61
+ /**
62
+ * Geodesic length of a line (or polygon perimeter) in `unit` (default meters).
63
+ * Wraps `@turf/length`.
64
+ */
65
+ export function length(input, unit = "meters") {
66
+ return turfLength(toTurfInput(input), { units: unit });
67
+ }
68
+ /** Centroid of a geometry as a GeoJSON `Point`. Wraps `@turf/centroid`. */
69
+ export function centroid(input) {
70
+ return fromTurfGeometry(turfCentroid(toTurfInput(input)).geometry);
71
+ }
72
+ /** Bounding box `[minX, minY, maxX, maxY]` of a geometry. Wraps `@turf/bbox`. */
73
+ export function bbox(input) {
74
+ const [minX, minY, maxX, maxY] = turfBbox(toTurfInput(input));
75
+ return [minX, minY, maxX, maxY];
76
+ }
77
+ /**
78
+ * Ramer–Douglas–Peucker simplification. `tolerance` is in the geometry's
79
+ * coordinate units; `highQuality` trades speed for fidelity. Wraps
80
+ * `@turf/simplify`.
81
+ */
82
+ export function simplify(input, tolerance, highQuality = false) {
83
+ const geometry = toTurfGeometry(inputToGeometry(input));
84
+ const simplified = turfSimplify(geometry, { tolerance, highQuality, mutate: false });
85
+ return fromTurfGeometry(simplified);
86
+ }
87
+ /** True if `a` and `b` share any point. Wraps `@turf/boolean-intersects`. */
88
+ export function booleanIntersects(a, b) {
89
+ return turfBooleanIntersects(toTurfGeometry(inputToGeometry(a)), toTurfGeometry(inputToGeometry(b)));
90
+ }
91
+ /** True if `a` completely contains `b`. Wraps `@turf/boolean-contains`. */
92
+ export function booleanContains(a, b) {
93
+ return turfBooleanContains(toTurfGeometry(inputToGeometry(a)), toTurfGeometry(inputToGeometry(b)));
94
+ }
95
+ /** True if `a` is completely within `b`. Wraps `@turf/boolean-within`. */
96
+ export function booleanWithin(a, b) {
97
+ return turfBooleanWithin(toTurfGeometry(inputToGeometry(a)), toTurfGeometry(inputToGeometry(b)));
98
+ }
99
+ /**
100
+ * Polygon union of two or more polygonal geometries. Wraps `@turf/union`.
101
+ * Returns `null` when the inputs do not combine into a polygon.
102
+ */
103
+ export function union(...polygons) {
104
+ if (polygons.length === 0) {
105
+ return null;
106
+ }
107
+ const result = turfUnion(toPolygonFeatureCollection(polygons));
108
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
109
+ }
110
+ /**
111
+ * Polygon intersection of two polygonal geometries. Wraps `@turf/intersect`.
112
+ * Returns `null` when the polygons do not overlap.
113
+ */
114
+ export function intersect(a, b) {
115
+ const result = turfIntersect(toPolygonFeatureCollection([a, b]));
116
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
117
+ }
118
+ /**
119
+ * Polygon difference `a − b`. Wraps `@turf/difference`. Returns `null` when the
120
+ * subtraction removes the whole polygon.
121
+ */
122
+ export function difference(a, b) {
123
+ const result = turfDifference(toPolygonFeatureCollection([a, b]));
124
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
125
+ }
126
+ /** Convex hull of a geometry. Wraps `@turf/convex`. Returns `null` if undefined. */
127
+ export function convex(input) {
128
+ const result = turfConvex(toTurfInput(input));
129
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
130
+ }
131
+ /**
132
+ * Nearest point in `points` to `target`, as a GeoJSON `Feature<Point>` carrying
133
+ * turf's `featureIndex` / `distanceToPoint` properties. Wraps
134
+ * `@turf/nearest-point`.
135
+ */
136
+ export function nearestPoint(target, points) {
137
+ const collection = {
138
+ type: "FeatureCollection",
139
+ features: points.map((point) => ({
140
+ type: "Feature",
141
+ properties: {},
142
+ geometry: toTurfGeometry(point),
143
+ })),
144
+ };
145
+ const nearest = turfNearestPoint(toTurfGeometry(target), collection);
146
+ return fromTurfFeature(nearest);
147
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Reprojection helpers backed by `proj4`.
3
+ *
4
+ * Only EPSG:4326 (WGS84) and EPSG:3857 (Web Mercator) are needed by default —
5
+ * both are built into proj4, so this module registers **nothing** at import
6
+ * time and stays side-effect-free for tree-shaking. Additional coordinate
7
+ * systems are registered on demand via {@link defineProjection}.
8
+ *
9
+ * @module
10
+ */
11
+ import type { GeoJsonGeometry } from "../expr/expression.js";
12
+ import type { GeometryInput } from "./types.js";
13
+ /**
14
+ * Normalize a CRS identifier into a proj4-resolvable string. Accepts:
15
+ * - a numeric EPSG code (`4326`, `102100`),
16
+ * - an `"EPSG:xxxx"` string,
17
+ * - a raw proj4/WKT definition string (passed through untouched).
18
+ */
19
+ export declare function normalizeCrs(code: number | string): string;
20
+ /**
21
+ * Register a coordinate system so {@link project} (and the `toWgs84` /
22
+ * `toWebMercator` fast paths) can resolve it. Idempotent; safe to call at app
23
+ * startup or lazily before the first `project` call.
24
+ *
25
+ * @param code EPSG code or name to register the definition under.
26
+ * @param proj4def A proj4 or WKT definition string.
27
+ */
28
+ export declare function defineProjection(code: number | string, proj4def: string): void;
29
+ /**
30
+ * Reproject a geometry from `fromCrs` to `toCrs`. CRS arguments accept EPSG
31
+ * codes, `"EPSG:xxxx"` strings, or raw proj4 definitions. Returns a new
32
+ * geometry; the input is never mutated. A no-op (deep clone) when the two CRS
33
+ * resolve to the same definition.
34
+ */
35
+ export declare function project(input: GeometryInput, fromCrs: number | string, toCrs: number | string): GeoJsonGeometry;
36
+ /** Fast path: reproject a geometry from `fromCrs` into WGS84 (EPSG:4326). */
37
+ export declare function toWgs84(input: GeometryInput, fromCrs: number | string): GeoJsonGeometry;
38
+ /** Fast path: reproject a geometry from `fromCrs` into Web Mercator (EPSG:3857). */
39
+ export declare function toWebMercator(input: GeometryInput, fromCrs: number | string): GeoJsonGeometry;
40
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/geometry/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAc1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9E;AAqBD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAY/G;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAEvF;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAE7F"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Reprojection helpers backed by `proj4`.
3
+ *
4
+ * Only EPSG:4326 (WGS84) and EPSG:3857 (Web Mercator) are needed by default —
5
+ * both are built into proj4, so this module registers **nothing** at import
6
+ * time and stays side-effect-free for tree-shaking. Additional coordinate
7
+ * systems are registered on demand via {@link defineProjection}.
8
+ *
9
+ * @module
10
+ */
11
+ import proj4 from "proj4";
12
+ import { inputToGeometry } from "./internal.js";
13
+ /** EPSG codes that are aliases for Web Mercator across Esri/OGC usage. */
14
+ const WEB_MERCATOR_ALIASES = new Set([3857, 3785, 900913, 102100, 102113]);
15
+ /**
16
+ * Normalize a CRS identifier into a proj4-resolvable string. Accepts:
17
+ * - a numeric EPSG code (`4326`, `102100`),
18
+ * - an `"EPSG:xxxx"` string,
19
+ * - a raw proj4/WKT definition string (passed through untouched).
20
+ */
21
+ export function normalizeCrs(code) {
22
+ if (typeof code === "number") {
23
+ return WEB_MERCATOR_ALIASES.has(code) ? "EPSG:3857" : `EPSG:${code}`;
24
+ }
25
+ const trimmed = code.trim();
26
+ // A definition string (proj4 or WKT), not a code — hand it to proj4 as-is.
27
+ if (trimmed.includes("+proj") || trimmed.includes("PROJCS") || trimmed.includes("GEOGCS")) {
28
+ return trimmed;
29
+ }
30
+ const epsgMatch = /^epsg:(\d+)$/i.exec(trimmed);
31
+ if (epsgMatch) {
32
+ return normalizeCrs(Number(epsgMatch[1]));
33
+ }
34
+ return trimmed;
35
+ }
36
+ /**
37
+ * Register a coordinate system so {@link project} (and the `toWgs84` /
38
+ * `toWebMercator` fast paths) can resolve it. Idempotent; safe to call at app
39
+ * startup or lazily before the first `project` call.
40
+ *
41
+ * @param code EPSG code or name to register the definition under.
42
+ * @param proj4def A proj4 or WKT definition string.
43
+ */
44
+ export function defineProjection(code, proj4def) {
45
+ proj4.defs(normalizeCrs(code), proj4def);
46
+ }
47
+ function projectPosition(position, converter) {
48
+ const [x, y, ...rest] = position;
49
+ const projected = converter.forward([x, y]);
50
+ return [projected[0], projected[1], ...rest];
51
+ }
52
+ function projectCoordinates(coordinates, converter) {
53
+ if (!Array.isArray(coordinates)) {
54
+ return coordinates;
55
+ }
56
+ // A bare position is an array of finite numbers.
57
+ if (typeof coordinates[0] === "number") {
58
+ return projectPosition(coordinates, converter);
59
+ }
60
+ return coordinates.map((entry) => projectCoordinates(entry, converter));
61
+ }
62
+ /**
63
+ * Reproject a geometry from `fromCrs` to `toCrs`. CRS arguments accept EPSG
64
+ * codes, `"EPSG:xxxx"` strings, or raw proj4 definitions. Returns a new
65
+ * geometry; the input is never mutated. A no-op (deep clone) when the two CRS
66
+ * resolve to the same definition.
67
+ */
68
+ export function project(input, fromCrs, toCrs) {
69
+ const geometry = inputToGeometry(input);
70
+ const from = normalizeCrs(fromCrs);
71
+ const to = normalizeCrs(toCrs);
72
+ if (from === to) {
73
+ return structuredClone(geometry);
74
+ }
75
+ const converter = proj4(from, to);
76
+ return {
77
+ ...geometry,
78
+ coordinates: projectCoordinates(geometry.coordinates, converter),
79
+ };
80
+ }
81
+ /** Fast path: reproject a geometry from `fromCrs` into WGS84 (EPSG:4326). */
82
+ export function toWgs84(input, fromCrs) {
83
+ return project(input, fromCrs, "EPSG:4326");
84
+ }
85
+ /** Fast path: reproject a geometry from `fromCrs` into Web Mercator (EPSG:3857). */
86
+ export function toWebMercator(input, fromCrs) {
87
+ return project(input, fromCrs, "EPSG:3857");
88
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Public GeoJSON and unit types for `@honua/geometry`.
3
+ *
4
+ * The geometry operations are typed against the SDK's own GeoJSON contract
5
+ * (`src/expr/expression.ts` geometry union + `src/core/types.ts`
6
+ * {@link GeoJsonFeature}) rather than pulling in the `@types/geojson`
7
+ * declarations as a public surface. Internally the turf wrappers bridge to the
8
+ * `geojson` types, but consumers only ever see Honua's own types.
9
+ *
10
+ * @module
11
+ */
12
+ export type { GeoJsonGeometry, GeoJsonPoint, GeoJsonMultiPoint, GeoJsonLineString, GeoJsonMultiLineString, GeoJsonPolygon, GeoJsonMultiPolygon, } from "../expr/expression.js";
13
+ export type { GeoJsonFeature } from "../core/types.js";
14
+ import type { GeoJsonFeature } from "../core/types.js";
15
+ import type { GeoJsonGeometry } from "../expr/expression.js";
16
+ /**
17
+ * A GeoJSON `FeatureCollection` typed against the SDK feature type. The SDK
18
+ * contract intentionally ships only `GeoJsonFeature`; the geometry package adds
19
+ * the collection wrapper it needs for union/nearest-point style operations.
20
+ */
21
+ export interface GeoJsonFeatureCollection {
22
+ type: "FeatureCollection";
23
+ features: GeoJsonFeature[];
24
+ }
25
+ /**
26
+ * Anything the geometry ops accept as an input shape: a bare geometry, a
27
+ * `Feature`, or a `FeatureCollection`. Operations always return the SDK
28
+ * geometry (or feature) types.
29
+ */
30
+ export type GeometryInput = GeoJsonGeometry | GeoJsonFeature | GeoJsonFeatureCollection;
31
+ /**
32
+ * Linear distance units understood by {@link buffer} and {@link length}. This is
33
+ * the subset of turf's unit vocabulary that has an unambiguous geodesic meaning.
34
+ */
35
+ export type LinearUnit = "meters" | "kilometers" | "miles" | "feet" | "yards" | "nauticalmiles";
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/geometry/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,GAAG,wBAAwB,CAAC;AAExF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAC"}