Skip to content

Commit e917599

Browse files
committed
fix 挂掉的graph相关UT和源码。review by caoxinke.
1 parent 071b846 commit e917599

File tree

15 files changed

+162
-95
lines changed

15 files changed

+162
-95
lines changed

dist/iclient9-leaflet.js

Lines changed: 114 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18870,17 +18870,14 @@ var GeoFeatureThemeLayer = exports.GeoFeatureThemeLayer = _ThemeLayer.ThemeLayer
1887018870
if (!_leaflet2["default"].Util.isArray(features)) {
1887118871
features = [features];
1887218872
}
18873-
var me = this,
18874-
event = { features: features };
18875-
me.fire("beforefeaturesadded", event);
18876-
features = event.features;
18873+
var me = this;
18874+
me.fire("beforefeaturesadded", { features: features });
18875+
1887718876
for (var i = 0, len = features.length; i < len; i++) {
1887818877
var feature = features[i];
1887918878
feature = me._createFeature(feature);
1888018879
me.features.push(feature);
1888118880
}
18882-
var succeed = me.features.length === 0;
18883-
me.fire("featuresadded", { features: me.features, succeed: succeed });
1888418881

1888518882
if (!me.isCustomSetMaxCacheCount) {
1888618883
me.maxCacheCount = me.features.length * 5;
@@ -19974,18 +19971,17 @@ var GraphThemeLayer = exports.GraphThemeLayer = _ThemeLayer.ThemeLayer.extend({
1997419971
newArgs.push(name);
1997519972
newArgs.push(options);
1997619973
_ThemeLayer.ThemeLayer.prototype.initialize.apply(this, newArgs);
19977-
this.map = options && options.map || null;
1997819974
this.chartsType = chartsType;
19979-
this.chartsSetting = options.chartsSetting || {};
19980-
this.themeFields = options.themeFields || null;
19981-
this.charts = options.charts || [];
19982-
this.cache = options.cache || {};
19975+
this.themeFields = options && options.themeFields ? options.themeFields : null;
19976+
this.charts = options && options.charts ? options.charts : [];
19977+
this.cache = options && options.cache ? options.cache : {};
19978+
this.chartsSetting = options && options.chartsSetting ? options.chartsSetting : {};
1998319979
},
1998419980

1998519981
/**
1998619982
* @function L.supermap.GraphThemeLayer.prototype.setChartsType
19987-
* @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。图表类型,目前支持:"Bar", "Line", "Pie"。
19988-
* @param chartsType - {string} 图表类型。目前可用:"Bar", "Line", "Pie"。
19983+
* @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。图表类型,目前支持:"Bar", "Bar3D", "Line","Point","Pie","Ring"。
19984+
* @param chartsType - {string} 图表类型。目前可用:"Bar", "Bar3D", "Line","Point","Pie","Ring"。
1998919985
*/
1999019986
setChartsType: function setChartsType(chartsType) {
1999119987
this.chartsType = chartsType;
@@ -27536,11 +27532,10 @@ var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
2753627532
initialize: function initialize(name, options) {
2753727533
_leaflet2["default"].Util.setOptions(this, options);
2753827534
this.options.name = name;
27539-
this.features = [];
27540-
this.TFEvents = [];
27535+
this.features = options && options.features ? options.features : [];
27536+
this.TFEvents = options && options.TFEvents ? options.TFEvents : [];
2754127537
this.levelRenderer = new _LevelRenderer2["default"]();
2754227538
this.movingOffset = [0, 0];
27543-
this.map = options && options.map || null;
2754427539
},
2754527540

2754627541
/**
@@ -27595,7 +27590,7 @@ var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
2759527590

2759627591
me.renderer = me.levelRenderer.init(me.container);
2759727592
me.renderer.clear();
27598-
if (me.features.length > 0) {
27593+
if (me.features && me.features.length > 0) {
2759927594
me._reset();
2760027595
me.redrawThematicFeatures(me.map.getBounds());
2760127596
}
@@ -93972,7 +93967,108 @@ exports.names = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
9397293967
/* 466 */
9397393968
/***/ (function(module, exports) {
9397493969

93975-
module.exports = {"_args":[[{"raw":"proj4@2.3.15","scope":null,"escapedName":"proj4","name":"proj4","rawSpec":"2.3.15","spec":"2.3.15","type":"version"},"E:\\git\\iClient9"]],"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inCache":true,"_location":"/proj4","_nodeVersion":"6.1.0","_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/proj4-2.3.15.tgz_1471808262546_0.6752060337457806"},"_npmUser":{"name":"ahocevar","email":"andreas.hocevar@gmail.com"},"_npmVersion":"3.8.6","_phantomChildren":{},"_requested":{"raw":"proj4@2.3.15","scope":null,"escapedName":"proj4","name":"proj4","rawSpec":"2.3.15","spec":"2.3.15","type":"version"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_shrinkwrap":null,"_spec":"proj4@2.3.15","_where":"E:\\git\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"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":"~0.0.2"},"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"dist":{"shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","tarball":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz"},"gitHead":"9fa5249c1f4183d5ddee3c4793dfd7b9f29f1886","homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","maintainers":[{"name":"cwmma","email":"calvin.metcalf@gmail.com"},{"name":"ahocevar","email":"andreas.hocevar@gmail.com"}],"name":"proj4","optionalDependencies":{},"readme":"ERROR: No README data found!","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
93970+
module.exports = {
93971+
"_from": "proj4@2.3.15",
93972+
"_id": "proj4@2.3.15",
93973+
"_inBundle": false,
93974+
"_integrity": "sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=",
93975+
"_location": "/proj4",
93976+
"_phantomChildren": {},
93977+
"_requested": {
93978+
"type": "version",
93979+
"registry": true,
93980+
"raw": "proj4@2.3.15",
93981+
"name": "proj4",
93982+
"escapedName": "proj4",
93983+
"rawSpec": "2.3.15",
93984+
"saveSpec": null,
93985+
"fetchSpec": "2.3.15"
93986+
},
93987+
"_requiredBy": [
93988+
"/"
93989+
],
93990+
"_resolved": "https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz",
93991+
"_shasum": "5ad06e8bca30be0ffa389a49e4565f51f06d089e",
93992+
"_spec": "proj4@2.3.15",
93993+
"_where": "G:\\github-iClient\\iClient9",
93994+
"author": "",
93995+
"bugs": {
93996+
"url": "https://github.com/proj4js/proj4js/issues"
93997+
},
93998+
"bundleDependencies": false,
93999+
"contributors": [
94000+
{
94001+
"name": "Mike Adair",
94002+
"email": "madair@dmsolutions.ca"
94003+
},
94004+
{
94005+
"name": "Richard Greenwood",
94006+
"email": "rich@greenwoodmap.com"
94007+
},
94008+
{
94009+
"name": "Calvin Metcalf",
94010+
"email": "calvin.metcalf@gmail.com"
94011+
},
94012+
{
94013+
"name": "Richard Marsden",
94014+
"url": "http://www.winwaed.com"
94015+
},
94016+
{
94017+
"name": "T. Mittan"
94018+
},
94019+
{
94020+
"name": "D. Steinwand"
94021+
},
94022+
{
94023+
"name": "S. Nelson"
94024+
}
94025+
],
94026+
"dependencies": {
94027+
"mgrs": "~0.0.2"
94028+
},
94029+
"deprecated": false,
94030+
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
94031+
"devDependencies": {
94032+
"browserify": "~12.0.1",
94033+
"chai": "~1.8.1",
94034+
"curl": "git://github.com/cujojs/curl.git",
94035+
"grunt": "~0.4.2",
94036+
"grunt-browserify": "~4.0.1",
94037+
"grunt-cli": "~0.1.13",
94038+
"grunt-contrib-connect": "~0.6.0",
94039+
"grunt-contrib-jshint": "~0.8.0",
94040+
"grunt-contrib-uglify": "~0.11.1",
94041+
"grunt-mocha-phantomjs": "~0.4.0",
94042+
"istanbul": "~0.2.4",
94043+
"mocha": "~1.17.1",
94044+
"tin": "~0.4.0"
94045+
},
94046+
"directories": {
94047+
"test": "test",
94048+
"doc": "docs"
94049+
},
94050+
"homepage": "https://github.com/proj4js/proj4js#readme",
94051+
"jam": {
94052+
"main": "dist/proj4.js",
94053+
"include": [
94054+
"dist/proj4.js",
94055+
"README.md",
94056+
"AUTHORS",
94057+
"LICENSE.md"
94058+
]
94059+
},
94060+
"license": "MIT",
94061+
"main": "lib/index.js",
94062+
"name": "proj4",
94063+
"repository": {
94064+
"type": "git",
94065+
"url": "git://github.com/proj4js/proj4js.git"
94066+
},
94067+
"scripts": {
94068+
"test": "./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"
94069+
},
94070+
"version": "2.3.15"
94071+
};
9397694072

9397794073
/***/ }),
9397894074
/* 467 */

dist/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.

dist/iclient9-mapboxgl.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19448,7 +19448,7 @@ var GeoText = function (_Geometry) {
1944819448
if (style.fontSize) {
1944919449
fontSize = parseFloat(style.fontSize);
1945019450
} else {
19451-
return null;
19451+
fontSize = parseFloat("12px");
1945219452
}
1945319453

1945419454
//标签宽高
@@ -22016,16 +22016,12 @@ var GeoFeature = function (_Theme) {
2201622016
if (!_SuperMap2.default.Util.isArray(features)) {
2201722017
features = [features];
2201822018
}
22019-
var event = { features: features };
22020-
_mapboxGl2.default.Evented.prototype.fire('beforefeaturesadded', event);
2202122019

22022-
features = event.features;
22023-
var featuresFailAdded = [];
22020+
_mapboxGl2.default.Evented.prototype.fire('beforefeaturesadded', { features: features });
22021+
2202422022
for (var i = 0, len = features.length; i < len; i++) {
2202522023
this.features.push(this.toiClientFeature(features[i]));
2202622024
}
22027-
var succeed = featuresFailAdded.length == 0 ? true : false;
22028-
_mapboxGl2.default.Evented.prototype.fire('featuresadded', { features: featuresFailAdded, succeed: succeed });
2202922025
if (!this.isCustomSetMaxCacheCount) {
2203022026
this.maxCacheCount = this.features.length * 5;
2203122027
}
@@ -27512,11 +27508,7 @@ var NetworkAnalystService = function (_ServiceBase) {
2751227508
}
2751327509

2751427510
if (params.event) {
27515-
if (params.event instanceof _mapboxGl2.default.LngLat) {
27516-
params.event = { x: params.event.lng, y: params.event.lat };
27517-
} else if (_Util2.default.isArray(params.event)) {
27518-
params.event = { x: params.event[0], y: params.event[1] };
27519-
}
27511+
return params.event = me._toPointObject(params.event);
2752027512
}
2752127513

2752227514
if (params.facilities && _Util2.default.isArray(params.facilities)) {
@@ -27549,17 +27541,17 @@ var NetworkAnalystService = function (_ServiceBase) {
2754927541
x: point[0],
2755027542
y: point[1]
2755127543
};
27552-
} else if (point instanceof _mapboxGl2.default.LngLat) {
27544+
}
27545+
if (point instanceof _mapboxGl2.default.LngLat) {
2755327546
return {
2755427547
x: point.lng,
2755527548
y: point.lat
2755627549
};
27557-
} else {
27558-
return point instanceof _mapboxGl2.default.Point ? {
27559-
x: point.x,
27560-
y: point.y
27561-
} : point;
2756227550
}
27551+
return point instanceof _mapboxGl2.default.Point ? {
27552+
x: point.x,
27553+
y: point.y
27554+
} : point;
2756327555
}
2756427556
}, {
2756527557
key: '_processFormat',

dist/iclient9-mapboxgl.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/iclient9-openlayers.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19427,16 +19427,10 @@ var GeoFeature = function (_Theme) {
1942719427
if (!_SuperMap2.default.Util.isArray(features)) {
1942819428
features = [features];
1942919429
}
19430-
var event = { features: features };
19431-
this.dispatchEvent({ type: 'beforefeaturesadded', value: event });
19432-
19433-
features = event.features;
19434-
var featuresFailAdded = [];
19430+
this.dispatchEvent({ type: 'beforefeaturesadded', value: { features: features } });
1943519431
for (var i = 0, len = features.length; i < len; i++) {
1943619432
this.features.push(this.toiClientFeature(features[i]));
1943719433
}
19438-
var succeed = featuresFailAdded.length == 0 ? true : false;
19439-
this.dispatchEvent({ type: 'featuresadded', value: { features: featuresFailAdded, succeed: succeed } });
1944019434
if (!this.isCustomSetMaxCacheCount) {
1944119435
this.maxCacheCount = this.features.length * 5;
1944219436
}
@@ -92087,10 +92081,10 @@ module.exports = {
9208792081
"_requiredBy": [
9208892082
"/"
9208992083
],
92090-
"_resolved": "http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz",
92084+
"_resolved": "https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz",
9209192085
"_shasum": "5ad06e8bca30be0ffa389a49e4565f51f06d089e",
9209292086
"_spec": "proj4@2.3.15",
92093-
"_where": "F:\\dev\\iClient",
92087+
"_where": "G:\\github-iClient\\iClient9",
9209492088
"author": "",
9209592089
"bugs": {
9209692090
"url": "https://github.com/proj4js/proj4js/issues"

dist/iclient9-openlayers.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.

examples/leaflet/turf_analysis.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
div.addEventListener('mouseout', function () {
5252
map.scrollWheelZoom.enable();
5353
map.doubleClickZoom.enable();
54-
if(!drawing){
54+
if (!drawing) {
5555
map.on('mousemove', pointerMoveHandler);
5656
}
5757
if (turfAnalyzeType === 'Classification_nearest') {
@@ -303,7 +303,6 @@
303303
showAlert("已有分析范围,请勿重复绘制。");
304304
return;
305305
}
306-
//todo 没有找到监听地图点击时的监听事件
307306
tooltip.removeFrom(map);
308307
map.off('mousemove', pointerMoveHandler);
309308
var layer = e.layer;
@@ -633,7 +632,7 @@
633632
$('#msg').html(msg);
634633
}
635634

636-
function closeAlert(){
635+
function closeAlert() {
637636
if (alertDiv) {
638637
$(alertDiv).remove();
639638
}

src/leaflet/overlay/GraphThemeLayer.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,17 @@ export var GraphThemeLayer = ThemeLayer.extend({
5151
newArgs.push(name);
5252
newArgs.push(options);
5353
ThemeLayer.prototype.initialize.apply(this, newArgs);
54-
this.map = options && options.map || null;
5554
this.chartsType = chartsType;
56-
this.chartsSetting = options.chartsSetting || {};
57-
this.themeFields = options.themeFields || null;
58-
this.charts = options.charts || [];
59-
this.cache = options.cache || {};
55+
this.themeFields = options && options.themeFields ? options.themeFields : null;
56+
this.charts = options && options.charts ? options.charts : [];
57+
this.cache = options && options.cache ? options.cache : {};
58+
this.chartsSetting = options && options.chartsSetting ? options.chartsSetting : {};
6059
},
6160

6261
/**
6362
* @function L.supermap.GraphThemeLayer.prototype.setChartsType
64-
* @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。图表类型,目前支持:"Bar", "Line", "Pie"。
65-
* @param chartsType - {string} 图表类型。目前可用:"Bar", "Line", "Pie"。
63+
* @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。图表类型,目前支持:"Bar", "Bar3D", "Line","Point","Pie","Ring"。
64+
* @param chartsType - {string} 图表类型。目前可用:"Bar", "Bar3D", "Line","Point","Pie","Ring"。
6665
*/
6766
setChartsType: function (chartsType) {
6867
this.chartsType = chartsType;

src/leaflet/overlay/theme/GeoFeatureThemeLayer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ export var GeoFeatureThemeLayer = ThemeLayer.extend({
6464
if (!(L.Util.isArray(features))) {
6565
features = [features];
6666
}
67-
var me = this, event = {features: features};
68-
me.fire("beforefeaturesadded", event);
69-
features = event.features;
67+
var me = this;
68+
me.fire("beforefeaturesadded", {features: features});
69+
7070
for (var i = 0, len = features.length; i < len; i++) {
7171
var feature = features[i];
7272
feature = me._createFeature(feature);
7373
me.features.push(feature);
7474
}
75-
var succeed = me.features.length === 0;
76-
me.fire("featuresadded", {features: me.features, succeed: succeed});
7775

7876
if (!me.isCustomSetMaxCacheCount) {
7977
me.maxCacheCount = me.features.length * 5;

src/leaflet/overlay/theme/ThemeLayer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ export var ThemeLayer = L.Layer.extend({
2828
initialize: function (name, options) {
2929
L.Util.setOptions(this, options);
3030
this.options.name = name;
31-
this.features = [];
32-
this.TFEvents = [];
31+
this.features = options && options.features ? options.features : [];
32+
this.TFEvents = options && options.TFEvents ? options.TFEvents : [];
3333
this.levelRenderer = new LevelRenderer();
3434
this.movingOffset = [0, 0];
35-
this.map = options && options.map || null;
3635
},
3736

3837
/**
@@ -87,7 +86,7 @@ export var ThemeLayer = L.Layer.extend({
8786

8887
me.renderer = me.levelRenderer.init(me.container);
8988
me.renderer.clear();
90-
if (me.features.length > 0) {
89+
if (me.features && me.features.length > 0) {
9190
me._reset();
9291
me.redrawThematicFeatures(me.map.getBounds());
9392
}

0 commit comments

Comments
 (0)