@hzab/map-combine 0.4.1 → 0.4.2-alpha.1
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.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/basic/BasicElement.ts +14 -14
- package/src/basic/BasicMarker.ts +32 -26
- package/src/basic/BasicMouseHandler.ts +4 -4
- package/src/basic/Point.ts +173 -173
- package/src/basic/PointAggregation.tsx +1 -0
- package/src/basic/Polygon.ts +81 -70
- package/src/basic/Polyline.ts +85 -75
- package/src/basic/ReactPopup.tsx +12 -10
- package/src/cesium/CesiumPoint.ts +69 -69
- package/src/cesium/CesiumPolygon.ts +181 -190
- package/src/cesium/CesiumPolyline.ts +369 -369
- package/src/mine/MinePoint.ts +70 -78
- package/src/mine/MinePolygon.ts +206 -216
- package/src/mine/MinePolyline.ts +193 -203
- package/src/mine/MineTile3D.ts +7 -11
- package/src/openlayer/OpenlayerMap.ts +287 -287
- package/src/openlayer/OpenlayerPoint.ts +185 -177
- package/src/openlayer/OpenlayerPolygon.ts +307 -299
- package/src/openlayer/OpenlayerPolyline.ts +303 -289
- package/src/utils/Image.ts +16 -20
- package/src/utils/PolygonEditor.ts +78 -99
- package/src/utils/PolylineEditor.ts +75 -90
- package/src/utils/static.ts +3 -3
|
@@ -1,159 +1,138 @@
|
|
|
1
|
-
import Eventful from "zrender/lib/core/Eventful"
|
|
2
|
-
|
|
1
|
+
import Eventful from "zrender/lib/core/Eventful";
|
|
3
2
|
|
|
4
3
|
export class PolygonEditor<M, N> extends Eventful<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>{
|
|
10
|
-
first: ChainNode<M, N
|
|
4
|
+
"create-node": (n: ChainNode<M, N> | VirtualNode<M, N>) => void;
|
|
5
|
+
"update-node": (n: ChainNode<M, N> | VirtualNode<M, N>) => void;
|
|
6
|
+
"remove-node": (n: ChainNode<M, N> | VirtualNode<M, N>) => void;
|
|
7
|
+
empty: () => void;
|
|
8
|
+
}> {
|
|
9
|
+
first: ChainNode<M, N>;
|
|
11
10
|
setCoordinates(ps: number[][]) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let anchor = this.first
|
|
11
|
+
let anchor = this.first;
|
|
15
12
|
if (this.first) {
|
|
16
|
-
this.first.previous.next = undefined
|
|
13
|
+
this.first.previous.next = undefined;
|
|
17
14
|
while (anchor) {
|
|
18
|
-
this.trigger(
|
|
19
|
-
anchor.virtual && this.trigger(
|
|
20
|
-
anchor = anchor.next
|
|
15
|
+
this.trigger("remove-node", anchor);
|
|
16
|
+
anchor.virtual && this.trigger("remove-node", anchor.virtual);
|
|
17
|
+
anchor = anchor.next;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
ps.forEach(e => {
|
|
21
|
+
ps.forEach((e) => {
|
|
25
22
|
if (anchor) {
|
|
26
|
-
anchor = anchor.createNext(e)
|
|
27
|
-
|
|
23
|
+
anchor = anchor.createNext(e);
|
|
28
24
|
} else {
|
|
29
|
-
this.first = new ChainNode(this, e)
|
|
30
|
-
anchor = this.first
|
|
25
|
+
this.first = new ChainNode(this, e);
|
|
26
|
+
anchor = this.first;
|
|
31
27
|
}
|
|
32
|
-
})
|
|
28
|
+
});
|
|
33
29
|
if (anchor) {
|
|
34
|
-
this.first.previous = anchor
|
|
35
|
-
anchor.next = this.first
|
|
36
|
-
anchor.virtual = new VirtualNode(anchor)
|
|
30
|
+
this.first.previous = anchor;
|
|
31
|
+
anchor.next = this.first;
|
|
32
|
+
anchor.virtual = new VirtualNode(anchor);
|
|
37
33
|
} else {
|
|
38
|
-
this.first = undefined
|
|
34
|
+
this.first = undefined;
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
}
|
|
42
37
|
getCoordinates() {
|
|
43
38
|
if (this.first) {
|
|
44
|
-
this.first.previous.next = undefined
|
|
45
|
-
const res: number[][] = []
|
|
46
|
-
let anchor = this.first
|
|
39
|
+
this.first.previous.next = undefined;
|
|
40
|
+
const res: number[][] = [];
|
|
41
|
+
let anchor = this.first;
|
|
47
42
|
while (anchor) {
|
|
48
|
-
res.push(anchor.position)
|
|
49
|
-
anchor = anchor.next
|
|
43
|
+
res.push(anchor.position);
|
|
44
|
+
anchor = anchor.next;
|
|
50
45
|
}
|
|
51
|
-
this.first.previous.next = this.first
|
|
52
|
-
return res
|
|
46
|
+
this.first.previous.next = this.first;
|
|
47
|
+
return res;
|
|
53
48
|
} else {
|
|
54
|
-
return []
|
|
49
|
+
return [];
|
|
55
50
|
}
|
|
56
|
-
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
shape: M
|
|
69
|
-
previous: ChainNode<M, N>
|
|
70
|
-
next: ChainNode<M, N>
|
|
71
|
-
virtual: VirtualNode<M, N>
|
|
54
|
+
export class ChainNode<M, N> {
|
|
55
|
+
type = "node" as const;
|
|
56
|
+
position: number[];
|
|
57
|
+
editor: PolygonEditor<M, N>;
|
|
58
|
+
shape: M;
|
|
59
|
+
previous: ChainNode<M, N>;
|
|
60
|
+
next: ChainNode<M, N>;
|
|
61
|
+
virtual: VirtualNode<M, N>;
|
|
72
62
|
constructor(editor: PolygonEditor<M, N>, position: number[]) {
|
|
73
|
-
this.editor = editor
|
|
74
|
-
this.position = position
|
|
75
|
-
editor.trigger(
|
|
76
|
-
|
|
63
|
+
this.editor = editor;
|
|
64
|
+
this.position = position;
|
|
65
|
+
editor.trigger("create-node", this);
|
|
77
66
|
}
|
|
78
67
|
|
|
79
68
|
update(p: number[]) {
|
|
80
|
-
this.position = p
|
|
81
|
-
this.editor.trigger(
|
|
82
|
-
this.previous?.virtual.update()
|
|
83
|
-
this.virtual?.update()
|
|
69
|
+
this.position = p;
|
|
70
|
+
this.editor.trigger("update-node", this);
|
|
71
|
+
this.previous?.virtual.update();
|
|
72
|
+
this.virtual?.update();
|
|
84
73
|
}
|
|
85
74
|
|
|
86
75
|
createNext(p: number[]) {
|
|
87
|
-
this.next = new ChainNode(this.editor, p)
|
|
88
|
-
this.next.previous = this
|
|
89
|
-
this.virtual = new VirtualNode(this)
|
|
90
|
-
return this.next
|
|
76
|
+
this.next = new ChainNode(this.editor, p);
|
|
77
|
+
this.next.previous = this;
|
|
78
|
+
this.virtual = new VirtualNode(this);
|
|
79
|
+
return this.next;
|
|
91
80
|
}
|
|
92
81
|
|
|
93
|
-
|
|
94
|
-
|
|
95
82
|
destroy() {
|
|
96
|
-
const { editor, virtual, previous, next } = this
|
|
83
|
+
const { editor, virtual, previous, next } = this;
|
|
97
84
|
if (editor.first.next.next.next == editor.first) {
|
|
98
|
-
|
|
99
|
-
editor.
|
|
100
|
-
editor.trigger('empty')
|
|
85
|
+
editor.setCoordinates([]);
|
|
86
|
+
editor.trigger("empty");
|
|
101
87
|
} else {
|
|
102
88
|
if (editor.first == this) {
|
|
103
|
-
editor.first = this.next
|
|
89
|
+
editor.first = this.next;
|
|
104
90
|
}
|
|
105
|
-
previous.next = next
|
|
106
|
-
next.previous = previous
|
|
107
|
-
previous.virtual.update()
|
|
108
|
-
editor.trigger(
|
|
109
|
-
editor.trigger(
|
|
91
|
+
previous.next = next;
|
|
92
|
+
next.previous = previous;
|
|
93
|
+
previous.virtual.update();
|
|
94
|
+
editor.trigger("remove-node", this);
|
|
95
|
+
editor.trigger("remove-node", virtual);
|
|
110
96
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
97
|
}
|
|
115
98
|
}
|
|
116
99
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
previous: ChainNode<M, N>
|
|
100
|
+
export class VirtualNode<M, N> {
|
|
101
|
+
type = "virtual" as const;
|
|
102
|
+
shape: N;
|
|
103
|
+
previous: ChainNode<M, N>;
|
|
122
104
|
|
|
123
105
|
get next() {
|
|
124
|
-
return this.previous.next
|
|
106
|
+
return this.previous.next;
|
|
125
107
|
}
|
|
126
108
|
get editor() {
|
|
127
|
-
return this.previous.editor
|
|
109
|
+
return this.previous.editor;
|
|
128
110
|
}
|
|
129
111
|
get position() {
|
|
130
|
-
const { previous, next } = this
|
|
131
|
-
return previous.position.map((e, i) => (e + next.position[i]) / 2)
|
|
112
|
+
const { previous, next } = this;
|
|
113
|
+
return previous.position.map((e, i) => (e + next.position[i]) / 2);
|
|
132
114
|
}
|
|
133
115
|
constructor(n: ChainNode<M, N>) {
|
|
134
|
-
this.previous = n
|
|
135
|
-
this.editor.trigger(
|
|
116
|
+
this.previous = n;
|
|
117
|
+
this.editor.trigger("create-node", this);
|
|
136
118
|
}
|
|
137
119
|
update() {
|
|
138
|
-
this.editor.trigger(
|
|
120
|
+
this.editor.trigger("update-node", this);
|
|
139
121
|
}
|
|
140
122
|
|
|
141
123
|
insert() {
|
|
142
|
-
const { previous, next } = this
|
|
143
|
-
const p = this.position
|
|
144
|
-
this.previous = previous.createNext(p)
|
|
145
|
-
this.previous.virtual = this
|
|
146
|
-
this.previous.next = next
|
|
147
|
-
next.previous = this.previous
|
|
148
|
-
this.update()
|
|
149
|
-
return this.previous
|
|
124
|
+
const { previous, next } = this;
|
|
125
|
+
const p = this.position;
|
|
126
|
+
this.previous = previous.createNext(p);
|
|
127
|
+
this.previous.virtual = this;
|
|
128
|
+
this.previous.next = next;
|
|
129
|
+
next.previous = this.previous;
|
|
130
|
+
this.update();
|
|
131
|
+
return this.previous;
|
|
150
132
|
}
|
|
151
133
|
|
|
152
134
|
destroy() {
|
|
153
|
-
this.previous.virtual = undefined
|
|
154
|
-
this.editor.trigger(
|
|
135
|
+
this.previous.virtual = undefined;
|
|
136
|
+
this.editor.trigger("remove-node", this);
|
|
155
137
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
138
|
}
|
|
159
|
-
|
|
@@ -1,149 +1,134 @@
|
|
|
1
|
-
import Eventful from "zrender/lib/core/Eventful"
|
|
2
|
-
|
|
1
|
+
import Eventful from "zrender/lib/core/Eventful";
|
|
3
2
|
|
|
4
3
|
export class PolylineEditor<M, N> extends Eventful<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>{
|
|
10
|
-
first: ChainNode<M, N
|
|
4
|
+
"create-node": (n: ChainNode<M, N> | VirtualNode<M, N>) => void;
|
|
5
|
+
"update-node": (n: ChainNode<M, N> | VirtualNode<M, N>) => void;
|
|
6
|
+
"remove-node": (n: ChainNode<M, N> | VirtualNode<M, N>) => void;
|
|
7
|
+
empty: () => void;
|
|
8
|
+
}> {
|
|
9
|
+
first: ChainNode<M, N>;
|
|
11
10
|
setCoordinates(ps: number[][]) {
|
|
12
|
-
|
|
13
|
-
let anchor = this.first
|
|
11
|
+
let anchor = this.first;
|
|
14
12
|
|
|
15
13
|
while (anchor) {
|
|
16
|
-
this.trigger(
|
|
17
|
-
anchor.virtual && this.trigger(
|
|
18
|
-
anchor = anchor.next
|
|
14
|
+
this.trigger("remove-node", anchor);
|
|
15
|
+
anchor.virtual && this.trigger("remove-node", anchor.virtual);
|
|
16
|
+
anchor = anchor.next;
|
|
19
17
|
}
|
|
20
|
-
ps.forEach(e => {
|
|
18
|
+
ps.forEach((e) => {
|
|
21
19
|
if (anchor) {
|
|
22
|
-
anchor = anchor.createNext(e)
|
|
23
|
-
|
|
20
|
+
anchor = anchor.createNext(e);
|
|
24
21
|
} else {
|
|
25
|
-
this.first = new ChainNode(this, e)
|
|
26
|
-
anchor = this.first
|
|
22
|
+
this.first = new ChainNode(this, e);
|
|
23
|
+
anchor = this.first;
|
|
27
24
|
}
|
|
28
|
-
})
|
|
25
|
+
});
|
|
29
26
|
}
|
|
30
27
|
getCoordinates() {
|
|
31
|
-
const res: number[][] = []
|
|
32
|
-
let anchor = this.first
|
|
28
|
+
const res: number[][] = [];
|
|
29
|
+
let anchor = this.first;
|
|
33
30
|
while (anchor) {
|
|
34
|
-
res.push(anchor.position)
|
|
35
|
-
anchor = anchor.next
|
|
31
|
+
res.push(anchor.position);
|
|
32
|
+
anchor = anchor.next;
|
|
36
33
|
}
|
|
37
|
-
return res
|
|
34
|
+
return res;
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
shape: M
|
|
50
|
-
previous: ChainNode<M, N>
|
|
51
|
-
next: ChainNode<M, N>
|
|
52
|
-
virtual: VirtualNode<M, N>
|
|
38
|
+
export class ChainNode<M, N> {
|
|
39
|
+
type = "node" as const;
|
|
40
|
+
position: number[];
|
|
41
|
+
editor: PolylineEditor<M, N>;
|
|
42
|
+
shape: M;
|
|
43
|
+
previous: ChainNode<M, N>;
|
|
44
|
+
next: ChainNode<M, N>;
|
|
45
|
+
virtual: VirtualNode<M, N>;
|
|
53
46
|
constructor(editor: PolylineEditor<M, N>, position: number[]) {
|
|
54
|
-
this.editor = editor
|
|
55
|
-
this.position = position
|
|
56
|
-
editor.trigger(
|
|
47
|
+
this.editor = editor;
|
|
48
|
+
this.position = position;
|
|
49
|
+
editor.trigger("create-node", this);
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
update(p: number[]) {
|
|
60
|
-
this.position = p
|
|
61
|
-
this.editor.trigger(
|
|
62
|
-
this.previous?.virtual.update()
|
|
63
|
-
this.virtual?.update()
|
|
53
|
+
this.position = p;
|
|
54
|
+
this.editor.trigger("update-node", this);
|
|
55
|
+
this.previous?.virtual.update();
|
|
56
|
+
this.virtual?.update();
|
|
64
57
|
}
|
|
65
58
|
|
|
66
59
|
createNext(p: number[]) {
|
|
67
|
-
this.next = new ChainNode(this.editor, p)
|
|
68
|
-
this.next.previous = this
|
|
69
|
-
this.virtual = new VirtualNode(this)
|
|
70
|
-
return this.next
|
|
60
|
+
this.next = new ChainNode(this.editor, p);
|
|
61
|
+
this.next.previous = this;
|
|
62
|
+
this.virtual = new VirtualNode(this);
|
|
63
|
+
return this.next;
|
|
71
64
|
}
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
|
|
75
66
|
destroy() {
|
|
76
|
-
const { editor, virtual, previous, next } = this
|
|
67
|
+
const { editor, virtual, previous, next } = this;
|
|
77
68
|
if (previous && next) {
|
|
78
|
-
previous.next = next
|
|
79
|
-
next.previous = previous
|
|
80
|
-
previous.virtual.update()
|
|
69
|
+
previous.next = next;
|
|
70
|
+
next.previous = previous;
|
|
71
|
+
previous.virtual.update();
|
|
81
72
|
|
|
82
|
-
editor.trigger(
|
|
73
|
+
editor.trigger("remove-node", virtual);
|
|
83
74
|
} else if (previous) {
|
|
84
|
-
previous.next = undefined
|
|
75
|
+
previous.next = undefined;
|
|
85
76
|
|
|
86
|
-
previous.virtual.destroy()
|
|
77
|
+
previous.virtual.destroy();
|
|
87
78
|
} else if (next) {
|
|
88
|
-
editor.first = next
|
|
89
|
-
next.previous = undefined
|
|
79
|
+
editor.first = next;
|
|
80
|
+
next.previous = undefined;
|
|
90
81
|
|
|
91
|
-
editor.trigger(
|
|
82
|
+
editor.trigger("remove-node", virtual);
|
|
92
83
|
} else {
|
|
93
|
-
editor.first = undefined
|
|
94
|
-
editor.trigger(
|
|
84
|
+
editor.first = undefined;
|
|
85
|
+
editor.trigger("empty");
|
|
95
86
|
}
|
|
96
87
|
|
|
97
|
-
|
|
98
88
|
if (editor.first && !editor.first.next) {
|
|
99
|
-
editor.first.destroy()
|
|
89
|
+
editor.first.destroy();
|
|
100
90
|
}
|
|
101
91
|
|
|
102
|
-
editor.trigger(
|
|
103
|
-
|
|
92
|
+
editor.trigger("remove-node", this);
|
|
104
93
|
}
|
|
105
94
|
}
|
|
106
95
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
previous: ChainNode<M, N>
|
|
96
|
+
export class VirtualNode<M, N> {
|
|
97
|
+
type = "virtual" as const;
|
|
98
|
+
shape: N;
|
|
99
|
+
previous: ChainNode<M, N>;
|
|
112
100
|
|
|
113
101
|
get next() {
|
|
114
|
-
return this.previous.next
|
|
102
|
+
return this.previous.next;
|
|
115
103
|
}
|
|
116
104
|
get editor() {
|
|
117
|
-
return this.previous.editor
|
|
105
|
+
return this.previous.editor;
|
|
118
106
|
}
|
|
119
107
|
get position() {
|
|
120
|
-
const { previous, next } = this
|
|
121
|
-
return previous.position.map((e, i) => (e + next.position[i]) / 2)
|
|
108
|
+
const { previous, next } = this;
|
|
109
|
+
return previous.position.map((e, i) => (e + next.position[i]) / 2);
|
|
122
110
|
}
|
|
123
111
|
constructor(n: ChainNode<M, N>) {
|
|
124
|
-
this.previous = n
|
|
125
|
-
this.editor.trigger(
|
|
112
|
+
this.previous = n;
|
|
113
|
+
this.editor.trigger("create-node", this);
|
|
126
114
|
}
|
|
127
115
|
update() {
|
|
128
|
-
this.editor.trigger(
|
|
116
|
+
this.editor.trigger("update-node", this);
|
|
129
117
|
}
|
|
130
118
|
|
|
131
119
|
insert() {
|
|
132
|
-
const { previous, next } = this
|
|
133
|
-
const p = this.position
|
|
134
|
-
this.previous = previous.createNext(p)
|
|
135
|
-
this.previous.virtual = this
|
|
136
|
-
this.previous.next = next
|
|
137
|
-
next.previous = this.previous
|
|
138
|
-
this.update()
|
|
139
|
-
return this.previous
|
|
120
|
+
const { previous, next } = this;
|
|
121
|
+
const p = this.position;
|
|
122
|
+
this.previous = previous.createNext(p);
|
|
123
|
+
this.previous.virtual = this;
|
|
124
|
+
this.previous.next = next;
|
|
125
|
+
next.previous = this.previous;
|
|
126
|
+
this.update();
|
|
127
|
+
return this.previous;
|
|
140
128
|
}
|
|
141
129
|
|
|
142
130
|
destroy() {
|
|
143
|
-
this.previous.virtual = undefined
|
|
144
|
-
this.editor.trigger(
|
|
131
|
+
this.previous.virtual = undefined;
|
|
132
|
+
this.editor.trigger("remove-node", this);
|
|
145
133
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
134
|
}
|
|
149
|
-
|
package/src/utils/static.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OneDimensional } from
|
|
1
|
+
import { OneDimensional } from ".";
|
|
2
2
|
|
|
3
3
|
/** 经度归一化函数 */
|
|
4
|
-
export const LONTOONE = new OneDimensional([-180, 180])
|
|
4
|
+
export const LONTOONE = new OneDimensional([-180, 180]);
|
|
5
5
|
|
|
6
6
|
/** 纬度归一化函数 */
|
|
7
|
-
export const LATTOONE = new OneDimensional([-85.0511287798066, 85.0511287798066])
|
|
7
|
+
export const LATTOONE = new OneDimensional([-85.0511287798066, 85.0511287798066]);
|