Skip to content

Commit 1f3ef04

Browse files
committed
完善 toiClientFeature 方法。
1 parent 1c64b25 commit 1f3ef04

19 files changed

+442
-391
lines changed

dist/leaflet/iclient9-leaflet-es6.js

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -71654,34 +71654,35 @@ var ThemeLayer = external_L_default.a.Layer.extend({
7165471654
* @function L.supermap.ThemeLayer.prototype.toiClientFeature
7165571655
* @description 转为 iClient 要素
7165671656
* @param {L.supermap.themeFeature|Object} features - 待转要素包括 L.supermap.ThemeFeature 类型和 GeoJOSN 规范数据类型
71657-
* @return {SuperMap.Feature.Vector} 转换后的iClient要素
71657+
* @return {Array.<SuperMap.Feature.Vector>} 转换后的iClient要素
7165871658
*/
7165971659
toiClientFeature: function (features) {
71660-
if (Util.isArray(features)) {
71661-
var featuresTemp = [];
71662-
for (let i = 0; i < features.length; i++) {
71663-
//L.supermap.themeFeature 数据类型
71664-
if (features[i] instanceof ThemeFeature) {
71665-
featuresTemp.push(features[i].toFeature());
71666-
continue;
71667-
}
71668-
// 若是 GeometryVector 直接返回
71669-
if (features[i] instanceof Vector_Vector) {
71670-
featuresTemp.push(features[i]);
71671-
continue;
71672-
}
71673-
//iServer服务器返回数据格式
71660+
//若 features 非数组形式 feature 则先做以下处理:
71661+
if (!Util.isArray(features)) {
71662+
features = [features];
71663+
}
71664+
71665+
let featuresTemp = [];
71666+
for (let i = 0; i < features.length; i++) {
71667+
//L.supermap.themeFeature 数据类型
71668+
if (features[i] instanceof ThemeFeature) {
71669+
featuresTemp.push(features[i].toFeature());
71670+
} else if (features[i] instanceof Vector_Vector) {
71671+
// 若是 GeometryVector 类型直接返回
71672+
featuresTemp.push(features[i]);
71673+
} else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
71674+
//GeoJOSN 规范数据类型
71675+
const format = new GeoJSON_GeoJSON();
71676+
featuresTemp = featuresTemp.concat(format.read(features[i]));
71677+
} else if (features[i].geometry && features[i].geometry.parts) {
71678+
//iServer服务器返回数据格式 todo 暂未找到更好的参数判断,暂用 geometry.parts 试用
7167471679
featuresTemp.push(ServerFeature_ServerFeature.fromJson(features[i]).toFeature());
71680+
} else {
71681+
throw new Error(`features[${i}]'s type is not be supported.`);
7167571682
}
71676-
return featuresTemp;
71677-
}
71678-
//GeoJOSN 规范数据类型
71679-
if (["FeatureCollection", "Feature", "Geometry"].indexOf(features.type) != -1) {
71680-
var format = new GeoJSON_GeoJSON();
71681-
return format.read(features, "FeatureCollection");
71682-
}
7168371683

71684-
throw new Error(`features's type is not be supported.`);
71684+
}
71685+
return featuresTemp;
7168571686
},
7168671687

7168771688
/**
@@ -80723,23 +80724,26 @@ var HeatMapLayer = external_L_default.a.Layer.extend({
8072380724
* @return {SuperMap.Feature.Vector} 转换后的iClient要素
8072480725
*/
8072580726
toiClientFeature: function (features) {
80726-
//支持传入geojson类型
80727-
if (["FeatureCollection", "Feature", "Geometry"].indexOf(features.type) != -1) {
80728-
var format = new GeoJSON_GeoJSON();
80729-
return format.read(features, "FeatureCollection");
80730-
}
80731-
//支持传入ThemeFeature类型,ThemeFeature.geometry instanceof L.LatLng | ThemeFeature.geometry instanceof L.Point
80732-
if (external_L_default.a.Util.isArray(features)) {
80733-
var featuresTemp = [];
80734-
for (var i = 0, len = features.length; i < len; i++) {
80735-
//支持ThemeFeature类型的feature
80736-
if (features[i] instanceof HeatMapFeature) {
80737-
featuresTemp.push(features[i].toFeature());
80738-
}
80727+
if (!external_L_default.a.Util.isArray(features)) {
80728+
features = [features];
80729+
}
80730+
let featuresTemp = [];
80731+
for (let i = 0, len = features.length; i < len; i++) {
80732+
//支持ThemeFeature类型的feature
80733+
//支持传入ThemeFeature类型,ThemeFeature.geometry instanceof L.LatLng | ThemeFeature.geometry instanceof L.Point
80734+
if (features[i] instanceof HeatMapFeature) {
80735+
featuresTemp.push(features[i].toFeature());
80736+
} else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
80737+
const format = new GeoJSON_GeoJSON();
80738+
featuresTemp = featuresTemp.concat(format.read(features[i]));
80739+
} else if (features[i].geometry && features[i].geometry.parts) {
80740+
//iServer服务器返回数据格式 todo 暂未找到更好的参数判断,暂用 geometry.parts 试用
80741+
featuresTemp.push(ServerFeature_ServerFeature.fromJson(features[i]).toFeature());
80742+
} else {
80743+
throw new Error("Features's type does not match, please check.");
8073980744
}
80740-
return featuresTemp;
8074180745
}
80742-
throw new Error("Features's type does not match, please check.");
80746+
return featuresTemp;
8074380747
},
8074480748

8074580749
_zoomAnim: function (e) {

dist/leaflet/iclient9-leaflet-es6.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/leaflet/iclient9-leaflet.js

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21875,34 +21875,34 @@ var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
2187521875
* @function L.supermap.ThemeLayer.prototype.toiClientFeature
2187621876
* @description 转为 iClient 要素
2187721877
* @param {L.supermap.themeFeature|Object} features - 待转要素包括 L.supermap.ThemeFeature 类型和 GeoJOSN 规范数据类型
21878-
* @return {SuperMap.Feature.Vector} 转换后的iClient要素
21878+
* @return {Array.<SuperMap.Feature.Vector>} 转换后的iClient要素
2187921879
*/
2188021880
toiClientFeature: function toiClientFeature(features) {
21881-
if (_iclientCommon.CommonUtil.isArray(features)) {
21882-
var featuresTemp = [];
21883-
for (var i = 0; i < features.length; i++) {
21884-
//L.supermap.themeFeature 数据类型
21885-
if (features[i] instanceof _ThemeFeature.ThemeFeature) {
21886-
featuresTemp.push(features[i].toFeature());
21887-
continue;
21888-
}
21889-
// 若是 GeometryVector 直接返回
21890-
if (features[i] instanceof _iclientCommon.GeometryVector) {
21891-
featuresTemp.push(features[i]);
21892-
continue;
21893-
}
21894-
//iServer服务器返回数据格式
21881+
//若 features 非数组形式 feature 则先做以下处理:
21882+
if (!_iclientCommon.CommonUtil.isArray(features)) {
21883+
features = [features];
21884+
}
21885+
21886+
var featuresTemp = [];
21887+
for (var i = 0; i < features.length; i++) {
21888+
//L.supermap.themeFeature 数据类型
21889+
if (features[i] instanceof _ThemeFeature.ThemeFeature) {
21890+
featuresTemp.push(features[i].toFeature());
21891+
} else if (features[i] instanceof _iclientCommon.GeometryVector) {
21892+
// 若是 GeometryVector 类型直接返回
21893+
featuresTemp.push(features[i]);
21894+
} else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
21895+
//GeoJOSN 规范数据类型
21896+
var format = new _iclientCommon.GeoJSON();
21897+
featuresTemp = featuresTemp.concat(format.read(features[i]));
21898+
} else if (features[i].geometry && features[i].geometry.parts) {
21899+
//iServer服务器返回数据格式 todo 暂未找到更好的参数判断,暂用 geometry.parts 试用
2189521900
featuresTemp.push(_iclientCommon.ServerFeature.fromJson(features[i]).toFeature());
21901+
} else {
21902+
throw new Error('features[' + i + ']\'s type is not be supported.');
2189621903
}
21897-
return featuresTemp;
21898-
}
21899-
//GeoJOSN 规范数据类型
21900-
if (["FeatureCollection", "Feature", "Geometry"].indexOf(features.type) != -1) {
21901-
var format = new _iclientCommon.GeoJSON();
21902-
return format.read(features, "FeatureCollection");
2190321904
}
21904-
21905-
throw new Error('features\'s type is not be supported.');
21905+
return featuresTemp;
2190621906
},
2190721907

2190821908
/**
@@ -63346,23 +63346,26 @@ var HeatMapLayer = exports.HeatMapLayer = _leaflet2["default"].Layer.extend({
6334663346
* @return {SuperMap.Feature.Vector} 转换后的iClient要素
6334763347
*/
6334863348
toiClientFeature: function toiClientFeature(features) {
63349-
//支持传入geojson类型
63350-
if (["FeatureCollection", "Feature", "Geometry"].indexOf(features.type) != -1) {
63351-
var format = new _iclientCommon.GeoJSON();
63352-
return format.read(features, "FeatureCollection");
63349+
if (!_leaflet2["default"].Util.isArray(features)) {
63350+
features = [features];
6335363351
}
63354-
//支持传入ThemeFeature类型,ThemeFeature.geometry instanceof L.LatLng | ThemeFeature.geometry instanceof L.Point
63355-
if (_leaflet2["default"].Util.isArray(features)) {
63356-
var featuresTemp = [];
63357-
for (var i = 0, len = features.length; i < len; i++) {
63358-
//支持ThemeFeature类型的feature
63359-
if (features[i] instanceof HeatMapFeature) {
63360-
featuresTemp.push(features[i].toFeature());
63361-
}
63352+
var featuresTemp = [];
63353+
for (var i = 0, len = features.length; i < len; i++) {
63354+
//支持ThemeFeature类型的feature
63355+
//支持传入ThemeFeature类型,ThemeFeature.geometry instanceof L.LatLng | ThemeFeature.geometry instanceof L.Point
63356+
if (features[i] instanceof HeatMapFeature) {
63357+
featuresTemp.push(features[i].toFeature());
63358+
} else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
63359+
var format = new _iclientCommon.GeoJSON();
63360+
featuresTemp = featuresTemp.concat(format.read(features[i]));
63361+
} else if (features[i].geometry && features[i].geometry.parts) {
63362+
//iServer服务器返回数据格式 todo 暂未找到更好的参数判断,暂用 geometry.parts 试用
63363+
featuresTemp.push(_iclientCommon.ServerFeature.fromJson(features[i]).toFeature());
63364+
} else {
63365+
throw new Error("Features's type does not match, please check.");
6336263366
}
63363-
return featuresTemp;
6336463367
}
63365-
throw new Error("Features's type does not match, please check.");
63368+
return featuresTemp;
6336663369
},
6336763370

6336863371
_zoomAnim: function _zoomAnim(e) {
@@ -74149,7 +74152,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
7414974152
/* 400 */
7415074153
/***/ (function(module) {
7415174154

74152-
module.exports = {"_from":"proj4@2.4.4","_id":"proj4@2.4.4","_inBundle":false,"_integrity":"sha1-wD2CXjgPaFCkp69dINNl9rcsQEI=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.4.4","name":"proj4","escapedName":"proj4","rawSpec":"2.4.4","saveSpec":null,"fetchSpec":"2.4.4"},"_requiredBy":["/"],"_resolved":"http://registry.npm.taobao.org/proj4/download/proj4-2.4.4.tgz","_shasum":"c03d825e380f6850a4a7af5d20d365f6b72c4042","_spec":"proj4@2.4.4","_where":"E:\\2018\\git\\iClient-JavaScript","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"1.0.0","wkt-parser":"^1.2.0"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"^1.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~1.1.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","grunt-rollup":"^1.0.1","istanbul":"~0.2.4","mocha":"~1.17.1","rollup":"^0.41.4","rollup-plugin-json":"^2.0.1","rollup-plugin-node-resolve":"^2.0.0","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","license":"MIT","main":"dist/proj4-src.js","module":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"build":"grunt","build:tmerc":"grunt build:tmerc","test":"npm run build && istanbul test _mocha test/test.js"},"version":"2.4.4"};
74155+
module.exports = {"_from":"proj4@2.4.4","_id":"proj4@2.4.4","_inBundle":false,"_integrity":"sha1-wD2CXjgPaFCkp69dINNl9rcsQEI=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.4.4","name":"proj4","escapedName":"proj4","rawSpec":"2.4.4","saveSpec":null,"fetchSpec":"2.4.4"},"_requiredBy":["/"],"_resolved":"http://registry.npm.taobao.org/proj4/download/proj4-2.4.4.tgz","_shasum":"c03d825e380f6850a4a7af5d20d365f6b72c4042","_spec":"proj4@2.4.4","_where":"G:\\iClient\\iClient-JavaScript","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"1.0.0","wkt-parser":"^1.2.0"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"^1.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~1.1.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","grunt-rollup":"^1.0.1","istanbul":"~0.2.4","mocha":"~1.17.1","rollup":"^0.41.4","rollup-plugin-json":"^2.0.1","rollup-plugin-node-resolve":"^2.0.0","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","license":"MIT","main":"dist/proj4-src.js","module":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"build":"grunt","build:tmerc":"grunt build:tmerc","test":"npm run build && istanbul test _mocha test/test.js"},"version":"2.4.4"};
7415374156

7415474157
/***/ }),
7415574158
/* 401 */

dist/leaflet/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)