From 79b3e9dd1c889e6d976958dd4c6add985aea061e Mon Sep 17 00:00:00 2001 From: felixpalmer Date: Wed, 8 Nov 2023 13:21:23 +0100 Subject: [PATCH] CARTO: API v3.3 reenable (#8265) --- modules/carto/src/api/common.ts | 2 +- modules/carto/src/sources/h3-query-source.ts | 23 ++++++++++++------ modules/carto/src/sources/h3-table-source.ts | 23 ++++++++++++------ .../carto/src/sources/quadbin-query-source.ts | 23 ++++++++++++------ .../carto/src/sources/quadbin-table-source.ts | 24 +++++++++++++------ modules/carto/src/sources/types.ts | 2 +- .../carto/src/sources/vector-query-source.ts | 14 ++++++----- .../carto/src/sources/vector-table-source.ts | 14 ++++++----- 8 files changed, 83 insertions(+), 42 deletions(-) diff --git a/modules/carto/src/api/common.ts b/modules/carto/src/api/common.ts index 2091c2c2a84..8c7571603a0 100644 --- a/modules/carto/src/api/common.ts +++ b/modules/carto/src/api/common.ts @@ -1,6 +1,6 @@ export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com'; export const DEFAULT_CLIENT = 'deck-gl-carto'; -export const V3_MINOR_VERSION = '3.2'; +export const V3_MINOR_VERSION = '3.3'; export const MAX_GET_LENGTH = 8192; export const DEFAULT_PARAMETERS = { diff --git a/modules/carto/src/sources/h3-query-source.ts b/modules/carto/src/sources/h3-query-source.ts index f528ee17cb8..50517ddbdda 100644 --- a/modules/carto/src/sources/h3-query-source.ts +++ b/modules/carto/src/sources/h3-query-source.ts @@ -1,12 +1,19 @@ /* eslint-disable camelcase */ import {baseSource} from './base-source'; -import type {AggregationOptions, QuerySourceOptions, SourceOptions, TilejsonResult} from './types'; +import type { + AggregationOptions, + QuerySourceOptions, + SourceOptions, + SpatialDataType, + TilejsonResult +} from './types'; export type H3QuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions; type UrlParameters = { aggregationExp: string; aggregationResLevel?: string; - geo_column?: string; + spatialDataType: SpatialDataType; + spatialDataColumn?: string; q: string; queryParameters?: string; }; @@ -18,17 +25,19 @@ export const h3QuerySource = async function ( aggregationExp, aggregationResLevel = 4, sqlQuery, - spatialDataColumn = 'h3:h3', + spatialDataColumn = 'h3', queryParameters } = options; - const urlParameters: UrlParameters = {aggregationExp, q: sqlQuery}; + const urlParameters: UrlParameters = { + aggregationExp, + spatialDataColumn, + spatialDataType: 'h3', + q: sqlQuery + }; if (aggregationResLevel) { urlParameters.aggregationResLevel = String(aggregationResLevel); } - if (spatialDataColumn) { - urlParameters.geo_column = spatialDataColumn; - } if (queryParameters) { urlParameters.queryParameters = JSON.stringify(queryParameters); } diff --git a/modules/carto/src/sources/h3-table-source.ts b/modules/carto/src/sources/h3-table-source.ts index 2c5bb265c51..ee3a9c738c8 100644 --- a/modules/carto/src/sources/h3-table-source.ts +++ b/modules/carto/src/sources/h3-table-source.ts @@ -1,6 +1,12 @@ /* eslint-disable camelcase */ import {baseSource} from './base-source'; -import type {AggregationOptions, SourceOptions, TableSourceOptions, TilejsonResult} from './types'; +import type { + AggregationOptions, + SourceOptions, + SpatialDataType, + TableSourceOptions, + TilejsonResult +} from './types'; export type H3TableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions; @@ -8,7 +14,8 @@ type UrlParameters = { aggregationExp: string; aggregationResLevel?: string; columns?: string; - geo_column?: string; + spatialDataType: SpatialDataType; + spatialDataColumn?: string; name: string; }; @@ -19,10 +26,15 @@ export const h3TableSource = async function ( aggregationExp, aggregationResLevel = 4, columns, - spatialDataColumn = 'h3:h3', + spatialDataColumn = 'h3', tableName } = options; - const urlParameters: UrlParameters = {aggregationExp, name: tableName}; + const urlParameters: UrlParameters = { + aggregationExp, + name: tableName, + spatialDataColumn, + spatialDataType: 'h3' + }; if (aggregationResLevel) { urlParameters.aggregationResLevel = String(aggregationResLevel); @@ -30,8 +42,5 @@ export const h3TableSource = async function ( if (columns) { urlParameters.columns = columns.join(','); } - if (spatialDataColumn) { - urlParameters.geo_column = spatialDataColumn; - } return baseSource('table', options, urlParameters) as Promise; }; diff --git a/modules/carto/src/sources/quadbin-query-source.ts b/modules/carto/src/sources/quadbin-query-source.ts index 89965405ff6..a0542912027 100644 --- a/modules/carto/src/sources/quadbin-query-source.ts +++ b/modules/carto/src/sources/quadbin-query-source.ts @@ -1,13 +1,20 @@ /* eslint-disable camelcase */ import {baseSource} from './base-source'; -import type {AggregationOptions, QuerySourceOptions, SourceOptions, TilejsonResult} from './types'; +import type { + AggregationOptions, + QuerySourceOptions, + SourceOptions, + SpatialDataType, + TilejsonResult +} from './types'; export type QuadbinQuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions; type UrlParameters = { aggregationExp: string; aggregationResLevel?: string; - geo_column?: string; + spatialDataType: SpatialDataType; + spatialDataColumn?: string; q: string; queryParameters?: string; }; @@ -19,17 +26,19 @@ export const quadbinQuerySource = async function ( aggregationExp, aggregationResLevel = 6, sqlQuery, - spatialDataColumn = 'quadbin:quadbin', + spatialDataColumn = 'quadbin', queryParameters } = options; - const urlParameters: UrlParameters = {aggregationExp, q: sqlQuery}; + const urlParameters: UrlParameters = { + aggregationExp, + q: sqlQuery, + spatialDataColumn, + spatialDataType: 'quadbin' + }; if (aggregationResLevel) { urlParameters.aggregationResLevel = String(aggregationResLevel); } - if (spatialDataColumn) { - urlParameters.geo_column = spatialDataColumn; - } if (queryParameters) { urlParameters.queryParameters = JSON.stringify(queryParameters); } diff --git a/modules/carto/src/sources/quadbin-table-source.ts b/modules/carto/src/sources/quadbin-table-source.ts index 920970a20db..45b54abcc41 100644 --- a/modules/carto/src/sources/quadbin-table-source.ts +++ b/modules/carto/src/sources/quadbin-table-source.ts @@ -1,6 +1,12 @@ /* eslint-disable camelcase */ import {baseSource} from './base-source'; -import type {AggregationOptions, SourceOptions, TableSourceOptions, TilejsonResult} from './types'; +import type { + AggregationOptions, + SourceOptions, + SpatialDataType, + TableSourceOptions, + TilejsonResult +} from './types'; export type QuadbinTableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions; @@ -8,7 +14,8 @@ type UrlParameters = { aggregationExp: string; aggregationResLevel?: string; columns?: string; - geo_column?: string; + spatialDataType: SpatialDataType; + spatialDataColumn?: string; name: string; }; @@ -19,10 +26,16 @@ export const quadbinTableSource = async function ( aggregationExp, aggregationResLevel = 6, columns, - spatialDataColumn = 'quadbin:quadbin', + spatialDataColumn = 'quadbin', tableName } = options; - const urlParameters: UrlParameters = {aggregationExp, name: tableName}; + + const urlParameters: UrlParameters = { + aggregationExp, + name: tableName, + spatialDataColumn, + spatialDataType: 'quadbin' + }; if (aggregationResLevel) { urlParameters.aggregationResLevel = String(aggregationResLevel); @@ -30,8 +43,5 @@ export const quadbinTableSource = async function ( if (columns) { urlParameters.columns = columns.join(','); } - if (spatialDataColumn) { - urlParameters.geo_column = spatialDataColumn; - } return baseSource('table', options, urlParameters) as Promise; }; diff --git a/modules/carto/src/sources/types.ts b/modules/carto/src/sources/types.ts index e2413986ec0..e1bb270aa55 100644 --- a/modules/carto/src/sources/types.ts +++ b/modules/carto/src/sources/types.ts @@ -39,7 +39,7 @@ export type TilesetSourceOptions = { tableName: string; }; -export type SpatialDataType = 'geometry' | 'h3' | 'quadbin'; +export type SpatialDataType = 'geo' | 'h3' | 'quadbin'; export type TilejsonMapInstantiation = MapInstantiation & { tilejson: {url: string[]}; diff --git a/modules/carto/src/sources/vector-query-source.ts b/modules/carto/src/sources/vector-query-source.ts index d2aa9e98a4d..e861b8a930b 100644 --- a/modules/carto/src/sources/vector-query-source.ts +++ b/modules/carto/src/sources/vector-query-source.ts @@ -3,17 +3,19 @@ import {baseSource} from './base-source'; import type {SourceOptions, QuerySourceOptions, SpatialDataType, TilejsonResult} from './types'; export type VectorQuerySourceOptions = SourceOptions & QuerySourceOptions; -type UrlParameters = {geo_column?: string; q: string; queryParameters?: string}; +type UrlParameters = { + spatialDataType: SpatialDataType; + spatialDataColumn?: string; + q: string; + queryParameters?: string; +}; export const vectorQuerySource = async function ( options: VectorQuerySourceOptions ): Promise { - const {spatialDataColumn, sqlQuery, queryParameters} = options; - const urlParameters: UrlParameters = {q: sqlQuery}; + const {spatialDataColumn = 'geom', sqlQuery, queryParameters} = options; + const urlParameters: UrlParameters = {spatialDataColumn, spatialDataType: 'geo', q: sqlQuery}; - if (spatialDataColumn) { - urlParameters.geo_column = spatialDataColumn; - } if (queryParameters) { urlParameters.queryParameters = JSON.stringify(queryParameters); } diff --git a/modules/carto/src/sources/vector-table-source.ts b/modules/carto/src/sources/vector-table-source.ts index 857a777af8c..5265caae850 100644 --- a/modules/carto/src/sources/vector-table-source.ts +++ b/modules/carto/src/sources/vector-table-source.ts @@ -3,19 +3,21 @@ import {baseSource} from './base-source'; import type {SourceOptions, SpatialDataType, TableSourceOptions, TilejsonResult} from './types'; export type VectorTableSourceOptions = SourceOptions & TableSourceOptions; -type UrlParameters = {columns?: string; geo_column?: string; name: string}; +type UrlParameters = { + columns?: string; + spatialDataType: SpatialDataType; + spatialDataColumn?: string; + name: string; +}; export const vectorTableSource = async function ( options: VectorTableSourceOptions ): Promise { - const {columns, spatialDataColumn, tableName} = options; - const urlParameters: UrlParameters = {name: tableName}; + const {columns, spatialDataColumn = 'geom', tableName} = options; + const urlParameters: UrlParameters = {name: tableName, spatialDataColumn, spatialDataType: 'geo'}; if (columns) { urlParameters.columns = columns.join(','); } - if (spatialDataColumn) { - urlParameters.geo_column = spatialDataColumn; - } return baseSource('table', options, urlParameters) as Promise; };