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