From 623c54ee267bc4226ecc3946a22dd256310eb52c Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Thu, 14 Nov 2024 15:06:07 -0500 Subject: [PATCH] fix(picking): Fixes for Picking Model API calls --- src/models/model.ts | 18 +++++++++++++----- src/widget-sources/types.ts | 3 +++ src/widget-sources/widget-base-source.ts | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/models/model.ts b/src/models/model.ts index b31af27..cfd6057 100644 --- a/src/models/model.ts +++ b/src/models/model.ts @@ -75,7 +75,13 @@ export function executeModel(props: { let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`; - const {filters, filtersLogicalOperator = 'and', data} = source; + const { + data, + filters, + filtersLogicalOperator = 'and', + geoColumn = DEFAULT_GEO_COLUMN, + } = source; + const queryParameters = source.queryParameters ? JSON.stringify(source.queryParameters) : ''; @@ -90,12 +96,14 @@ export function executeModel(props: { filtersLogicalOperator, }; + // Picking Model API requires 'spatialDataColumn'. + if (model === 'pick') { + queryParams.spatialDataColumn = geoColumn; + } + // API supports multiple filters, we apply it only to geoColumn const spatialFilters = source.spatialFilter - ? { - [source.geoColumn ? source.geoColumn : DEFAULT_GEO_COLUMN]: - source.spatialFilter, - } + ? {[geoColumn]: source.spatialFilter} : undefined; if (spatialFilters) { diff --git a/src/widget-sources/types.ts b/src/widget-sources/types.ts index fa0502b..37f1094 100644 --- a/src/widget-sources/types.ts +++ b/src/widget-sources/types.ts @@ -44,6 +44,9 @@ export interface FeaturesRequestOptions extends BaseRequestOptions { /** Topology of objects to be picked. */ dataType: 'points' | 'lines' | 'polygons'; + /** Zoom level, required if using 'points' data type. */ + z?: number; + /** * Maximum number of objects to return in the result set. For datasets * containing features with identical geometry, those features will have diff --git a/src/widget-sources/widget-base-source.ts b/src/widget-sources/widget-base-source.ts index 4a88520..3768aba 100644 --- a/src/widget-sources/widget-base-source.ts +++ b/src/widget-sources/widget-base-source.ts @@ -126,7 +126,7 @@ export abstract class WidgetBaseSource { options: FeaturesRequestOptions ): Promise { const {filterOwner, spatialFilter, abortController, ...params} = options; - const {columns, dataType, featureIds, limit, tileResolution} = params; + const {columns, dataType, featureIds, z, limit, tileResolution} = params; type FeaturesModelResponse = {rows: Record[]}; @@ -137,6 +137,7 @@ export abstract class WidgetBaseSource { columns, dataType, featureIds, + z, limit: limit || 1000, tileResolution: tileResolution || DEFAULT_TILE_RESOLUTION, },