@honua/sdk-esri-compat 0.0.6-alpha.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 (289) hide show
  1. package/README.md +5 -0
  2. package/contract/edit-session.d.ts +203 -0
  3. package/contract/edit-session.d.ts.map +1 -0
  4. package/contract/edit-session.js +717 -0
  5. package/contract/index.d.ts +20 -0
  6. package/contract/index.d.ts.map +1 -0
  7. package/contract/index.js +15 -0
  8. package/contract/jobs.d.ts +115 -0
  9. package/contract/jobs.d.ts.map +1 -0
  10. package/contract/jobs.js +22 -0
  11. package/contract/source.d.ts +138 -0
  12. package/contract/source.d.ts.map +1 -0
  13. package/contract/source.js +3364 -0
  14. package/contract/spatial-aggregation.d.ts +312 -0
  15. package/contract/spatial-aggregation.d.ts.map +1 -0
  16. package/contract/spatial-aggregation.js +196 -0
  17. package/contract/types.d.ts +542 -0
  18. package/contract/types.d.ts.map +1 -0
  19. package/contract/types.js +171 -0
  20. package/core/batch.d.ts +37 -0
  21. package/core/batch.d.ts.map +1 -0
  22. package/core/batch.js +78 -0
  23. package/core/cache-state.d.ts +76 -0
  24. package/core/cache-state.d.ts.map +1 -0
  25. package/core/cache-state.js +84 -0
  26. package/core/client.d.ts +289 -0
  27. package/core/client.d.ts.map +1 -0
  28. package/core/client.js +2625 -0
  29. package/core/errors.d.ts +68 -0
  30. package/core/errors.d.ts.map +1 -0
  31. package/core/errors.js +116 -0
  32. package/core/grpc-adapter.d.ts +23 -0
  33. package/core/grpc-adapter.d.ts.map +1 -0
  34. package/core/grpc-adapter.js +704 -0
  35. package/core/odata.d.ts +347 -0
  36. package/core/odata.d.ts.map +1 -0
  37. package/core/odata.js +837 -0
  38. package/core/ogc-conformance.d.ts +35 -0
  39. package/core/ogc-conformance.d.ts.map +1 -0
  40. package/core/ogc-conformance.js +121 -0
  41. package/core/ogc-maps.d.ts +45 -0
  42. package/core/ogc-maps.d.ts.map +1 -0
  43. package/core/ogc-maps.js +53 -0
  44. package/core/ogc-processes.d.ts +92 -0
  45. package/core/ogc-processes.d.ts.map +1 -0
  46. package/core/ogc-processes.js +325 -0
  47. package/core/ogc-tiles.d.ts +55 -0
  48. package/core/ogc-tiles.d.ts.map +1 -0
  49. package/core/ogc-tiles.js +81 -0
  50. package/core/pbf-decoder.d.ts +28 -0
  51. package/core/pbf-decoder.d.ts.map +1 -0
  52. package/core/pbf-decoder.js +627 -0
  53. package/core/query-builder.d.ts +261 -0
  54. package/core/query-builder.d.ts.map +1 -0
  55. package/core/query-builder.js +538 -0
  56. package/core/spatial-filter.d.ts +93 -0
  57. package/core/spatial-filter.d.ts.map +1 -0
  58. package/core/spatial-filter.js +153 -0
  59. package/core/stac.d.ts +43 -0
  60. package/core/stac.d.ts.map +1 -0
  61. package/core/stac.js +116 -0
  62. package/core/surfaces.d.ts +464 -0
  63. package/core/surfaces.d.ts.map +1 -0
  64. package/core/surfaces.js +1322 -0
  65. package/core/types.d.ts +1238 -0
  66. package/core/types.d.ts.map +1 -0
  67. package/core/types.js +13 -0
  68. package/core/wfs-capabilities.d.ts +143 -0
  69. package/core/wfs-capabilities.d.ts.map +1 -0
  70. package/core/wfs-capabilities.js +478 -0
  71. package/core/wfs-filter.d.ts +118 -0
  72. package/core/wfs-filter.d.ts.map +1 -0
  73. package/core/wfs-filter.js +586 -0
  74. package/core/wfs.d.ts +219 -0
  75. package/core/wfs.d.ts.map +1 -0
  76. package/core/wfs.js +406 -0
  77. package/core/wms-capabilities.d.ts +110 -0
  78. package/core/wms-capabilities.d.ts.map +1 -0
  79. package/core/wms-capabilities.js +566 -0
  80. package/core/wms-types.d.ts +128 -0
  81. package/core/wms-types.d.ts.map +1 -0
  82. package/core/wms-types.js +32 -0
  83. package/core/wms.d.ts +108 -0
  84. package/core/wms.d.ts.map +1 -0
  85. package/core/wms.js +182 -0
  86. package/core/wmts-capabilities.d.ts +82 -0
  87. package/core/wmts-capabilities.d.ts.map +1 -0
  88. package/core/wmts-capabilities.js +409 -0
  89. package/core/wmts.d.ts +80 -0
  90. package/core/wmts.d.ts.map +1 -0
  91. package/core/wmts.js +173 -0
  92. package/esri-compat/basemap-gallery.d.ts +38 -0
  93. package/esri-compat/basemap-gallery.d.ts.map +1 -0
  94. package/esri-compat/basemap-gallery.js +159 -0
  95. package/esri-compat/basemap-layer-list.d.ts +35 -0
  96. package/esri-compat/basemap-layer-list.d.ts.map +1 -0
  97. package/esri-compat/basemap-layer-list.js +139 -0
  98. package/esri-compat/basemap.d.ts +32 -0
  99. package/esri-compat/basemap.d.ts.map +1 -0
  100. package/esri-compat/basemap.js +84 -0
  101. package/esri-compat/bookmarks.d.ts +36 -0
  102. package/esri-compat/bookmarks.d.ts.map +1 -0
  103. package/esri-compat/bookmarks.js +108 -0
  104. package/esri-compat/class-breaks-renderer.d.ts +50 -0
  105. package/esri-compat/class-breaks-renderer.d.ts.map +1 -0
  106. package/esri-compat/class-breaks-renderer.js +164 -0
  107. package/esri-compat/color.d.ts +22 -0
  108. package/esri-compat/color.d.ts.map +1 -0
  109. package/esri-compat/color.js +106 -0
  110. package/esri-compat/controls.d.ts +174 -0
  111. package/esri-compat/controls.d.ts.map +1 -0
  112. package/esri-compat/controls.js +479 -0
  113. package/esri-compat/coordinate-conversion.d.ts +41 -0
  114. package/esri-compat/coordinate-conversion.d.ts.map +1 -0
  115. package/esri-compat/coordinate-conversion.js +125 -0
  116. package/esri-compat/directions.d.ts +45 -0
  117. package/esri-compat/directions.d.ts.map +1 -0
  118. package/esri-compat/directions.js +123 -0
  119. package/esri-compat/editor.d.ts +47 -0
  120. package/esri-compat/editor.d.ts.map +1 -0
  121. package/esri-compat/editor.js +170 -0
  122. package/esri-compat/esri-config.d.ts +16 -0
  123. package/esri-compat/esri-config.d.ts.map +1 -0
  124. package/esri-compat/esri-config.js +23 -0
  125. package/esri-compat/esri-request.d.ts +17 -0
  126. package/esri-compat/esri-request.d.ts.map +1 -0
  127. package/esri-compat/esri-request.js +66 -0
  128. package/esri-compat/event-bus.d.ts +106 -0
  129. package/esri-compat/event-bus.d.ts.map +1 -0
  130. package/esri-compat/event-bus.js +90 -0
  131. package/esri-compat/expand.d.ts +36 -0
  132. package/esri-compat/expand.d.ts.map +1 -0
  133. package/esri-compat/expand.js +97 -0
  134. package/esri-compat/extent.d.ts +43 -0
  135. package/esri-compat/extent.d.ts.map +1 -0
  136. package/esri-compat/extent.js +140 -0
  137. package/esri-compat/feature-form.d.ts +64 -0
  138. package/esri-compat/feature-form.d.ts.map +1 -0
  139. package/esri-compat/feature-form.js +137 -0
  140. package/esri-compat/feature-layer.d.ts +173 -0
  141. package/esri-compat/feature-layer.d.ts.map +1 -0
  142. package/esri-compat/feature-layer.js +655 -0
  143. package/esri-compat/feature-set.d.ts +32 -0
  144. package/esri-compat/feature-set.d.ts.map +1 -0
  145. package/esri-compat/feature-set.js +80 -0
  146. package/esri-compat/feature-table.d.ts +141 -0
  147. package/esri-compat/feature-table.d.ts.map +1 -0
  148. package/esri-compat/feature-table.js +500 -0
  149. package/esri-compat/feature-templates.d.ts +41 -0
  150. package/esri-compat/feature-templates.d.ts.map +1 -0
  151. package/esri-compat/feature-templates.js +97 -0
  152. package/esri-compat/feature.d.ts +33 -0
  153. package/esri-compat/feature.d.ts.map +1 -0
  154. package/esri-compat/feature.js +83 -0
  155. package/esri-compat/graphic.d.ts +46 -0
  156. package/esri-compat/graphic.d.ts.map +1 -0
  157. package/esri-compat/graphic.js +103 -0
  158. package/esri-compat/graphics-layer.d.ts +49 -0
  159. package/esri-compat/graphics-layer.d.ts.map +1 -0
  160. package/esri-compat/graphics-layer.js +185 -0
  161. package/esri-compat/group-layer.d.ts +48 -0
  162. package/esri-compat/group-layer.d.ts.map +1 -0
  163. package/esri-compat/group-layer.js +212 -0
  164. package/esri-compat/identify.d.ts +71 -0
  165. package/esri-compat/identify.d.ts.map +1 -0
  166. package/esri-compat/identify.js +299 -0
  167. package/esri-compat/identity-manager.d.ts +31 -0
  168. package/esri-compat/identity-manager.d.ts.map +1 -0
  169. package/esri-compat/identity-manager.js +115 -0
  170. package/esri-compat/label-class.d.ts +31 -0
  171. package/esri-compat/label-class.d.ts.map +1 -0
  172. package/esri-compat/label-class.js +102 -0
  173. package/esri-compat/layer-list.d.ts +77 -0
  174. package/esri-compat/layer-list.d.ts.map +1 -0
  175. package/esri-compat/layer-list.js +342 -0
  176. package/esri-compat/legend.d.ts +53 -0
  177. package/esri-compat/legend.d.ts.map +1 -0
  178. package/esri-compat/legend.js +254 -0
  179. package/esri-compat/map-image-layer.d.ts +162 -0
  180. package/esri-compat/map-image-layer.d.ts.map +1 -0
  181. package/esri-compat/map-image-layer.js +704 -0
  182. package/esri-compat/map-view.d.ts +315 -0
  183. package/esri-compat/map-view.d.ts.map +1 -0
  184. package/esri-compat/map-view.js +1110 -0
  185. package/esri-compat/map.d.ts +47 -0
  186. package/esri-compat/map.d.ts.map +1 -0
  187. package/esri-compat/map.js +209 -0
  188. package/esri-compat/measurement-2d.d.ts +61 -0
  189. package/esri-compat/measurement-2d.d.ts.map +1 -0
  190. package/esri-compat/measurement-2d.js +184 -0
  191. package/esri-compat/measurement.d.ts +45 -0
  192. package/esri-compat/measurement.d.ts.map +1 -0
  193. package/esri-compat/measurement.js +193 -0
  194. package/esri-compat/oauth-info.d.ts +35 -0
  195. package/esri-compat/oauth-info.d.ts.map +1 -0
  196. package/esri-compat/oauth-info.js +115 -0
  197. package/esri-compat/picture-marker-symbol.d.ts +35 -0
  198. package/esri-compat/picture-marker-symbol.d.ts.map +1 -0
  199. package/esri-compat/picture-marker-symbol.js +126 -0
  200. package/esri-compat/point.d.ts +31 -0
  201. package/esri-compat/point.d.ts.map +1 -0
  202. package/esri-compat/point.js +102 -0
  203. package/esri-compat/polygon.d.ts +31 -0
  204. package/esri-compat/polygon.d.ts.map +1 -0
  205. package/esri-compat/polygon.js +107 -0
  206. package/esri-compat/polyline.d.ts +31 -0
  207. package/esri-compat/polyline.d.ts.map +1 -0
  208. package/esri-compat/polyline.js +107 -0
  209. package/esri-compat/popup-template.d.ts +55 -0
  210. package/esri-compat/popup-template.d.ts.map +1 -0
  211. package/esri-compat/popup-template.js +128 -0
  212. package/esri-compat/popup.d.ts +54 -0
  213. package/esri-compat/popup.d.ts.map +1 -0
  214. package/esri-compat/popup.js +312 -0
  215. package/esri-compat/print.d.ts +47 -0
  216. package/esri-compat/print.d.ts.map +1 -0
  217. package/esri-compat/print.js +105 -0
  218. package/esri-compat/query.d.ts +46 -0
  219. package/esri-compat/query.d.ts.map +1 -0
  220. package/esri-compat/query.js +119 -0
  221. package/esri-compat/reactive-utils.d.ts +23 -0
  222. package/esri-compat/reactive-utils.d.ts.map +1 -0
  223. package/esri-compat/reactive-utils.js +178 -0
  224. package/esri-compat/request.d.ts +41 -0
  225. package/esri-compat/request.d.ts.map +1 -0
  226. package/esri-compat/request.js +253 -0
  227. package/esri-compat/route-layer.d.ts +59 -0
  228. package/esri-compat/route-layer.d.ts.map +1 -0
  229. package/esri-compat/route-layer.js +223 -0
  230. package/esri-compat/route-task.d.ts +88 -0
  231. package/esri-compat/route-task.d.ts.map +1 -0
  232. package/esri-compat/route-task.js +225 -0
  233. package/esri-compat/scene-view.d.ts +41 -0
  234. package/esri-compat/scene-view.d.ts.map +1 -0
  235. package/esri-compat/scene-view.js +68 -0
  236. package/esri-compat/search.d.ts +112 -0
  237. package/esri-compat/search.d.ts.map +1 -0
  238. package/esri-compat/search.js +820 -0
  239. package/esri-compat/simple-fill-symbol.d.ts +27 -0
  240. package/esri-compat/simple-fill-symbol.d.ts.map +1 -0
  241. package/esri-compat/simple-fill-symbol.js +85 -0
  242. package/esri-compat/simple-line-symbol.d.ts +27 -0
  243. package/esri-compat/simple-line-symbol.d.ts.map +1 -0
  244. package/esri-compat/simple-line-symbol.js +85 -0
  245. package/esri-compat/simple-marker-symbol.d.ts +29 -0
  246. package/esri-compat/simple-marker-symbol.d.ts.map +1 -0
  247. package/esri-compat/simple-marker-symbol.js +92 -0
  248. package/esri-compat/simple-renderer.d.ts +29 -0
  249. package/esri-compat/simple-renderer.d.ts.map +1 -0
  250. package/esri-compat/simple-renderer.js +92 -0
  251. package/esri-compat/sketch.d.ts +64 -0
  252. package/esri-compat/sketch.d.ts.map +1 -0
  253. package/esri-compat/sketch.js +227 -0
  254. package/esri-compat/spatial-reference.d.ts +31 -0
  255. package/esri-compat/spatial-reference.d.ts.map +1 -0
  256. package/esri-compat/spatial-reference.js +102 -0
  257. package/esri-compat/swipe.d.ts +34 -0
  258. package/esri-compat/swipe.d.ts.map +1 -0
  259. package/esri-compat/swipe.js +93 -0
  260. package/esri-compat/table-list.d.ts +36 -0
  261. package/esri-compat/table-list.d.ts.map +1 -0
  262. package/esri-compat/table-list.js +126 -0
  263. package/esri-compat/text-symbol.d.ts +37 -0
  264. package/esri-compat/text-symbol.d.ts.map +1 -0
  265. package/esri-compat/text-symbol.js +123 -0
  266. package/esri-compat/tile-layer.d.ts +52 -0
  267. package/esri-compat/tile-layer.d.ts.map +1 -0
  268. package/esri-compat/tile-layer.js +167 -0
  269. package/esri-compat/time-slider.d.ts +70 -0
  270. package/esri-compat/time-slider.d.ts.map +1 -0
  271. package/esri-compat/time-slider.js +208 -0
  272. package/esri-compat/track.d.ts +51 -0
  273. package/esri-compat/track.d.ts.map +1 -0
  274. package/esri-compat/track.js +174 -0
  275. package/esri-compat/unique-value-renderer.d.ts +41 -0
  276. package/esri-compat/unique-value-renderer.d.ts.map +1 -0
  277. package/esri-compat/unique-value-renderer.js +127 -0
  278. package/esri-compat/url.d.ts +12 -0
  279. package/esri-compat/url.d.ts.map +1 -0
  280. package/esri-compat/url.js +54 -0
  281. package/esri-compat/web-map.d.ts +14 -0
  282. package/esri-compat/web-map.d.ts.map +1 -0
  283. package/esri-compat/web-map.js +24 -0
  284. package/gen/honua/v1/feature_service_pb.d.ts +918 -0
  285. package/gen/honua/v1/feature_service_pb.d.ts.map +1 -0
  286. package/gen/honua/v1/feature_service_pb.js +375 -0
  287. package/index.d.ts +130 -0
  288. package/index.js +65 -0
  289. package/package.json +22 -0
@@ -0,0 +1,409 @@
1
+ /**
2
+ * WMTS 1.0.0 Capabilities parser. Hand-rolled, narrow-scope walker over
3
+ * the `Capabilities` document advertised by honua-server (single
4
+ * advertised TileMatrixSet today: `WebMercatorQuad`). Yields a typed
5
+ * `WmtsCapabilities` shape so the SDK can route through the canonical
6
+ * `Source` surface without leaking XML.
7
+ *
8
+ * @module
9
+ */
10
+ export class HonuaWmtsCapabilitiesParseError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = "HonuaWmtsCapabilitiesParseError";
14
+ }
15
+ }
16
+ /**
17
+ * Parse a `Capabilities` text body for WMTS 1.0 into the typed
18
+ * `WmtsCapabilities` shape.
19
+ */
20
+ export function parseWmtsCapabilities(xml) {
21
+ if (typeof xml !== "string" || xml.length === 0) {
22
+ throw new HonuaWmtsCapabilitiesParseError("WMTS Capabilities body is empty");
23
+ }
24
+ const root = findElement(xml, 0, "Capabilities");
25
+ if (!root) {
26
+ throw new HonuaWmtsCapabilitiesParseError("missing <Capabilities> root element");
27
+ }
28
+ const version = readAttribute(root.openTag, "version") ?? "1.0.0";
29
+ const service = parseServiceMetadata(root.inner);
30
+ const contents = findElement(root.inner, 0, "Contents");
31
+ const layers = contents ? collectLayers(contents.inner) : [];
32
+ const tileMatrixSets = contents ? collectTileMatrixSets(contents.inner) : [];
33
+ return { version, service, layers, tileMatrixSets };
34
+ }
35
+ function parseServiceMetadata(xml) {
36
+ const node = findElement(xml, 0, "ows:ServiceIdentification") ?? findElement(xml, 0, "ServiceIdentification");
37
+ if (!node)
38
+ return {};
39
+ const out = {};
40
+ const title = readTextElement(node.inner, "ows:Title") ?? readTextElement(node.inner, "Title");
41
+ if (title !== undefined)
42
+ out.title = title;
43
+ const abstract = readTextElement(node.inner, "ows:Abstract") ?? readTextElement(node.inner, "Abstract");
44
+ if (abstract !== undefined)
45
+ out.abstract = abstract;
46
+ return out;
47
+ }
48
+ function collectLayers(contentsInner) {
49
+ const out = [];
50
+ let cursor = 0;
51
+ while (cursor < contentsInner.length) {
52
+ const node = findElement(contentsInner, cursor, "Layer");
53
+ if (!node)
54
+ break;
55
+ const identifier = readTextElement(node.inner, "Identifier") ?? readTextElement(node.inner, "ows:Identifier") ?? "";
56
+ if (identifier.length > 0) {
57
+ const title = readTextElement(node.inner, "Title") ?? readTextElement(node.inner, "ows:Title");
58
+ const abstract = readTextElement(node.inner, "Abstract") ?? readTextElement(node.inner, "ows:Abstract");
59
+ const formats = collectChildText(node.inner, "Format");
60
+ const styles = collectStyles(node.inner);
61
+ const tileMatrixSetIds = collectTileMatrixSetLinks(node.inner);
62
+ const resources = collectResources(node.inner, "tile");
63
+ const featureInfoResources = collectResources(node.inner, "FeatureInfo");
64
+ const bbox = readWgs84BoundingBox(node.inner);
65
+ const layer = {
66
+ identifier,
67
+ formats,
68
+ styles,
69
+ tileMatrixSetIds,
70
+ resourceTemplates: resources,
71
+ featureInfoTemplates: featureInfoResources,
72
+ };
73
+ if (title !== undefined)
74
+ layer.title = title;
75
+ if (abstract !== undefined)
76
+ layer.abstract = abstract;
77
+ if (bbox !== undefined)
78
+ layer.bbox = bbox;
79
+ out.push(layer);
80
+ }
81
+ cursor = node.endIndex;
82
+ }
83
+ return out;
84
+ }
85
+ function collectStyles(layerInner) {
86
+ const out = [];
87
+ let cursor = 0;
88
+ while (cursor < layerInner.length) {
89
+ const node = findElement(layerInner, cursor, "Style");
90
+ if (!node)
91
+ break;
92
+ const identifier = readTextElement(node.inner, "Identifier") ?? readTextElement(node.inner, "ows:Identifier") ?? "";
93
+ if (identifier.length > 0) {
94
+ const title = readTextElement(node.inner, "Title") ?? readTextElement(node.inner, "ows:Title");
95
+ const isDefault = readAttribute(node.openTag, "isDefault") === "true";
96
+ const legend = findElement(node.inner, 0, "LegendURL");
97
+ const legendUrl = legend ? readAttribute(legend.openTag, "xlink:href") : undefined;
98
+ const style = { identifier, isDefault };
99
+ if (title !== undefined)
100
+ style.title = title;
101
+ if (legendUrl !== undefined)
102
+ style.legendUrl = legendUrl;
103
+ out.push(style);
104
+ }
105
+ cursor = node.endIndex;
106
+ }
107
+ return out;
108
+ }
109
+ function collectTileMatrixSetLinks(layerInner) {
110
+ const out = [];
111
+ let cursor = 0;
112
+ while (cursor < layerInner.length) {
113
+ const node = findElement(layerInner, cursor, "TileMatrixSetLink");
114
+ if (!node)
115
+ break;
116
+ const tms = readTextElement(node.inner, "TileMatrixSet") ?? readTextElement(node.inner, "ows:TileMatrixSet");
117
+ if (tms !== undefined && tms.length > 0)
118
+ out.push(tms);
119
+ cursor = node.endIndex;
120
+ }
121
+ return out;
122
+ }
123
+ function collectResources(layerInner, resourceType) {
124
+ const out = [];
125
+ let cursor = 0;
126
+ while (cursor < layerInner.length) {
127
+ const node = findElement(layerInner, cursor, "ResourceURL");
128
+ if (!node)
129
+ break;
130
+ const type = readAttribute(node.openTag, "resourceType");
131
+ if (type === resourceType) {
132
+ const format = readAttribute(node.openTag, "format") ?? "";
133
+ const template = readAttribute(node.openTag, "template") ?? "";
134
+ if (template.length > 0) {
135
+ out.push({ format, template });
136
+ }
137
+ }
138
+ cursor = node.endIndex;
139
+ }
140
+ return out;
141
+ }
142
+ function readWgs84BoundingBox(layerInner) {
143
+ const node = findElement(layerInner, 0, "WGS84BoundingBox") ?? findElement(layerInner, 0, "ows:WGS84BoundingBox");
144
+ if (!node)
145
+ return undefined;
146
+ const lower = readTextElement(node.inner, "LowerCorner") ?? readTextElement(node.inner, "ows:LowerCorner") ?? "";
147
+ const upper = readTextElement(node.inner, "UpperCorner") ?? readTextElement(node.inner, "ows:UpperCorner") ?? "";
148
+ const lowerParts = lower.trim().split(/\s+/).map(Number);
149
+ const upperParts = upper.trim().split(/\s+/).map(Number);
150
+ if (lowerParts.length !== 2 ||
151
+ upperParts.length !== 2 ||
152
+ !Number.isFinite(lowerParts[0]) ||
153
+ !Number.isFinite(lowerParts[1]) ||
154
+ !Number.isFinite(upperParts[0]) ||
155
+ !Number.isFinite(upperParts[1])) {
156
+ return undefined;
157
+ }
158
+ return {
159
+ west: lowerParts[0],
160
+ south: lowerParts[1],
161
+ east: upperParts[0],
162
+ north: upperParts[1],
163
+ };
164
+ }
165
+ function collectTileMatrixSets(contentsInner) {
166
+ const out = [];
167
+ let cursor = 0;
168
+ while (cursor < contentsInner.length) {
169
+ const node = findElement(contentsInner, cursor, "TileMatrixSet");
170
+ if (!node)
171
+ break;
172
+ const identifier = readTextElement(node.inner, "Identifier") ?? readTextElement(node.inner, "ows:Identifier");
173
+ // Skip the per-layer `TileMatrixSet` reference inside `TileMatrixSetLink`
174
+ // (those carry only an identifier and no nested `TileMatrix` children).
175
+ const matrices = collectTileMatrices(node.inner);
176
+ if (identifier !== undefined && identifier.length > 0 && matrices.length > 0) {
177
+ const supportedCrs = readTextElement(node.inner, "SupportedCRS") ?? readTextElement(node.inner, "ows:SupportedCRS");
178
+ const wellKnown = readTextElement(node.inner, "WellKnownScaleSet") ?? readTextElement(node.inner, "ows:WellKnownScaleSet");
179
+ const tms = {
180
+ identifier,
181
+ matrices,
182
+ };
183
+ if (supportedCrs !== undefined)
184
+ tms.supportedCrs = supportedCrs;
185
+ if (wellKnown !== undefined)
186
+ tms.wellKnownScaleSet = wellKnown;
187
+ out.push(tms);
188
+ }
189
+ cursor = node.endIndex;
190
+ }
191
+ return out;
192
+ }
193
+ function collectTileMatrices(tmsInner) {
194
+ const out = [];
195
+ let cursor = 0;
196
+ while (cursor < tmsInner.length) {
197
+ const node = findElement(tmsInner, cursor, "TileMatrix");
198
+ if (!node)
199
+ break;
200
+ const identifier = readTextElement(node.inner, "Identifier") ?? readTextElement(node.inner, "ows:Identifier") ?? "";
201
+ const scale = Number.parseFloat(readTextElement(node.inner, "ScaleDenominator") ?? "");
202
+ const topLeft = (readTextElement(node.inner, "TopLeftCorner") ?? "").trim().split(/\s+/).map(Number);
203
+ const tileWidth = Number.parseFloat(readTextElement(node.inner, "TileWidth") ?? "");
204
+ const tileHeight = Number.parseFloat(readTextElement(node.inner, "TileHeight") ?? "");
205
+ const matrixWidth = Number.parseFloat(readTextElement(node.inner, "MatrixWidth") ?? "");
206
+ const matrixHeight = Number.parseFloat(readTextElement(node.inner, "MatrixHeight") ?? "");
207
+ if (identifier.length > 0 &&
208
+ Number.isFinite(scale) &&
209
+ Number.isFinite(tileWidth) &&
210
+ Number.isFinite(tileHeight) &&
211
+ Number.isFinite(matrixWidth) &&
212
+ Number.isFinite(matrixHeight) &&
213
+ topLeft.length === 2 &&
214
+ Number.isFinite(topLeft[0]) &&
215
+ Number.isFinite(topLeft[1])) {
216
+ out.push({
217
+ identifier,
218
+ scaleDenominator: scale,
219
+ tileWidth,
220
+ tileHeight,
221
+ matrixWidth,
222
+ matrixHeight,
223
+ topLeftCorner: [topLeft[0], topLeft[1]],
224
+ });
225
+ }
226
+ cursor = node.endIndex;
227
+ }
228
+ return out;
229
+ }
230
+ function collectChildText(inner, tag) {
231
+ const out = [];
232
+ let cursor = 0;
233
+ while (cursor < inner.length) {
234
+ const node = findElement(inner, cursor, tag);
235
+ if (!node)
236
+ break;
237
+ const text = decodeXmlText(node.inner.trim());
238
+ if (text.length > 0)
239
+ out.push(text);
240
+ cursor = node.endIndex;
241
+ }
242
+ return out;
243
+ }
244
+ function findElement(xml, from, tag) {
245
+ let i = from;
246
+ while (i < xml.length) {
247
+ if (xml[i] !== "<") {
248
+ i += 1;
249
+ continue;
250
+ }
251
+ const next = xml[i + 1];
252
+ if (next === "!" && xml.startsWith("<!--", i)) {
253
+ const end = xml.indexOf("-->", i + 4);
254
+ if (end < 0)
255
+ return undefined;
256
+ i = end + 3;
257
+ continue;
258
+ }
259
+ if (next === "!" && xml.startsWith("<![CDATA[", i)) {
260
+ const end = xml.indexOf("]]>", i + 9);
261
+ if (end < 0)
262
+ return undefined;
263
+ i = end + 3;
264
+ continue;
265
+ }
266
+ if (next === "?" || next === "!") {
267
+ const end = xml.indexOf(">", i);
268
+ if (end < 0)
269
+ return undefined;
270
+ i = end + 1;
271
+ continue;
272
+ }
273
+ const isClosing = next === "/";
274
+ const nameStart = isClosing ? i + 2 : i + 1;
275
+ const matchesTag = xml.startsWith(tag, nameStart) && isTagBoundary(xml.charCodeAt(nameStart + tag.length));
276
+ if (!matchesTag) {
277
+ const close = xml.indexOf(">", i);
278
+ if (close < 0)
279
+ return undefined;
280
+ i = close + 1;
281
+ continue;
282
+ }
283
+ const close = xml.indexOf(">", i);
284
+ if (close < 0)
285
+ return undefined;
286
+ const openTag = xml.slice(i, close + 1);
287
+ const selfClosing = !isClosing && xml.charCodeAt(close - 1) === 47;
288
+ if (selfClosing)
289
+ return { openTag, inner: "", endIndex: close + 1 };
290
+ if (isClosing) {
291
+ i = close + 1;
292
+ continue;
293
+ }
294
+ let depth = 1;
295
+ let cursor = close + 1;
296
+ while (cursor < xml.length && depth > 0) {
297
+ const angle = xml.indexOf("<", cursor);
298
+ if (angle < 0)
299
+ break;
300
+ const next2 = xml[angle + 1];
301
+ if (next2 === "!" && xml.startsWith("<!--", angle)) {
302
+ const end = xml.indexOf("-->", angle + 4);
303
+ if (end < 0)
304
+ return undefined;
305
+ cursor = end + 3;
306
+ continue;
307
+ }
308
+ if (next2 === "!" && xml.startsWith("<![CDATA[", angle)) {
309
+ const end = xml.indexOf("]]>", angle + 9);
310
+ if (end < 0)
311
+ return undefined;
312
+ cursor = end + 3;
313
+ continue;
314
+ }
315
+ const isCloser = next2 === "/";
316
+ const inspectStart = isCloser ? angle + 2 : angle + 1;
317
+ const matchesSame = xml.startsWith(tag, inspectStart) && isTagBoundary(xml.charCodeAt(inspectStart + tag.length));
318
+ const angleClose = xml.indexOf(">", angle);
319
+ if (angleClose < 0)
320
+ return undefined;
321
+ if (matchesSame) {
322
+ if (isCloser) {
323
+ depth -= 1;
324
+ if (depth === 0) {
325
+ return {
326
+ openTag,
327
+ inner: xml.slice(close + 1, angle),
328
+ endIndex: angleClose + 1,
329
+ };
330
+ }
331
+ }
332
+ else {
333
+ const innerSelfClose = xml.charCodeAt(angleClose - 1) === 47;
334
+ if (!innerSelfClose)
335
+ depth += 1;
336
+ }
337
+ }
338
+ cursor = angleClose + 1;
339
+ }
340
+ return undefined;
341
+ }
342
+ return undefined;
343
+ }
344
+ function isTagBoundary(code) {
345
+ return code === 32 || code === 9 || code === 10 || code === 13 || code === 47 || code === 62;
346
+ }
347
+ function readAttribute(openTag, name) {
348
+ const idx = findAttributeIndex(openTag, name);
349
+ if (idx < 0)
350
+ return undefined;
351
+ const after = openTag.slice(idx + name.length);
352
+ const eq = after.indexOf("=");
353
+ if (eq < 0)
354
+ return undefined;
355
+ let cursor = eq + 1;
356
+ while (cursor < after.length && /\s/.test(after[cursor]))
357
+ cursor += 1;
358
+ const quote = after[cursor];
359
+ if (quote !== '"' && quote !== "'")
360
+ return undefined;
361
+ const end = after.indexOf(quote, cursor + 1);
362
+ if (end < 0)
363
+ return undefined;
364
+ return decodeXmlText(after.slice(cursor + 1, end));
365
+ }
366
+ function findAttributeIndex(openTag, name) {
367
+ let i = 0;
368
+ while (i < openTag.length) {
369
+ const found = openTag.indexOf(name, i);
370
+ if (found < 0)
371
+ return -1;
372
+ const before = openTag.charCodeAt(found - 1);
373
+ const isBoundaryStart = found === 0 || before === 32 || before === 9 || before === 10 || before === 13;
374
+ const after = openTag.charCodeAt(found + name.length);
375
+ const isBoundaryEnd = after === 61 || after === 32 || after === 9 || after === 10 || after === 13;
376
+ if (isBoundaryStart && isBoundaryEnd) {
377
+ return found;
378
+ }
379
+ i = found + 1;
380
+ }
381
+ return -1;
382
+ }
383
+ function readTextElement(xml, tag) {
384
+ const node = findElement(xml, 0, tag);
385
+ if (!node)
386
+ return undefined;
387
+ return decodeXmlText(node.inner.trim());
388
+ }
389
+ function decodeXmlText(text) {
390
+ if (text.indexOf("&") < 0 && text.indexOf("<![CDATA[") < 0)
391
+ return text;
392
+ return text
393
+ .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1")
394
+ .replace(/&lt;/g, "<")
395
+ .replace(/&gt;/g, ">")
396
+ .replace(/&amp;/g, "&")
397
+ .replace(/&apos;/g, "'")
398
+ .replace(/&quot;/g, '"')
399
+ .replace(/&#(\d+);/g, (_match, dec) => String.fromCodePoint(Number(dec)))
400
+ .replace(/&#x([0-9a-fA-F]+);/g, (_match, hex) => String.fromCodePoint(Number.parseInt(hex, 16)));
401
+ }
402
+ /** Find a layer by identifier in a parsed `WmtsCapabilities`. */
403
+ export function findWmtsLayer(capabilities, identifier) {
404
+ return capabilities.layers.find((l) => l.identifier === identifier);
405
+ }
406
+ /** Find a tile-matrix-set by identifier. */
407
+ export function findWmtsTileMatrixSet(capabilities, identifier) {
408
+ return capabilities.tileMatrixSets.find((t) => t.identifier === identifier);
409
+ }
package/core/wmts.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * First-party WMTS 1.0.0 adapter. `HonuaWmts` is the service-level
3
+ * handle returned by `client.wmts(serviceId)`; `HonuaWmtsLayer` is a
4
+ * single-layer projection that pre-fills LAYER and (optionally) STYLE;
5
+ * `HonuaWmtsTileset` adds a TileMatrixSet binding so per-call requests
6
+ * shrink to `{tileMatrix, tileRow, tileCol}`.
7
+ *
8
+ * The wire path lives on `HonuaClient` (`getWmtsCapabilities`,
9
+ * `fetchWmtsTile`, `getWmtsFeatureInfo`).
10
+ *
11
+ * @module
12
+ */
13
+ import type { HonuaClient } from "./client.js";
14
+ import type { HonuaWmtsFeatureInfoResponse, HonuaWmtsTileResponse, WmtsFeatureInfoRequest, WmtsTileRequest } from "./wms-types.js";
15
+ import type { WmtsCapabilities, WmtsCapabilityLayer, WmtsCapabilityTileMatrixSet } from "./wmts-capabilities.js";
16
+ export interface HonuaWmtsOptions {
17
+ client: HonuaClient;
18
+ serviceId: string;
19
+ }
20
+ export interface HonuaWmtsLayerOptions extends HonuaWmtsOptions {
21
+ layerName: string;
22
+ defaultStyleId?: string;
23
+ defaultTileMatrixSetId?: string;
24
+ }
25
+ export interface HonuaWmtsTilesetOptions extends HonuaWmtsOptions {
26
+ layerName: string;
27
+ styleId: string;
28
+ tileMatrixSetId: string;
29
+ }
30
+ export declare class HonuaWmts {
31
+ readonly client: HonuaClient;
32
+ readonly serviceId: string;
33
+ constructor(options: HonuaWmtsOptions);
34
+ /** Bind a single LAYER + optional STYLE / TileMatrixSet defaults. */
35
+ layer(name: string, options?: {
36
+ styleId?: string;
37
+ tileMatrixSetId?: string;
38
+ }): HonuaWmtsLayer;
39
+ tileset(layerName: string, styleId: string, tileMatrixSetId: string): HonuaWmtsTileset;
40
+ capabilities(options?: {
41
+ signal?: AbortSignal;
42
+ }): Promise<WmtsCapabilities>;
43
+ tile(request: WmtsTileRequest): Promise<HonuaWmtsTileResponse>;
44
+ featureInfo<T = Record<string, unknown>>(request: WmtsFeatureInfoRequest): Promise<HonuaWmtsFeatureInfoResponse<T>>;
45
+ }
46
+ export declare class HonuaWmtsLayer {
47
+ readonly client: HonuaClient;
48
+ readonly serviceId: string;
49
+ readonly layerName: string;
50
+ readonly defaultStyleId: string | undefined;
51
+ readonly defaultTileMatrixSetId: string | undefined;
52
+ constructor(options: HonuaWmtsLayerOptions);
53
+ describe(capabilities: WmtsCapabilities): WmtsCapabilityLayer | undefined;
54
+ tileset(styleId?: string, tileMatrixSetId?: string): HonuaWmtsTileset;
55
+ tile(request: Omit<WmtsTileRequest, "layer" | "style" | "tileMatrixSet"> & {
56
+ style?: string;
57
+ tileMatrixSet?: string;
58
+ }): Promise<HonuaWmtsTileResponse>;
59
+ featureInfo<T = Record<string, unknown>>(request: Omit<WmtsFeatureInfoRequest, "layer" | "style" | "tileMatrixSet"> & {
60
+ style?: string;
61
+ tileMatrixSet?: string;
62
+ }): Promise<HonuaWmtsFeatureInfoResponse<T>>;
63
+ }
64
+ /**
65
+ * Tileset handle bound to (layer × style × tileMatrixSet). The runtime
66
+ * binding for MapLibre's `raster` source spec is keyed off this shape.
67
+ */
68
+ export declare class HonuaWmtsTileset {
69
+ readonly client: HonuaClient;
70
+ readonly serviceId: string;
71
+ readonly layerName: string;
72
+ readonly styleId: string;
73
+ readonly tileMatrixSetId: string;
74
+ constructor(options: HonuaWmtsTilesetOptions);
75
+ describe(capabilities: WmtsCapabilities): WmtsCapabilityTileMatrixSet | undefined;
76
+ tile(request: Omit<WmtsTileRequest, "layer" | "style" | "tileMatrixSet">): Promise<HonuaWmtsTileResponse>;
77
+ featureInfo<T = Record<string, unknown>>(request: Omit<WmtsFeatureInfoRequest, "layer" | "style" | "tileMatrixSet">): Promise<HonuaWmtsFeatureInfoResponse<T>>;
78
+ }
79
+ export declare function createHonuaWmts(client: HonuaClient, serviceId: string): HonuaWmts;
80
+ //# sourceMappingURL=wmts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wmts.d.ts","sourceRoot":"","sources":["../../../src/core/wmts.ts"],"names":[],"mappings":"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"}
package/core/wmts.js ADDED
@@ -0,0 +1,173 @@
1
+ /**
2
+ * First-party WMTS 1.0.0 adapter. `HonuaWmts` is the service-level
3
+ * handle returned by `client.wmts(serviceId)`; `HonuaWmtsLayer` is a
4
+ * single-layer projection that pre-fills LAYER and (optionally) STYLE;
5
+ * `HonuaWmtsTileset` adds a TileMatrixSet binding so per-call requests
6
+ * shrink to `{tileMatrix, tileRow, tileCol}`.
7
+ *
8
+ * The wire path lives on `HonuaClient` (`getWmtsCapabilities`,
9
+ * `fetchWmtsTile`, `getWmtsFeatureInfo`).
10
+ *
11
+ * @module
12
+ */
13
+ import { findWmtsLayer, findWmtsTileMatrixSet } from "./wmts-capabilities.js";
14
+ export class HonuaWmts {
15
+ client;
16
+ serviceId;
17
+ constructor(options) {
18
+ this.client = options.client;
19
+ this.serviceId = options.serviceId;
20
+ }
21
+ /** Bind a single LAYER + optional STYLE / TileMatrixSet defaults. */
22
+ layer(name, options) {
23
+ const opts = {
24
+ client: this.client,
25
+ serviceId: this.serviceId,
26
+ layerName: name,
27
+ };
28
+ if (options?.styleId !== undefined)
29
+ opts.defaultStyleId = options.styleId;
30
+ if (options?.tileMatrixSetId !== undefined)
31
+ opts.defaultTileMatrixSetId = options.tileMatrixSetId;
32
+ return new HonuaWmtsLayer(opts);
33
+ }
34
+ tileset(layerName, styleId, tileMatrixSetId) {
35
+ return new HonuaWmtsTileset({
36
+ client: this.client,
37
+ serviceId: this.serviceId,
38
+ layerName,
39
+ styleId,
40
+ tileMatrixSetId,
41
+ });
42
+ }
43
+ async capabilities(options) {
44
+ return this.client.getWmtsCapabilities({
45
+ serviceId: this.serviceId,
46
+ ...(options?.signal ? { signal: options.signal } : {}),
47
+ });
48
+ }
49
+ async tile(request) {
50
+ return this.client.fetchWmtsTile({ serviceId: this.serviceId, ...request });
51
+ }
52
+ async featureInfo(request) {
53
+ return this.client.getWmtsFeatureInfo({ serviceId: this.serviceId, ...request });
54
+ }
55
+ }
56
+ export class HonuaWmtsLayer {
57
+ client;
58
+ serviceId;
59
+ layerName;
60
+ defaultStyleId;
61
+ defaultTileMatrixSetId;
62
+ constructor(options) {
63
+ this.client = options.client;
64
+ this.serviceId = options.serviceId;
65
+ this.layerName = options.layerName;
66
+ this.defaultStyleId = options.defaultStyleId;
67
+ this.defaultTileMatrixSetId = options.defaultTileMatrixSetId;
68
+ }
69
+ describe(capabilities) {
70
+ return findWmtsLayer(capabilities, this.layerName);
71
+ }
72
+ tileset(styleId, tileMatrixSetId) {
73
+ const style = styleId ?? this.defaultStyleId ?? "default";
74
+ const tms = tileMatrixSetId ?? this.defaultTileMatrixSetId ?? "WebMercatorQuad";
75
+ return new HonuaWmtsTileset({
76
+ client: this.client,
77
+ serviceId: this.serviceId,
78
+ layerName: this.layerName,
79
+ styleId: style,
80
+ tileMatrixSetId: tms,
81
+ });
82
+ }
83
+ async tile(request) {
84
+ return this.client.fetchWmtsTile({
85
+ serviceId: this.serviceId,
86
+ layer: this.layerName,
87
+ style: request.style ?? this.defaultStyleId,
88
+ tileMatrixSet: request.tileMatrixSet ?? this.defaultTileMatrixSetId,
89
+ tileMatrix: request.tileMatrix,
90
+ tileRow: request.tileRow,
91
+ tileCol: request.tileCol,
92
+ ...(request.format !== undefined ? { format: request.format } : {}),
93
+ ...(request.mode !== undefined ? { mode: request.mode } : {}),
94
+ ...(request.signal !== undefined ? { signal: request.signal } : {}),
95
+ ...(request.extraParams !== undefined ? { extraParams: request.extraParams } : {}),
96
+ });
97
+ }
98
+ async featureInfo(request) {
99
+ return this.client.getWmtsFeatureInfo({
100
+ serviceId: this.serviceId,
101
+ layer: this.layerName,
102
+ style: request.style ?? this.defaultStyleId,
103
+ tileMatrixSet: request.tileMatrixSet ?? this.defaultTileMatrixSetId,
104
+ tileMatrix: request.tileMatrix,
105
+ tileRow: request.tileRow,
106
+ tileCol: request.tileCol,
107
+ i: request.i,
108
+ j: request.j,
109
+ ...(request.format !== undefined ? { format: request.format } : {}),
110
+ ...(request.infoFormat !== undefined ? { infoFormat: request.infoFormat } : {}),
111
+ ...(request.mode !== undefined ? { mode: request.mode } : {}),
112
+ ...(request.signal !== undefined ? { signal: request.signal } : {}),
113
+ ...(request.extraParams !== undefined ? { extraParams: request.extraParams } : {}),
114
+ });
115
+ }
116
+ }
117
+ /**
118
+ * Tileset handle bound to (layer × style × tileMatrixSet). The runtime
119
+ * binding for MapLibre's `raster` source spec is keyed off this shape.
120
+ */
121
+ export class HonuaWmtsTileset {
122
+ client;
123
+ serviceId;
124
+ layerName;
125
+ styleId;
126
+ tileMatrixSetId;
127
+ constructor(options) {
128
+ this.client = options.client;
129
+ this.serviceId = options.serviceId;
130
+ this.layerName = options.layerName;
131
+ this.styleId = options.styleId;
132
+ this.tileMatrixSetId = options.tileMatrixSetId;
133
+ }
134
+ describe(capabilities) {
135
+ return findWmtsTileMatrixSet(capabilities, this.tileMatrixSetId);
136
+ }
137
+ async tile(request) {
138
+ return this.client.fetchWmtsTile({
139
+ serviceId: this.serviceId,
140
+ layer: this.layerName,
141
+ style: this.styleId,
142
+ tileMatrixSet: this.tileMatrixSetId,
143
+ tileMatrix: request.tileMatrix,
144
+ tileRow: request.tileRow,
145
+ tileCol: request.tileCol,
146
+ ...(request.format !== undefined ? { format: request.format } : {}),
147
+ ...(request.mode !== undefined ? { mode: request.mode } : {}),
148
+ ...(request.signal !== undefined ? { signal: request.signal } : {}),
149
+ ...(request.extraParams !== undefined ? { extraParams: request.extraParams } : {}),
150
+ });
151
+ }
152
+ async featureInfo(request) {
153
+ return this.client.getWmtsFeatureInfo({
154
+ serviceId: this.serviceId,
155
+ layer: this.layerName,
156
+ style: this.styleId,
157
+ tileMatrixSet: this.tileMatrixSetId,
158
+ tileMatrix: request.tileMatrix,
159
+ tileRow: request.tileRow,
160
+ tileCol: request.tileCol,
161
+ i: request.i,
162
+ j: request.j,
163
+ ...(request.format !== undefined ? { format: request.format } : {}),
164
+ ...(request.infoFormat !== undefined ? { infoFormat: request.infoFormat } : {}),
165
+ ...(request.mode !== undefined ? { mode: request.mode } : {}),
166
+ ...(request.signal !== undefined ? { signal: request.signal } : {}),
167
+ ...(request.extraParams !== undefined ? { extraParams: request.extraParams } : {}),
168
+ });
169
+ }
170
+ }
171
+ export function createHonuaWmts(client, serviceId) {
172
+ return new HonuaWmts({ client, serviceId });
173
+ }