@openglobus/og 0.13.2 → 0.13.5
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/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/og/control/TouchNavigation.js +340 -319
- package/src/og/entity/Billboard.js +165 -165
- package/src/og/entity/BillboardHandler.js +1 -1
- package/src/og/entity/GeoObject.js +4 -0
- package/src/og/entity/GeoObjectHandler.js +22 -33
- package/src/og/entity/Geometry.js +319 -319
- package/src/og/entity/Label.js +348 -346
- package/src/og/entity/LabelHandler.js +44 -37
- package/src/og/renderer/RendererEvents.js +1051 -1051
- package/src/og/shaders/billboard.js +8 -0
- package/src/og/shaders/label.js +59 -16
- package/src/og/utils/FontAtlas.js +25 -15
- package/src/og/utils/TextureAtlas.js +291 -280
- package/types/entity/GeoObject.d.ts +1 -0
- package/types/entity/Label.d.ts +1 -0
- package/types/entity/LabelHandler.d.ts +1 -1
- package/types/utils/TextureAtlas.d.ts +2 -0
|
@@ -1,319 +1,319 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/entity/Geometry
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import * as utils from "../utils/shared.js";
|
|
8
|
-
import { Extent } from "../Extent.js";
|
|
9
|
-
import { Vec4 } from "../math/Vec4.js";
|
|
10
|
-
import { LonLat } from "../LonLat.js";
|
|
11
|
-
|
|
12
|
-
const GeometryType = {
|
|
13
|
-
POINT: 1,
|
|
14
|
-
LINESTRING: 2,
|
|
15
|
-
POLYGON: 3,
|
|
16
|
-
MULTIPOLYGON: 4,
|
|
17
|
-
MULTILINESTRING: 5
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
class Geometry {
|
|
21
|
-
constructor(options) {
|
|
22
|
-
this._id = Geometry._staticCounter++;
|
|
23
|
-
|
|
24
|
-
options = options || {};
|
|
25
|
-
options.style = options.style || {};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Entity instance that holds this geometry.
|
|
29
|
-
* @protected
|
|
30
|
-
* @type {Entity}
|
|
31
|
-
*/
|
|
32
|
-
this._entity = null;
|
|
33
|
-
|
|
34
|
-
this._handler = null;
|
|
35
|
-
this._handlerIndex = -1;
|
|
36
|
-
|
|
37
|
-
// Polygon
|
|
38
|
-
this._polyVerticesHighMerc = [];
|
|
39
|
-
this._polyVerticesLowMerc = [];
|
|
40
|
-
this._polyVerticesLength = -1;
|
|
41
|
-
this._polyIndexesLength = -1;
|
|
42
|
-
this._polyVerticesHandlerIndex = -1;
|
|
43
|
-
this._polyIndexesHandlerIndex = -1;
|
|
44
|
-
|
|
45
|
-
// Line(Linestring and polygon's stroke(s)
|
|
46
|
-
this._lineVerticesHighMerc = [];
|
|
47
|
-
this._lineVerticesLowMerc = [];
|
|
48
|
-
this._lineVerticesLength = -1;
|
|
49
|
-
this._lineOrdersLength = -1;
|
|
50
|
-
this._lineIndexesLength = -1;
|
|
51
|
-
this._lineColorsLength = -1;
|
|
52
|
-
this._lineThicknessLength = -1;
|
|
53
|
-
this._lineVerticesHandlerIndex = -1;
|
|
54
|
-
this._lineOrdersHandlerIndex = -1;
|
|
55
|
-
this._lineIndexesHandlerIndex = -1;
|
|
56
|
-
this._lineThicknessHandlerIndex = -1;
|
|
57
|
-
this._lineColorsHandlerIndex = -1;
|
|
58
|
-
|
|
59
|
-
this._type = (options.type && Geometry.getType(options.type)) || GeometryType.POINT;
|
|
60
|
-
this._coordinates = [];
|
|
61
|
-
this._extent = Geometry.getExtent(
|
|
62
|
-
{
|
|
63
|
-
type: options.type || "Point",
|
|
64
|
-
coordinates: options.coordinates || []
|
|
65
|
-
},
|
|
66
|
-
this._coordinates
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
this._style = options.style || {};
|
|
70
|
-
this._style.fillColor = utils.createColorRGBA(
|
|
71
|
-
options.style.fillColor,
|
|
72
|
-
new Vec4(0.19, 0.62, 0.85, 0.4)
|
|
73
|
-
);
|
|
74
|
-
this._style.lineColor = utils.createColorRGBA(
|
|
75
|
-
options.style.lineColor,
|
|
76
|
-
new Vec4(0.19, 0.62, 0.85, 1)
|
|
77
|
-
);
|
|
78
|
-
this._style.strokeColor = utils.createColorRGBA(
|
|
79
|
-
options.style.strokeColor,
|
|
80
|
-
new Vec4(1, 1, 1, 0.95)
|
|
81
|
-
);
|
|
82
|
-
this._style.lineWidth = options.style.lineWidth || 3;
|
|
83
|
-
this._style.strokeWidth = options.style.strokeWidth || 0;
|
|
84
|
-
|
|
85
|
-
this._visibility = options.visibility || true;
|
|
86
|
-
|
|
87
|
-
// optimization flag for picking mask rendering pass
|
|
88
|
-
this._pickingReady = false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static get _staticCounter() {
|
|
92
|
-
if (!this._counter && this._counter !== 0) {
|
|
93
|
-
this._counter = 0;
|
|
94
|
-
}
|
|
95
|
-
return this._counter;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static set _staticCounter(n) {
|
|
99
|
-
this._counter = n;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
static getType(typeStr) {
|
|
103
|
-
return GeometryType[typeStr.toUpperCase()];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Returns geometry feature extent.
|
|
108
|
-
@static
|
|
109
|
-
@param {Object} geometryObj - GeoJSON style geometry feature.
|
|
110
|
-
@param {LonLat[]} outCoordinates - Geometry feature coordinates clone.
|
|
111
|
-
@returns {Extent} -
|
|
112
|
-
*/
|
|
113
|
-
static getExtent(geometryObj, outCoordinates) {
|
|
114
|
-
var res = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
|
|
115
|
-
var t = Geometry.getType(geometryObj.type);
|
|
116
|
-
|
|
117
|
-
if (t === GeometryType.POINT) {
|
|
118
|
-
let lon = res.coordinates[0],
|
|
119
|
-
lat = res.coordinates[1];
|
|
120
|
-
res.southWest.lon = lon;
|
|
121
|
-
res.southWest.lat = lat;
|
|
122
|
-
res.northEast.lon = lon;
|
|
123
|
-
res.northEast.lat = lat;
|
|
124
|
-
outCoordinates && (outCoordinates[0] = lon) && (outCoordinates[1] = lat);
|
|
125
|
-
} else if (t === GeometryType.LINESTRING) {
|
|
126
|
-
let c = geometryObj.coordinates;
|
|
127
|
-
for (let i = 0; i < c.length; i++) {
|
|
128
|
-
let lon = c[i][0],
|
|
129
|
-
lat = c[i][1];
|
|
130
|
-
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
131
|
-
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
132
|
-
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
133
|
-
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
134
|
-
outCoordinates && (outCoordinates[i] = [lon, lat]);
|
|
135
|
-
}
|
|
136
|
-
} else if (t === GeometryType.POLYGON) {
|
|
137
|
-
let c = geometryObj.coordinates;
|
|
138
|
-
for (let i = 0; i < c.length; i++) {
|
|
139
|
-
let ci = c[i];
|
|
140
|
-
outCoordinates && (outCoordinates[i] = []);
|
|
141
|
-
for (let j = 0; j < ci.length; j++) {
|
|
142
|
-
let cij = ci[j];
|
|
143
|
-
let lon = cij[0],
|
|
144
|
-
lat = cij[1];
|
|
145
|
-
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
146
|
-
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
147
|
-
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
148
|
-
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
149
|
-
outCoordinates && (outCoordinates[i][j] = [lon, lat]);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
} else if (t === GeometryType.MULTIPOLYGON) {
|
|
153
|
-
let p = geometryObj.coordinates;
|
|
154
|
-
for (let i = 0; i < p.length; i++) {
|
|
155
|
-
let pi = p[i];
|
|
156
|
-
outCoordinates && (outCoordinates[i] = []);
|
|
157
|
-
for (let j = 0; j < pi.length; j++) {
|
|
158
|
-
let pij = pi[j];
|
|
159
|
-
outCoordinates && (outCoordinates[i][j] = []);
|
|
160
|
-
for (let k = 0; k < pij.length; k++) {
|
|
161
|
-
let pijk = pij[k];
|
|
162
|
-
let lon = pijk[0],
|
|
163
|
-
lat = pijk[1];
|
|
164
|
-
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
165
|
-
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
166
|
-
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
167
|
-
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
168
|
-
outCoordinates && (outCoordinates[i][j][k] = [lon, lat]);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
} else if (t === GeometryType.MULTILINESTRING) {
|
|
173
|
-
let c = geometryObj.coordinates;
|
|
174
|
-
for (let i = 0; i < c.length; i++) {
|
|
175
|
-
let ci = c[i];
|
|
176
|
-
outCoordinates && (outCoordinates[i] = []);
|
|
177
|
-
for (let j = 0; j < ci.length; j++) {
|
|
178
|
-
let cij = ci[j];
|
|
179
|
-
let lon = cij[0],
|
|
180
|
-
lat = cij[1];
|
|
181
|
-
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
182
|
-
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
183
|
-
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
184
|
-
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
185
|
-
outCoordinates && (outCoordinates[i][j] = [lon, lat]);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
} else {
|
|
189
|
-
res.southWest.lon = res.southWest.lat = res.northEast.lon = res.northEast.lat = 0.0;
|
|
190
|
-
outCoordinates && (outCoordinates[0] = 0) && (outCoordinates[1] = 0);
|
|
191
|
-
}
|
|
192
|
-
return res;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
setGeometry(geoJson) {
|
|
196
|
-
var h = this._handler;
|
|
197
|
-
this.remove();
|
|
198
|
-
this._type = Geometry.getType(geoJson.type || "Point");
|
|
199
|
-
this._extent = Geometry.getExtent(geoJson, this._coordinates);
|
|
200
|
-
h.add(this);
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
setFillColor(r, g, b, a) {
|
|
205
|
-
var c = this._style.fillColor;
|
|
206
|
-
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
|
|
207
|
-
this._pickingReady = false;
|
|
208
|
-
}
|
|
209
|
-
c.x = r;
|
|
210
|
-
c.y = g;
|
|
211
|
-
c.z = b;
|
|
212
|
-
c.w = a;
|
|
213
|
-
this._handler && this._handler.setPolyColorArr(this, c);
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
setFillColor4v(rgba) {
|
|
218
|
-
return this.setFillColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
setStrokeColor(r, g, b, a) {
|
|
222
|
-
var c = this._style.strokeColor;
|
|
223
|
-
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
|
|
224
|
-
this._pickingReady = false;
|
|
225
|
-
}
|
|
226
|
-
c.x = r;
|
|
227
|
-
c.y = g;
|
|
228
|
-
c.z = b;
|
|
229
|
-
c.w = a;
|
|
230
|
-
this._handler && this._handler.
|
|
231
|
-
return this;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
setLineColor(r, g, b, a) {
|
|
235
|
-
var c = this._style.lineColor;
|
|
236
|
-
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
|
|
237
|
-
this._pickingReady = false;
|
|
238
|
-
}
|
|
239
|
-
c.x = r;
|
|
240
|
-
c.y = g;
|
|
241
|
-
c.z = b;
|
|
242
|
-
c.w = a;
|
|
243
|
-
this._handler && this._handler.setLineColorArr(this, c);
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
setStrokeColor4v(rgba) {
|
|
248
|
-
return this.setStrokeColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
setLineColor4v(rgba) {
|
|
252
|
-
return this.setLineColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
setStrokeOpacity(opacity) {
|
|
256
|
-
var c = this._style.strokeColor;
|
|
257
|
-
c.w = opacity;
|
|
258
|
-
return this.setStrokeColor(c.x, c.y, c.z, opacity);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
setLineOpacity(opacity) {
|
|
262
|
-
var c = this._style.lineColor;
|
|
263
|
-
c.w = opacity;
|
|
264
|
-
return this.setLineColor(c.x, c.y, c.z, opacity);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
setStrokeWidth(width) {
|
|
268
|
-
this._style.strokeWidth = width;
|
|
269
|
-
this._pickingReady = false;
|
|
270
|
-
this._handler && this._handler.setLineStrokeArr(this, width);
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
bringToFront() {
|
|
275
|
-
this._handler && this._handler.bringToFront(this);
|
|
276
|
-
return this;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
setLineWidth(width) {
|
|
280
|
-
this._style.lineWidth = width;
|
|
281
|
-
this._pickingReady = false;
|
|
282
|
-
this._handler && this._handler.setLineThicknessArr(this, width);
|
|
283
|
-
return this;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
setFillOpacity(opacity) {
|
|
287
|
-
var c = this._style.fillColor;
|
|
288
|
-
if ((c.w === 0.0 && opacity !== 0.0) || (c.w !== 0.0 && opacity === 0.0)) {
|
|
289
|
-
this._pickingReady = false;
|
|
290
|
-
}
|
|
291
|
-
c.w = opacity;
|
|
292
|
-
this._handler && this._handler.setPolyColorArr(this, c);
|
|
293
|
-
return this;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
setVisibility(visibility) {
|
|
297
|
-
this._visibility = visibility;
|
|
298
|
-
this._handler && this._handler.setGeometryVisibility(this);
|
|
299
|
-
return this;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
getVisibility() {
|
|
303
|
-
return this._visibility;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
remove() {
|
|
307
|
-
this._handler && this._handler.remove(this);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
getExtent() {
|
|
311
|
-
return this._extent.clone();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
getType() {
|
|
315
|
-
return this._type;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export { Geometry, GeometryType };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/entity/Geometry
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as utils from "../utils/shared.js";
|
|
8
|
+
import { Extent } from "../Extent.js";
|
|
9
|
+
import { Vec4 } from "../math/Vec4.js";
|
|
10
|
+
import { LonLat } from "../LonLat.js";
|
|
11
|
+
|
|
12
|
+
const GeometryType = {
|
|
13
|
+
POINT: 1,
|
|
14
|
+
LINESTRING: 2,
|
|
15
|
+
POLYGON: 3,
|
|
16
|
+
MULTIPOLYGON: 4,
|
|
17
|
+
MULTILINESTRING: 5
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
class Geometry {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this._id = Geometry._staticCounter++;
|
|
23
|
+
|
|
24
|
+
options = options || {};
|
|
25
|
+
options.style = options.style || {};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Entity instance that holds this geometry.
|
|
29
|
+
* @protected
|
|
30
|
+
* @type {Entity}
|
|
31
|
+
*/
|
|
32
|
+
this._entity = null;
|
|
33
|
+
|
|
34
|
+
this._handler = null;
|
|
35
|
+
this._handlerIndex = -1;
|
|
36
|
+
|
|
37
|
+
// Polygon
|
|
38
|
+
this._polyVerticesHighMerc = [];
|
|
39
|
+
this._polyVerticesLowMerc = [];
|
|
40
|
+
this._polyVerticesLength = -1;
|
|
41
|
+
this._polyIndexesLength = -1;
|
|
42
|
+
this._polyVerticesHandlerIndex = -1;
|
|
43
|
+
this._polyIndexesHandlerIndex = -1;
|
|
44
|
+
|
|
45
|
+
// Line(Linestring and polygon's stroke(s)
|
|
46
|
+
this._lineVerticesHighMerc = [];
|
|
47
|
+
this._lineVerticesLowMerc = [];
|
|
48
|
+
this._lineVerticesLength = -1;
|
|
49
|
+
this._lineOrdersLength = -1;
|
|
50
|
+
this._lineIndexesLength = -1;
|
|
51
|
+
this._lineColorsLength = -1;
|
|
52
|
+
this._lineThicknessLength = -1;
|
|
53
|
+
this._lineVerticesHandlerIndex = -1;
|
|
54
|
+
this._lineOrdersHandlerIndex = -1;
|
|
55
|
+
this._lineIndexesHandlerIndex = -1;
|
|
56
|
+
this._lineThicknessHandlerIndex = -1;
|
|
57
|
+
this._lineColorsHandlerIndex = -1;
|
|
58
|
+
|
|
59
|
+
this._type = (options.type && Geometry.getType(options.type)) || GeometryType.POINT;
|
|
60
|
+
this._coordinates = [];
|
|
61
|
+
this._extent = Geometry.getExtent(
|
|
62
|
+
{
|
|
63
|
+
type: options.type || "Point",
|
|
64
|
+
coordinates: options.coordinates || []
|
|
65
|
+
},
|
|
66
|
+
this._coordinates
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
this._style = options.style || {};
|
|
70
|
+
this._style.fillColor = utils.createColorRGBA(
|
|
71
|
+
options.style.fillColor,
|
|
72
|
+
new Vec4(0.19, 0.62, 0.85, 0.4)
|
|
73
|
+
);
|
|
74
|
+
this._style.lineColor = utils.createColorRGBA(
|
|
75
|
+
options.style.lineColor,
|
|
76
|
+
new Vec4(0.19, 0.62, 0.85, 1)
|
|
77
|
+
);
|
|
78
|
+
this._style.strokeColor = utils.createColorRGBA(
|
|
79
|
+
options.style.strokeColor,
|
|
80
|
+
new Vec4(1, 1, 1, 0.95)
|
|
81
|
+
);
|
|
82
|
+
this._style.lineWidth = options.style.lineWidth || 3;
|
|
83
|
+
this._style.strokeWidth = options.style.strokeWidth || 0;
|
|
84
|
+
|
|
85
|
+
this._visibility = options.visibility || true;
|
|
86
|
+
|
|
87
|
+
// optimization flag for picking mask rendering pass
|
|
88
|
+
this._pickingReady = false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static get _staticCounter() {
|
|
92
|
+
if (!this._counter && this._counter !== 0) {
|
|
93
|
+
this._counter = 0;
|
|
94
|
+
}
|
|
95
|
+
return this._counter;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static set _staticCounter(n) {
|
|
99
|
+
this._counter = n;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static getType(typeStr) {
|
|
103
|
+
return GeometryType[typeStr.toUpperCase()];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns geometry feature extent.
|
|
108
|
+
@static
|
|
109
|
+
@param {Object} geometryObj - GeoJSON style geometry feature.
|
|
110
|
+
@param {LonLat[]} outCoordinates - Geometry feature coordinates clone.
|
|
111
|
+
@returns {Extent} -
|
|
112
|
+
*/
|
|
113
|
+
static getExtent(geometryObj, outCoordinates) {
|
|
114
|
+
var res = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
|
|
115
|
+
var t = Geometry.getType(geometryObj.type);
|
|
116
|
+
|
|
117
|
+
if (t === GeometryType.POINT) {
|
|
118
|
+
let lon = res.coordinates[0],
|
|
119
|
+
lat = res.coordinates[1];
|
|
120
|
+
res.southWest.lon = lon;
|
|
121
|
+
res.southWest.lat = lat;
|
|
122
|
+
res.northEast.lon = lon;
|
|
123
|
+
res.northEast.lat = lat;
|
|
124
|
+
outCoordinates && (outCoordinates[0] = lon) && (outCoordinates[1] = lat);
|
|
125
|
+
} else if (t === GeometryType.LINESTRING) {
|
|
126
|
+
let c = geometryObj.coordinates;
|
|
127
|
+
for (let i = 0; i < c.length; i++) {
|
|
128
|
+
let lon = c[i][0],
|
|
129
|
+
lat = c[i][1];
|
|
130
|
+
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
131
|
+
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
132
|
+
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
133
|
+
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
134
|
+
outCoordinates && (outCoordinates[i] = [lon, lat]);
|
|
135
|
+
}
|
|
136
|
+
} else if (t === GeometryType.POLYGON) {
|
|
137
|
+
let c = geometryObj.coordinates;
|
|
138
|
+
for (let i = 0; i < c.length; i++) {
|
|
139
|
+
let ci = c[i];
|
|
140
|
+
outCoordinates && (outCoordinates[i] = []);
|
|
141
|
+
for (let j = 0; j < ci.length; j++) {
|
|
142
|
+
let cij = ci[j];
|
|
143
|
+
let lon = cij[0],
|
|
144
|
+
lat = cij[1];
|
|
145
|
+
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
146
|
+
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
147
|
+
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
148
|
+
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
149
|
+
outCoordinates && (outCoordinates[i][j] = [lon, lat]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} else if (t === GeometryType.MULTIPOLYGON) {
|
|
153
|
+
let p = geometryObj.coordinates;
|
|
154
|
+
for (let i = 0; i < p.length; i++) {
|
|
155
|
+
let pi = p[i];
|
|
156
|
+
outCoordinates && (outCoordinates[i] = []);
|
|
157
|
+
for (let j = 0; j < pi.length; j++) {
|
|
158
|
+
let pij = pi[j];
|
|
159
|
+
outCoordinates && (outCoordinates[i][j] = []);
|
|
160
|
+
for (let k = 0; k < pij.length; k++) {
|
|
161
|
+
let pijk = pij[k];
|
|
162
|
+
let lon = pijk[0],
|
|
163
|
+
lat = pijk[1];
|
|
164
|
+
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
165
|
+
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
166
|
+
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
167
|
+
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
168
|
+
outCoordinates && (outCoordinates[i][j][k] = [lon, lat]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} else if (t === GeometryType.MULTILINESTRING) {
|
|
173
|
+
let c = geometryObj.coordinates;
|
|
174
|
+
for (let i = 0; i < c.length; i++) {
|
|
175
|
+
let ci = c[i];
|
|
176
|
+
outCoordinates && (outCoordinates[i] = []);
|
|
177
|
+
for (let j = 0; j < ci.length; j++) {
|
|
178
|
+
let cij = ci[j];
|
|
179
|
+
let lon = cij[0],
|
|
180
|
+
lat = cij[1];
|
|
181
|
+
if (lon < res.southWest.lon) res.southWest.lon = lon;
|
|
182
|
+
if (lat < res.southWest.lat) res.southWest.lat = lat;
|
|
183
|
+
if (lon > res.northEast.lon) res.northEast.lon = lon;
|
|
184
|
+
if (lat > res.northEast.lat) res.northEast.lat = lat;
|
|
185
|
+
outCoordinates && (outCoordinates[i][j] = [lon, lat]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
res.southWest.lon = res.southWest.lat = res.northEast.lon = res.northEast.lat = 0.0;
|
|
190
|
+
outCoordinates && (outCoordinates[0] = 0) && (outCoordinates[1] = 0);
|
|
191
|
+
}
|
|
192
|
+
return res;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
setGeometry(geoJson) {
|
|
196
|
+
var h = this._handler;
|
|
197
|
+
this.remove();
|
|
198
|
+
this._type = Geometry.getType(geoJson.type || "Point");
|
|
199
|
+
this._extent = Geometry.getExtent(geoJson, this._coordinates);
|
|
200
|
+
h.add(this);
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
setFillColor(r, g, b, a) {
|
|
205
|
+
var c = this._style.fillColor;
|
|
206
|
+
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
|
|
207
|
+
this._pickingReady = false;
|
|
208
|
+
}
|
|
209
|
+
c.x = r;
|
|
210
|
+
c.y = g;
|
|
211
|
+
c.z = b;
|
|
212
|
+
c.w = a;
|
|
213
|
+
this._handler && this._handler.setPolyColorArr(this, c);
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
setFillColor4v(rgba) {
|
|
218
|
+
return this.setFillColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
setStrokeColor(r, g, b, a) {
|
|
222
|
+
var c = this._style.strokeColor;
|
|
223
|
+
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
|
|
224
|
+
this._pickingReady = false;
|
|
225
|
+
}
|
|
226
|
+
c.x = r;
|
|
227
|
+
c.y = g;
|
|
228
|
+
c.z = b;
|
|
229
|
+
c.w = a;
|
|
230
|
+
this._handler && this._handler.setLineStrokeColorArr(this, c);
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
setLineColor(r, g, b, a) {
|
|
235
|
+
var c = this._style.lineColor;
|
|
236
|
+
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
|
|
237
|
+
this._pickingReady = false;
|
|
238
|
+
}
|
|
239
|
+
c.x = r;
|
|
240
|
+
c.y = g;
|
|
241
|
+
c.z = b;
|
|
242
|
+
c.w = a;
|
|
243
|
+
this._handler && this._handler.setLineColorArr(this, c);
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
setStrokeColor4v(rgba) {
|
|
248
|
+
return this.setStrokeColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
setLineColor4v(rgba) {
|
|
252
|
+
return this.setLineColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
setStrokeOpacity(opacity) {
|
|
256
|
+
var c = this._style.strokeColor;
|
|
257
|
+
c.w = opacity;
|
|
258
|
+
return this.setStrokeColor(c.x, c.y, c.z, opacity);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
setLineOpacity(opacity) {
|
|
262
|
+
var c = this._style.lineColor;
|
|
263
|
+
c.w = opacity;
|
|
264
|
+
return this.setLineColor(c.x, c.y, c.z, opacity);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
setStrokeWidth(width) {
|
|
268
|
+
this._style.strokeWidth = width;
|
|
269
|
+
this._pickingReady = false;
|
|
270
|
+
this._handler && this._handler.setLineStrokeArr(this, width);
|
|
271
|
+
return this;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
bringToFront() {
|
|
275
|
+
this._handler && this._handler.bringToFront(this);
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
setLineWidth(width) {
|
|
280
|
+
this._style.lineWidth = width;
|
|
281
|
+
this._pickingReady = false;
|
|
282
|
+
this._handler && this._handler.setLineThicknessArr(this, width);
|
|
283
|
+
return this;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
setFillOpacity(opacity) {
|
|
287
|
+
var c = this._style.fillColor;
|
|
288
|
+
if ((c.w === 0.0 && opacity !== 0.0) || (c.w !== 0.0 && opacity === 0.0)) {
|
|
289
|
+
this._pickingReady = false;
|
|
290
|
+
}
|
|
291
|
+
c.w = opacity;
|
|
292
|
+
this._handler && this._handler.setPolyColorArr(this, c);
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
setVisibility(visibility) {
|
|
297
|
+
this._visibility = visibility;
|
|
298
|
+
this._handler && this._handler.setGeometryVisibility(this);
|
|
299
|
+
return this;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
getVisibility() {
|
|
303
|
+
return this._visibility;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
remove() {
|
|
307
|
+
this._handler && this._handler.remove(this);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
getExtent() {
|
|
311
|
+
return this._extent.clone();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
getType() {
|
|
315
|
+
return this._type;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export { Geometry, GeometryType };
|