| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5d6b0b3 commit 6e91563
230 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | * This program are made available under the terms of the Apache License, Version 2.0 | |
| 3 | 3 | * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/ | |
| 4 | 4 | ||
| 5 | - importScripts('https://cdnjs.cloudflare.com/ajax/libs/Turf.js/5.1.6/turf.js') | ||
| 5 | + importScripts('https://cdn.bootcss.com/Turf.js/5.1.6/turf.min.js') | ||
| 6 | 6 | ||
| 7 | 7 | /** | |
| 8 | 8 | * 空间分析所需工具类 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -292,14 +292,17 @@ SuperMap.Util.getParameterString = function (params) { | |||
| 292 | 292 | }; | |
| 293 | 293 | ||
| 294 | 294 | /** | |
| 295 | - * @description 给 URL 追加参数。 | ||
| 295 | + * @description 给 URL 追加查询参数。 | ||
| 296 | 296 | * @param {string} url - 待追加参数的 URL 字符串。 | |
| 297 | - * @param {string} paramStr - 待追加的参数。 | ||
| 297 | + * @param {string} paramStr - 待追加的查询参数。 | ||
| 298 | 298 | * @returns {string} 新的 URL。 | |
| 299 | 299 | */ | |
| 300 | 300 | SuperMap.Util.urlAppend = function (url, paramStr) { | |
| 301 | 301 | var newUrl = url; | |
| 302 | 302 | if (paramStr) { | |
| 303 | + if(paramStr.startsWith('?')){ | ||
| 304 | + paramStr = paramStr.substring(1); | ||
| 305 | + } | ||
| 303 | 306 | var parts = (url + " ").split(/[?&]/); | |
| 304 | 307 | newUrl += (parts.pop() === " " ? | |
| 305 | 308 | paramStr : | |
@@ -308,6 +311,28 @@ SuperMap.Util.urlAppend = function (url, paramStr) { | |||
| 308 | 311 | return newUrl; | |
| 309 | 312 | }; | |
| 310 | 313 | ||
| 314 | + /** | ||
| 315 | + * @description 给 URL 追加 path 参数。 | ||
| 316 | + * @param {string} url - 待追加参数的 URL 字符串。 | ||
| 317 | + * @param {string} paramStr - 待追加的path参数。 | ||
| 318 | + * @returns {string} 新的 URL。 | ||
| 319 | + */ | ||
| 320 | + SuperMap.Util.urlPathAppend = function (url, pathStr) { | ||
| 321 | + let newUrl = url; | ||
| 322 | + if (!pathStr) { | ||
| 323 | + return newUrl; | ||
| 324 | + } | ||
| 325 | + if (pathStr.startsWith('/')) { | ||
| 326 | + pathStr = pathStr.substring(1); | ||
| 327 | + } | ||
| 328 | + const parts = url.split('?'); | ||
| 329 | + if(!parts[0].endsWith('/')){ | ||
| 330 | + parts[0] += '/' | ||
| 331 | + } | ||
| 332 | + newUrl = `${parts[0]}${pathStr}${parts.length > 1 ? `?${parts[1]}` : ''}`; | ||
| 333 | + return newUrl; | ||
| 334 | + }; | ||
| 335 | + | ||
| 311 | 336 | /** | |
| 312 | 337 | * @description 为了避免浮点精度错误而保留的有效位数。 | |
| 313 | 338 | * @type {number} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,24 +52,17 @@ export class AreaSolarRadiationService extends SpatialAnalystBase { | |||
| 52 | 52 | return; | |
| 53 | 53 | } | |
| 54 | 54 | var me = this; | |
| 55 | - | ||
| 56 | - var end = me.url.substr(me.url.length - 1, 1); | ||
| 57 | - if (end !== '/') { | ||
| 58 | - me.url += "/"; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | 55 | var parameterObject = {}; | |
| 62 | 56 | ||
| 63 | 57 | if (parameter instanceof AreaSolarRadiationParameters) { | |
| 64 | - me.url += 'datasets/' + parameter.dataset + '/solarradiation'; | ||
| 58 | + me.url = Util.urlPathAppend(me.url, `datasets/${parameter.dataset}/solarradiation`); | ||
| 65 | 59 | } | |
| 66 | - | ||
| 60 | + me.url = Util.urlAppend(me.url, 'returnContent=true'); | ||
| 67 | 61 | AreaSolarRadiationParameters.toObject(parameter, parameterObject); | |
| 68 | 62 | var jsonParameters = Util.toJSON(parameterObject); | |
| 69 | - me.url += '.json?returnContent=true'; | ||
| 70 | 63 | ||
| 71 | 64 | me.request({ | |
| 72 | - method: "POST", | ||
| 65 | + method: 'POST', | ||
| 73 | 66 | data: jsonParameters, | |
| 74 | 67 | scope: me, | |
| 75 | 68 | success: me.serviceProcessCompleted, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,24 +66,18 @@ export class BufferAnalystService extends SpatialAnalystBase { | |||
| 66 | 66 | processAsync(parameter) { | |
| 67 | 67 | var parameterObject = {}; | |
| 68 | 68 | var me = this; | |
| 69 | - | ||
| 70 | - var end = me.url.substr(me.url.length - 1, 1); | ||
| 71 | - if (end !== '/') { | ||
| 72 | - me.url += "/"; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | 69 | if (parameter instanceof DatasetBufferAnalystParameters) { | |
| 76 | - me.mode = "datasets"; | ||
| 77 | - me.url += 'datasets/' + parameter.dataset + '/buffer'; | ||
| 70 | + me.mode = 'datasets'; | ||
| 71 | + me.url = Util.urlPathAppend(me.url, 'datasets/' + parameter.dataset + '/buffer'); | ||
| 78 | 72 | DatasetBufferAnalystParameters.toObject(parameter, parameterObject); | |
| 79 | 73 | } else if (parameter instanceof GeometryBufferAnalystParameters) { | |
| 80 | - me.mode = "geometry"; | ||
| 81 | - me.url += 'geometry/buffer'; | ||
| 74 | + me.mode = 'geometry'; | ||
| 75 | + me.url = Util.urlPathAppend(me.url, 'geometry/buffer'); | ||
| 82 | 76 | GeometryBufferAnalystParameters.toObject(parameter, parameterObject); | |
| 83 | 77 | } | |
| 84 | 78 | ||
| 85 | 79 | var jsonParameters = Util.toJSON(parameterObject); | |
| 86 | - me.url += '.json?returnContent=true'; | ||
| 80 | + me.url = Util.urlAppend(me.url, 'returnContent=true'); | ||
| 87 | 81 | me.request({ | |
| 88 | 82 | method: "POST", | |
| 89 | 83 | data: jsonParameters, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,10 @@ | |||
| 1 | 1 | /* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved. | |
| 2 | 2 | * This program are made available under the terms of the Apache License, Version 2.0 | |
| 3 | 3 | * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/ | |
| 4 | - import {SuperMap} from '../SuperMap'; | ||
| 5 | - import {ProcessingServiceBase} from './ProcessingServiceBase'; | ||
| 6 | - import {BuffersAnalystJobsParameter} from './BuffersAnalystJobsParameter'; | ||
| 4 | + import { SuperMap } from '../SuperMap'; | ||
| 5 | + import { Util } from '../commontypes/Util'; | ||
| 6 | + import { ProcessingServiceBase } from './ProcessingServiceBase'; | ||
| 7 | + import { BuffersAnalystJobsParameter } from './BuffersAnalystJobsParameter'; | ||
| 7 | 8 | ||
| 8 | 9 | /** | |
| 9 | 10 | * @class SuperMap.BuffersAnalystJobsService | |
@@ -18,8 +19,8 @@ import {BuffersAnalystJobsParameter} from './BuffersAnalystJobsParameter'; | |||
| 18 | 19 | export class BuffersAnalystJobsService extends ProcessingServiceBase { | |
| 19 | 20 | constructor(url, options) { | |
| 20 | 21 | super(url, options); | |
| 21 | - this.url += "/spatialanalyst/buffers"; | ||
| 22 | - this.CLASS_NAME = "SuperMap.BuffersAnalystJobsService"; | ||
| 22 | + this.url = Util.urlPathAppend(this.url, 'spatialanalyst/buffers'); | ||
| 23 | + this.CLASS_NAME = 'SuperMap.BuffersAnalystJobsService'; | ||
| 23 | 24 | } | |
| 24 | 25 | ||
| 25 | 26 | /** | |
@@ -43,7 +44,7 @@ export class BuffersAnalystJobsService extends ProcessingServiceBase { | |||
| 43 | 44 | * @param {string} id - 指定要获取数据的id。 | |
| 44 | 45 | */ | |
| 45 | 46 | getBuffersJob(id) { | |
| 46 | - super.getJobs(this.url + '/' + id); | ||
| 47 | + super.getJobs(Util.urlPathAppend(this.url, id)); | ||
| 47 | 48 | } | |
| 48 | 49 | ||
| 49 | 50 | /** | |
@@ -57,4 +58,4 @@ export class BuffersAnalystJobsService extends ProcessingServiceBase { | |||
| 57 | 58 | } | |
| 58 | 59 | } | |
| 59 | 60 | ||
| 60 | - SuperMap.BuffersAnalystJobsService = BuffersAnalystJobsService; | ||
| 61 | + SuperMap.BuffersAnalystJobsService = BuffersAnalystJobsService; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,10 @@ | |||
| 1 | 1 | /* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved. | |
| 2 | 2 | * This program are made available under the terms of the Apache License, Version 2.0 | |
| 3 | 3 | * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/ | |
| 4 | - import {SuperMap} from '../SuperMap'; | ||
| 5 | - import {NetworkAnalystServiceBase} from './NetworkAnalystServiceBase'; | ||
| 6 | - import {BurstPipelineAnalystParameters} from './BurstPipelineAnalystParameters'; | ||
| 4 | + import { SuperMap } from '../SuperMap'; | ||
| 5 | + import { Util } from '../commontypes/Util'; | ||
| 6 | + import { NetworkAnalystServiceBase } from './NetworkAnalystServiceBase'; | ||
| 7 | + import { BurstPipelineAnalystParameters } from './BurstPipelineAnalystParameters'; | ||
| 7 | 8 | ||
| 8 | 9 | /** | |
| 9 | 10 | * @class SuperMap.BurstPipelineAnalystService | |
@@ -43,9 +44,7 @@ export class BurstPipelineAnalystService extends NetworkAnalystServiceBase { | |||
| 43 | 44 | return null; | |
| 44 | 45 | } | |
| 45 | 46 | var me = this, jsonObject; | |
| 46 | - var end = me.url.substr(me.url.length - 1, 1); | ||
| 47 | - me.url = me.url + ((end === "/") ? "burstAnalyse" : "/burstAnalyse") + ".json?"; | ||
| 48 | - | ||
| 47 | + me.url = Util.urlPathAppend(me.url, 'burstAnalyse'); | ||
| 49 | 48 | jsonObject = { | |
| 50 | 49 | sourceNodeIDs: params.sourceNodeIDs, | |
| 51 | 50 | isUncertainDirectionValid: params.isUncertainDirectionValid | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,13 +48,9 @@ export class ChartFeatureInfoSpecsService extends CommonServiceBase { | |||
| 48 | 48 | * 2. 通过监听 ChartFeatureInfoSpecsEvent.PROCESS_COMPLETE 事件获取。 | |
| 49 | 49 | */ | |
| 50 | 50 | processAsync() { | |
| 51 | - var me = this, method = "GET", | ||
| 52 | - end = me.url.substr(me.url.length - 1, 1); | ||
| 51 | + var me = this, method = "GET"; | ||
| 53 | 52 | if (!me.isTempLayers) { | |
| 54 | - me.url += (end === "/") ? '' : '/'; | ||
| 55 | - me.url += "chartFeatureInfoSpecs.json?"; | ||
| 56 | - } else { | ||
| 57 | - me.url += ".json?"; | ||
| 53 | + Util.urlPathAppend(me.url,'chartFeatureInfoSpecs'); | ||
| 58 | 54 | } | |
| 59 | 55 | me.request({ | |
| 60 | 56 | method: method, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,23 +71,15 @@ export class ChartQueryService extends CommonServiceBase { | |||
| 71 | 71 | this.format = DataFormat.GEOJSON; | |
| 72 | 72 | ||
| 73 | 73 | Util.extend(this, options); | |
| 74 | - var me = this, end; | ||
| 74 | + var me = this; | ||
| 75 | 75 | if (options.format) { | |
| 76 | 76 | me.format = options.format.toUpperCase(); | |
| 77 | 77 | } | |
| 78 | 78 | ||
| 79 | 79 | if (!me.url) { | |
| 80 | 80 | return; | |
| 81 | 81 | } | |
| 82 | - end = me.url.substr(me.url.length - 1, 1); | ||
| 83 | - | ||
| 84 | - // TODO 待iServer featureResul资源GeoJSON表述bug修复当使用以下注释掉的逻辑 | ||
| 85 | - // if (me.format==="geojson") { | ||
| 86 | - // me.url += (end == "/") ? "featureResults.geojson?" : "/featureResults.geojson?"; | ||
| 87 | - // } else { | ||
| 88 | - // me.url += (end == "/") ? "featureResults.json?" : "/featureResults.json?"; | ||
| 89 | - // } | ||
| 90 | - me.url += (end === "/") ? "queryResults.json?" : "/queryResults.json?"; | ||
| 82 | + me.url = Util.urlPathAppend(me.url, 'queryResults'); | ||
| 91 | 83 | ||
| 92 | 84 | this.CLASS_NAME = "SuperMap.ChartQueryService"; | |
| 93 | 85 | } | |
@@ -119,7 +111,7 @@ export class ChartQueryService extends CommonServiceBase { | |||
| 119 | 111 | me.returnContent = params.returnContent; | |
| 120 | 112 | jsonParameters = params.getVariablesJson(); | |
| 121 | 113 | if (me.returnContent) { | |
| 122 | - me.url += "returnContent=" + me.returnContent; | ||
| 114 | + me.url = Util.urlAppend(me.url, 'returnContent=true'); | ||
| 123 | 115 | } | |
| 124 | 116 | me.request({ | |
| 125 | 117 | method: "POST", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,17 +173,7 @@ export class CommonServiceBase { | |||
| 173 | 173 | //为url添加安全认证信息片段 | |
| 174 | 174 | let credential = this.getCredential(options.url); | |
| 175 | 175 | if (credential) { | |
| 176 | - //当url中含有?,并且?在url末尾的时候直接添加token *网络分析等服务请求url会出现末尾是?的情况* | ||
| 177 | - //当url中含有?,并且?不在url末尾的时候添加&token | ||
| 178 | - //当url中不含有?,在url末尾添加?token | ||
| 179 | - let endStr = options.url.substring(options.url.length - 1, options.url.length); | ||
| 180 | - if (options.url.indexOf("?") > -1 && endStr === "?") { | ||
| 181 | - options.url += credential.getUrlParameters(); | ||
| 182 | - } else if (options.url.indexOf("?") > -1 && endStr !== "?") { | ||
| 183 | - options.url += "&" + credential.getUrlParameters(); | ||
| 184 | - } else { | ||
| 185 | - options.url += "?" + credential.getUrlParameters(); | ||
| 186 | - } | ||
| 176 | + options.url = Util.urlAppend(options.url, credential.getUrlParameters()); | ||
| 187 | 177 | } | |
| 188 | 178 | ||
| 189 | 179 | me.calculatePollingTimes(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,9 +55,9 @@ export class ComputeWeightMatrixService extends NetworkAnalystServiceBase { | |||
| 55 | 55 | if (!(params instanceof ComputeWeightMatrixParameters)) { | |
| 56 | 56 | return; | |
| 57 | 57 | } | |
| 58 | - var me = this, jsonObject, | ||
| 59 | - end = me.url.substr(me.url.length - 1, 1); | ||
| 60 | - me.url = me.url + ((end === "/") ? "weightmatrix" : "/weightmatrix") + ".json?"; | ||
| 58 | + var me = this, | ||
| 59 | + jsonObject; | ||
| 60 | + me.url = Util.urlPathAppend(me.url, 'weightmatrix'); | ||
| 61 | 61 | jsonObject = { | |
| 62 | 62 | parameter: Util.toJSON(params.parameter), | |
| 63 | 63 | nodes: me.getJson(params.isAnalyzeById, params.nodes) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments