From 80081e6711ab38973a9065f6c94eee55442127a3 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Tue, 10 Dec 2024 13:45:42 +0800 Subject: [PATCH] [fix]webmap returnFeaturesOnly --- src/common/mapping/WebMapService.js | 3 ++- test/common/mapping/WebMapServiceSpec.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/mapping/WebMapService.js b/src/common/mapping/WebMapService.js index 2398dba81..970406d4a 100644 --- a/src/common/mapping/WebMapService.js +++ b/src/common/mapping/WebMapService.js @@ -1208,7 +1208,8 @@ export class WebMapService { fromIndex: 0, toIndex: -1, maxFeatures: -1, - returnContent: true + returnContent: true, + returnFeaturesOnly: true }); if (baseProjection && baseProjection !== 'EPSG:4326') { getFeatureBySQLParams.targetEpsgCode = 4326; diff --git a/test/common/mapping/WebMapServiceSpec.js b/test/common/mapping/WebMapServiceSpec.js index d4548ab08..539a23267 100644 --- a/test/common/mapping/WebMapServiceSpec.js +++ b/test/common/mapping/WebMapServiceSpec.js @@ -880,7 +880,8 @@ describe('WebMapServiceSpec.js', () => { let getFeatureBySQLParams; spyOn(FetchRequest, 'post').and.callFake((url, options) => { getFeatureBySQLParams = options; - return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT))); + expect(url.includes('returnFeaturesOnly=true')).toBeTruthy() + return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT.features))); }); const type = 'rest_data'; const layer = { @@ -894,13 +895,14 @@ describe('WebMapServiceSpec.js', () => { const baseProjection = 'EPSG:3857'; const service = new WebMapService(mapId, options); const spy = spyOn(service, '_getFeatureBySQL').and.callThrough();; - service.getLayerFeatures(type, layer, baseProjection).then(() => { + service.getLayerFeatures(type, layer, baseProjection).then((res) => { const params = spy.calls.allArgs()[0]; expect(params[0]).toBe(layer.dataSource.url); expect(params[1]).toEqual(["中国矢量数据:飞机场"]); expect(params[4]).toEqual(baseProjection); expect(typeof getFeatureBySQLParams).toBe('string'); expect(getFeatureBySQLParams).toContain(`'targetEpsgCode':4326`); + expect(res.features instanceof Array).toBeTruthy(); done(); }); });