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