@pirireis/webglobeplugins 0.8.11 → 0.8.12
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
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({
|
|
@@ -261,7 +261,8 @@ export default class BearingLinePlugin {
|
|
|
261
261
|
const long = radian(item.long)
|
|
262
262
|
const endLat = radian(item.endLat)
|
|
263
263
|
const endLong = radian(item.endLong)
|
|
264
|
-
const
|
|
264
|
+
const altitude = (item.altitude ?? 0) / 1000;
|
|
265
|
+
const bigRadius = item.bigRadius ?? globe.Math.GetDist3D(item.long, item.lat, item.endLong, item.endLat);
|
|
265
266
|
const radius = item.radius !== undefined ? item.radius : bigRadius * 0.2;
|
|
266
267
|
const { long: bearingLong, lat: bearingLat } = globe.Math.FindPointByPolar(item.long, item.lat, bigRadius, item.bearingAngle)
|
|
267
268
|
const startAngle2d = calculateStartAngle(long, lat, endLong, endLat);
|
|
@@ -285,6 +286,7 @@ export default class BearingLinePlugin {
|
|
|
285
286
|
long: item.long,
|
|
286
287
|
endLat: item.endLat,
|
|
287
288
|
endLong: item.endLong,
|
|
289
|
+
altitude,
|
|
288
290
|
bearingAngle,
|
|
289
291
|
radius,
|
|
290
292
|
bigRadius,
|
|
@@ -322,9 +324,7 @@ export default class BearingLinePlugin {
|
|
|
322
324
|
this.circle3DProgram = Circle3DCache.get(globe);
|
|
323
325
|
const circleFlatEdgeCount = this.circleFlatEdgeCount
|
|
324
326
|
{
|
|
325
|
-
|
|
326
|
-
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137);
|
|
327
|
-
}
|
|
327
|
+
|
|
328
328
|
// createBuffers
|
|
329
329
|
const bufferType = "DYNAMIC_DRAW";
|
|
330
330
|
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
@@ -340,7 +340,7 @@ export default class BearingLinePlugin {
|
|
|
340
340
|
}],
|
|
341
341
|
["centerCoords3d", {
|
|
342
342
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
343
|
-
'adaptor': (item) => sphereCoord(item.long, item.lat,
|
|
343
|
+
'adaptor': (item) => sphereCoord(item.long, item.lat, globe, item.altitude),
|
|
344
344
|
}],
|
|
345
345
|
["targetCoords2d", {
|
|
346
346
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -348,8 +348,7 @@ export default class BearingLinePlugin {
|
|
|
348
348
|
}],
|
|
349
349
|
["targetCoords3d", {
|
|
350
350
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
351
|
-
'adaptor': (item) =>
|
|
352
|
-
globe.api_GetCartesian3DPoint(item.endLong, item.endLat, 0, 0))
|
|
351
|
+
'adaptor': (item) => sphereCoord(item.endLong, item.endLat, globe, item.altitude)
|
|
353
352
|
}],
|
|
354
353
|
["bearingTargetCoords2d", {
|
|
355
354
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -357,7 +356,7 @@ export default class BearingLinePlugin {
|
|
|
357
356
|
}],
|
|
358
357
|
["bearingTargetCoords3d", {
|
|
359
358
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
360
|
-
'adaptor': (item) =>
|
|
359
|
+
'adaptor': (item) => sphereCoord(item.bearingLong, item.bearingLat, globe, item.altitude)
|
|
361
360
|
}],
|
|
362
361
|
["startAngle2d", {
|
|
363
362
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
@@ -276,7 +276,7 @@ export class CircleLineChainPlugin {
|
|
|
276
276
|
}],
|
|
277
277
|
["centerCoords3d", {
|
|
278
278
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
279
|
-
'adaptor': (item) => sphereCoord(item.long, item.lat, globe),
|
|
279
|
+
'adaptor': (item) => sphereCoord(item.long, item.lat, globe, item.altitude),
|
|
280
280
|
}],
|
|
281
281
|
["targetCoords2d", {
|
|
282
282
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -284,7 +284,7 @@ export class CircleLineChainPlugin {
|
|
|
284
284
|
}],
|
|
285
285
|
["targetCoords3d", {
|
|
286
286
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
287
|
-
'adaptor': (item) => sphereCoord(item.targetLong, item.targetLat, globe),
|
|
287
|
+
'adaptor': (item) => sphereCoord(item.targetLong, item.targetLat, globe, item.altitude),
|
|
288
288
|
}],
|
|
289
289
|
["rgba", {
|
|
290
290
|
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
@@ -382,12 +382,13 @@ export class CircleLineChainPlugin {
|
|
|
382
382
|
if (i === array.length - 1) return null;
|
|
383
383
|
|
|
384
384
|
const centerCoords2dflat = centerCoords2dflatDataCreator(globe, v.long, v.lat, array[i + 1].long, array[i + 1].lat, { edgeCount: this._circleFlatEdgeCount });
|
|
385
|
-
|
|
385
|
+
const altitude = (v.altitude ?? chainProperties.altitude ?? 0) / 1000;
|
|
386
386
|
return {
|
|
387
387
|
chainProperties: chainProperties,
|
|
388
388
|
// bigRadius: radiusM(v, i, array),
|
|
389
389
|
targetLong: array[i + 1].long,
|
|
390
390
|
targetLat: array[i + 1].lat,
|
|
391
|
+
altitude: altitude,
|
|
391
392
|
long: v.long,
|
|
392
393
|
lat: v.lat,
|
|
393
394
|
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,9 +42,9 @@ 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
|
|
|
69
50
|
class RangeRings {
|
|
@@ -460,10 +441,10 @@ class RangeRings {
|
|
|
460
441
|
const { globe } = this;
|
|
461
442
|
const centerItem = this._ringAccount.getCenter(centerID);
|
|
462
443
|
if (centerItem === undefined) throw new Error("Center not found");
|
|
463
|
-
const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
|
|
444
|
+
const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0, altitude: centerAltitude = 0 } = centerItem;
|
|
464
445
|
const result = [];
|
|
465
446
|
const color = hide === 1 ? new Float32Array([0, 0, 0, 0]) : new Float32Array(rgba)
|
|
466
|
-
for (const { ringID, radius, padding } of rings) {
|
|
447
|
+
for (const { ringID, radius, padding, altitude = centerAltitude } of rings) {
|
|
467
448
|
let azimuthAngle = 0;
|
|
468
449
|
while (azimuthAngle < 360) {
|
|
469
450
|
const circlePoint = globe.Math.FindPointByPolar(long, lat, radius, azimuthAngle); // long lat
|
|
@@ -472,8 +453,8 @@ class RangeRings {
|
|
|
472
453
|
key: ringBigPaddingKeyMethod(centerID, ringID, azimuthAngle),
|
|
473
454
|
circlePoint2d: new Float32Array(globe.api_GetMercator2DPoint(circlePoint.long, circlePoint.lat)),
|
|
474
455
|
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),
|
|
456
|
+
circlePoint3d: coordOnSphere(circlePoint.long, circlePoint.lat, globe, altitude / 1000),
|
|
457
|
+
paddingPoint3d: coordOnSphere(paddingPoint.long, paddingPoint.lat, globe, altitude / 1000),
|
|
477
458
|
rgba: color,
|
|
478
459
|
hide,
|
|
479
460
|
textHide
|
|
@@ -491,17 +472,18 @@ class RangeRings {
|
|
|
491
472
|
const centerItem = this._ringAccount.getCenter(centerID);
|
|
492
473
|
if (centerItem === undefined) throw new Error("Center not found");
|
|
493
474
|
|
|
494
|
-
const { long, lat, rgba, rings, hide = 0, textHide = 0 } = centerItem;
|
|
495
|
-
const centerCoords3d = coordOnSphere(long, lat, globe);
|
|
475
|
+
const { long, lat, rgba, rings, hide = 0, textHide = 0, altitude: centralAltitude = 0 } = centerItem;
|
|
476
|
+
const centerCoords3d = coordOnSphere(long, lat, globe, centralAltitude / 1000);
|
|
496
477
|
|
|
497
478
|
const result = [];
|
|
498
479
|
|
|
499
|
-
for (const { ringID, radius, padding, __identity__ } of rings) {
|
|
480
|
+
for (const { ringID, radius, padding, __identity__, altitude = centralAltitude } of rings) {
|
|
500
481
|
const key = __identity__;
|
|
482
|
+
|
|
501
483
|
const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
502
484
|
const radiusPadding = hide === ENUM_HIDE.HIDE_1_DEGREE_PADDINGS ? radius : radius - padding / 3;
|
|
503
485
|
const targetPoint = globe.Math.FindPointByPolar(long, lat, radius, 0); // long lat
|
|
504
|
-
const targetCoords3d = coordOnSphere(targetPoint.long, targetPoint.lat, globe);
|
|
486
|
+
const targetCoords3d = coordOnSphere(targetPoint.long, targetPoint.lat, globe, altitude / 1000);
|
|
505
487
|
const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radiusPadding, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
506
488
|
result.push({
|
|
507
489
|
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, {
|