@pirireis/webglobeplugins 0.8.11 → 0.8.13
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/bearing-line/plugin.js +28 -25
- package/circle-line-chain/plugin.js +8 -4
- package/package.json +1 -1
- package/rangerings/plugin.js +37 -31
- package/util/geometry/index.js +2 -2
- package/write-text/context-text3.js +2 -0
package/bearing-line/plugin.js
CHANGED
|
@@ -7,7 +7,7 @@ import { mapGetOrThrow } from "../util/check/get";
|
|
|
7
7
|
import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
8
8
|
import { ContextTextWriter3 } from '../write-text/context-text3'
|
|
9
9
|
import { constraintFloat, isBoolean } from '../util/check/typecheck';
|
|
10
|
-
import {
|
|
10
|
+
import { sphereCoord } from '../util/geometry';
|
|
11
11
|
import { createBufferAndReadInfo } from '../util/gl-util/buffer/integrate-buffer';
|
|
12
12
|
|
|
13
13
|
export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
@@ -16,6 +16,23 @@ export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{key, long, lat, endLong, endLat, bearingAngle, radius, rgba:[4numbers], rgbaMode, bigRadius, dashRatio, dashOpacity, circleDashAngle}} BearingLineItem
|
|
21
|
+
* @property {string} key
|
|
22
|
+
* @property {number} long
|
|
23
|
+
* @property {number} lat
|
|
24
|
+
* @property {number} endLong
|
|
25
|
+
* @property {number} endLat
|
|
26
|
+
* @property {number} bearingAngle 0-360
|
|
27
|
+
* @property {number} radius angle ring radius
|
|
28
|
+
* @property {number} altitude in meters effects all parts of the item
|
|
29
|
+
* @property {Array<numbers>} rgba [r,g,b,a] 0-1
|
|
30
|
+
* @property {number} rgbaMode 0 constant, 1 fading, 2 hides angle ring
|
|
31
|
+
* @property {number} bigRadius undefined means it will be calculated from long, lat, endLong, endLat
|
|
32
|
+
* @property {number} dashRatio 0-1
|
|
33
|
+
* @property {number} dashOpacity 0-1
|
|
34
|
+
* @property {number} circleDashAngle 0-360
|
|
35
|
+
*/
|
|
19
36
|
|
|
20
37
|
const textWriterGetOrThrow = mapGetOrThrow("BearingLine textContextInjection id does not exist in map")
|
|
21
38
|
|
|
@@ -110,21 +127,8 @@ export default class BearingLinePlugin {
|
|
|
110
127
|
|
|
111
128
|
|
|
112
129
|
/**
|
|
113
|
-
|
|
114
|
-
* @
|
|
115
|
-
* @property {number} long
|
|
116
|
-
* @property {number} lat
|
|
117
|
-
* @property {number} endLong
|
|
118
|
-
* @property {number} endLat
|
|
119
|
-
* @property {number} bearingAngle 0-360
|
|
120
|
-
* @property {number} radius angle ring radius
|
|
121
|
-
* @property {Array<4numbers>} rgba [r,g,b,a]
|
|
122
|
-
* @property {number} rgbaMode 0 constant, 1 fading, 2 hides angle ring
|
|
123
|
-
* @property {number} bigRadius undefined means it will be calculated from long, lat, endLong, endLat
|
|
124
|
-
* @property {number} dashRatio 0-1
|
|
125
|
-
* @property {number} dashOpacity 0-1
|
|
126
|
-
* @property {number} circleDashAngle 0-360
|
|
127
|
-
* @param {Array<item>} items
|
|
130
|
+
|
|
131
|
+
* @param {Array<BearingLineItem>} items
|
|
128
132
|
* @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
|
|
129
133
|
*/
|
|
130
134
|
insertBulk(items, { textWriterIDs = [] } = {}) {
|
|
@@ -198,7 +202,7 @@ export default class BearingLinePlugin {
|
|
|
198
202
|
|
|
199
203
|
/**
|
|
200
204
|
*
|
|
201
|
-
* @param {
|
|
205
|
+
* @param {Array<BearingLineItem>} items some colums EXCEPT positional ones
|
|
202
206
|
* @param {string} propertyIDs
|
|
203
207
|
* @param {string} textWriterIDs
|
|
204
208
|
* Do NOT send empty data if property ID of this data is entered or NaN is loaded to the buffer, resulting in an unwanted behaviour.
|
|
@@ -261,7 +265,8 @@ export default class BearingLinePlugin {
|
|
|
261
265
|
const long = radian(item.long)
|
|
262
266
|
const endLat = radian(item.endLat)
|
|
263
267
|
const endLong = radian(item.endLong)
|
|
264
|
-
const
|
|
268
|
+
const altitude = (item.altitude ?? 0) / 1000;
|
|
269
|
+
const bigRadius = item.bigRadius ?? globe.Math.GetDist3D(item.long, item.lat, item.endLong, item.endLat);
|
|
265
270
|
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
266
271
|
const { long: bearingLong, lat: bearingLat } = globe.Math.FindPointByPolar(item.long, item.lat, bigRadius, item.bearingAngle)
|
|
267
272
|
const startAngle2d = calculateStartAngle(long, lat, endLong, endLat);
|
|
@@ -285,6 +290,7 @@ export default class BearingLinePlugin {
|
|
|
285
290
|
long: item.long,
|
|
286
291
|
endLat: item.endLat,
|
|
287
292
|
endLong: item.endLong,
|
|
293
|
+
altitude,
|
|
288
294
|
bearingAngle,
|
|
289
295
|
radius,
|
|
290
296
|
bigRadius,
|
|
@@ -322,9 +328,7 @@ export default class BearingLinePlugin {
|
|
|
322
328
|
this.circle3DProgram = Circle3DCache.get(globe);
|
|
323
329
|
const circleFlatEdgeCount = this.circleFlatEdgeCount
|
|
324
330
|
{
|
|
325
|
-
|
|
326
|
-
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137);
|
|
327
|
-
}
|
|
331
|
+
|
|
328
332
|
// createBuffers
|
|
329
333
|
const bufferType = "DYNAMIC_DRAW";
|
|
330
334
|
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
@@ -340,7 +344,7 @@ export default class BearingLinePlugin {
|
|
|
340
344
|
}],
|
|
341
345
|
["centerCoords3d", {
|
|
342
346
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
343
|
-
'adaptor': (item) => sphereCoord(item.long, item.lat,
|
|
347
|
+
'adaptor': (item) => sphereCoord(item.long, item.lat, globe, item.altitude),
|
|
344
348
|
}],
|
|
345
349
|
["targetCoords2d", {
|
|
346
350
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -348,8 +352,7 @@ export default class BearingLinePlugin {
|
|
|
348
352
|
}],
|
|
349
353
|
["targetCoords3d", {
|
|
350
354
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
351
|
-
'adaptor': (item) =>
|
|
352
|
-
globe.api_GetCartesian3DPoint(item.endLong, item.endLat, 0, 0))
|
|
355
|
+
'adaptor': (item) => sphereCoord(item.endLong, item.endLat, globe, item.altitude)
|
|
353
356
|
}],
|
|
354
357
|
["bearingTargetCoords2d", {
|
|
355
358
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -357,7 +360,7 @@ export default class BearingLinePlugin {
|
|
|
357
360
|
}],
|
|
358
361
|
["bearingTargetCoords3d", {
|
|
359
362
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
360
|
-
'adaptor': (item) =>
|
|
363
|
+
'adaptor': (item) => sphereCoord(item.bearingLong, item.bearingLat, globe, item.altitude)
|
|
361
364
|
}],
|
|
362
365
|
["startAngle2d", {
|
|
363
366
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
@@ -37,6 +37,7 @@ import { sphereCoord } from '../util/geometry/index';
|
|
|
37
37
|
* @property {string} key
|
|
38
38
|
* @property {number} long
|
|
39
39
|
* @property {number} lat
|
|
40
|
+
* @property {number} altitude
|
|
40
41
|
* @property {StyleProperties} circleProperties
|
|
41
42
|
*
|
|
42
43
|
* @typedef {Object} Node
|
|
@@ -49,7 +50,9 @@ import { sphereCoord } from '../util/geometry/index';
|
|
|
49
50
|
* @property { number} dashOpacity 0-1
|
|
50
51
|
* @property { number} dashRatio 0-1
|
|
51
52
|
* @property { number } circleDashAngle 0-360
|
|
52
|
-
* @property {
|
|
53
|
+
* @property { number} altitude
|
|
54
|
+
*
|
|
55
|
+
* //property {Array<Node>} nodes
|
|
53
56
|
*/
|
|
54
57
|
|
|
55
58
|
|
|
@@ -276,7 +279,7 @@ export class CircleLineChainPlugin {
|
|
|
276
279
|
}],
|
|
277
280
|
["centerCoords3d", {
|
|
278
281
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
279
|
-
'adaptor': (item) => sphereCoord(item.long, item.lat, globe),
|
|
282
|
+
'adaptor': (item) => sphereCoord(item.long, item.lat, globe, item.altitude),
|
|
280
283
|
}],
|
|
281
284
|
["targetCoords2d", {
|
|
282
285
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -284,7 +287,7 @@ export class CircleLineChainPlugin {
|
|
|
284
287
|
}],
|
|
285
288
|
["targetCoords3d", {
|
|
286
289
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
287
|
-
'adaptor': (item) => sphereCoord(item.targetLong, item.targetLat, globe),
|
|
290
|
+
'adaptor': (item) => sphereCoord(item.targetLong, item.targetLat, globe, item.altitude),
|
|
288
291
|
}],
|
|
289
292
|
["rgba", {
|
|
290
293
|
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
@@ -382,12 +385,13 @@ export class CircleLineChainPlugin {
|
|
|
382
385
|
if (i === array.length - 1) return null;
|
|
383
386
|
|
|
384
387
|
const centerCoords2dflat = centerCoords2dflatDataCreator(globe, v.long, v.lat, array[i + 1].long, array[i + 1].lat, { edgeCount: this._circleFlatEdgeCount });
|
|
385
|
-
|
|
388
|
+
const altitude = (v.altitude ?? chainProperties.altitude ?? 0) / 1000;
|
|
386
389
|
return {
|
|
387
390
|
chainProperties: chainProperties,
|
|
388
391
|
// bigRadius: radiusM(v, i, array),
|
|
389
392
|
targetLong: array[i + 1].long,
|
|
390
393
|
targetLat: array[i + 1].lat,
|
|
394
|
+
altitude: altitude,
|
|
391
395
|
long: v.long,
|
|
392
396
|
lat: v.lat,
|
|
393
397
|
lineProperties: v.lineProperties,
|
package/package.json
CHANGED
package/rangerings/plugin.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re implementation of rangering plugin.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Circlelari cizen programlar
|
|
8
|
-
* Circlelari cizen bufferlarin muhasevesi.
|
|
9
|
-
*
|
|
10
|
-
* 1 derecelikler çok masraflı.
|
|
11
|
-
* bir dereceklikler için ayrı buffer orchastrator oluşturulmalı.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* A Range Ring {
|
|
15
|
-
* rings: [ ring, ]
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
1
|
/**
|
|
21
2
|
* @typedef RangeRingData
|
|
22
3
|
* @property {number} centerX
|
|
@@ -61,11 +42,36 @@ import { normalize } from "../util/geometry"
|
|
|
61
42
|
const CIRCLE_FLAT_EDGE_COUNT = 362; // 360 + 2 for closing the circle and a cutting point
|
|
62
43
|
|
|
63
44
|
|
|
64
|
-
const coordOnSphere = (long, lat, globe) => {
|
|
45
|
+
const coordOnSphere = (long, lat, globe, altitude = 0) => {
|
|
65
46
|
const coord = globe.api_GetCartesian3DPoint(long, lat, 0, 0);
|
|
66
|
-
return normalize(coord, 6378.137);
|
|
47
|
+
return normalize(coord, 6378.137 + altitude);
|
|
67
48
|
}
|
|
68
49
|
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
* @typedef {string} centerID
|
|
55
|
+
*
|
|
56
|
+
* @typedef {Object} RangeRing
|
|
57
|
+
* @property {string} ringID
|
|
58
|
+
* @property {number} radius in range meters
|
|
59
|
+
* @property {number} padding badding range in meter
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* Array < centerID: string, long: number, lat: number, stepAngle: number, rgba: [4 numbers], rings: rings, hide, textHide
|
|
63
|
+
* @typedef {Object} RangeRingsItem
|
|
64
|
+
* @property {centerID} centerID
|
|
65
|
+
* @property {number} long
|
|
66
|
+
* @property {number} lat
|
|
67
|
+
* @property {number} stepAngle
|
|
68
|
+
* @property {number} altitude
|
|
69
|
+
* @property {number} hide
|
|
70
|
+
* @property {number} textHide
|
|
71
|
+
* @property {number} rgba
|
|
72
|
+
* @property {Array<RangeRing>} rings
|
|
73
|
+
*/
|
|
74
|
+
|
|
69
75
|
class RangeRings {
|
|
70
76
|
constructor(id,
|
|
71
77
|
{
|
|
@@ -121,8 +127,7 @@ class RangeRings {
|
|
|
121
127
|
|
|
122
128
|
/**
|
|
123
129
|
* @method insertBulk
|
|
124
|
-
* @
|
|
125
|
-
* @param { Array < centerID: string, long: number, lat: number, stepAngle: number, rgba: [4 numbers], rings: rings, hide, textHide } items
|
|
130
|
+
* @param { Array < RangeRingsItem> } items
|
|
126
131
|
*/
|
|
127
132
|
insertBulk(items, { textWriterIDs = [] } = {}) {
|
|
128
133
|
// Algorithm
|
|
@@ -460,10 +465,10 @@ class RangeRings {
|
|
|
460
465
|
const { globe } = this;
|
|
461
466
|
const centerItem = this._ringAccount.getCenter(centerID);
|
|
462
467
|
if (centerItem === undefined) throw new Error("Center not found");
|
|
463
|
-
const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
|
|
468
|
+
const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0, altitude: centerAltitude = 0 } = centerItem;
|
|
464
469
|
const result = [];
|
|
465
470
|
const color = hide === 1 ? new Float32Array([0, 0, 0, 0]) : new Float32Array(rgba)
|
|
466
|
-
for (const { ringID, radius, padding } of rings) {
|
|
471
|
+
for (const { ringID, radius, padding, altitude = centerAltitude } of rings) {
|
|
467
472
|
let azimuthAngle = 0;
|
|
468
473
|
while (azimuthAngle < 360) {
|
|
469
474
|
const circlePoint = globe.Math.FindPointByPolar(long, lat, radius, azimuthAngle); // long lat
|
|
@@ -472,8 +477,8 @@ class RangeRings {
|
|
|
472
477
|
key: ringBigPaddingKeyMethod(centerID, ringID, azimuthAngle),
|
|
473
478
|
circlePoint2d: new Float32Array(globe.api_GetMercator2DPoint(circlePoint.long, circlePoint.lat)),
|
|
474
479
|
paddingPoint2d: new Float32Array(globe.api_GetMercator2DPoint(paddingPoint.long, paddingPoint.lat)),
|
|
475
|
-
circlePoint3d: coordOnSphere(circlePoint.long, circlePoint.lat, globe),
|
|
476
|
-
paddingPoint3d: coordOnSphere(paddingPoint.long, paddingPoint.lat, globe),
|
|
480
|
+
circlePoint3d: coordOnSphere(circlePoint.long, circlePoint.lat, globe, altitude / 1000),
|
|
481
|
+
paddingPoint3d: coordOnSphere(paddingPoint.long, paddingPoint.lat, globe, altitude / 1000),
|
|
477
482
|
rgba: color,
|
|
478
483
|
hide,
|
|
479
484
|
textHide
|
|
@@ -491,17 +496,18 @@ class RangeRings {
|
|
|
491
496
|
const centerItem = this._ringAccount.getCenter(centerID);
|
|
492
497
|
if (centerItem === undefined) throw new Error("Center not found");
|
|
493
498
|
|
|
494
|
-
const { long, lat, rgba, rings, hide = 0, textHide = 0 } = centerItem;
|
|
495
|
-
const centerCoords3d = coordOnSphere(long, lat, globe);
|
|
499
|
+
const { long, lat, rgba, rings, hide = 0, textHide = 0, altitude: centralAltitude = 0 } = centerItem;
|
|
500
|
+
const centerCoords3d = coordOnSphere(long, lat, globe, centralAltitude / 1000);
|
|
496
501
|
|
|
497
502
|
const result = [];
|
|
498
503
|
|
|
499
|
-
for (const { ringID, radius, padding, __identity__ } of rings) {
|
|
504
|
+
for (const { ringID, radius, padding, __identity__, altitude = centralAltitude } of rings) {
|
|
500
505
|
const key = __identity__;
|
|
506
|
+
|
|
501
507
|
const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
502
508
|
const radiusPadding = hide === ENUM_HIDE.HIDE_1_DEGREE_PADDINGS ? radius : radius - padding / 3;
|
|
503
509
|
const targetPoint = globe.Math.FindPointByPolar(long, lat, radius, 0); // long lat
|
|
504
|
-
const targetCoords3d = coordOnSphere(targetPoint.long, targetPoint.lat, globe);
|
|
510
|
+
const targetCoords3d = coordOnSphere(targetPoint.long, targetPoint.lat, globe, altitude / 1000);
|
|
505
511
|
const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radiusPadding, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
506
512
|
result.push({
|
|
507
513
|
key,
|
package/util/geometry/index.js
CHANGED
|
@@ -45,6 +45,6 @@ export function normalize(array, newLength = 1) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
export function sphereCoord(long, lat, globe) {
|
|
49
|
-
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137);
|
|
48
|
+
export function sphereCoord(long, lat, globe, height = 0) {
|
|
49
|
+
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137 + height);
|
|
50
50
|
}
|
|
@@ -6,6 +6,8 @@ import { isTextFont, opacityCheck } from "../util/check/typecheck";
|
|
|
6
6
|
* 1) update all if initials change (propably need a context and a callback to iterate over zPayload)
|
|
7
7
|
* 2) expose a mechanic to update text on zoom change
|
|
8
8
|
* 3) extend the mechanic on 2 to other events
|
|
9
|
+
*
|
|
10
|
+
* TODO: key check and raise error if doesnt exist
|
|
9
11
|
*/
|
|
10
12
|
export class ContextTextWriter3 {
|
|
11
13
|
constructor(globe, {
|