@basemaps/lambda-tiler 6.30.0 → 6.32.1

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 (276) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/build/__tests__/config.data.d.ts +6 -1
  3. package/build/__tests__/config.data.d.ts.map +1 -1
  4. package/build/__tests__/config.data.js +33 -2
  5. package/build/__tests__/config.data.js.map +1 -1
  6. package/build/__tests__/index.test.js +3 -13
  7. package/build/__tests__/index.test.js.map +1 -1
  8. package/build/__tests__/wmts.capability.test.js +88 -6
  9. package/build/__tests__/wmts.capability.test.js.map +1 -1
  10. package/build/__tests__/xyz.util.d.ts +7 -9
  11. package/build/__tests__/xyz.util.d.ts.map +1 -1
  12. package/build/__tests__/xyz.util.js +14 -20
  13. package/build/__tests__/xyz.util.js.map +1 -1
  14. package/build/index.d.ts +0 -2
  15. package/build/index.d.ts.map +1 -1
  16. package/build/index.js +57 -26
  17. package/build/index.js.map +1 -1
  18. package/build/routes/__tests__/attribution.test.js +350 -400
  19. package/build/routes/__tests__/attribution.test.js.map +1 -1
  20. package/build/routes/__tests__/fonts.test.js +11 -5
  21. package/build/routes/__tests__/fonts.test.js.map +1 -1
  22. package/build/routes/__tests__/health.test.js +16 -13
  23. package/build/routes/__tests__/health.test.js.map +1 -1
  24. package/build/routes/__tests__/sprites.test.js +6 -0
  25. package/build/routes/__tests__/sprites.test.js.map +1 -1
  26. package/build/routes/__tests__/tile.json.test.d.ts +2 -0
  27. package/build/routes/__tests__/tile.json.test.d.ts.map +1 -0
  28. package/build/routes/__tests__/tile.json.test.js +124 -0
  29. package/build/routes/__tests__/tile.json.test.js.map +1 -0
  30. package/build/routes/__tests__/tile.style.json.test.d.ts +2 -0
  31. package/build/routes/__tests__/tile.style.json.test.d.ts.map +1 -0
  32. package/build/routes/__tests__/tile.style.json.test.js +95 -0
  33. package/build/routes/__tests__/tile.style.json.test.js.map +1 -0
  34. package/build/routes/__tests__/wmts.test.js +5 -44
  35. package/build/routes/__tests__/wmts.test.js.map +1 -1
  36. package/build/{__tests__ → routes/__tests__}/xyz.test.d.ts +0 -0
  37. package/build/routes/__tests__/xyz.test.d.ts.map +1 -0
  38. package/build/routes/__tests__/xyz.test.js +99 -0
  39. package/build/routes/__tests__/xyz.test.js.map +1 -0
  40. package/build/routes/attribution.d.ts +7 -5
  41. package/build/routes/attribution.d.ts.map +1 -1
  42. package/build/routes/attribution.js +49 -91
  43. package/build/routes/attribution.js.map +1 -1
  44. package/build/routes/fonts.d.ts +1 -1
  45. package/build/routes/fonts.d.ts.map +1 -1
  46. package/build/routes/fonts.js +30 -15
  47. package/build/routes/fonts.js.map +1 -1
  48. package/build/routes/health.d.ts +3 -3
  49. package/build/routes/health.d.ts.map +1 -1
  50. package/build/routes/health.js +15 -13
  51. package/build/routes/health.js.map +1 -1
  52. package/build/routes/imagery.d.ts.map +1 -1
  53. package/build/routes/imagery.js +11 -10
  54. package/build/routes/imagery.js.map +1 -1
  55. package/build/routes/ping.d.ts +3 -0
  56. package/build/routes/ping.d.ts.map +1 -0
  57. package/build/routes/ping.js +7 -0
  58. package/build/routes/ping.js.map +1 -0
  59. package/build/routes/sprites.d.ts.map +1 -1
  60. package/build/routes/sprites.js +16 -10
  61. package/build/routes/sprites.js.map +1 -1
  62. package/build/routes/tile.json.d.ts +7 -1
  63. package/build/routes/tile.json.d.ts.map +1 -1
  64. package/build/routes/tile.json.js +18 -21
  65. package/build/routes/tile.json.js.map +1 -1
  66. package/build/routes/tile.style.json.d.ts +6 -1
  67. package/build/routes/tile.style.json.d.ts.map +1 -1
  68. package/build/routes/tile.style.json.js +10 -13
  69. package/build/routes/tile.style.json.js.map +1 -1
  70. package/build/routes/tile.wmts.d.ts +9 -3
  71. package/build/routes/tile.wmts.d.ts.map +1 -1
  72. package/build/routes/tile.wmts.js +26 -35
  73. package/build/routes/tile.wmts.js.map +1 -1
  74. package/build/routes/tile.xyz.d.ts +14 -4
  75. package/build/routes/tile.xyz.d.ts.map +1 -1
  76. package/build/routes/tile.xyz.js +21 -17
  77. package/build/routes/tile.xyz.js.map +1 -1
  78. package/build/routes/tile.xyz.raster.d.ts +11 -0
  79. package/build/routes/tile.xyz.raster.d.ts.map +1 -0
  80. package/build/routes/tile.xyz.raster.js +90 -0
  81. package/build/routes/tile.xyz.raster.js.map +1 -0
  82. package/build/routes/tile.xyz.vector.d.ts +8 -0
  83. package/build/routes/tile.xyz.vector.d.ts.map +1 -0
  84. package/build/routes/tile.xyz.vector.js +46 -0
  85. package/build/routes/tile.xyz.vector.js.map +1 -0
  86. package/build/routes/version.d.ts +3 -0
  87. package/build/routes/version.d.ts.map +1 -0
  88. package/build/routes/version.js +9 -0
  89. package/build/routes/version.js.map +1 -0
  90. package/build/util/__test__/validate.test.d.ts +2 -0
  91. package/build/util/__test__/validate.test.d.ts.map +1 -0
  92. package/build/util/__test__/validate.test.js +66 -0
  93. package/build/util/__test__/validate.test.js.map +1 -0
  94. package/build/{cotar.cache.d.ts → util/cotar.serve.d.ts} +3 -8
  95. package/build/util/cotar.serve.d.ts.map +1 -0
  96. package/build/util/cotar.serve.js +41 -0
  97. package/build/util/cotar.serve.js.map +1 -0
  98. package/build/util/etag.d.ts +6 -0
  99. package/build/util/etag.d.ts.map +1 -0
  100. package/build/util/etag.js +20 -0
  101. package/build/util/etag.js.map +1 -0
  102. package/build/util/response.d.ts +4 -0
  103. package/build/util/response.d.ts.map +1 -0
  104. package/build/util/response.js +4 -0
  105. package/build/util/response.js.map +1 -0
  106. package/build/util/source.cache.d.ts +28 -0
  107. package/build/util/source.cache.d.ts.map +1 -0
  108. package/build/util/source.cache.js +53 -0
  109. package/build/util/source.cache.js.map +1 -0
  110. package/build/{source.tracer.d.ts → util/source.tracer.d.ts} +1 -0
  111. package/build/util/source.tracer.d.ts.map +1 -0
  112. package/build/{source.tracer.js → util/source.tracer.js} +3 -0
  113. package/build/util/source.tracer.js.map +1 -0
  114. package/build/util/swapping.lru.d.ts +21 -0
  115. package/build/util/swapping.lru.d.ts.map +1 -0
  116. package/build/util/swapping.lru.js +56 -0
  117. package/build/util/swapping.lru.js.map +1 -0
  118. package/build/util/validate.d.ts +46 -0
  119. package/build/util/validate.d.ts.map +1 -0
  120. package/build/util/validate.js +107 -0
  121. package/build/util/validate.js.map +1 -0
  122. package/build/wmts.capability.d.ts +1 -1
  123. package/build/wmts.capability.d.ts.map +1 -1
  124. package/build/wmts.capability.js +24 -8
  125. package/build/wmts.capability.js.map +1 -1
  126. package/dist/index.js +78 -76
  127. package/dist/node_modules/.package-lock.json +1 -1
  128. package/dist/package-lock.json +2 -2
  129. package/dist/package.json +1 -1
  130. package/package.json +10 -10
  131. package/src/__tests__/config.data.ts +41 -3
  132. package/src/__tests__/index.test.ts +3 -19
  133. package/src/__tests__/wmts.capability.test.ts +109 -6
  134. package/src/__tests__/xyz.util.ts +18 -21
  135. package/src/index.ts +66 -29
  136. package/src/routes/__tests__/attribution.test.ts +356 -403
  137. package/src/routes/__tests__/fonts.test.ts +11 -5
  138. package/src/routes/__tests__/health.test.ts +17 -13
  139. package/src/routes/__tests__/sprites.test.ts +6 -1
  140. package/src/routes/__tests__/tile.json.test.ts +145 -0
  141. package/src/routes/__tests__/tile.style.json.test.ts +105 -0
  142. package/src/routes/__tests__/wmts.test.ts +5 -55
  143. package/src/routes/__tests__/xyz.test.ts +119 -0
  144. package/src/routes/attribution.ts +59 -111
  145. package/src/routes/fonts.ts +29 -15
  146. package/src/routes/health.ts +17 -16
  147. package/src/routes/imagery.ts +10 -9
  148. package/src/routes/ping.ts +8 -0
  149. package/src/routes/sprites.ts +16 -10
  150. package/src/routes/tile.json.ts +24 -18
  151. package/src/routes/tile.style.json.ts +15 -12
  152. package/src/routes/tile.wmts.ts +30 -31
  153. package/src/routes/tile.xyz.raster.ts +106 -0
  154. package/src/routes/tile.xyz.ts +31 -16
  155. package/src/routes/tile.xyz.vector.ts +47 -0
  156. package/src/routes/version.ts +8 -0
  157. package/src/util/__test__/validate.test.ts +74 -0
  158. package/src/util/cotar.serve.ts +46 -0
  159. package/src/util/etag.ts +20 -0
  160. package/src/util/response.ts +4 -0
  161. package/src/util/source.cache.ts +71 -0
  162. package/src/{source.tracer.ts → util/source.tracer.ts} +4 -0
  163. package/src/util/swapping.lru.ts +63 -0
  164. package/src/util/validate.ts +126 -0
  165. package/src/wmts.capability.ts +30 -13
  166. package/tsconfig.tsbuildinfo +1 -1
  167. package/build/__tests__/route.test.d.ts +0 -2
  168. package/build/__tests__/route.test.d.ts.map +0 -1
  169. package/build/__tests__/route.test.js +0 -21
  170. package/build/__tests__/route.test.js.map +0 -1
  171. package/build/__tests__/tiff.cache.test.d.ts +0 -2
  172. package/build/__tests__/tiff.cache.test.d.ts.map +0 -1
  173. package/build/__tests__/tiff.cache.test.js +0 -59
  174. package/build/__tests__/tiff.cache.test.js.map +0 -1
  175. package/build/__tests__/tile.cache.key.test.d.ts +0 -2
  176. package/build/__tests__/tile.cache.key.test.d.ts.map +0 -1
  177. package/build/__tests__/tile.cache.key.test.js +0 -49
  178. package/build/__tests__/tile.cache.key.test.js.map +0 -1
  179. package/build/__tests__/tile.set.cache.test.d.ts +0 -2
  180. package/build/__tests__/tile.set.cache.test.d.ts.map +0 -1
  181. package/build/__tests__/tile.set.cache.test.js +0 -72
  182. package/build/__tests__/tile.set.cache.test.js.map +0 -1
  183. package/build/__tests__/tile.set.test.d.ts +0 -2
  184. package/build/__tests__/tile.set.test.d.ts.map +0 -1
  185. package/build/__tests__/tile.set.test.js +0 -12
  186. package/build/__tests__/tile.set.test.js.map +0 -1
  187. package/build/__tests__/xyz.test.d.ts.map +0 -1
  188. package/build/__tests__/xyz.test.js +0 -275
  189. package/build/__tests__/xyz.test.js.map +0 -1
  190. package/build/api.key.d.ts +0 -2
  191. package/build/api.key.d.ts.map +0 -1
  192. package/build/api.key.js +0 -24
  193. package/build/api.key.js.map +0 -1
  194. package/build/cli/dump.d.ts +0 -2
  195. package/build/cli/dump.d.ts.map +0 -1
  196. package/build/cli/dump.js +0 -48
  197. package/build/cli/dump.js.map +0 -1
  198. package/build/cli/tile.set.local.d.ts +0 -12
  199. package/build/cli/tile.set.local.d.ts.map +0 -1
  200. package/build/cli/tile.set.local.js +0 -40
  201. package/build/cli/tile.set.local.js.map +0 -1
  202. package/build/cotar.cache.d.ts.map +0 -1
  203. package/build/cotar.cache.js +0 -50
  204. package/build/cotar.cache.js.map +0 -1
  205. package/build/router.d.ts +0 -15
  206. package/build/router.d.ts.map +0 -1
  207. package/build/router.js +0 -50
  208. package/build/router.js.map +0 -1
  209. package/build/routes/api.d.ts +0 -4
  210. package/build/routes/api.d.ts.map +0 -1
  211. package/build/routes/api.js +0 -14
  212. package/build/routes/api.js.map +0 -1
  213. package/build/routes/esri/rest.d.ts +0 -10
  214. package/build/routes/esri/rest.d.ts.map +0 -1
  215. package/build/routes/esri/rest.js +0 -88
  216. package/build/routes/esri/rest.js.map +0 -1
  217. package/build/routes/response.d.ts +0 -4
  218. package/build/routes/response.d.ts.map +0 -1
  219. package/build/routes/response.js +0 -4
  220. package/build/routes/response.js.map +0 -1
  221. package/build/routes/tile.d.ts +0 -3
  222. package/build/routes/tile.d.ts.map +0 -1
  223. package/build/routes/tile.etag.d.ts +0 -11
  224. package/build/routes/tile.etag.d.ts.map +0 -1
  225. package/build/routes/tile.etag.js +0 -30
  226. package/build/routes/tile.etag.js.map +0 -1
  227. package/build/routes/tile.js +0 -28
  228. package/build/routes/tile.js.map +0 -1
  229. package/build/source.tracer.d.ts.map +0 -1
  230. package/build/source.tracer.js.map +0 -1
  231. package/build/tiff.cache.d.ts +0 -17
  232. package/build/tiff.cache.d.ts.map +0 -1
  233. package/build/tiff.cache.js +0 -46
  234. package/build/tiff.cache.js.map +0 -1
  235. package/build/tile.set.cache.d.ts +0 -20
  236. package/build/tile.set.cache.d.ts.map +0 -1
  237. package/build/tile.set.cache.js +0 -72
  238. package/build/tile.set.cache.js.map +0 -1
  239. package/build/tile.set.d.ts +0 -4
  240. package/build/tile.set.d.ts.map +0 -1
  241. package/build/tile.set.js +0 -2
  242. package/build/tile.set.js.map +0 -1
  243. package/build/tile.set.raster.d.ts +0 -49
  244. package/build/tile.set.raster.d.ts.map +0 -1
  245. package/build/tile.set.raster.js +0 -189
  246. package/build/tile.set.raster.js.map +0 -1
  247. package/build/tile.set.vector.d.ts +0 -18
  248. package/build/tile.set.vector.d.ts.map +0 -1
  249. package/build/tile.set.vector.js +0 -54
  250. package/build/tile.set.vector.js.map +0 -1
  251. package/build/validate.d.ts +0 -16
  252. package/build/validate.d.ts.map +0 -1
  253. package/build/validate.js +0 -32
  254. package/build/validate.js.map +0 -1
  255. package/src/__tests__/route.test.ts +0 -24
  256. package/src/__tests__/tiff.cache.test.ts +0 -73
  257. package/src/__tests__/tile.cache.key.test.ts +0 -56
  258. package/src/__tests__/tile.set.cache.test.ts +0 -80
  259. package/src/__tests__/tile.set.test.ts +0 -12
  260. package/src/__tests__/xyz.test.ts +0 -318
  261. package/src/api.key.ts +0 -23
  262. package/src/cli/dump.ts +0 -61
  263. package/src/cli/tile.set.local.ts +0 -51
  264. package/src/cotar.cache.ts +0 -54
  265. package/src/router.ts +0 -58
  266. package/src/routes/api.ts +0 -15
  267. package/src/routes/esri/rest.ts +0 -90
  268. package/src/routes/response.ts +0 -4
  269. package/src/routes/tile.etag.ts +0 -36
  270. package/src/routes/tile.ts +0 -23
  271. package/src/tiff.cache.ts +0 -51
  272. package/src/tile.set.cache.ts +0 -84
  273. package/src/tile.set.raster.ts +0 -230
  274. package/src/tile.set.ts +0 -4
  275. package/src/tile.set.vector.ts +0 -61
  276. package/src/validate.ts +0 -32
@@ -1,414 +1,364 @@
1
- import { EpsgCode, GoogleTms, Nztm2000QuadTms, Nztm2000Tms, Stac, TileMatrixSets } from '@basemaps/geo';
1
+ import { Attribution } from '@basemaps/attribution';
2
+ import { Config, ConfigProviderMemory } from '@basemaps/config';
3
+ import { Nztm2000QuadTms } from '@basemaps/geo';
4
+ import { LogConfig } from '@basemaps/shared';
2
5
  import { HttpHeader } from '@linzjs/lambda';
3
- import { Config } from '@basemaps/shared';
4
- import { mockFileOperator } from '@basemaps/shared/build/file/__tests__/file.operator.test.helper.js';
5
- import { round } from '@basemaps/test/build/rounding.js';
6
6
  import o from 'ospec';
7
7
  import sinon from 'sinon';
8
- const sandbox = sinon.createSandbox();
9
- import { TileSets } from '../../tile.set.cache.js';
10
- import { TileSetRaster } from '../../tile.set.raster.js';
11
- import { FakeTileSet, mockRequest } from '../../__tests__/xyz.util.js';
12
- import { attribution, createAttributionCollection } from '../attribution.js';
13
- import { TileEtag } from '../tile.etag.js';
14
- import { Attribution } from '@basemaps/attribution';
15
- import { Provider } from '../../__tests__/config.data.js';
16
- const ExpectedJson = {
17
- id: 'aerial_WebMercatorQuad',
18
- type: 'FeatureCollection',
19
- stac_version: '1.0.0-beta.2',
20
- stac_extensions: ['single-file-stac'],
21
- title: 'aerial:title',
22
- description: 'aerial:description',
23
- features: [
24
- {
25
- type: 'Feature',
26
- stac_version: '1.0.0-beta.2',
27
- id: 'im_imageId1_item',
28
- collection: 'im_imageId1',
29
- assets: {},
30
- links: [],
31
- bbox: [-22.5, 48.9225, -11.25, 55.7766],
32
- geometry: {
33
- type: 'MultiPolygon',
34
- coordinates: [
35
- [
36
- [
37
- [-22.5, 48.9225],
38
- [-19.6875, 48.9225],
39
- [-19.6875, 49.838],
40
- [-22.5, 49.838],
41
- [-22.5, 48.9225],
42
- ],
43
- ],
44
- ],
45
- },
46
- properties: {
47
- title: 'Hastings-district urban 2011-13 0.1m',
48
- datetime: null,
49
- start_datetime: '2011-01-01T00:00:00Z',
50
- end_datetime: '2014-01-01T00:00:00Z',
51
- },
52
- },
53
- {
54
- type: 'Feature',
55
- stac_version: '1.0.0-beta.2',
56
- id: 'im_imageId2_item',
57
- collection: 'im_imageId2',
58
- assets: {},
59
- links: [],
60
- bbox: [-11.25, 48.9225, 0, 55.7766],
61
- geometry: {
62
- type: 'MultiPolygon',
63
- coordinates: [
64
- [
65
- [
66
- [-11.25, 48.9225],
67
- [-8.4375, 48.9225],
68
- [-8.4375, 49.838],
69
- [-11.25, 49.838],
70
- [-11.25, 48.9225],
71
- ],
72
- ],
73
- ],
74
- },
75
- properties: {
76
- title: 'Hastings-district urban 2013-14 0.1m',
77
- datetime: null,
78
- start_datetime: '2013-01-01T00:00:00Z',
79
- end_datetime: '2015-01-01T00:00:00Z',
80
- },
81
- },
82
- {
83
- type: 'Feature',
84
- stac_version: '1.0.0-beta.2',
85
- id: 'im_imageId3_item',
86
- collection: 'im_imageId3',
87
- assets: {},
88
- links: [],
89
- bbox: [0, 48.9225, 11.25, 55.7766],
90
- geometry: {
91
- type: 'MultiPolygon',
92
- coordinates: [
93
- [
94
- [
95
- [0, 48.9225],
96
- [2.8125, 48.9225],
97
- [2.8125, 49.838],
98
- [0, 49.838],
99
- [0, 48.9225],
100
- ],
101
- ],
102
- ],
103
- },
104
- properties: {
105
- title: 'Hastings-district urban 2015-17 0.1m',
106
- datetime: null,
107
- start_datetime: '2015-01-01T00:00:00Z',
108
- end_datetime: '2018-01-01T00:00:00Z',
109
- },
110
- },
111
- {
112
- type: 'Feature',
113
- stac_version: '1.0.0-beta.2',
114
- id: 'im_imageId4_item',
115
- collection: 'im_imageId4',
116
- assets: {},
117
- links: [],
118
- bbox: [-22.5, 48.9225, -11.25, 55.7766],
119
- geometry: {
120
- type: 'MultiPolygon',
121
- coordinates: [
122
- [
123
- [
124
- [-22.5, 48.9225],
125
- [-19.6875, 48.9225],
126
- [-19.6875, 49.838],
127
- [-22.5, 49.838],
128
- [-22.5, 48.9225],
129
- ],
130
- ],
131
- ],
132
- },
133
- properties: {
134
- title: 'Hastings-district urban 2017-18 0.1m',
135
- datetime: null,
136
- start_datetime: '2017-01-01T00:00:00Z',
137
- end_datetime: '2019-01-01T00:00:00Z',
138
- },
139
- },
140
- ],
141
- collections: [
142
- {
143
- stac_version: '1.0.0-beta.2',
144
- license: 'CC BY 4.0',
145
- id: 'im_imageId1',
146
- providers: [
147
- {
148
- name: 'the name',
149
- url: 'https://example.provider.com',
150
- roles: ['host'],
151
- },
152
- ],
153
- title: 'Hastings-district urban 2011-13 0.1m',
154
- description: 'No description',
155
- extent: {
156
- spatial: {
157
- bbox: [[-22.5, 48.9225, -11.25, 55.7766]],
158
- },
159
- temporal: {
160
- interval: [['2011-01-01T00:00:00Z', '2014-01-01T00:00:00Z']],
161
- },
162
- },
163
- links: [],
164
- summaries: {
165
- 'linz:zoom': {
166
- min: 14,
167
- max: 16,
168
- },
169
- 'linz:priority': [1000],
170
- },
171
- },
172
- {
173
- stac_version: '1.0.0-beta.2',
174
- license: 'CC BY 4.0',
175
- id: 'im_imageId2',
176
- providers: [
177
- {
178
- name: 'the name',
179
- url: 'https://example.provider.com',
180
- roles: ['host'],
181
- },
182
- ],
183
- title: 'Hastings-district urban 2013-14 0.1m',
184
- description: 'No description',
185
- extent: {
186
- spatial: {
187
- bbox: [[-11.25, 48.9225, 0, 55.7766]],
188
- },
189
- temporal: {
190
- interval: [['2013-01-01T00:00:00Z', '2015-01-01T00:00:00Z']],
191
- },
192
- },
193
- links: [],
194
- summaries: {
195
- 'linz:zoom': {
196
- min: 15,
197
- max: 17,
198
- },
199
- 'linz:priority': [1001],
200
- },
201
- },
202
- {
203
- stac_version: '1.0.0-beta.2',
204
- license: 'CC BY 4.0',
205
- id: 'im_imageId3',
206
- providers: [
207
- {
208
- name: 'the name',
209
- url: 'https://example.provider.com',
210
- roles: ['host'],
211
- },
212
- ],
213
- title: 'Hastings-district urban 2015-17 0.1m',
214
- description: 'No description',
215
- extent: {
216
- spatial: {
217
- bbox: [[0, 48.9225, 11.25, 55.7766]],
218
- },
219
- temporal: {
220
- interval: [['2015-01-01T00:00:00Z', '2018-01-01T00:00:00Z']],
221
- },
222
- },
223
- links: [],
224
- summaries: {
225
- 'linz:zoom': {
226
- min: 16,
227
- max: 18,
228
- },
229
- 'linz:priority': [1002],
230
- },
231
- },
232
- {
233
- stac_version: '1.0.0-beta.2',
234
- license: 'CC BY 4.0',
235
- id: 'im_imageId4',
236
- providers: [
237
- {
238
- name: 'the name',
239
- url: 'https://example.provider.com',
240
- roles: ['host'],
241
- },
242
- ],
243
- title: 'Hastings-district urban 2017-18 0.1m',
244
- description: 'No description',
245
- extent: {
246
- spatial: {
247
- bbox: [[-22.5, 48.9225, -11.25, 55.7766]],
248
- },
249
- temporal: {
250
- interval: [['2017-01-01T00:00:00Z', '2019-01-01T00:00:00Z']],
251
- },
252
- },
253
- links: [],
254
- summaries: {
255
- 'linz:zoom': {
256
- min: 14,
257
- max: 16,
258
- },
259
- 'linz:priority': [1003],
260
- },
261
- },
262
- ],
263
- links: [],
264
- };
265
- function makeImageRecord(id, name, x = 10) {
266
- return {
267
- id,
268
- name,
269
- projection: EpsgCode.Google,
270
- tileMatrix: 'WebMercatorQuad',
271
- uri: 's3://bucket/path/' + name,
272
- bounds: GoogleTms.tileToSourceBounds({ x, y: 10, z: 5 }),
273
- files: [0, 1].map((i) => {
274
- const b = GoogleTms.tileToSourceBounds({ x, y: 10, z: 5 }).toJson();
275
- b.name = name + i;
276
- b.width /= 8;
277
- b.height /= 8;
278
- b.x += i * b.width;
279
- return b;
280
- }),
281
- updatedAt: Date.now(),
282
- };
283
- }
284
- o.spec('attribution', () => {
285
- o.spec('fetch', () => {
286
- const origTileEtag = TileEtag.generate;
287
- const generateMock = o.spy(() => 'foo');
288
- const TileSetNames = ['aerial', 'aerial@head', 'aerial@beta', '01E7PJFR9AMQFJ05X9G7FQ3XMW'];
289
- const mockFs = mockFileOperator();
290
- o.beforeEach(() => {
291
- mockFs.setup();
292
- TileEtag.generate = generateMock;
293
- // Mock the tile generation
294
- for (const tileSetName of TileSetNames) {
295
- for (const tileMatrix of TileMatrixSets.Defaults.values()) {
296
- const tileSet = new FakeTileSet(tileSetName, tileMatrix);
297
- TileSets.add(tileSet);
298
- const layers = [];
299
- const imagery = new Map();
300
- const addRule = (id, name, minZoom = 10) => {
301
- const imgId = Config.Imagery.id(id);
302
- imagery.set(imgId, makeImageRecord(imgId, name, minZoom));
303
- layers.push({
304
- [3857]: imgId,
305
- name,
306
- minZoom,
307
- maxZoom: minZoom + 2,
308
- });
309
- };
310
- addRule('imageId1', 'hastings-district_urban_2011-13_0.1m', 14);
311
- addRule('imageId2', 'hastings-district_urban_2013-14_0.1m', 15);
312
- addRule('imageId3', 'hastings-district_urban_2015-17_0.1m', 16);
313
- addRule('imageId4', 'hastings-district_urban_2017-18_0.1m', 14);
314
- tileSet.tileSet.layers = layers;
315
- tileSet.imagery = imagery;
316
- }
317
- }
318
- sandbox.stub(Config.Provider, 'get').callsFake(() => Promise.resolve(Provider));
319
- });
320
- o.afterEach(() => {
321
- sandbox.restore();
322
- mockFs.teardown();
323
- TileSets.cache.clear();
324
- TileEtag.generate = origTileEtag;
8
+ import { handler } from '../../index.js';
9
+ import { FakeData, Imagery2193, Imagery3857, Provider, TileSetAerial } from '../../__tests__/config.data.js';
10
+ import { mockUrlRequest } from '../../__tests__/xyz.util.js';
11
+ // const ExpectedJson = {
12
+ // id: 'aerial_WebMercatorQuad',
13
+ // type: 'FeatureCollection',
14
+ // stac_version: '1.0.0-beta.2',
15
+ // stac_extensions: ['single-file-stac'],
16
+ // title: 'aerial:title',
17
+ // description: 'aerial:description',
18
+ // features: [
19
+ // {
20
+ // type: 'Feature',
21
+ // stac_version: '1.0.0-beta.2',
22
+ // id: 'im_imageId1_item',
23
+ // collection: 'im_imageId1',
24
+ // assets: {},
25
+ // links: [],
26
+ // bbox: [-22.5, 48.9225, -11.25, 55.7766],
27
+ // geometry: {
28
+ // type: 'MultiPolygon',
29
+ // coordinates: [
30
+ // [
31
+ // [
32
+ // [-22.5, 48.9225],
33
+ // [-19.6875, 48.9225],
34
+ // [-19.6875, 49.838],
35
+ // [-22.5, 49.838],
36
+ // [-22.5, 48.9225],
37
+ // ],
38
+ // ],
39
+ // ],
40
+ // },
41
+ // properties: {
42
+ // title: 'Hastings-district urban 2011-13 0.1m',
43
+ // datetime: null,
44
+ // start_datetime: '2011-01-01T00:00:00Z',
45
+ // end_datetime: '2014-01-01T00:00:00Z',
46
+ // },
47
+ // },
48
+ // {
49
+ // type: 'Feature',
50
+ // stac_version: '1.0.0-beta.2',
51
+ // id: 'im_imageId2_item',
52
+ // collection: 'im_imageId2',
53
+ // assets: {},
54
+ // links: [],
55
+ // bbox: [-11.25, 48.9225, 0, 55.7766],
56
+ // geometry: {
57
+ // type: 'MultiPolygon',
58
+ // coordinates: [
59
+ // [
60
+ // [
61
+ // [-11.25, 48.9225],
62
+ // [-8.4375, 48.9225],
63
+ // [-8.4375, 49.838],
64
+ // [-11.25, 49.838],
65
+ // [-11.25, 48.9225],
66
+ // ],
67
+ // ],
68
+ // ],
69
+ // },
70
+ // properties: {
71
+ // title: 'Hastings-district urban 2013-14 0.1m',
72
+ // datetime: null,
73
+ // start_datetime: '2013-01-01T00:00:00Z',
74
+ // end_datetime: '2015-01-01T00:00:00Z',
75
+ // },
76
+ // },
77
+ // {
78
+ // type: 'Feature',
79
+ // stac_version: '1.0.0-beta.2',
80
+ // id: 'im_imageId3_item',
81
+ // collection: 'im_imageId3',
82
+ // assets: {},
83
+ // links: [],
84
+ // bbox: [0, 48.9225, 11.25, 55.7766],
85
+ // geometry: {
86
+ // type: 'MultiPolygon',
87
+ // coordinates: [
88
+ // [
89
+ // [
90
+ // [0, 48.9225],
91
+ // [2.8125, 48.9225],
92
+ // [2.8125, 49.838],
93
+ // [0, 49.838],
94
+ // [0, 48.9225],
95
+ // ],
96
+ // ],
97
+ // ],
98
+ // },
99
+ // properties: {
100
+ // title: 'Hastings-district urban 2015-17 0.1m',
101
+ // datetime: null,
102
+ // start_datetime: '2015-01-01T00:00:00Z',
103
+ // end_datetime: '2018-01-01T00:00:00Z',
104
+ // },
105
+ // },
106
+ // {
107
+ // type: 'Feature',
108
+ // stac_version: '1.0.0-beta.2',
109
+ // id: 'im_imageId4_item',
110
+ // collection: 'im_imageId4',
111
+ // assets: {},
112
+ // links: [],
113
+ // bbox: [-22.5, 48.9225, -11.25, 55.7766],
114
+ // geometry: {
115
+ // type: 'MultiPolygon',
116
+ // coordinates: [
117
+ // [
118
+ // [
119
+ // [-22.5, 48.9225],
120
+ // [-19.6875, 48.9225],
121
+ // [-19.6875, 49.838],
122
+ // [-22.5, 49.838],
123
+ // [-22.5, 48.9225],
124
+ // ],
125
+ // ],
126
+ // ],
127
+ // },
128
+ // properties: {
129
+ // title: 'Hastings-district urban 2017-18 0.1m',
130
+ // datetime: null,
131
+ // start_datetime: '2017-01-01T00:00:00Z',
132
+ // end_datetime: '2019-01-01T00:00:00Z',
133
+ // },
134
+ // },
135
+ // ],
136
+ // collections: [
137
+ // {
138
+ // stac_version: '1.0.0-beta.2',
139
+ // license: 'CC BY 4.0',
140
+ // id: 'im_imageId1',
141
+ // providers: [
142
+ // {
143
+ // name: 'the name',
144
+ // url: 'https://example.provider.com',
145
+ // roles: ['host'],
146
+ // },
147
+ // ],
148
+ // title: 'Hastings-district urban 2011-13 0.1m',
149
+ // description: 'No description',
150
+ // extent: {
151
+ // spatial: {
152
+ // bbox: [[-22.5, 48.9225, -11.25, 55.7766]],
153
+ // },
154
+ // temporal: {
155
+ // interval: [['2011-01-01T00:00:00Z', '2014-01-01T00:00:00Z']],
156
+ // },
157
+ // },
158
+ // links: [],
159
+ // summaries: {
160
+ // 'linz:zoom': {
161
+ // min: 14,
162
+ // max: 16,
163
+ // },
164
+ // 'linz:priority': [1000],
165
+ // },
166
+ // },
167
+ // {
168
+ // stac_version: '1.0.0-beta.2',
169
+ // license: 'CC BY 4.0',
170
+ // id: 'im_imageId2',
171
+ // providers: [
172
+ // {
173
+ // name: 'the name',
174
+ // url: 'https://example.provider.com',
175
+ // roles: ['host'],
176
+ // },
177
+ // ],
178
+ // title: 'Hastings-district urban 2013-14 0.1m',
179
+ // description: 'No description',
180
+ // extent: {
181
+ // spatial: {
182
+ // bbox: [[-11.25, 48.9225, 0, 55.7766]],
183
+ // },
184
+ // temporal: {
185
+ // interval: [['2013-01-01T00:00:00Z', '2015-01-01T00:00:00Z']],
186
+ // },
187
+ // },
188
+ // links: [],
189
+ // summaries: {
190
+ // 'linz:zoom': {
191
+ // min: 15,
192
+ // max: 17,
193
+ // },
194
+ // 'linz:priority': [1001],
195
+ // },
196
+ // },
197
+ // {
198
+ // stac_version: '1.0.0-beta.2',
199
+ // license: 'CC BY 4.0',
200
+ // id: 'im_imageId3',
201
+ // providers: [
202
+ // {
203
+ // name: 'the name',
204
+ // url: 'https://example.provider.com',
205
+ // roles: ['host'],
206
+ // },
207
+ // ],
208
+ // title: 'Hastings-district urban 2015-17 0.1m',
209
+ // description: 'No description',
210
+ // extent: {
211
+ // spatial: {
212
+ // bbox: [[0, 48.9225, 11.25, 55.7766]],
213
+ // },
214
+ // temporal: {
215
+ // interval: [['2015-01-01T00:00:00Z', '2018-01-01T00:00:00Z']],
216
+ // },
217
+ // },
218
+ // links: [],
219
+ // summaries: {
220
+ // 'linz:zoom': {
221
+ // min: 16,
222
+ // max: 18,
223
+ // },
224
+ // 'linz:priority': [1002],
225
+ // },
226
+ // },
227
+ // {
228
+ // stac_version: '1.0.0-beta.2',
229
+ // license: 'CC BY 4.0',
230
+ // id: 'im_imageId4',
231
+ // providers: [
232
+ // {
233
+ // name: 'the name',
234
+ // url: 'https://example.provider.com',
235
+ // roles: ['host'],
236
+ // },
237
+ // ],
238
+ // title: 'Hastings-district urban 2017-18 0.1m',
239
+ // description: 'No description',
240
+ // extent: {
241
+ // spatial: {
242
+ // bbox: [[-22.5, 48.9225, -11.25, 55.7766]],
243
+ // },
244
+ // temporal: {
245
+ // interval: [['2017-01-01T00:00:00Z', '2019-01-01T00:00:00Z']],
246
+ // },
247
+ // },
248
+ // links: [],
249
+ // summaries: {
250
+ // 'linz:zoom': {
251
+ // min: 14,
252
+ // max: 16,
253
+ // },
254
+ // 'linz:priority': [1003],
255
+ // },
256
+ // },
257
+ // ],
258
+ // links: [],
259
+ // };
260
+ // function makeImageRecord(id: string, name: string, x = 10): ConfigImagery {
261
+ // return {
262
+ // id,
263
+ // name,
264
+ // projection: EpsgCode.Google,
265
+ // tileMatrix: 'WebMercatorQuad',
266
+ // uri: 's3://bucket/path/' + name,
267
+ // bounds: GoogleTms.tileToSourceBounds({ x, y: 10, z: 5 }),
268
+ // files: [0, 1].map((i) => {
269
+ // const b = GoogleTms.tileToSourceBounds({ x, y: 10, z: 5 }).toJson() as NamedBounds;
270
+ // b.name = name + i;
271
+ // b.width /= 8;
272
+ // b.height /= 8;
273
+ // b.x += i * b.width;
274
+ // return b;
275
+ // }),
276
+ // updatedAt: Date.now(),
277
+ // };
278
+ // }
279
+ o.spec('/v1/attribution', () => {
280
+ const config = new ConfigProviderMemory();
281
+ const sandbox = sinon.createSandbox();
282
+ o.beforeEach(() => {
283
+ LogConfig.get().level = 'silent';
284
+ Config.setConfigProvider(config);
285
+ config.objects.clear();
286
+ config.put(TileSetAerial);
287
+ config.put(Imagery2193);
288
+ config.put(Imagery3857);
289
+ config.put(Provider);
290
+ });
291
+ o.afterEach(() => {
292
+ sandbox.restore();
293
+ });
294
+ o('should notFound', async () => {
295
+ const request = mockUrlRequest(`/v1/attribution/aerial/1234/summary.json`);
296
+ const res = await handler.router.handle(request);
297
+ o(res.status).equals(404);
298
+ });
299
+ o('should 304 with etag match', async () => {
300
+ const request = mockUrlRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`, 'get', {
301
+ [HttpHeader.IfNoneMatch]: 'E5HGpTqF8AiJ7VgGVKLehYnVfLN9jaVw8Sy6UafJRh2f',
325
302
  });
326
- o('should notFound', async () => {
327
- const request = mockRequest(`/v1/attribution/aerial/1234/summary.json`);
328
- const res = await attribution(request);
329
- o(res.status).equals(404);
303
+ const res = await handler.router.handle(request);
304
+ if (res.status === 200)
305
+ o(res.header('etag')).equals('E5HGpTqF8AiJ7VgGVKLehYnVfLN9jaVw8Sy6UafJRh2f');
306
+ console.log(res.header('etag'));
307
+ o(res.status).equals(304);
308
+ });
309
+ o('should parse attribution', async () => {
310
+ const request = mockUrlRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`);
311
+ const res = await handler.router.handle(request);
312
+ o(res.status).equals(200);
313
+ const json = JSON.parse(res.body);
314
+ const attr = Attribution.fromStac(json);
315
+ o(attr.attributions.length).equals(1);
316
+ o(attr.attributions[0].minZoom).equals(0);
317
+ o(attr.attributions[0].maxZoom).equals(32);
318
+ });
319
+ o.spec('ImageryRules', () => {
320
+ const fakeLayer = { [2193]: Imagery2193.id, name: 'image', minZoom: 9, maxZoom: 16 };
321
+ const ts = FakeData.tileSetRaster('fake');
322
+ o.beforeEach(() => {
323
+ ts.layers = [fakeLayer];
324
+ config.put(Imagery2193);
325
+ config.put(ts);
330
326
  });
331
- o('should 200 with etag mismatch', async () => {
332
- mockFs.jsStore['s3://bucket/path/image1/collection.json'] = {
333
- extent: {
334
- spatial: { bbox: [1, 2, 3, 4] },
335
- temporal: { interval: [['2018-02-03T01:02:03Z', '2018-09-13T11:32:43Z']] },
336
- },
337
- title: 'image one',
338
- description: 'image one description',
339
- license: Stac.License,
340
- providers: [
341
- {
342
- name: 'p1',
343
- },
344
- ],
345
- summaries: {},
346
- };
347
- mockFs.jsStore['s3://bucket/path/image2/collection.json'] = {
348
- extent: {
349
- spatial: { bbox: [5, 6, 7, 8] },
350
- temporal: { interval: [['2016-02-03T01:02:03Z', '2018-09-13T11:32:43Z']] },
351
- },
352
- summaries: {},
353
- };
354
- const request = mockRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`);
355
- const res = await attribution(request);
327
+ o('should generate for NZTM', async () => {
328
+ const req = mockUrlRequest('/v1/tiles/fake/NZTM2000/attribution.json', '');
329
+ const res = await handler.router.handle(req);
356
330
  o(res.status).equals(200);
357
- o(res.header(HttpHeader.ETag)).equals('GAwx9M7X1ygnn2kr9KPCin2gcaGq7DwYMY1dCpJj3no=');
358
- o(res.header(HttpHeader.CacheControl)).equals('public, max-age=86400, stale-while-revalidate=604800');
359
- const body = round(JSON.parse(res.body), 4);
360
- o(body).deepEquals(ExpectedJson);
361
- });
362
- o('should 304 with etag match', async () => {
363
- const request = mockRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`, 'get', {
364
- [HttpHeader.IfNoneMatch]: 'GAwx9M7X1ygnn2kr9KPCin2gcaGq7DwYMY1dCpJj3no=',
365
- });
366
- const res = await attribution(request);
367
- o(res.status).equals(304);
368
- });
369
- o('should parse attribution', async () => {
370
- const request = mockRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`);
371
- const res = await attribution(request);
372
- const json = JSON.parse(res.body);
373
- const attr = Attribution.fromStac(json);
374
- o(attr.attributions.length).equals(4);
375
- o(attr.attributions[0].minZoom).equals(14);
376
- o(attr.attributions[0].maxZoom).equals(16);
377
- });
378
- });
379
- o.spec('ImageryRule', () => {
380
- const fakeIm = { name: 'someName' };
381
- const fakeHost = { serviceProvider: {} };
382
- const fakeLayer = { [2193]: 'id', name: 'image', minZoom: 9, maxZoom: 16 };
383
- o('should generate for NZTM', () => {
384
- const ts = new TileSetRaster('Fake', Nztm2000Tms);
385
- ts.tileSet = { ...ts.tileSet, layers: [fakeLayer] };
386
- const output = createAttributionCollection(ts, null, fakeIm, fakeLayer, fakeHost, null);
387
- o(output.title).equals('SomeName');
388
- o(output.summaries['linz:zoom']).deepEquals({ min: 5, max: 11 });
331
+ const output = JSON.parse(res.body);
332
+ o(output.title).equals(ts.title);
333
+ o(output.collections[0].summaries['linz:zoom']).deepEquals({ min: 5, max: 11 });
389
334
  });
390
- o('should generate with correct zooms for NZTM2000Quad', () => {
391
- const ts = new TileSetRaster('Fake', Nztm2000QuadTms);
392
- ts.tileSet = { ...ts.tileSet, layers: [fakeLayer] };
393
- const output = createAttributionCollection(ts, null, fakeIm, fakeLayer, fakeHost, null);
394
- o(output.title).equals('SomeName');
395
- o(output.summaries['linz:zoom']).deepEquals({ min: 7, max: 14 });
335
+ o('should generate with correct zooms for NZTM2000Quad', async () => {
336
+ const req = mockUrlRequest('/v1/tiles/fake/NZTM2000Quad/attribution.json', '');
337
+ const res = await handler.router.handle(req);
338
+ o(res.status).equals(200);
339
+ const output = JSON.parse(res.body);
340
+ o(output.title).equals(ts.title);
341
+ o(output.collections[0].summaries['linz:zoom']).deepEquals({ min: 7, max: 14 });
396
342
  });
397
- o('should generate with correct zooms for gebco NZTM2000Quad', () => {
343
+ o('should generate with correct zooms for gebco NZTM2000Quad', async () => {
398
344
  const fakeGebco = { ...fakeLayer, minZoom: 0, maxZoom: 15 };
399
- const ts = new TileSetRaster('Fake', Nztm2000QuadTms);
400
- ts.tileSet = { ...ts.tileSet, layers: [fakeLayer] };
401
- const output = createAttributionCollection(ts, null, fakeIm, fakeGebco, fakeHost, null);
402
- o(output.title).equals('SomeName');
403
- o(output.summaries['linz:zoom']).deepEquals({ min: 0, max: 13 });
345
+ ts.layers = [fakeGebco];
346
+ const req = mockUrlRequest('/v1/tiles/fake/NZTM2000Quad/attribution.json', '');
347
+ const res = await handler.router.handle(req);
348
+ o(res.status).equals(200);
349
+ const output = JSON.parse(res.body);
350
+ o(output.title).equals(ts.title);
351
+ o(output.collections[0].summaries['linz:zoom']).deepEquals({ min: 0, max: 13 });
404
352
  });
405
- o('should generate with correct zooms for nz sentinel NZTM2000Quad', () => {
353
+ o('should generate with correct zooms for nz sentinel NZTM2000Quad', async () => {
406
354
  const fakeGebco = { ...fakeLayer, minZoom: 0, maxZoom: 32 };
407
- const ts = new TileSetRaster('Fake', Nztm2000QuadTms);
408
- ts.tileSet = { ...ts.tileSet, layers: [fakeLayer] };
409
- const output = createAttributionCollection(ts, null, fakeIm, fakeGebco, fakeHost, null);
410
- o(output.title).equals('SomeName');
411
- o(output.summaries['linz:zoom']).deepEquals({ min: 0, max: Nztm2000QuadTms.maxZoom });
355
+ ts.layers = [fakeGebco];
356
+ const req = mockUrlRequest('/v1/tiles/fake/NZTM2000Quad/attribution.json', '');
357
+ const res = await handler.router.handle(req);
358
+ o(res.status).equals(200);
359
+ const output = JSON.parse(res.body);
360
+ o(output.title).equals(ts.title);
361
+ o(output.collections[0].summaries['linz:zoom']).deepEquals({ min: 0, max: Nztm2000QuadTms.maxZoom });
412
362
  });
413
363
  });
414
364
  });