@deck.gl/carto 9.0.35 → 9.1.0-beta.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 (242) hide show
  1. package/dist/api/basemap.d.ts +2 -1
  2. package/dist/api/basemap.d.ts.map +1 -1
  3. package/dist/api/basemap.js +3 -0
  4. package/dist/api/fetch-map.d.ts.map +1 -1
  5. package/dist/api/fetch-map.js +9 -11
  6. package/dist/api/index.d.ts +1 -4
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/index.js +3 -2
  9. package/dist/api/layer-map.d.ts.map +1 -1
  10. package/dist/api/layer-map.js +5 -2
  11. package/dist/api/parse-map.d.ts.map +1 -1
  12. package/dist/api/parse-map.js +3 -0
  13. package/dist/api/types.d.ts +0 -56
  14. package/dist/api/types.d.ts.map +1 -1
  15. package/dist/api/types.js +4 -20
  16. package/dist/basemap.d.ts +2 -1
  17. package/dist/basemap.d.ts.map +1 -1
  18. package/dist/basemap.js +4 -1
  19. package/dist/cartoRasterTile-worker.js +25 -2
  20. package/dist/cartoSpatialTile-worker.js +28 -3
  21. package/dist/cartoVectorTile-worker.js +29 -3
  22. package/dist/constants.d.ts +0 -3
  23. package/dist/constants.d.ts.map +1 -1
  24. package/dist/constants.js +3 -3
  25. package/dist/dist.dev.js +4391 -3737
  26. package/dist/index.cjs +224 -531
  27. package/dist/index.cjs.map +4 -4
  28. package/dist/index.d.ts +16 -16
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +5 -2
  31. package/dist/layers/cluster-tile-layer.d.ts +1 -1
  32. package/dist/layers/cluster-tile-layer.d.ts.map +1 -1
  33. package/dist/layers/cluster-tile-layer.js +4 -0
  34. package/dist/layers/cluster-utils.d.ts.map +1 -1
  35. package/dist/layers/cluster-utils.js +3 -0
  36. package/dist/layers/h3-tile-layer.d.ts +1 -1
  37. package/dist/layers/h3-tile-layer.d.ts.map +1 -1
  38. package/dist/layers/h3-tile-layer.js +3 -0
  39. package/dist/layers/h3-tileset-2d.d.ts.map +1 -1
  40. package/dist/layers/h3-tileset-2d.js +3 -0
  41. package/dist/layers/heatmap-tile-layer.d.ts +1 -1
  42. package/dist/layers/heatmap-tile-layer.d.ts.map +1 -1
  43. package/dist/layers/heatmap-tile-layer.js +23 -7
  44. package/dist/layers/heatmap.d.ts +3 -3
  45. package/dist/layers/heatmap.d.ts.map +1 -1
  46. package/dist/layers/heatmap.js +69 -36
  47. package/dist/layers/point-label-layer.d.ts.map +1 -1
  48. package/dist/layers/point-label-layer.js +5 -2
  49. package/dist/layers/post-process-utils.d.ts.map +1 -1
  50. package/dist/layers/post-process-utils.js +9 -5
  51. package/dist/layers/quadbin-layer.d.ts.map +1 -1
  52. package/dist/layers/quadbin-layer.js +3 -0
  53. package/dist/layers/quadbin-tile-layer.d.ts +1 -1
  54. package/dist/layers/quadbin-tile-layer.d.ts.map +1 -1
  55. package/dist/layers/quadbin-tile-layer.js +3 -0
  56. package/dist/layers/quadbin-tileset-2d.d.ts.map +1 -1
  57. package/dist/layers/quadbin-tileset-2d.js +3 -0
  58. package/dist/layers/quadbin-utils.d.ts.map +1 -1
  59. package/dist/layers/quadbin-utils.js +3 -0
  60. package/dist/layers/raster-layer-vertex.glsl.d.ts +1 -1
  61. package/dist/layers/raster-layer-vertex.glsl.d.ts.map +1 -1
  62. package/dist/layers/raster-layer-vertex.glsl.js +19 -24
  63. package/dist/layers/raster-layer.d.ts +6 -6
  64. package/dist/layers/raster-layer.d.ts.map +1 -1
  65. package/dist/layers/raster-layer.js +6 -1
  66. package/dist/layers/raster-tile-layer.d.ts +1 -1
  67. package/dist/layers/raster-tile-layer.d.ts.map +1 -1
  68. package/dist/layers/raster-tile-layer.js +3 -0
  69. package/dist/layers/schema/carto-properties-tile-loader.d.ts.map +1 -1
  70. package/dist/layers/schema/carto-properties-tile-loader.js +3 -0
  71. package/dist/layers/schema/carto-properties-tile.d.ts.map +1 -1
  72. package/dist/layers/schema/carto-properties-tile.js +3 -0
  73. package/dist/layers/schema/carto-raster-tile-loader.d.ts.map +1 -1
  74. package/dist/layers/schema/carto-raster-tile-loader.js +4 -1
  75. package/dist/layers/schema/carto-raster-tile.d.ts.map +1 -1
  76. package/dist/layers/schema/carto-raster-tile.js +3 -0
  77. package/dist/layers/schema/carto-spatial-tile-loader.d.ts.map +1 -1
  78. package/dist/layers/schema/carto-spatial-tile-loader.js +4 -1
  79. package/dist/layers/schema/carto-spatial-tile.d.ts.map +1 -1
  80. package/dist/layers/schema/carto-spatial-tile.js +3 -0
  81. package/dist/layers/schema/carto-tile.d.ts.map +1 -1
  82. package/dist/layers/schema/carto-tile.js +3 -0
  83. package/dist/layers/schema/carto-vector-tile-loader.d.ts.map +1 -1
  84. package/dist/layers/schema/carto-vector-tile-loader.js +4 -1
  85. package/dist/layers/schema/fast-pbf.d.ts.map +1 -1
  86. package/dist/layers/schema/fast-pbf.js +3 -0
  87. package/dist/layers/schema/spatialjson-utils.d.ts.map +1 -1
  88. package/dist/layers/schema/spatialjson-utils.js +3 -0
  89. package/dist/layers/schema/tile-loader-utils.d.ts.map +1 -1
  90. package/dist/layers/schema/tile-loader-utils.js +3 -0
  91. package/dist/layers/spatial-index-tile-layer.d.ts.map +1 -1
  92. package/dist/layers/spatial-index-tile-layer.js +3 -0
  93. package/dist/layers/utils.d.ts +2 -2
  94. package/dist/layers/utils.d.ts.map +1 -1
  95. package/dist/layers/utils.js +3 -0
  96. package/dist/layers/vector-tile-layer.d.ts +1 -1
  97. package/dist/layers/vector-tile-layer.d.ts.map +1 -1
  98. package/dist/layers/vector-tile-layer.js +3 -0
  99. package/dist/style/color-bins-style.d.ts.map +1 -1
  100. package/dist/style/color-bins-style.js +3 -0
  101. package/dist/style/color-categories-style.d.ts.map +1 -1
  102. package/dist/style/color-categories-style.js +3 -0
  103. package/dist/style/color-continuous-style.d.ts.map +1 -1
  104. package/dist/style/color-continuous-style.js +3 -0
  105. package/dist/style/palette.d.ts.map +1 -1
  106. package/dist/style/palette.js +3 -0
  107. package/dist/style/utils.d.ts.map +1 -1
  108. package/dist/style/utils.js +3 -0
  109. package/dist/utils.d.ts.map +1 -1
  110. package/dist/utils.js +3 -0
  111. package/dist/workers/cartoRasterTile.js +3 -0
  112. package/dist/workers/cartoSpatialTile.js +3 -0
  113. package/dist/workers/cartoVectorTile.js +3 -0
  114. package/dist.min.js +113 -73
  115. package/package.json +13 -11
  116. package/src/api/basemap.ts +6 -1
  117. package/src/api/fetch-map.ts +23 -15
  118. package/src/api/index.ts +5 -13
  119. package/src/api/layer-map.ts +6 -2
  120. package/src/api/parse-map.ts +4 -0
  121. package/src/api/types.ts +4 -75
  122. package/src/basemap.ts +6 -2
  123. package/src/constants.ts +4 -4
  124. package/src/index.ts +7 -9
  125. package/src/layers/cluster-tile-layer.ts +6 -1
  126. package/src/layers/cluster-utils.ts +4 -0
  127. package/src/layers/h3-tile-layer.ts +5 -1
  128. package/src/layers/h3-tileset-2d.ts +4 -0
  129. package/src/layers/heatmap-tile-layer.ts +29 -8
  130. package/src/layers/heatmap.ts +8 -2
  131. package/src/layers/point-label-layer.ts +6 -2
  132. package/src/layers/post-process-utils.ts +10 -5
  133. package/src/layers/quadbin-layer.ts +4 -0
  134. package/src/layers/quadbin-tile-layer.ts +5 -1
  135. package/src/layers/quadbin-tileset-2d.ts +4 -0
  136. package/src/layers/quadbin-utils.ts +4 -0
  137. package/src/layers/raster-layer-vertex.glsl.ts +20 -26
  138. package/src/layers/raster-layer.ts +7 -1
  139. package/src/layers/raster-tile-layer.ts +5 -1
  140. package/src/layers/schema/carto-properties-tile-loader.ts +4 -0
  141. package/src/layers/schema/carto-properties-tile.ts +4 -0
  142. package/src/layers/schema/carto-raster-tile-loader.ts +4 -0
  143. package/src/layers/schema/carto-raster-tile.ts +4 -0
  144. package/src/layers/schema/carto-spatial-tile-loader.ts +4 -0
  145. package/src/layers/schema/carto-spatial-tile.ts +4 -0
  146. package/src/layers/schema/carto-tile.ts +4 -0
  147. package/src/layers/schema/carto-vector-tile-loader.ts +4 -0
  148. package/src/layers/schema/fast-pbf.ts +4 -0
  149. package/src/layers/schema/spatialjson-utils.ts +4 -0
  150. package/src/layers/schema/tile-loader-utils.ts +4 -0
  151. package/src/layers/spatial-index-tile-layer.ts +4 -0
  152. package/src/layers/utils.ts +5 -1
  153. package/src/layers/vector-tile-layer.ts +5 -1
  154. package/src/style/color-bins-style.ts +4 -0
  155. package/src/style/color-categories-style.ts +4 -0
  156. package/src/style/color-continuous-style.ts +4 -0
  157. package/src/style/palette.ts +4 -0
  158. package/src/style/utils.ts +4 -0
  159. package/src/utils.ts +4 -0
  160. package/src/workers/cartoRasterTile.ts +4 -0
  161. package/src/workers/cartoSpatialTile.ts +4 -0
  162. package/src/workers/cartoVectorTile.ts +4 -0
  163. package/dist/api/carto-api-error.d.ts +0 -19
  164. package/dist/api/carto-api-error.d.ts.map +0 -1
  165. package/dist/api/carto-api-error.js +0 -48
  166. package/dist/api/common.d.ts +0 -5
  167. package/dist/api/common.d.ts.map +0 -1
  168. package/dist/api/common.js +0 -5
  169. package/dist/api/endpoints.d.ts +0 -23
  170. package/dist/api/endpoints.d.ts.map +0 -1
  171. package/dist/api/endpoints.js +0 -22
  172. package/dist/api/query.d.ts +0 -4
  173. package/dist/api/query.d.ts.map +0 -1
  174. package/dist/api/query.js +0 -26
  175. package/dist/api/request-with-parameters.d.ts +0 -9
  176. package/dist/api/request-with-parameters.d.ts.map +0 -1
  177. package/dist/api/request-with-parameters.js +0 -86
  178. package/dist/sources/base-source.d.ts +0 -5
  179. package/dist/sources/base-source.d.ts.map +0 -1
  180. package/dist/sources/base-source.js +0 -60
  181. package/dist/sources/boundary-query-source.d.ts +0 -10
  182. package/dist/sources/boundary-query-source.d.ts.map +0 -1
  183. package/dist/sources/boundary-query-source.js +0 -18
  184. package/dist/sources/boundary-table-source.d.ts +0 -8
  185. package/dist/sources/boundary-table-source.d.ts.map +0 -1
  186. package/dist/sources/boundary-table-source.js +0 -15
  187. package/dist/sources/h3-query-source.d.ts +0 -4
  188. package/dist/sources/h3-query-source.d.ts.map +0 -1
  189. package/dist/sources/h3-query-source.js +0 -22
  190. package/dist/sources/h3-table-source.d.ts +0 -4
  191. package/dist/sources/h3-table-source.d.ts.map +0 -1
  192. package/dist/sources/h3-table-source.js +0 -19
  193. package/dist/sources/h3-tileset-source.d.ts +0 -4
  194. package/dist/sources/h3-tileset-source.d.ts.map +0 -1
  195. package/dist/sources/h3-tileset-source.js +0 -6
  196. package/dist/sources/index.d.ts +0 -28
  197. package/dist/sources/index.d.ts.map +0 -1
  198. package/dist/sources/index.js +0 -13
  199. package/dist/sources/quadbin-query-source.d.ts +0 -4
  200. package/dist/sources/quadbin-query-source.d.ts.map +0 -1
  201. package/dist/sources/quadbin-query-source.js +0 -22
  202. package/dist/sources/quadbin-table-source.d.ts +0 -4
  203. package/dist/sources/quadbin-table-source.d.ts.map +0 -1
  204. package/dist/sources/quadbin-table-source.js +0 -19
  205. package/dist/sources/quadbin-tileset-source.d.ts +0 -4
  206. package/dist/sources/quadbin-tileset-source.d.ts.map +0 -1
  207. package/dist/sources/quadbin-tileset-source.js +0 -6
  208. package/dist/sources/raster-source.d.ts +0 -4
  209. package/dist/sources/raster-source.d.ts.map +0 -1
  210. package/dist/sources/raster-source.js +0 -9
  211. package/dist/sources/types.d.ts +0 -219
  212. package/dist/sources/types.d.ts.map +0 -1
  213. package/dist/sources/types.js +0 -1
  214. package/dist/sources/vector-query-source.d.ts +0 -4
  215. package/dist/sources/vector-query-source.d.ts.map +0 -1
  216. package/dist/sources/vector-query-source.js +0 -22
  217. package/dist/sources/vector-table-source.d.ts +0 -4
  218. package/dist/sources/vector-table-source.d.ts.map +0 -1
  219. package/dist/sources/vector-table-source.js +0 -19
  220. package/dist/sources/vector-tileset-source.d.ts +0 -4
  221. package/dist/sources/vector-tileset-source.d.ts.map +0 -1
  222. package/dist/sources/vector-tileset-source.js +0 -6
  223. package/src/api/carto-api-error.ts +0 -68
  224. package/src/api/common.ts +0 -6
  225. package/src/api/endpoints.ts +0 -69
  226. package/src/api/query.ts +0 -42
  227. package/src/api/request-with-parameters.ts +0 -117
  228. package/src/sources/base-source.ts +0 -79
  229. package/src/sources/boundary-query-source.ts +0 -39
  230. package/src/sources/boundary-table-source.ts +0 -33
  231. package/src/sources/h3-query-source.ts +0 -55
  232. package/src/sources/h3-table-source.ts +0 -51
  233. package/src/sources/h3-tileset-source.ts +0 -14
  234. package/src/sources/index.ts +0 -45
  235. package/src/sources/quadbin-query-source.ts +0 -56
  236. package/src/sources/quadbin-table-source.ts +0 -52
  237. package/src/sources/quadbin-tileset-source.ts +0 -14
  238. package/src/sources/raster-source.ts +0 -17
  239. package/src/sources/types.ts +0 -231
  240. package/src/sources/vector-query-source.ts +0 -57
  241. package/src/sources/vector-table-source.ts +0 -51
  242. package/src/sources/vector-tileset-source.ts +0 -14
@@ -1,56 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants';
3
- import {baseSource} from './base-source';
4
- import type {
5
- AggregationOptions,
6
- FilterOptions,
7
- QuerySourceOptions,
8
- SourceOptions,
9
- SpatialDataType,
10
- TilejsonResult
11
- } from './types';
12
-
13
- export type QuadbinQuerySourceOptions = SourceOptions &
14
- QuerySourceOptions &
15
- AggregationOptions &
16
- FilterOptions;
17
-
18
- type UrlParameters = {
19
- aggregationExp: string;
20
- aggregationResLevel?: string;
21
- spatialDataType: SpatialDataType;
22
- spatialDataColumn?: string;
23
- q: string;
24
- queryParameters?: Record<string, unknown> | unknown[];
25
- filters?: Record<string, unknown>;
26
- };
27
-
28
- export const quadbinQuerySource = async function (
29
- options: QuadbinQuerySourceOptions
30
- ): Promise<TilejsonResult> {
31
- const {
32
- aggregationExp,
33
- aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
34
- sqlQuery,
35
- spatialDataColumn = 'quadbin',
36
- queryParameters,
37
- filters
38
- } = options;
39
- const urlParameters: UrlParameters = {
40
- aggregationExp,
41
- q: sqlQuery,
42
- spatialDataColumn,
43
- spatialDataType: 'quadbin'
44
- };
45
-
46
- if (aggregationResLevel) {
47
- urlParameters.aggregationResLevel = String(aggregationResLevel);
48
- }
49
- if (queryParameters) {
50
- urlParameters.queryParameters = queryParameters;
51
- }
52
- if (filters) {
53
- urlParameters.filters = filters;
54
- }
55
- return baseSource<UrlParameters>('query', options, urlParameters) as Promise<TilejsonResult>;
56
- };
@@ -1,52 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants';
3
- import {baseSource} from './base-source';
4
- import type {
5
- AggregationOptions,
6
- FilterOptions,
7
- SourceOptions,
8
- SpatialDataType,
9
- TableSourceOptions,
10
- TilejsonResult
11
- } from './types';
12
-
13
- export type QuadbinTableSourceOptions = SourceOptions &
14
- TableSourceOptions &
15
- AggregationOptions &
16
- FilterOptions;
17
-
18
- type UrlParameters = {
19
- aggregationExp: string;
20
- aggregationResLevel?: string;
21
- spatialDataType: SpatialDataType;
22
- spatialDataColumn?: string;
23
- name: string;
24
- filters?: Record<string, unknown>;
25
- };
26
-
27
- export const quadbinTableSource = async function (
28
- options: QuadbinTableSourceOptions
29
- ): Promise<TilejsonResult> {
30
- const {
31
- aggregationExp,
32
- aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
33
- spatialDataColumn = 'quadbin',
34
- tableName,
35
- filters
36
- } = options;
37
-
38
- const urlParameters: UrlParameters = {
39
- aggregationExp,
40
- name: tableName,
41
- spatialDataColumn,
42
- spatialDataType: 'quadbin'
43
- };
44
-
45
- if (aggregationResLevel) {
46
- urlParameters.aggregationResLevel = String(aggregationResLevel);
47
- }
48
- if (filters) {
49
- urlParameters.filters = filters;
50
- }
51
- return baseSource<UrlParameters>('table', options, urlParameters) as Promise<TilejsonResult>;
52
- };
@@ -1,14 +0,0 @@
1
- import {baseSource} from './base-source';
2
- import type {SourceOptions, TilejsonResult, TilesetSourceOptions} from './types';
3
-
4
- export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
5
- type UrlParameters = {name: string};
6
-
7
- export const quadbinTilesetSource = async function (
8
- options: QuadbinTilesetSourceOptions
9
- ): Promise<TilejsonResult> {
10
- const {tableName} = options;
11
- const urlParameters: UrlParameters = {name: tableName};
12
-
13
- return baseSource<UrlParameters>('tileset', options, urlParameters) as Promise<TilejsonResult>;
14
- };
@@ -1,17 +0,0 @@
1
- import {baseSource} from './base-source';
2
- import type {FilterOptions, SourceOptions, TilejsonResult, TilesetSourceOptions} from './types';
3
-
4
- export type RasterSourceOptions = SourceOptions & TilesetSourceOptions & FilterOptions;
5
- type UrlParameters = {
6
- name: string;
7
- filters?: Record<string, unknown>;
8
- };
9
-
10
- export const rasterSource = async function (options: RasterSourceOptions): Promise<TilejsonResult> {
11
- const {tableName, filters} = options;
12
- const urlParameters: UrlParameters = {name: tableName};
13
- if (filters) {
14
- urlParameters.filters = filters;
15
- }
16
- return baseSource<UrlParameters>('raster', options, urlParameters) as Promise<TilejsonResult>;
17
- };
@@ -1,231 +0,0 @@
1
- import type {Feature} from 'geojson';
2
- import type {Filters, Format, MapInstantiation, QueryParameters} from '../api/types';
3
-
4
- export type SourceRequiredOptions = {
5
- /** Carto platform access token. */
6
- accessToken: string;
7
-
8
- /** Data warehouse connection name in Carto platform. */
9
- connectionName: string;
10
- };
11
-
12
- export type SourceOptionalOptions = {
13
- /**
14
- * Base URL of the CARTO Maps API.
15
- *
16
- * Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com`
17
- *
18
- * @default https://gcp-us-east1.api.carto.com
19
- */
20
- apiBaseUrl: string;
21
-
22
- /**
23
- * Custom HTTP headers added to map instantiation and data requests.
24
- */
25
- headers: Record<string, string>;
26
-
27
- /**
28
- * Cache buster value returned by map instantiation.
29
- *
30
- * Carto source saves `cache` value of map instantiation response in `cache.value`, so it can be used to
31
- * check if underlying map data has changed between distinct source requests.
32
- */
33
- cache?: {value?: number};
34
-
35
- clientId: string;
36
- /** @deprecated use `query` instead **/
37
- format: Format;
38
-
39
- /**
40
- * Maximum URL character length. Above this limit, requests use POST.
41
- * Used to avoid browser and CDN limits.
42
- * @default {@link DEFAULT_MAX_LENGTH_URL}
43
- */
44
- maxLengthURL?: number;
45
- };
46
-
47
- export type SourceOptions = SourceRequiredOptions & Partial<SourceOptionalOptions>;
48
-
49
- export type AggregationOptions = {
50
- /**
51
- * Defines the aggregation expressions that will be calculated from the resulting columns on each grid cell.
52
- *
53
- * Example:
54
- *
55
- * sum(pop) as total_population, avg(rev) as average_revenue
56
- */
57
- aggregationExp: string;
58
-
59
- /**
60
- * Defines the tile aggregation resolution.
61
- *
62
- * @default 6 for quadbin and 4 for h3 sources
63
- */
64
- aggregationResLevel?: number;
65
- };
66
-
67
- export type FilterOptions = {
68
- /**
69
- * Filters to apply to the data source on the server
70
- */
71
- filters?: Filters;
72
- };
73
-
74
- export type QuerySourceOptions = {
75
- /**
76
- * The column name and the type of geospatial support.
77
- *
78
- * If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
79
- */
80
- spatialDataColumn?: string;
81
-
82
- /** SQL query. */
83
- sqlQuery: string;
84
-
85
- /**
86
- * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
87
- * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
88
- * the quantization grid proportionately.
89
- *
90
- * Supported `tileResolution` values, with corresponding grid sizes:
91
- *
92
- * - 0.25: 256x256
93
- * - 0.5: 512x512
94
- * - 1: 1024x1024
95
- * - 2: 2048x2048
96
- * - 4: 4096x4096
97
- */
98
- tileResolution?: TileResolution;
99
-
100
- /**
101
- * Values for named or positional paramteres in the query.
102
- *
103
- * The way query parameters are determined by data warehouse.
104
- *
105
- * * BigQuery has named query parameters, specified with a dictionary, and referenced by key (`@key`)
106
- *
107
- * ```
108
- * sqlQuery: "SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = ⁣@type AND revenue > ⁣@minRevenue"
109
- * queryParameters: { type: 'Supermarket', minRevenue: 1000000 }
110
- * ```
111
- * * Snowflake supports positional parameters, in the form `:1`, `:2`, etc.
112
- *
113
- * ```
114
- * sqlQuery: "SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1
115
- * queryParameters: [100000, "Supermarket"]
116
- * ```
117
- * * Postgres and Redhisft supports positional parameters, but in the form `$1`, `$2`, etc.
118
- *
119
- * ```
120
- * sqlQuery: "SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1
121
- * queryParameters: [100000, "Supermarket"]
122
- * ```
123
- */
124
- queryParameters?: QueryParameters;
125
- };
126
-
127
- export type TableSourceOptions = {
128
- /**
129
- * Fully qualified name of table.
130
- */
131
- tableName: string;
132
-
133
- /**
134
- * The column name and the type of geospatial support.
135
- *
136
- * If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
137
- */
138
- spatialDataColumn?: string;
139
-
140
- /**
141
- * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
142
- * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
143
- * the quantization grid proportionately.
144
- *
145
- * Supported `tileResolution` values, with corresponding grid sizes:
146
- *
147
- * - 0.25: 256x256
148
- * - 0.5: 512x512
149
- * - 1: 1024x1024
150
- * - 2: 2048x2048
151
- * - 4: 4096x4096
152
- */
153
- tileResolution?: TileResolution;
154
- };
155
-
156
- export type TilesetSourceOptions = {
157
- /**
158
- * Fully qualified name of tileset.
159
- */
160
- tableName: string;
161
- };
162
-
163
- export type ColumnsOption = {
164
- /**
165
- * Columns to retrieve from the table.
166
- *
167
- * If not present, all columns are returned.
168
- */
169
- columns?: string[];
170
- };
171
-
172
- export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
173
-
174
- export type TilejsonMapInstantiation = MapInstantiation & {
175
- tilejson: {url: string[]};
176
- };
177
-
178
- export type TileResolution = 0.25 | 0.5 | 1 | 2 | 4;
179
-
180
- export interface Tilejson {
181
- tilejson: string;
182
- name: string;
183
- description: string;
184
- version: string;
185
- attribution: string;
186
- scheme: string;
187
- tiles: string[];
188
- properties_tiles: string[];
189
- minresolution: number;
190
- maxresolution: number;
191
- minzoom: number;
192
- maxzoom: number;
193
- bounds: [number, number, number, number];
194
- center: [number, number, number];
195
- vector_layers: VectorLayer[];
196
- tilestats: Tilestats;
197
- tileResolution?: TileResolution;
198
- }
199
-
200
- export interface Tilestats {
201
- layerCount: number;
202
- layers: Layer[];
203
- }
204
-
205
- export interface Layer {
206
- layer: string;
207
- count: number;
208
- attributeCount: number;
209
- attributes: Attribute[];
210
- }
211
-
212
- export interface Attribute {
213
- attribute: string;
214
- type: string;
215
- }
216
-
217
- export interface VectorLayer {
218
- id: string;
219
- minzoom: number;
220
- maxzoom: number;
221
- fields: Record<string, string>;
222
- }
223
-
224
- export type TilejsonResult = Tilejson & {accessToken: string};
225
- export type GeojsonResult = {type: 'FeatureCollection'; features: Feature[]};
226
- export type JsonResult = any[];
227
- export type QueryResult = {
228
- meta: {cacheHit: boolean; location: string; totalBytesProcessed: string};
229
- rows: Record<string, any>[];
230
- schema: {name: string; type: string}[];
231
- };
@@ -1,57 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import {DEFAULT_TILE_RESOLUTION} from '../constants';
3
- import {baseSource} from './base-source';
4
- import type {
5
- FilterOptions,
6
- SourceOptions,
7
- QuerySourceOptions,
8
- SpatialDataType,
9
- TilejsonResult,
10
- ColumnsOption
11
- } from './types';
12
-
13
- export type VectorQuerySourceOptions = SourceOptions &
14
- QuerySourceOptions &
15
- FilterOptions &
16
- ColumnsOption;
17
-
18
- type UrlParameters = {
19
- columns?: string;
20
- filters?: Record<string, unknown>;
21
- spatialDataType: SpatialDataType;
22
- spatialDataColumn?: string;
23
- tileResolution?: string;
24
- q: string;
25
- queryParameters?: Record<string, unknown> | unknown[];
26
- };
27
-
28
- export const vectorQuerySource = async function (
29
- options: VectorQuerySourceOptions
30
- ): Promise<TilejsonResult> {
31
- const {
32
- columns,
33
- filters,
34
- spatialDataColumn = 'geom',
35
- sqlQuery,
36
- tileResolution = DEFAULT_TILE_RESOLUTION,
37
- queryParameters
38
- } = options;
39
-
40
- const urlParameters: UrlParameters = {
41
- spatialDataColumn,
42
- spatialDataType: 'geo',
43
- tileResolution: tileResolution.toString(),
44
- q: sqlQuery
45
- };
46
-
47
- if (columns) {
48
- urlParameters.columns = columns.join(',');
49
- }
50
- if (filters) {
51
- urlParameters.filters = filters;
52
- }
53
- if (queryParameters) {
54
- urlParameters.queryParameters = queryParameters;
55
- }
56
- return baseSource<UrlParameters>('query', options, urlParameters) as Promise<TilejsonResult>;
57
- };
@@ -1,51 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import {DEFAULT_TILE_RESOLUTION} from '../constants';
3
- import {baseSource} from './base-source';
4
- import type {
5
- FilterOptions,
6
- ColumnsOption,
7
- SourceOptions,
8
- SpatialDataType,
9
- TableSourceOptions,
10
- TilejsonResult
11
- } from './types';
12
-
13
- export type VectorTableSourceOptions = SourceOptions &
14
- TableSourceOptions &
15
- FilterOptions &
16
- ColumnsOption;
17
- type UrlParameters = {
18
- columns?: string;
19
- filters?: Record<string, unknown>;
20
- spatialDataType: SpatialDataType;
21
- spatialDataColumn?: string;
22
- tileResolution?: string;
23
- name: string;
24
- };
25
-
26
- export const vectorTableSource = async function (
27
- options: VectorTableSourceOptions
28
- ): Promise<TilejsonResult> {
29
- const {
30
- columns,
31
- filters,
32
- spatialDataColumn = 'geom',
33
- tableName,
34
- tileResolution = DEFAULT_TILE_RESOLUTION
35
- } = options;
36
-
37
- const urlParameters: UrlParameters = {
38
- name: tableName,
39
- spatialDataColumn,
40
- spatialDataType: 'geo',
41
- tileResolution: tileResolution.toString()
42
- };
43
-
44
- if (columns) {
45
- urlParameters.columns = columns.join(',');
46
- }
47
- if (filters) {
48
- urlParameters.filters = filters;
49
- }
50
- return baseSource<UrlParameters>('table', options, urlParameters) as Promise<TilejsonResult>;
51
- };
@@ -1,14 +0,0 @@
1
- import {baseSource} from './base-source';
2
- import type {SourceOptions, TilesetSourceOptions, TilejsonResult} from './types';
3
-
4
- export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
5
- type UrlParameters = {name: string};
6
-
7
- export const vectorTilesetSource = async function (
8
- options: VectorTilesetSourceOptions
9
- ): Promise<TilejsonResult> {
10
- const {tableName} = options;
11
- const urlParameters: UrlParameters = {name: tableName};
12
-
13
- return baseSource<UrlParameters>('tileset', options, urlParameters) as Promise<TilejsonResult>;
14
- };