Skip to content

Commit ab8e267

Browse files
[fix]ISVJ-10807 preferServer featureService webmap
1 parent 1175a97 commit ab8e267

20 files changed

+464
-181
lines changed

src/common/commontypes/Util.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,18 @@ const Util = {
435435
return paramsArray.join('&');
436436
},
437437

438+
handleUrlSuffix(url, suffix = '.json') {
439+
if (url.indexOf('?') < 0) {
440+
url += suffix;
441+
} else {
442+
var urlArrays = url.split('?');
443+
if (urlArrays.length === 2) {
444+
url = urlArrays[0] + suffix + '?' + urlArrays[1];
445+
}
446+
}
447+
return url
448+
},
449+
438450
/**
439451
* @memberOf CommonUtil
440452
* @description 给 URL 追加查询参数。

src/common/iServer/CommonServiceBase.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export class CommonServiceBase {
150150
options.headers = options.headers || me.headers;
151151
options.isInTheSameDomain = me.isInTheSameDomain;
152152
options.withoutFormatSuffix = options.scope.withoutFormatSuffix || false;
153+
options.preferServer = options.preferServer || me.preferServer;
153154
//为url添加安全认证信息片段
154155
options.url = SecurityManager.appendCredential(options.url);
155156

src/common/iServer/FeatureService.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const FEATURE_SERVICE_MAP = {
1717
bounds: GetFeaturesByBoundsService,
1818
buffer: GetFeaturesByBufferService,
1919
geometry: GetFeaturesByGeometryService
20-
}
20+
};
2121

2222
/**
2323
* @class FeatureService
@@ -34,11 +34,11 @@ const FEATURE_SERVICE_MAP = {
3434
* @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
3535
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
3636
* @param {Object} [options.headers] - 请求头。
37+
* @param {boolean} [options.preferServer=false] - 当resultFormat=DataFormat.GEOJSON时,使用服务器直接返回geojson。
3738
* @extends {ServiceBase}
3839
* @usage
3940
*/
4041
export class FeatureService {
41-
4242
constructor(url, options) {
4343
this.url = url;
4444
this.options = options || {};
@@ -59,7 +59,8 @@ export class FeatureService {
5959
withCredentials: me.options.withCredentials,
6060
crossOrigin: me.options.crossOrigin,
6161
headers: me.options.headers,
62-
format: resultFormat
62+
format: resultFormat,
63+
preferServer: me.options.preferServer
6364
});
6465
return getFeaturesByIDsService.processAsync(params, callback);
6566
}
@@ -79,7 +80,8 @@ export class FeatureService {
7980
withCredentials: me.options.withCredentials,
8081
crossOrigin: me.options.crossOrigin,
8182
headers: me.options.headers,
82-
format: me._processFormat(resultFormat)
83+
format: me._processFormat(resultFormat),
84+
preferServer: me.options.preferServer
8385
});
8486
return getFeaturesByBoundsService.processAsync(params, callback);
8587
}
@@ -99,7 +101,8 @@ export class FeatureService {
99101
withCredentials: me.options.withCredentials,
100102
crossOrigin: me.options.crossOrigin,
101103
headers: me.options.headers,
102-
format: me._processFormat(resultFormat)
104+
format: me._processFormat(resultFormat),
105+
preferServer: me.options.preferServer
103106
});
104107
return getFeatureService.processAsync(params, callback);
105108
}
@@ -119,7 +122,8 @@ export class FeatureService {
119122
withCredentials: me.options.withCredentials,
120123
crossOrigin: me.options.crossOrigin,
121124
headers: me.options.headers,
122-
format: me._processFormat(resultFormat)
125+
format: me._processFormat(resultFormat),
126+
preferServer: me.options.preferServer
123127
});
124128
return getFeatureBySQLService.processAsync(params, callback);
125129
}
@@ -139,7 +143,8 @@ export class FeatureService {
139143
withCredentials: me.options.withCredentials,
140144
crossOrigin: me.options.crossOrigin,
141145
headers: me.options.headers,
142-
format: me._processFormat(resultFormat)
146+
format: me._processFormat(resultFormat),
147+
preferServer: me.options.preferServer
143148
});
144149
return getFeaturesByGeometryService.processAsync(params, callback);
145150
}
@@ -159,7 +164,7 @@ export class FeatureService {
159164
url = me.url,
160165
dataSourceName = params.dataSourceName,
161166
dataSetName = params.dataSetName;
162-
url = CommonUtil.urlPathAppend(url, "datasources/" + dataSourceName + "/datasets/" + dataSetName);
167+
url = CommonUtil.urlPathAppend(url, 'datasources/' + dataSourceName + '/datasets/' + dataSetName);
163168

164169
var editFeatureService = new EditFeaturesService(url, {
165170
proxy: me.options.proxy,
@@ -182,7 +187,7 @@ export class FeatureService {
182187
url = me.url,
183188
dataSourceName = params.dataSourceName,
184189
dataSetName = params.dataSetName;
185-
url = CommonUtil.urlPathAppend(url, "datasources/" + dataSourceName + "/datasets/" + dataSetName);
190+
url = CommonUtil.urlPathAppend(url, 'datasources/' + dataSourceName + '/datasets/' + dataSetName);
186191
var editFeatureService = new EditFeaturesService(url, {
187192
proxy: me.options.proxy,
188193
withCredentials: me.options.withCredentials,
@@ -207,7 +212,7 @@ export class FeatureService {
207212
url = me.url,
208213
dataSourceName = params.dataSourceName,
209214
dataSetName = params.dataSetName;
210-
url = CommonUtil.urlPathAppend(url, "datasources/" + dataSourceName + "/datasets/" + dataSetName);
215+
url = CommonUtil.urlPathAppend(url, 'datasources/' + dataSourceName + '/datasets/' + dataSetName);
211216
var featureAttachmentsService = new FeatureAttachmentsService(url, {
212217
proxy: me.options.proxy,
213218
withCredentials: me.options.withCredentials,
@@ -233,7 +238,7 @@ export class FeatureService {
233238
url = me.url,
234239
dataSourceName = params.dataSourceName,
235240
dataSetName = params.dataSetName;
236-
url = CommonUtil.urlPathAppend(url, "datasources/" + dataSourceName + "/datasets/" + dataSetName);
241+
url = CommonUtil.urlPathAppend(url, 'datasources/' + dataSourceName + '/datasets/' + dataSetName);
237242
var featureAttachmentsService = new FeatureAttachmentsService(url, {
238243
proxy: me.options.proxy,
239244
withCredentials: me.options.withCredentials,

src/common/iServer/GetFeaturesByBoundsService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {GetFeaturesByBoundsParameters} from './GetFeaturesByBoundsParameters';
1717
* @param {DataFormat} [options.format=DataFormat.GEOJSON] - 查询结果返回格式,目前支持 iServerJSON、GeoJSON、FGB 三种格式。参数格式为 "ISERVER","GEOJSON","FGB"。
1818
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
1919
* @param {Object} [options.headers] - 请求头。
20+
* @param {boolean} [options.preferServer=false] - 当options.format=DataFormat.GEOJSON时,使用服务器直接返回geojson。
2021
* @example
2122
* var myGetFeaturesByBoundsService = new SuperMa.GetFeaturesByBoundsService(url);
2223
* @usage

src/common/iServer/GetFeaturesByBufferService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {GetFeaturesByBufferParameters} from './GetFeaturesByBufferParameters';
1616
* @param {DataFormat} [options.format=DataFormat.GEOJSON] - 查询结果返回格式,目前支持 iServerJSON、GeoJSON、FGB 三种格式。参数格式为 "ISERVER","GEOJSON","FGB"。
1717
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
1818
* @param {Object} [options.headers] - 请求头。
19+
* @param {boolean} [options.preferServer=false] - 当options.format=DataFormat.GEOJSON时,使用服务器直接返回geojson。
1920
* @extends {GetFeaturesServiceBase}
2021
* @example
2122
* var myGetFeaturesByBufferService = new GetFeaturesByBufferService(url);

src/common/iServer/GetFeaturesByGeometryService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {GetFeaturesByGeometryParameters} from './GetFeaturesByGeometryParameters
1616
* @param {DataFormat} [options.format=DataFormat.GEOJSON] - 查询结果返回格式,目前支持 iServerJSON、GeoJSON、FGB 三种格式。参数格式为 "ISERVER","GEOJSON","FGB"。
1717
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
1818
* @param {Object} [options.headers] - 请求头。
19+
* @param {boolean} [options.preferServer=false] - 当options.format=DataFormat.GEOJSON时,使用服务器直接返回geojson。
1920
* @extends {GetFeaturesServiceBase}
2021
* @example
2122
* var myService = new GetFeaturesByGeometryService(url);

src/common/iServer/GetFeaturesByIDsService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {GetFeaturesByIDsParameters} from './GetFeaturesByIDsParameters';
1616
* @param {DataFormat} [options.format=DataFormat.GEOJSON] - 查询结果返回格式,目前支持 iServerJSON、GeoJSON、FGB 三种格式。参数格式为 "ISERVER","GEOJSON","FGB"。
1717
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
1818
* @param {Object} [options.headers] - 请求头。
19+
* @param {boolean} [options.preferServer=false] - 当options.format=DataFormat.GEOJSON时,使用服务器直接返回geojson。
1920
* @extends {GetFeaturesServiceBase}
2021
* @example
2122
* var myGetFeaturesByIDsService = new GetFeaturesByIDsService(url);

src/common/iServer/GetFeaturesBySQLService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {GetFeaturesBySQLParameters} from './GetFeaturesBySQLParameters';
1717
* @param {DataFormat} [options.format=DataFormat.GEOJSON] - 查询结果返回格式,目前支持 iServerJSON、GeoJSON、FGB 三种格式。参数格式为 "ISERVER","GEOJSON","FGB"。
1818
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
1919
* @param {Object} [options.headers] - 请求头。
20+
* @param {boolean} [options.preferServer=false] - 当options.format=DataFormat.GEOJSON时,使用服务器直接返回geojson。
2021
* @extends {GetFeaturesServiceBase}
2122
* @example
2223
* var myGetFeaturesBySQLService = new GetFeaturesBySQLService(url);

0 commit comments

Comments
 (0)