Skip to content

Commit b45847b

Browse files
committed
leaflet 新增空间分析服务
1 parent 4de4044 commit b45847b

5 files changed

Lines changed: 308 additions & 15 deletions

File tree

build/deps.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ var deps = {
117117
"./src/Leaflet/SuperMap/iServer/NetworkAnalyst3DService.js"
118118
]
119119
},
120+
"SpatialAnalyst": {
121+
"name": "空间分析服务",
122+
"src": [
123+
"./src/Leaflet/SuperMap/iServer/SpatialAnalystService.js"
124+
]
125+
},
120126
"TrafficTransferAnalyst": {
121127
"name": "交通换乘分析服务",
122128
"src": [

src/Core/iServer/SpatialAnalystBase.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@ require('../format/GeoJSON');
1313
require('./CoreServiceBase');
1414
SuperMap.REST.SpatialAnalystBase = SuperMap.Class(SuperMap.CoreServiceBase, {
1515

16-
/**
17-
* Property: format
18-
* {String} 查询结果返回格式,目前支持iServerJSON 和GeoJSON两种格式
19-
* 参数格式为"iserver","geojson",默认为geojson
20-
*/
21-
format: "geojson",
2216

2317
initialize: function (url, options) {
2418
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
25-
if (options) {
26-
SuperMap.Util.extend(this, options);
27-
}
28-
this.format = this.format.toLowerCase();
2919
},
3020

3121
/**
@@ -34,7 +24,6 @@ SuperMap.REST.SpatialAnalystBase = SuperMap.Class(SuperMap.CoreServiceBase, {
3424
*/
3525
destroy: function () {
3626
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
37-
this.format = null;
3827
},
3928

4029
/**

src/Leaflet/SuperMap/iServer/GetFeaturesService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* 数据集查询类。
44
* 提供:ID查询,范围查询,SQL查询,几何查询,bounds查询,缓冲区查询
55
* 用法:
6-
* L.superMap.getFeaturesService(url).getFeaturesByIDs{
6+
* L.superMap.getFeaturesService(url).getFeaturesByIDs({
77
* dataSetNames:name,
88
* IDs:IDs
9-
* }.on("complete",function(result){
10-
* //doSomething like L.geoJSON(result.data[0]).addTo(map)
9+
* }).on("complete",function(result){
10+
* //doSomething
1111
* }).on("failed",function(result){
1212
* //doSomething
1313
* });

src/Leaflet/SuperMap/iServer/QueryService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* filter:{name:name},
88
* bounds:bounds
99
* }.on("complete",function(result){
10-
* //doSomething like L.geoJSON(result.data[0]).addTo(map)
10+
* //doSomething
1111
* }).on("failed",function(result){
1212
* //doSomething
1313
* });
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
/**
2+
* Class:SpatialAnalystService
3+
* 空间分析服务类。
4+
* 提供:地区太阳辐射、缓冲区分析、点密度分析、动态分段分析、空间关系分析、插值分析、栅格代数运算、叠加分析、路由定位、路由测量计算、表面分析、地形曲率计算、泰森多边形分析。
5+
* 用法:
6+
* L.superMap.spatialAnalystService(url).bufferAnalysis({
7+
*
8+
* }).on("complete",function(result){
9+
* //doSomething
10+
* }).on("failed",function(result){
11+
* //doSomething
12+
* });
13+
*/
14+
15+
require('../../../Core/base');
16+
require('../../../Core/iServer/AreaSolarRadiationService');
17+
require('../../../Core/iServer/BufferAnalystService');
18+
require('../../../Core/iServer/DensityAnalystService');
19+
require('../../../Core/iServer/GenerateSpatialDataService');
20+
require('../../../Core/iServer/GeoRelationAnalystService');
21+
require('../../../Core/iServer/InterpolationAnalystService');
22+
require('../../../Core/iServer/MathExpressionAnalysisService');
23+
require('../../../Core/iServer/OverlayAnalystService');
24+
require('../../../Core/iServer/RouteCalculateMeasureService');
25+
require('../../../Core/iServer/RouteLocatorService');
26+
require('../../../Core/iServer/SurfaceAnalystService');
27+
require('../../../Core/iServer/TerrainCurvatureCalculationService');
28+
require('../../../Core/iServer/ThiessenAnalystService');
29+
require('./ServiceBase');
30+
31+
SpatialAnalystService = ServiceBase.extend({
32+
33+
/**
34+
* url - {String} 服务的访问地址。如 http://localhost:8090/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst 。
35+
* options - {Object} 参数。
36+
* @param url
37+
* @param options
38+
*/
39+
initialize: function (url, options) {
40+
ServiceBase.prototype.initialize.call(this, url, options);
41+
},
42+
/**
43+
* 地区太阳辐射
44+
*/
45+
getAreaSolarRadiationResult: function () {
46+
var me = this;
47+
var areaSolarRadiationParameters = new SuperMap.REST.AreaSolarRadiationParameters(params);
48+
var areaSolarRadiationService = new SuperMap.REST.AreaSolarRadiationService(me.options.url, {
49+
eventListeners: {
50+
scope: me,
51+
processCompleted: me.processCompleted,
52+
processFailed: me.processFailed
53+
}
54+
});
55+
areaSolarRadiationService.processAsync(areaSolarRadiationParameters);
56+
return me;
57+
},
58+
59+
/**
60+
* 缓冲区分析
61+
*/
62+
bufferAnalysis: function (params) {
63+
var me = this;
64+
var bufferAnalystParameters = new SuperMap.REST.DatasetBufferAnalystParameters(params);
65+
var bufferAnalystService = new SuperMap.REST.BufferAnalystService(me.options.url, {
66+
eventListeners: {
67+
scope: me,
68+
processCompleted: me.processCompleted,
69+
processFailed: me.processFailed
70+
}
71+
});
72+
bufferAnalystService.processAsync(bufferAnalystParameters);
73+
return me;
74+
},
75+
76+
/**
77+
* 点密度分析
78+
*/
79+
densityAnalysis: function (params) {
80+
var me = this, param = me._processParams(params);
81+
var densityKernelAnalystParameters = new SuperMap.REST.DensityKernelAnalystParameters(param);
82+
var densityAnalystService = new SuperMap.REST.DensityAnalystService(me.options.url, {
83+
eventListeners: {
84+
scope: me,
85+
processCompleted: me.processCompleted,
86+
processFailed: me.processFailed
87+
}
88+
});
89+
densityAnalystService.processAsync(densityKernelAnalystParameters);
90+
return me;
91+
},
92+
93+
/**
94+
* 动态分段分析
95+
*/
96+
generateSpatialData: function (params) {
97+
var me = this;
98+
var generateSpatialDataParameters = new SuperMap.REST.GenerateSpatialDataParameters(params);
99+
var generateSpatialDataService = new SuperMap.REST.GenerateSpatialDataService(me.options.url, {
100+
eventListeners: {
101+
scope: me,
102+
processCompleted: me.processCompleted,
103+
processFailed: me.processFailed
104+
}
105+
});
106+
generateSpatialDataService.processAsync(generateSpatialDataParameters);
107+
return me;
108+
},
109+
110+
/**
111+
* 空间关系分析
112+
*/
113+
geoRelationAnalysis: function (params) {
114+
var me = this;
115+
var geoRelationAnalystParameters = new SuperMap.REST.GeoRelationAnalystParameters(params);
116+
var geoRelationAnalystService = new SuperMap.REST.GeoRelationAnalystService(me.options.url, {
117+
eventListeners: {
118+
scope: me,
119+
processCompleted: me.processCompleted,
120+
processFailed: me.processFailed
121+
}
122+
});
123+
geoRelationAnalystService.processAsync(geoRelationAnalystParameters);
124+
return me;
125+
},
126+
127+
/**
128+
* 插值分析
129+
*/
130+
interpolationAnalysis: function (params) {
131+
var me = this, param = me._processParams(params);
132+
var interpolationRBFAnalystParameters = new SuperMap.REST.InterpolationRBFAnalystParameters(param);
133+
var interpolationAnalystService = new SuperMap.REST.InterpolationAnalystService(me.options.url, {
134+
eventListeners: {
135+
scope: me,
136+
processCompleted: me.processCompleted,
137+
processFailed: me.processFailed
138+
}
139+
});
140+
interpolationAnalystService.processAsync(interpolationRBFAnalystParameters);
141+
return me;
142+
},
143+
144+
/**
145+
* 栅格代数运算
146+
*/
147+
mathExpressionAnalysis: function (params) {
148+
var me = this, param = me._processParams(params);
149+
var mathExpressionAnalysisParameters = new SuperMap.REST.MathExpressionAnalysisParameters(param);
150+
var mathExpressionAnalysisService = new SuperMap.REST.MathExpressionAnalysisService(me.options.url, {
151+
eventListeners: {
152+
scope: me,
153+
processCompleted: me.processCompleted,
154+
processFailed: me.processFailed
155+
}
156+
});
157+
mathExpressionAnalysisService.processAsync(mathExpressionAnalysisParameters);
158+
return me;
159+
},
160+
161+
/**
162+
* 叠加分析
163+
*/
164+
overlayAnalysis: function (params) {
165+
var me = this, param = me._processParams(params);
166+
var datasetOverlayAnalystParameters = new SuperMap.REST.DatasetOverlayAnalystParameters(param);
167+
var overlayAnalystService = new SuperMap.REST.OverlayAnalystService(me.options.url, {
168+
eventListeners: {
169+
scope: me,
170+
processCompleted: me.processCompleted,
171+
processFailed: me.processFailed
172+
}
173+
});
174+
overlayAnalystService.processAsync(datasetOverlayAnalystParameters);
175+
return me;
176+
},
177+
178+
/**
179+
* 路由测量计算
180+
*/
181+
routeCalculateMeasure: function (params) {
182+
var me = this, param = me._processParams(params);
183+
var routeCalculateMeasureParameters = new SuperMap.REST.RouteCalculateMeasureParameters(param);
184+
var routeCalculateMeasureService = new SuperMap.REST.RouteCalculateMeasureService(me.options.url, {
185+
eventListeners: {
186+
scope: me,
187+
processCompleted: me.processCompleted,
188+
processFailed: me.processFailed
189+
}
190+
});
191+
routeCalculateMeasureService.processAsync(routeCalculateMeasureParameters);
192+
return me;
193+
},
194+
195+
/**
196+
* 路由定位
197+
*/
198+
routeLocate: function (params) {
199+
var me = this, param = me._processParams(params);
200+
var routeLocatorParameters = new SuperMap.REST.RouteLocatorParameters(param);
201+
var routeLocatorService = new SuperMap.REST.RouteLocatorService(me.options.url, {
202+
eventListeners: {
203+
scope: me,
204+
processCompleted: me.processCompleted,
205+
processFailed: me.processFailed
206+
}
207+
});
208+
routeLocatorService.processAsync(routeLocatorParameters);
209+
return me;
210+
},
211+
212+
/**
213+
* 表面分析
214+
*/
215+
surfaceAnalysis: function (params) {
216+
var me = this, param = me._processParams(params);
217+
var datasetSurfaceAnalystParameters = new SuperMap.REST.DatasetSurfaceAnalystParameters(param);
218+
var surfaceAnalystService = new SuperMap.REST.SurfaceAnalystService(me.options.url, {
219+
eventListeners: {
220+
scope: me,
221+
processCompleted: me.processCompleted,
222+
processFailed: me.processFailed
223+
}
224+
});
225+
surfaceAnalystService.processAsync(datasetSurfaceAnalystParameters);
226+
return me;
227+
},
228+
229+
/**
230+
* 地形曲率计算
231+
*/
232+
terrainCurvatureCalculate: function (params) {
233+
var me = this;
234+
var terrainCurvatureCalculationParameters = new SuperMap.REST.TerrainCurvatureCalculationParameters(params);
235+
var terrainCurvatureCalculationService = new SuperMap.REST.TerrainCurvatureCalculationService(me.options.url, {
236+
eventListeners: {
237+
scope: me,
238+
processCompleted: me.processCompleted,
239+
processFailed: me.processFailed
240+
}
241+
});
242+
terrainCurvatureCalculationService.processAsync(terrainCurvatureCalculationParameters);
243+
return me;
244+
},
245+
246+
/**
247+
* 泰森多边形分析
248+
*/
249+
thiessenAnalysis: function (params) {
250+
var me = this;
251+
var datasetThiessenAnalystParameters = new SuperMap.REST.DatasetThiessenAnalystParameters(params);
252+
var thiessenAnalystService = new SuperMap.REST.ThiessenAnalystService(me.options.url, {
253+
eventListeners: {
254+
scope: me,
255+
processCompleted: me.processCompleted,
256+
processFailed: me.processFailed
257+
}
258+
});
259+
thiessenAnalystService.processAsync(datasetThiessenAnalystParameters);
260+
return me;
261+
},
262+
263+
_processParams: function (params) {
264+
if (!params) {
265+
return {};
266+
}
267+
if (params.bounds && params.bounds instanceof L.LatLngBounds) {
268+
params.bounds = new SuperMap.Bounds(
269+
params.bounds.getSouthWest().lng,
270+
params.bounds.getSouthWest().lat,
271+
params.bounds.getNorthEast().lng,
272+
params.bounds.getNorthEast().lat
273+
);
274+
}
275+
if (params.inputPoints) {
276+
for (var i = 0; i < params.inputPoints.length; i++) {
277+
params.inputPoints[i] = {x: arams.inputPoints[i].flatCoordinates[0], y: params.inputPoints[i].flatCoordinates[1]};
278+
}
279+
}
280+
if (params.extractRegion) {
281+
params.extractRegion = L.Util.toSuperMapGeometry(params.extractRegion);
282+
}
283+
if (params.extractParameter && params.extractParameter.clipRegion) {
284+
params.extractParameter.clipRegion = L.Util.toSuperMapGeometry(params.extractParameter.clipRegion);
285+
}
286+
if (params.operateRegions) {
287+
params.operateRegions = L.Util.toSuperMapGeometry(params.operateRegions);
288+
}
289+
if (params.sourceRoute) {
290+
params.sourceRoute = L.Util.toSuperMapGeometry(params.sourceRoute);
291+
}
292+
return params;
293+
}
294+
});
295+
L.supermap.spatialAnalystService = function (url, options) {
296+
return new SpatialAnalystService(url, options);
297+
};
298+
module.exports = L.supermap.spatialAnalystService;

0 commit comments

Comments
 (0)