Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
48 Star 115 Fork 4

SuperMap/iClient-JavaScript

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (81)
Tags (32)
master
v12.1.0
v12.0.1
v11.3.x
dependabot/npm_and_yarn/src/common/fast-xml-parser-5.7.0
snyk-fix-54d9e7714a681c45b3ad4dacb6c8592a
dependabot/npm_and_yarn/turf/turf-7.3.3
snyk-fix-abdb4bdebc8b86ad9f7bfae6309e58ad
snyk-fix-4712f7a861c430e813f85333e4bfed82
snyk-upgrade-e88282fa32778b721e99887d92f3a0a7
snyk-upgrade-9a49cfee0586b226f385660495928af1
snyk-upgrade-976578446f1da59fc1ae66384683a906
snyk-upgrade-9b8759143442723b128989c089b4f3c3
dependabot/npm_and_yarn/mapbox-gl-3.18.1
dependabot/npm_and_yarn/elastic/elasticsearch-9.2.1
dependabot/npm_and_yarn/nightwatch-3.15.0
dependabot/npm_and_yarn/chromedriver-145.0.0
snyk-fix-34e860bf6537d6ef593f3733a0a21b4c
v12.0.0
v11.1.1
12.1.0-r
12.0.1-r
12.0.0-r
11.3.0
11.1.2
11.2.1
11.2.0
11.1.1
11.1.0
11.1.0-beta
11.0.1
11.0.0
11.0.0-beta
10.2.1
10.2.0
10.1.3
10.1.2
10.1.1
10.1.0
10.1.0-beta
master
Branches (81)
Tags (32)
master
v12.1.0
v12.0.1
v11.3.x
dependabot/npm_and_yarn/src/common/fast-xml-parser-5.7.0
snyk-fix-54d9e7714a681c45b3ad4dacb6c8592a
dependabot/npm_and_yarn/turf/turf-7.3.3
snyk-fix-abdb4bdebc8b86ad9f7bfae6309e58ad
snyk-fix-4712f7a861c430e813f85333e4bfed82
snyk-upgrade-e88282fa32778b721e99887d92f3a0a7
snyk-upgrade-9a49cfee0586b226f385660495928af1
snyk-upgrade-976578446f1da59fc1ae66384683a906
snyk-upgrade-9b8759143442723b128989c089b4f3c3
dependabot/npm_and_yarn/mapbox-gl-3.18.1
dependabot/npm_and_yarn/elastic/elasticsearch-9.2.1
dependabot/npm_and_yarn/nightwatch-3.15.0
dependabot/npm_and_yarn/chromedriver-145.0.0
snyk-fix-34e860bf6537d6ef593f3733a0a21b4c
v12.0.0
v11.1.1
12.1.0-r
12.0.1-r
12.0.0-r
11.3.0
11.1.2
11.2.1
11.2.0
11.1.1
11.1.0
11.1.0-beta
11.0.1
11.0.0
11.0.0-beta
10.2.1
10.2.0
10.1.3
10.1.2
10.1.1
10.1.0
10.1.0-beta
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (81)
Tags (32)
master
v12.1.0
v12.0.1
v11.3.x
dependabot/npm_and_yarn/src/common/fast-xml-parser-5.7.0
snyk-fix-54d9e7714a681c45b3ad4dacb6c8592a
dependabot/npm_and_yarn/turf/turf-7.3.3
snyk-fix-abdb4bdebc8b86ad9f7bfae6309e58ad
snyk-fix-4712f7a861c430e813f85333e4bfed82
snyk-upgrade-e88282fa32778b721e99887d92f3a0a7
snyk-upgrade-9a49cfee0586b226f385660495928af1
snyk-upgrade-976578446f1da59fc1ae66384683a906
snyk-upgrade-9b8759143442723b128989c089b4f3c3
dependabot/npm_and_yarn/mapbox-gl-3.18.1
dependabot/npm_and_yarn/elastic/elasticsearch-9.2.1
dependabot/npm_and_yarn/nightwatch-3.15.0
dependabot/npm_and_yarn/chromedriver-145.0.0
snyk-fix-34e860bf6537d6ef593f3733a0a21b4c
v12.0.0
v11.1.1
12.1.0-r
12.0.1-r
12.0.0-r
11.3.0
11.1.2
11.2.1
11.2.0
11.1.1
11.1.0
11.1.0-beta
11.0.1
11.0.0
11.0.0-beta
10.2.1
10.2.0
10.1.3
10.1.2
10.1.1
10.1.0
10.1.0-beta
QueryBySQLSpec.js 15.70 KB
Copy Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
import {queryService} from '../../../src/leaflet/services/QueryService';
import {QueryBySQLParameters} from '../../../src/common/iServer/QueryBySQLParameters';
import { FetchRequest } from '../../../src/common/util/FetchRequest';
var worldMapURL = GlobeParameter.mapServiceURL + "World Map";
var options = {
};
describe('leaflet_QueryService_queryBySQL', () => {
var serviceResult;
var originalTimeout;
beforeEach(() => {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
serviceResult = null;
});
afterEach(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});
it('proxy', () => {
var service = queryService(worldMapURL, { proxy: 'testProxy' });
expect(service).not.toBeNull();
expect(service.options.proxy).toEqual('testProxy');
service.destroy();
});
it('withCredentials', () => {
var service = queryService(worldMapURL, { withCredentials: true });
expect(service).not.toBeNull();
expect(service.options.withCredentials).toBeTruthy();
service.destroy();
});
it('crossOrigin', () => {
var service = queryService(worldMapURL, { crossOrigin: true });
expect(service).not.toBeNull();
expect(service.options.crossOrigin).toBeTruthy();
service.destroy();
});
it('headers', () => {
var service = queryService(worldMapURL, { headers: {} });
expect(service).not.toBeNull();
expect(service.options.headers).not.toBeNull();
service.destroy();
});
it('successEvent:queryBySQL_returnContent=true', (done) => {
var queryBySQLParams = new QueryBySQLParameters({
queryParams: {
name: "Capitals@World",
attributeFilter: "SMID < 10"
}
});
var queryBySQLService = queryService(worldMapURL, options);
spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
expect(method).toBe("POST");
expect(testUrl).toBe(worldMapURL + "/queryResults?returnContent=true");
expect(params).not.toBeNull();
var paramsObj = JSON.parse(params.replace(/'/g, "\""));
expect(paramsObj.queryMode).toBe("SqlQuery");
expect(paramsObj.queryParameters.queryParams[0].name).toBe("Capitals@World");
expect(options).not.toBeNull();
return Promise.resolve(new Response(JSON.stringify(queryResultJson)));
});
queryBySQLService.queryBySQL(queryBySQLParams, (result) => {
serviceResult = result;
try {
expect(queryBySQLService).not.toBeNull();
expect(serviceResult.type).toBe("processCompleted");
expect(serviceResult.object.isInTheSameDomain).toBeTruthy();
expect(serviceResult.result).not.toBeNull();
expect(serviceResult.result.succeed).toBeTruthy();
expect(serviceResult.result.customResponse).toBeNull();
expect(serviceResult.result.currentCount).toEqual(1);
expect(serviceResult.result.totalCount).toEqual(1);
expect(serviceResult.result.recordsets.length).toBeGreaterThan(0);
expect(serviceResult.result.recordsets[0].datasetName).toBe("Capitals@World");
expect(serviceResult.result.recordsets[0].fieldCaptions.length).toEqual(2);
expect(serviceResult.result.recordsets[0].fieldTypes.length).toEqual(2);
expect(serviceResult.result.recordsets[0].features.type).toBe("FeatureCollection");
expect(serviceResult.result.recordsets[0].features.features.length).toEqual(1);
for (var i = 0; i < serviceResult.result.recordsets[0].features.features.length; i++) {
expect(serviceResult.result.recordsets[0].features.features[i].type).toBe("Feature");
expect(serviceResult.result.recordsets[0].features.features[i].geometry.type).toBe("Point");
expect(serviceResult.result.recordsets[0].features.features[i].geometry.coordinates.length).toEqual(2);
}
expect(serviceResult.result.recordsets[0].features.features[0].properties).toEqual(Object({
CAPITAL: "拉巴斯",
SmID: "59"
}));
queryBySQLService.destroy();
done();
} catch (exception) {
console.log("leaflet_queryBySQL_'successEvent:returnContent=true'案例失败:" + exception.name + ":" + exception.message);
queryBySQLService.destroy();
expect(false).toBeTruthy();
done();
}
});
});
it('successEvent:queryBySQL_returnContent=true promise', (done) => {
var queryBySQLParams = new QueryBySQLParameters({
queryParams: {
name: "Capitals@World",
attributeFilter: "SMID < 10"
}
});
var queryBySQLService = queryService(worldMapURL, options);
spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
expect(method).toBe("POST");
expect(testUrl).toBe(worldMapURL + "/queryResults?returnContent=true");
expect(params).not.toBeNull();
var paramsObj = JSON.parse(params.replace(/'/g, "\""));
expect(paramsObj.queryMode).toBe("SqlQuery");
expect(paramsObj.queryParameters.queryParams[0].name).toBe("Capitals@World");
expect(options).not.toBeNull();
return Promise.resolve(new Response(JSON.stringify(queryResultJson)));
});
queryBySQLService.queryBySQL(queryBySQLParams).then((result) => {
serviceResult = result;
try {
expect(queryBySQLService).not.toBeNull();
expect(serviceResult.type).toBe("processCompleted");
expect(serviceResult.object.isInTheSameDomain).toBeTruthy();
expect(serviceResult.result).not.toBeNull();
expect(serviceResult.result.succeed).toBeTruthy();
expect(serviceResult.result.customResponse).toBeNull();
expect(serviceResult.result.currentCount).toEqual(1);
expect(serviceResult.result.totalCount).toEqual(1);
expect(serviceResult.result.recordsets.length).toBeGreaterThan(0);
expect(serviceResult.result.recordsets[0].datasetName).toBe("Capitals@World");
expect(serviceResult.result.recordsets[0].fieldCaptions.length).toEqual(2);
expect(serviceResult.result.recordsets[0].fieldTypes.length).toEqual(2);
expect(serviceResult.result.recordsets[0].features.type).toBe("FeatureCollection");
expect(serviceResult.result.recordsets[0].features.features.length).toEqual(1);
for (var i = 0; i < serviceResult.result.recordsets[0].features.features.length; i++) {
expect(serviceResult.result.recordsets[0].features.features[i].type).toBe("Feature");
expect(serviceResult.result.recordsets[0].features.features[i].geometry.type).toBe("Point");
expect(serviceResult.result.recordsets[0].features.features[i].geometry.coordinates.length).toEqual(2);
}
expect(serviceResult.result.recordsets[0].features.features[0].properties).toEqual(Object({
CAPITAL: "拉巴斯",
SmID: "59"
}));
queryBySQLService.destroy();
done();
} catch (exception) {
console.log("leaflet_queryBySQL_'successEvent:returnContent=true'案例失败:" + exception.name + ":" + exception.message);
queryBySQLService.destroy();
expect(false).toBeTruthy();
done();
}
});
});
it('successEvent:queryBySQL_returnContent=false', (done) => {
var queryBySQLParams = new QueryBySQLParameters({
queryParams: {
name: "Capitals@World",
attributeFilter: "SMID < 10"
},
returnContent: false
});
var queryBySQLService = queryService(worldMapURL, options);
spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
expect(method).toBe("POST");
expect(testUrl).toBe(worldMapURL + "/queryResults");
expect(params).not.toBeNull();
var paramsObj = JSON.parse(params.replace(/'/g, "\""));
expect(paramsObj.queryParameters.queryParams[0].name).toBe("Capitals@World");
expect(options).not.toBeNull();
return Promise.resolve(new Response(`{"postResultType":"CreateChild","newResourceID":"c01d29d8d41743adb673cd1cecda6ed0_3bd769669d614da2ac450c593b18e63a","succeed":true,"newResourceLocation":"http://localhost:8090/iserver/services/map-world/rest/maps/World Map/queryResults/c01d29d8d41743adb673cd1cecda6ed0_3bd769669d614da2ac450c593b18e63a.json"}`));
});
queryBySQLService.queryBySQL(queryBySQLParams, (result) => {
serviceResult = result;
try {
expect(queryBySQLService).not.toBeNull();
expect(serviceResult.type).toBe("processCompleted");
expect(serviceResult.object.isInTheSameDomain).toBeTruthy();
expect(serviceResult.result).not.toBeNull();
expect(serviceResult.result.succeed).toBeTruthy();
expect(serviceResult.result.postResultType).toBe("CreateChild");
expect(serviceResult.result.newResourceLocation.length).toBeGreaterThan(0);
expect(serviceResult.result.newResourceID.length).toBeGreaterThan(0);
queryBySQLService.destroy();
done();
} catch (exception) {
console.log("leaflet_queryBySQL_'successEvent:returnContent=false'案例失败:" + exception.name + ":" + exception.message);
queryBySQLService.destroy();
expect(false).toBeTruthy();
done();
}
});
});
it('successEvent:queryBySQL_customsResult=true', (done) => {
var queryBySQLParams = new QueryBySQLParameters({
queryParams: {
name: "Capitals@World",
attributeFilter: "SMID < 10"
},
returnContent: false,
returnCustomResult: true
});
var queryBySQLService = queryService(worldMapURL, options);
spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
expect(method).toBe("POST");
expect(testUrl).toBe(worldMapURL + "/queryResults?returnCustomResult=true");
expect(params).not.toBeNull();
var paramsObj = JSON.parse(params.replace(/'/g, "\""));
expect(paramsObj.queryParameters.queryParams[0].name).toBe("Capitals@World");
expect(options).not.toBeNull();
return Promise.resolve(new Response(`{"postResultType":"CreateChild","newResourceID":"c01d29d8d41743adb673cd1cecda6ed0_7c073408732d47e7bffb8314a595e1d8","succeed":true,"customResult":{"top":38.89090807427654,"left":-175.245650649682,"bottom":-21.13090205664112,"leftBottom":{"x":-175.245650649682,"y":-21.13090205664112},"right":-47.8977476573595,"rightTop":{"x":-47.8977476573595,"y":38.89090807427654}},"newResourceLocation":"http://localhost:8090/iserver/services/map-world/rest/maps/World Map/queryResults/c01d29d8d41743adb673cd1cecda6ed0_7c073408732d47e7bffb8314a595e1d8.json"}`));
});
queryBySQLService.queryBySQL(queryBySQLParams, (result) => {
serviceResult = result;
try {
expect(queryBySQLService).not.toBeNull();
expect(serviceResult.type).toBe("processCompleted");
expect(serviceResult.object.isInTheSameDomain).toBeTruthy();
expect(serviceResult.result).not.toBeNull();
expect(serviceResult.result.succeed).toBeTruthy();
expect(serviceResult.result.postResultType).toBe("CreateChild");
expect(serviceResult.result.newResourceLocation.length).toBeGreaterThan(0);
expect(serviceResult.result.newResourceID.length).toBeGreaterThan(0);
expect(serviceResult.result.customResult).not.toBeNull();
queryBySQLService.destroy();
done();
} catch (exception) {
console.log("leaflet_queryBySQL_'successEvent:customsResult=true'案例失败:" + exception.name + ":" + exception.message);
queryBySQLService.destroy();
expect(false).toBeTruthy();
done();
}
});
});
it('failEvent:queryBySQL_layerNotExist', (done) => {
var queryBySQLParams = new QueryBySQLParameters({
queryParams: {
name: "Capitals@World1",
attributeFilter: "SMID < 10"
}
});
var queryBySQLService = queryService(worldMapURL, options);
spyOn(FetchRequest, 'commit').and.callFake((method, testUrl) => {
expect(method).toBe("POST");
expect(testUrl).toBe(worldMapURL + "/queryResults?returnContent=true");
return Promise.resolve(new Response(`{"succeed":false,"error":{"code":400,"errorMsg":"查询目标图层不存在。(Capitals@World1)"}}`));
});
queryBySQLService.queryBySQL(queryBySQLParams, (result) => {
serviceResult = result;
try {
expect(queryBySQLService).not.toBeNull();
expect(serviceResult.type).toBe("processFailed");
expect(serviceResult.object.isInTheSameDomain).toBeTruthy();
expect(serviceResult.error).not.toBeNull();
expect(serviceResult.error.code).toEqual(400);
expect(serviceResult.error.errorMsg).toBe("查询目标图层不存在。(Capitals@World1)");
queryBySQLService.destroy();
done();
} catch (exception) {
console.log("leaflet_queryBySQL_'failEvent:layerNotExist'案例失败:" + exception.name + ":" + exception.message);
queryBySQLService.destroy();
expect(false).toBeTruthy();
done();
}
});
});
it('failEvent:queryBySQL_queryParamsNull', (done) => {
var queryBySQLParams = new QueryBySQLParameters({
queryParams: null
});
var queryBySQLService = queryService(worldMapURL, options);
spyOn(FetchRequest, 'commit').and.callFake((method,testUrl) => {
expect(method).toBe("POST");
expect(testUrl).toBe(worldMapURL + "/queryResults?returnContent=true");
return Promise.resolve(new Response(`{"succeed":false,"error":{"code":400,"errorMsg":"参数queryParameterSet.queryParams非法,不能为空。"}}`));
});
queryBySQLService.queryBySQL(queryBySQLParams, (result) => {
serviceResult = result;
try {
expect(queryBySQLService).not.toBeNull();
expect(serviceResult.type).toBe("processFailed");
expect(serviceResult.object.isInTheSameDomain).toBeTruthy();
expect(serviceResult.error).not.toBeNull();
expect(serviceResult.error.code).toEqual(400);
expect(serviceResult.error.errorMsg).toBe("参数queryParameterSet.queryParams非法,不能为空。");
queryBySQLService.destroy();
done();
} catch (exception) {
console.log("leaflet_queryBySQL_'failEvent:queryParamsNull'案例失败:" + exception.name + ":" + exception.message);
queryBySQLService.destroy();
expect(false).toBeTruthy();
done();
}
})
})
});
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

Cancel

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/isupermap/iClient-JavaScript.git
git@gitee.com:isupermap/iClient-JavaScript.git
isupermap
iClient-JavaScript
iClient-JavaScript
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /