egovamap 0.28.7 → 0.28.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,179 +1,181 @@
1
1
  var XEvent = function () {
2
- this.handlers = {};
2
+ this.handlers = {};
3
3
  };
4
4
  XEvent.prototype = {
5
- on: function (type, handler) {
6
- if (!this.handlers[type]) {
7
- this.handlers[type] = [];
8
- }
9
- this.handlers[type].push(handler);
10
- return handler;
11
- },
12
- fire: function (type, msgData) {
13
- if (this.handlers[type] instanceof Array) {
14
- var handlers = this.handlers[type];
15
- if (handlers && handlers.length == 1) {
16
- return handlers[0](msgData);
17
- } else {
18
- for (var i = 0, len = handlers.length; i < len; i++) {
19
- handlers[i](msgData);
20
- }
21
- }
22
- }
23
- },
24
- //除所有该事件下对应的方法
25
- remove: function (type) {
26
- if (this.handlers[type] instanceof Array) {
27
- this.handlers[type] = [];
28
- }
29
- },
30
- removeHandler: function (type, handler) {
31
- if (this.handlers[type] instanceof Array) {
32
- var handlers = this.handlers[type];
33
- for (var i = 0, len = handlers.length; i < len; i++) {
34
- if (handlers[i] === handler) {
35
- handlers.splice(i, 1);
36
- break;
37
- }
38
- }
39
- }
40
- },
41
- clear: function () {
42
- this.handlers = {};
43
- },
5
+ on: function (type, handler) {
6
+ if (!this.handlers[type]) {
7
+ this.handlers[type] = [];
8
+ }
9
+ this.handlers[type].push(handler);
10
+ return handler;
11
+ },
12
+ fire: function (type, msgData) {
13
+ if (this.handlers[type] instanceof Array) {
14
+ var handlers = this.handlers[type];
15
+ if (handlers && handlers.length == 1) {
16
+ return handlers[0](msgData);
17
+ } else {
18
+ for (var i = 0, len = handlers.length; i < len; i++) {
19
+ handlers[i](msgData);
20
+ }
21
+ }
22
+ }
23
+ },
24
+ //除所有该事件下对应的方法
25
+ remove: function (type) {
26
+ if (this.handlers[type] instanceof Array) {
27
+ this.handlers[type] = [];
28
+ }
29
+ },
30
+ removeHandler: function (type, handler) {
31
+ if (this.handlers[type] instanceof Array) {
32
+ var handlers = this.handlers[type];
33
+ for (var i = 0, len = handlers.length; i < len; i++) {
34
+ if (handlers[i] === handler) {
35
+ handlers.splice(i, 1);
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ },
41
+ clear: function () {
42
+ this.handlers = {};
43
+ },
44
44
  };
45
45
 
46
46
  var XScene = function (pageType, pageId) {
47
- this.pageType = pageType;
48
- this.pageId = pageId;
49
- this._evt = new XEvent();
50
- this._handler = [];
51
- this.hostWin = window;
47
+ this.pageType = pageType;
48
+ this.pageId = pageId;
49
+ this._evt = new XEvent();
50
+ this._handler = [];
51
+ this.hostWin = window;
52
52
  };
53
53
 
54
54
  XScene.prototype = {
55
- getParameter: function () {
56
- if (this.pageType == "modal") {
57
- return window.dialogArguments.parameter;
58
- }
59
- return null;
60
- },
55
+ getParameter: function () {
56
+ if (this.pageType == "modal") {
57
+ return window.dialogArguments.parameter;
58
+ }
59
+ return null;
60
+ },
61
61
 
62
- getCallback: function () {
63
- if (this.pageType == "modal") {
64
- return window.dialogArguments.callback;
65
- }
66
- return null;
67
- },
62
+ getCallback: function () {
63
+ if (this.pageType == "modal") {
64
+ return window.dialogArguments.callback;
65
+ }
66
+ return null;
67
+ },
68
68
 
69
- getParentScene: function (pageId, stopOnTop) {
70
- stopOnTop = stopOnTop || false;
71
- var parent = null;
72
- if (this.pageType == "iframe" || this.pageType == "iframe-dialog") {
73
- if (window != window.parent) {
74
- parent = window.parent;
75
- }
76
- }
77
- if (!stopOnTop) {
78
- if (this.pageType == "modal") {
79
- parent = window.dialogArguments.hostWin;
80
- }
81
- if (this.pageType == "dialog") {
82
- parent = window.opener;
83
- }
84
- }
85
- if (!parent || !parent.__xsense) return null;
86
- if (parent.__xsense && parent.__xsense.pageId !== pageId) {
87
- return parent.__xsense.getParentScene(pageId, stopOnTop);
88
- }
89
- return parent.__xsense;
90
- },
69
+ getParentScene: function (pageId, stopOnTop) {
70
+ stopOnTop = stopOnTop || false;
71
+ var parent = null;
72
+ if (this.pageType == "iframe" || this.pageType == "iframe-dialog") {
73
+ if (window != window.parent) {
74
+ parent = window.parent;
75
+ }
76
+ }
77
+ if (!stopOnTop) {
78
+ if (this.pageType == "modal") {
79
+ parent = window.dialogArguments.hostWin;
80
+ }
81
+ if (this.pageType == "dialog") {
82
+ parent = window.opener;
83
+ }
84
+ }
85
+ if (!parent || !parent.__xsense) return null;
86
+ if (parent.__xsense && parent.__xsense.pageId !== pageId) {
87
+ return parent.__xsense.getParentScene(pageId, stopOnTop);
88
+ }
89
+ return parent.__xsense;
90
+ },
91
91
 
92
- closeAllDialogs: function () {
93
- var parent = null;
94
- if (this.pageType == "iframe" || this.pageType == "iframe-dialog") {
95
- if (window != window.parent) {
96
- parent = window.top;
97
- }
98
- }
99
- if (this.pageType == "modal") {
100
- parent = window.dialogArguments.hostWin;
101
- window.close();
102
- }
103
- if (this.pageType == "dialog") {
104
- parent = window.opener;
105
- window.close();
106
- }
107
- if (!parent || !parent.__xsense) return null;
108
- if (parent.__xsense) {
109
- parent.__xsense.closeAllDialogs();
110
- }
111
- },
92
+ closeAllDialogs: function () {
93
+ var parent = null;
94
+ if (this.pageType == "iframe" || this.pageType == "iframe-dialog") {
95
+ if (window != window.parent) {
96
+ parent = window.top;
97
+ }
98
+ }
99
+ if (this.pageType == "modal") {
100
+ parent = window.dialogArguments.hostWin;
101
+ window.close();
102
+ }
103
+ if (this.pageType == "dialog") {
104
+ parent = window.opener;
105
+ window.close();
106
+ }
107
+ if (!parent || !parent.__xsense) return null;
108
+ if (parent.__xsense) {
109
+ parent.__xsense.closeAllDialogs();
110
+ }
111
+ },
112
112
 
113
- fire: function (msgId, msgData, pageId, stopOnTop) {
114
- stopOnTop = stopOnTop || false;
115
- if (!pageId || pageId === this.pageId) {
116
- return this._evt.fire(msgId, msgData);
117
- } else {
118
- var parent = this.getParentScene(pageId, stopOnTop);
119
- if (parent) {
120
- return parent.fire(msgId, msgData, pageId, stopOnTop);
121
- }
122
- return null;
123
- }
124
- },
125
- remove: function (msgId, pageId, stopOnTop) {
126
- stopOnTop = stopOnTop || false;
127
- if (!pageId || pageId === this.pageId) {
128
- this._evt.remove(msgId);
129
- return null;
130
- } else {
131
- var parent = this.getParentScene(pageId, stopOnTop);
132
- if (parent) {
133
- parent.remove(msgId, pageId, stopOnTop);
134
- }
135
- return null;
136
- }
137
- },
138
- removeHandler: function (msgId, msgHandler, pageId, stopOnTop) {
139
- stopOnTop = stopOnTop || false;
140
- if (!pageId || pageId === this.pageId) {
141
- this._evt.removeHandler(msgId, msgHandler);
142
- return null;
143
- } else {
144
- var parent = this.getParentScene(pageId, stopOnTop);
145
- if (parent) {
146
- parent.removeHandler(msgId, msgHandler, pageId, stopOnTop);
147
- }
148
- return null;
149
- }
150
- },
151
- on: function (msgId, msgHandler, pageId, stopOnTop) {
152
- stopOnTop = stopOnTop || false;
153
- if (!pageId || pageId === this.pageId) {
154
- var h = this._evt.on(msgId, msgHandler);
155
- return null;
156
- } else {
157
- var parent = this.getParentScene(pageId, stopOnTop);
158
- if (parent) {
159
- var h = parent.on(msgId, msgHandler, pageId, stopOnTop);
160
- if (h) {
161
- this._handler.push(h);
162
- }
163
- }
164
- return null;
165
- }
166
- },
167
- detachAll: function () {
168
- for (var i = 0; i < this._handler.length; i++) {
169
- this._handler[i].detach();
170
- }
171
- },
113
+ fire: function (msgId, msgData, pageId, stopOnTop) {
114
+ stopOnTop = stopOnTop || false;
115
+ if (!pageId || pageId === this.pageId) {
116
+ return this._evt.fire(msgId, msgData);
117
+ } else {
118
+ var parent = this.getParentScene(pageId, stopOnTop);
119
+ if (parent) {
120
+ return parent.fire(msgId, msgData, pageId, stopOnTop);
121
+ }
122
+ return null;
123
+ }
124
+ },
125
+ remove: function (msgId, pageId, stopOnTop) {
126
+ stopOnTop = stopOnTop || false;
127
+ if (!pageId || pageId === this.pageId) {
128
+ this._evt.remove(msgId);
129
+ return null;
130
+ } else {
131
+ var parent = this.getParentScene(pageId, stopOnTop);
132
+ if (parent) {
133
+ parent.remove(msgId, pageId, stopOnTop);
134
+ }
135
+ return null;
136
+ }
137
+ },
138
+ removeHandler: function (msgId, msgHandler, pageId, stopOnTop) {
139
+ stopOnTop = stopOnTop || false;
140
+ if (!pageId || pageId === this.pageId) {
141
+ this._evt.removeHandler(msgId, msgHandler);
142
+ return null;
143
+ } else {
144
+ var parent = this.getParentScene(pageId, stopOnTop);
145
+ if (parent) {
146
+ parent.removeHandler(msgId, msgHandler, pageId, stopOnTop);
147
+ }
148
+ return null;
149
+ }
150
+ },
151
+ on: function (msgId, msgHandler, pageId, stopOnTop) {
152
+ stopOnTop = stopOnTop || false;
153
+ if (!pageId || pageId === this.pageId) {
154
+ var h = this._evt.on(msgId, msgHandler);
155
+ return null;
156
+ } else {
157
+ var parent = this.getParentScene(pageId, stopOnTop);
158
+ if (parent) {
159
+ var h = parent.on(msgId, msgHandler, pageId, stopOnTop);
160
+ if (h) {
161
+ this._handler.push(h);
162
+ }
163
+ }
164
+ return null;
165
+ }
166
+ },
167
+ detachAll: function () {
168
+ for (var i = 0; i < this._handler.length; i++) {
169
+ this._handler[i].detach();
170
+ }
171
+ },
172
172
  };
173
173
 
174
174
  XScene.create = function (pageType, pageId) {
175
- window.__xsense = new XScene(pageType, pageId);
176
- return window.__xsense;
175
+ if(!window.__xsense){
176
+ window.__xsense = new XScene(pageType, pageId);
177
+ }
178
+ return window.__xsense;
177
179
  };
178
180
 
179
181
  //pageType: iframe, iframe-dialog, modal, dialog, desktop
@@ -182,12 +184,12 @@ XScene.create = function (pageType, pageId) {
182
184
  //modal 弹出的模态对话框
183
185
  //dialog 弹出的普通对话框
184
186
  var EGovaScene = {
185
- create: function (pageType, pageId) {
186
- return XScene.create(pageType, pageId);
187
- },
187
+ create: function (pageType, pageId) {
188
+ return XScene.create(pageType, pageId);
189
+ },
188
190
 
189
- getSense: function () {
190
- return window.__xsense;
191
- },
191
+ getSense: function () {
192
+ return window.__xsense;
193
+ },
192
194
  };
193
195
  export default EGovaScene;
@@ -78,7 +78,7 @@ let GeometryTrans = {
78
78
  "$1 $2"
79
79
  );
80
80
  wktStr = wktStr.replace(/\[/g, "(").replace(/\]/g, ")");
81
- if (geometryType === 'Point') {
81
+ if (geometryType === "Point") {
82
82
  wktStr = geometryType.toUpperCase() + "(" + wktStr + ")";
83
83
  } else {
84
84
  wktStr = geometryType.toUpperCase() + wktStr;
@@ -87,10 +87,10 @@ let GeometryTrans = {
87
87
  },
88
88
  geometryToWKT: function (geometry) {
89
89
  if (geometry["coordinates"]) {
90
- return this.geoJsonToWKT(geometry)
90
+ return this.geoJsonToWKT(geometry);
91
91
  } else {
92
- return this.agsToWKT(geometry)
92
+ return this.agsToWKT(geometry);
93
93
  }
94
- }
94
+ },
95
95
  };
96
96
  export default GeometryTrans;
@@ -13,7 +13,7 @@ function ringIsClockwise(ringToTest) {
13
13
  total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);
14
14
  pt1 = pt2;
15
15
  }
16
- return (total >= 0);
16
+ return total >= 0;
17
17
  }
18
18
 
19
19
  function closeRing(coordinates) {
@@ -36,9 +36,16 @@ function pointsEqual(a, b) {
36
36
  function coordinatesContainPoint(coordinates, point) {
37
37
  var contains = false;
38
38
  for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {
39
- if (((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1]) ||
40
- (coordinates[j][1] <= point[1] && point[1] < coordinates[i][1])) &&
41
- (point[0] < (coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1]) / (coordinates[j][1] - coordinates[i][1]) + coordinates[i][0])) {
39
+ if (
40
+ ((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1]) ||
41
+ (coordinates[j][1] <= point[1] &&
42
+ point[1] < coordinates[i][1])) &&
43
+ point[0] <
44
+ ((coordinates[j][0] - coordinates[i][0]) *
45
+ (point[1] - coordinates[i][1])) /
46
+ (coordinates[j][1] - coordinates[i][1]) +
47
+ coordinates[i][0]
48
+ ) {
42
49
  contains = !contains;
43
50
  }
44
51
  }
@@ -46,9 +53,12 @@ function coordinatesContainPoint(coordinates, point) {
46
53
  }
47
54
 
48
55
  function edgeIntersectsEdge(a1, a2, b1, b2) {
49
- var ua_t = (b2[0] - b1[0]) * (a1[1] - b1[1]) - (b2[1] - b1[1]) * (a1[0] - b1[0]);
50
- var ub_t = (a2[0] - a1[0]) * (a1[1] - b1[1]) - (a2[1] - a1[1]) * (a1[0] - b1[0]);
51
- var u_b = (b2[1] - b1[1]) * (a2[0] - a1[0]) - (b2[0] - b1[0]) * (a2[1] - a1[1]);
56
+ var ua_t =
57
+ (b2[0] - b1[0]) * (a1[1] - b1[1]) - (b2[1] - b1[1]) * (a1[0] - b1[0]);
58
+ var ub_t =
59
+ (a2[0] - a1[0]) * (a1[1] - b1[1]) - (a2[1] - a1[1]) * (a1[0] - b1[0]);
60
+ var u_b =
61
+ (b2[1] - b1[1]) * (a2[0] - a1[0]) - (b2[0] - b1[0]) * (a2[1] - a1[1]);
52
62
 
53
63
  if (u_b !== 0) {
54
64
  var ua = ua_t / u_b;
@@ -105,7 +115,6 @@ function convertRingsToGeoJSON(rings) {
105
115
  var outerRing;
106
116
  var hole;
107
117
 
108
-
109
118
  for (var r = 0; r < rings.length; r++) {
110
119
  var ring = closeRing(rings[r].slice(0));
111
120
  if (ring.length < 4) {
@@ -159,14 +168,14 @@ function convertRingsToGeoJSON(rings) {
159
168
 
160
169
  if (outerRings.length === 1) {
161
170
  return {
162
- type: 'Polygon',
163
- coordinates: outerRings[0]
171
+ type: "Polygon",
172
+ coordinates: outerRings[0],
164
173
  };
165
174
  } else {
166
175
  return {
167
- type: 'MultiPolygon',
168
- coordinates: outerRings
176
+ type: "MultiPolygon",
177
+ coordinates: outerRings,
169
178
  };
170
179
  }
171
180
  }
172
- export default convertRingsToGeoJSON;
181
+ export default convertRingsToGeoJSON;
@@ -1,5 +1,7 @@
1
- var CoordConvConfig={
2
- coordConvert4Params:'-47363.969#-4112623.75#0.0039286694040273984#1.0000046699602922#0#116.0',
3
- coordConvert4ParamsReverse:'31175.966131687164#4112791.5852928162#-0.003850255399136165#1.0000100832629242#0#116.0'
4
- }
5
- export default CoordConvConfig;
1
+ var CoordConvConfig = {
2
+ coordConvert4Params:
3
+ "-47363.969#-4112623.75#0.0039286694040273984#1.0000046699602922#0#116.0",
4
+ coordConvert4ParamsReverse:
5
+ "31175.966131687164#4112791.5852928162#-0.003850255399136165#1.0000100832629242#0#116.0",
6
+ };
7
+ export default CoordConvConfig;