Skip to content

Commit fb862b2

Browse files
fix icl-1520 上下游关键设施查询服务返回结果未转换geojson review by songym
1 parent 0e5757d commit fb862b2

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/common/iServer/FacilityAnalystStreamService.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import { Util } from '../commontypes/Util';
5+
import {GeoJSON} from '../format/GeoJSON';
56
import { NetworkAnalystServiceBase } from './NetworkAnalystServiceBase';
67
import { FacilityAnalystStreamParameters } from './FacilityAnalystStreamParameters';
78

@@ -85,4 +86,23 @@ export class FacilityAnalystStreamService extends NetworkAnalystServiceBase {
8586
});
8687
}
8788

89+
/**
90+
* @function FacilityAnalystStreamService.prototype.toGeoJSONResult
91+
* @description 将含有 geometry 的数据转换为 GeoJSON 格式。
92+
* @param {Object} result - 服务器返回的结果对象。
93+
*/
94+
toGeoJSONResult(result) {
95+
if (!result) {
96+
return null;
97+
}
98+
var geoJSONFormat = new GeoJSON();
99+
if (result.edgesFeatures) {
100+
result.edgesFeatures = geoJSONFormat.toGeoJSON(result.edgesFeatures);
101+
}
102+
if (result.nodesFeatures) {
103+
result.nodesFeatures = geoJSONFormat.toGeoJSON(result.nodesFeatures);
104+
}
105+
return result;
106+
}
107+
88108
}

test/mapboxgl/services/NetworkAnalystServiceSpec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,8 @@ describe('mapboxgl_NetworkAnalystService', () => {
668668
expect(serviceResult).not.toBeNull();
669669
expect(serviceResult.result).not.toBeNull();
670670
expect(serviceResult.type).toEqual("processCompleted");
671+
expect(serviceResult.result.edgesFeatures.type).toEqual('FeatureCollection');
672+
expect(Array.isArray(serviceResult.result.edgesFeatures.features)).toBeTruthy();
671673
done();
672674
} catch (e) {
673675
console.log("'streamFacilityAnalyst_test'案例失败" + e.name + ":" + e.message);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy