Skip to content

Commit d1a5c65

Browse files
committed
fix 漏提交
1 parent d2cf33c commit d1a5c65

File tree

4 files changed

+543
-0
lines changed

4 files changed

+543
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* Class:ChartService
3+
* 海图服务
4+
* 用法:
5+
* L.superMap.chartService(url)
6+
* .queryChart(param,function(result){
7+
* //doSomething
8+
* })
9+
*/
10+
require('./ServiceBase');
11+
require('../../common/iServer/ChartQueryService');
12+
require('../../common/iServer/ChartFeatureInfoSpecsService');
13+
14+
ChartService = ServiceBase.extend({
15+
16+
initialize: function (url, options) {
17+
ServiceBase.prototype.initialize.call(this, url, options);
18+
},
19+
20+
/**
21+
* @param params
22+
* <SuperMap.ChartQueryParameters>
23+
* @param callback
24+
* @param resultFormat
25+
* <SuperMap.DataFormat>
26+
*/
27+
queryChart: function (params, callback, resultFormat) {
28+
var me = this,
29+
param = me._processParams(params),
30+
format = me._processFormat(resultFormat);
31+
var chartQueryService = new SuperMap.REST.ChartQueryService(me.options.url, {
32+
eventListeners: {
33+
scope: me,
34+
processCompleted: callback,
35+
processFailed: callback
36+
},
37+
format: format
38+
});
39+
40+
chartQueryService.processAsync(param);
41+
return me;
42+
},
43+
44+
/**
45+
* 海图物标信息服务
46+
*/
47+
getChartFeatureInfo: function (callback) {
48+
var me = this, url = me.options.url.concat();
49+
url += "/chartFeatureInfoSpecs";
50+
var chartFeatureInfoSpecsService = new SuperMap.REST.ChartFeatureInfoSpecsService(url, {
51+
eventListeners: {
52+
scope: me,
53+
processCompleted: callback,
54+
processFailed: callback
55+
}
56+
});
57+
chartFeatureInfoSpecsService.processAsync();
58+
return me;
59+
},
60+
61+
_processParams: function (params) {
62+
if (!params) {
63+
return {};
64+
}
65+
params.returnContent = (params.returnContent == null) ? true : params.returnContent;
66+
if (params.chartQueryFilterParameters && !L.Util.isArray(params.chartQueryFilterParameters)) {
67+
params.chartQueryFilterParameters = [params.chartQueryFilterParameters];
68+
}
69+
70+
if (params.bounds && params.bounds instanceof L.LatLngBounds) {
71+
params.bounds = new SuperMap.Bounds(
72+
params.bounds.getSouthWest().lng,
73+
params.bounds.getSouthWest().lat,
74+
params.bounds.getNorthEast().lng,
75+
params.bounds.getNorthEast().lat
76+
);
77+
}
78+
},
79+
_processFormat: function (resultFormat) {
80+
return (resultFormat) ? resultFormat : SuperMap.DataFormat.GEOJSON;
81+
}
82+
});
83+
84+
L.supermap.chartService = function (url, options) {
85+
return new ChartService(url, options);
86+
};
87+
88+
module.exports = L.supermap.chartService;
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
/**
2+
* Class: FeatureService
3+
* 数据集类。
4+
* 提供:ID查询,范围查询,SQL查询,几何查询,bounds查询,缓冲区查询,地物编辑
5+
* 用法:
6+
* L.superMap.featureService(url)
7+
* .getFeaturesByIDs(param,function(result){
8+
* //doSomething
9+
* })
10+
*/
11+
require('./ServiceBase');
12+
require('../../common/iServer/GetFeaturesByIDsService');
13+
require('../../common/iServer/GetFeaturesBySQLService');
14+
require('../../common/iServer/GetFeaturesByBoundsService');
15+
require('../../common/iServer/GetFeaturesByBufferService');
16+
require('../../common/iServer/GetFeaturesByGeometryService');
17+
require('../../common/iServer/EditFeaturesService');
18+
19+
FeatureService = ServiceBase.extend({
20+
21+
initialize: function (url, options) {
22+
ServiceBase.prototype.initialize.call(this, url, options);
23+
},
24+
25+
/**
26+
* 数据集ID查询服务
27+
* @param params:
28+
* <SuperMap.GetFeaturesByIDsParameters>
29+
* @param callback
30+
* @param resultFormat
31+
* <SuperMap.DataFormat>
32+
*/
33+
getFeaturesByIDs: function (params, callback, resultFormat) {
34+
var me = this;
35+
var getFeaturesByIDsService = new SuperMap.REST.GetFeaturesByIDsService(me.options.url, {
36+
eventListeners: {
37+
processCompleted: callback,
38+
processFailed: callback
39+
},
40+
format: me._processFormat(resultFormat)
41+
});
42+
getFeaturesByIDsService.processAsync(me._processParams(params));
43+
return me;
44+
45+
},
46+
/**
47+
* 数据集Bounds查询服务
48+
* @param params:
49+
* <SuperMap.GetFeaturesByBoundsParameters>
50+
* @param callback
51+
* @param resultFormat
52+
* <SuperMap.DataFormat>
53+
*/
54+
getFeaturesByBounds: function (params, callback, resultFormat) {
55+
var me = this;
56+
var getFeaturesByBoundsService = new SuperMap.REST.GetFeaturesByBoundsService(me.options.url, {
57+
eventListeners: {
58+
processCompleted: callback,
59+
processFailed: callback
60+
},
61+
format: me._processFormat(resultFormat)
62+
});
63+
getFeaturesByBoundsService.processAsync(me._processParams(params));
64+
return me;
65+
},
66+
/**
67+
* 数据集Buffer查询服务
68+
* @param params:
69+
* <SuperMap.GetFeaturesByBufferParameters>
70+
* @param callback
71+
* @param resultFormat
72+
* <SuperMap.DataFormat>
73+
*/
74+
getFeaturesByBuffer: function (params, callback, resultFormat) {
75+
var me = this;
76+
var getFeatureService = new SuperMap.REST.GetFeaturesByBufferService(me.options.url, {
77+
eventListeners: {
78+
processCompleted: callback,
79+
processFailed: callback
80+
},
81+
format: me._processFormat(resultFormat)
82+
});
83+
getFeatureService.processAsync(me._processParams(params));
84+
return me;
85+
},
86+
/**
87+
* 数据集SQL查询服务
88+
* @param params:
89+
* <SuperMap.GetFeaturesBySQLParameters>
90+
* @param callback
91+
* @param resultFormat
92+
* <SuperMap.DataFormat>
93+
*/
94+
getFeaturesBySQL: function (params, callback, resultFormat) {
95+
var me = this;
96+
var getFeatureBySQLService = new SuperMap.REST.GetFeaturesBySQLService(me.options.url, {
97+
eventListeners: {
98+
processCompleted: callback,
99+
processFailed: callback
100+
},
101+
format: me._processFormat(resultFormat)
102+
});
103+
104+
getFeatureBySQLService.processAsync(me._processParams(params));
105+
return me;
106+
},
107+
/**
108+
* 数据集几何查询服务类
109+
* @param params:
110+
* <SuperMap.GetFeaturesByGeometryParameters>
111+
* @param callback
112+
* @param resultFormat
113+
* <SuperMap.DataFormat>
114+
*/
115+
getFeaturesByGeometry: function (params, callback, resultFormat) {
116+
var me = this;
117+
var getFeaturesByGeometryService = new SuperMap.REST.GetFeaturesByGeometryService(me.options.url, {
118+
eventListeners: {
119+
processCompleted: callback,
120+
processFailed: callback
121+
},
122+
format: me._processFormat(resultFormat)
123+
});
124+
getFeaturesByGeometryService.processAsync(me._processParams(params));
125+
return me;
126+
},
127+
128+
/**
129+
* 地物编辑服务
130+
* @param params
131+
* <SuperMap.EditFeaturesParameters>
132+
* @param callback
133+
*/
134+
135+
editFeatures: function (params, callback) {
136+
137+
if (!params || !params.dataSourceName || !params.dataSetName) {
138+
return;
139+
}
140+
141+
var me = this,
142+
url = me.options.url,
143+
dataSourceName = params.dataSourceName,
144+
dataSetName = params.dataSetName;
145+
146+
url += "/datasources/" + dataSourceName + "/datasets/" + dataSetName;
147+
editFeatureService = new SuperMap.REST.EditFeaturesService(url, {
148+
eventListeners: {
149+
150+
processCompleted: callback,
151+
processFailed: callback
152+
}
153+
});
154+
editFeatureService.processAsync(me._processParams(params));
155+
return me;
156+
},
157+
158+
_processParams: function (params) {
159+
if (!params) {
160+
return {};
161+
}
162+
params.returnContent = (params.returnContent == null) ? true : params.returnContent;
163+
params.fromIndex = params.fromIndex ? params.fromIndex : 0;
164+
params.toIndex = params.fromIndex ? params.fromIndex : -1;
165+
params.isUseBatch = (params.isUseBatch == null) ? false : params.isUseBatch;
166+
if (params.bounds && params.bounds instanceof L.LatLngBounds) {
167+
params.bounds = new SuperMap.Bounds(
168+
params.bounds.getSouthWest().lng,
169+
params.bounds.getSouthWest().lat,
170+
params.bounds.getNorthEast().lng,
171+
params.bounds.getNorthEast().lat
172+
);
173+
}
174+
if (params.geometry) {
175+
params.geometry = L.Util.toSuperMapGeometry(params.geometry);
176+
}
177+
178+
if (params.editType) {
179+
params.editType = params.editType.toLowerCase();
180+
}
181+
182+
var me = this;
183+
if (params.features) {
184+
var features = [];
185+
if (L.Util.isArray(params.features)) {
186+
params.features.map(function (feature) {
187+
features.push(me._createServerFeature(feature));
188+
});
189+
} else {
190+
features.push(me._createServerFeature(params.features));
191+
}
192+
params.features = features;
193+
}
194+
return params;
195+
},
196+
197+
_createServerFeature: function (geoFeature) {
198+
var geoJSONFeature, feature = {}, fieldNames = [], fieldValues = [];
199+
geoJSONFeature = geoFeature.toGeoJSON();
200+
for (var key in geoJSONFeature.properties) {
201+
fieldNames.push(key);
202+
fieldValues.push(geoJSONFeature.properties[key]);
203+
}
204+
feature.fieldNames = fieldNames;
205+
feature.fieldValues = fieldValues;
206+
feature.geometry = L.Util.toSuperMapGeometry(geoJSONFeature);
207+
return feature;
208+
},
209+
210+
_processFormat: function (resultFormat) {
211+
return (resultFormat) ? resultFormat : SuperMap.DataFormat.GEOJSON;
212+
}
213+
});
214+
215+
L.supermap.featureService = function (url, options) {
216+
return new FeatureService(url, options);
217+
};
218+
219+
module.exports = L.supermap.featureService;

0 commit comments

Comments
 (0)