@pirireis/webglobeplugins 0.6.8 → 0.6.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.
- package/bearing-line/plugin.js +7 -14
- package/circle-line-chain/plugin.js +5 -13
- package/package.json +1 -1
- package/util/check/get.js +12 -0
- package/util/check/typecheck.js +17 -4
- package/write-text/util.js +0 -8
package/bearing-line/plugin.js
CHANGED
|
@@ -3,6 +3,7 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
|
|
|
3
3
|
import { CircleCache } from '../programs/line-on-globe/circle';
|
|
4
4
|
import { BufferOrchestrator, BufferManager } from '../util/account';
|
|
5
5
|
import { AngledLineProgramCache } from '../programs/line-on-globe/angled-line';
|
|
6
|
+
import { mapGetOrThrow } from "../util/check/get";
|
|
6
7
|
import { ContextTextWriter } from '../write-text/context-text'
|
|
7
8
|
export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
8
9
|
LINE_STRIP: "LINE_STRIP",
|
|
@@ -235,7 +236,7 @@ export default class Plugin {
|
|
|
235
236
|
*/
|
|
236
237
|
insertBulk(items, textWriterInjectionSubSetIDs = []) {
|
|
237
238
|
const { globe, bufferOrchestrator, bufferManagersCompMap } = this;// angleTextContext, distanceTextContext,
|
|
238
|
-
const textWriterInjectionSubSets = this.
|
|
239
|
+
const textWriterInjectionSubSets = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);
|
|
239
240
|
const data = []
|
|
240
241
|
for (let item of items) {
|
|
241
242
|
this._insertTexts(item, textWriterInjectionSubSets);
|
|
@@ -269,7 +270,7 @@ export default class Plugin {
|
|
|
269
270
|
* @param {Array<string>} textWriterInjectionSubSetIDs | textContextInjectionMap keys to be used for writing text.
|
|
270
271
|
*/
|
|
271
272
|
updateCoordinatesBulk(items, textWriterInjectionSubSetIDs = []) { //TODO
|
|
272
|
-
const injectionsSubSet = this.
|
|
273
|
+
const injectionsSubSet = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);;
|
|
273
274
|
const { globe, bufferOrchestrator, bufferManagersCompMap, } = this;
|
|
274
275
|
const data = []
|
|
275
276
|
for (let item of items) {
|
|
@@ -292,7 +293,7 @@ export default class Plugin {
|
|
|
292
293
|
updatePartial(items, propertyIDs = [], textWriterInjectionSubSetIDs = []) { // textWriterInjectionSubSetIDs = []
|
|
293
294
|
if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
|
|
294
295
|
const { _textContextInjectionMap, bufferOrchestrator, bufferManagersCompMap } = this;
|
|
295
|
-
const writers = this.
|
|
296
|
+
const writers = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs); // TODO:filter out rgba? this might be a bug
|
|
296
297
|
for (let item of items) { this._insertTexts(item, writers) }
|
|
297
298
|
bufferOrchestrator.updateBulk(items, bufferManagersCompMap, propertyIDs);
|
|
298
299
|
// patch to update text opacity
|
|
@@ -406,17 +407,7 @@ export default class Plugin {
|
|
|
406
407
|
});
|
|
407
408
|
}
|
|
408
409
|
|
|
409
|
-
|
|
410
|
-
_getTextWriterInjectionSubSet(textWriterIds) {
|
|
411
|
-
const { _textContextInjectionMap } = this;
|
|
412
|
-
const result = [];
|
|
413
|
-
for (const id of textWriterIds) {
|
|
414
|
-
const writerAndAdaptors = _textContextInjectionMap.get(id);
|
|
415
|
-
if (writerAndAdaptors === undefined) throw new Error("textContextInjection id does not exist in map:" + id);
|
|
416
|
-
result.push(writerAndAdaptors)
|
|
417
|
-
}
|
|
418
|
-
return result;
|
|
419
|
-
}
|
|
410
|
+
|
|
420
411
|
}
|
|
421
412
|
|
|
422
413
|
|
|
@@ -427,6 +418,8 @@ const integralSec = (angle) => {
|
|
|
427
418
|
return Math.log(Math.tan(angle / 2 + Math.PI / 4));
|
|
428
419
|
}
|
|
429
420
|
|
|
421
|
+
const textWriterGetOrThrow = mapGetOrThrow("textContextInjection id does not exist in map:")
|
|
422
|
+
|
|
430
423
|
const calculateStartAngle = (long, lat, endLong, endLat) => {
|
|
431
424
|
const dLat = (integralSec(endLat) - integralSec(lat)); // Because lines are strectes toward poles.
|
|
432
425
|
const dLong = endLong - long;
|
|
@@ -2,6 +2,7 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
|
|
|
2
2
|
import { CircleCache } from '../programs/line-on-globe/circle';
|
|
3
3
|
import { BufferOrchestrator, BufferManager } from "../util/account";
|
|
4
4
|
import { ChainListMap } from "./chain-list-map";
|
|
5
|
+
import { mapGetOrThrow } from "../util/check/get";
|
|
5
6
|
import { keyMethod } from "./util";
|
|
6
7
|
import { ContextTextWriter3 } from '../write-text/context-text3';
|
|
7
8
|
// TODO: Add update buffer and update text mehods on add, delete, update methods
|
|
@@ -316,23 +317,12 @@ export class CircleLineChainPlugin {
|
|
|
316
317
|
|
|
317
318
|
_updateTexts(chainKeys, textWriterIDs) {
|
|
318
319
|
if (textWriterIDs.length === 0) return;
|
|
319
|
-
const textWriters = this.
|
|
320
|
+
const textWriters = textWriterGetOrThrow(this._textContextWriterInjectionMap, textWriterIDs)
|
|
320
321
|
chainKeys.forEach((chainKey) => {
|
|
321
322
|
this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
|
|
322
323
|
})
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
_getTextWriterInjectionSubSet(textWriterIds) {
|
|
326
|
-
const { _textContextWriterInjectionMap } = this;
|
|
327
|
-
const result = [];
|
|
328
|
-
for (const id of textWriterIds) {
|
|
329
|
-
const w = _textContextWriterInjectionMap.get(id);
|
|
330
|
-
if (w === undefined) throw new Error("textContextInjection id does not exist in map:" + id);
|
|
331
|
-
result.push(w)
|
|
332
|
-
}
|
|
333
|
-
return result;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
326
|
|
|
337
327
|
_reconstructChains(chainKeys) {
|
|
338
328
|
const { globe } = this;
|
|
@@ -400,4 +390,6 @@ export class CircleLineChainPlugin {
|
|
|
400
390
|
|
|
401
391
|
const radiusMethod = (globe) => (v, i, array) => {
|
|
402
392
|
return globe.Math.GetDist3D(v.long, v.lat, array[i + 1].long, array[i + 1].lat)
|
|
403
|
-
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const textWriterGetOrThrow = mapGetOrThrow("textWriterIds is invalid")
|
package/package.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
export const mapGetOrThrow = (errorNote) => {
|
|
3
|
+
return (mapInstance, ids) => {
|
|
4
|
+
const result = [];
|
|
5
|
+
for (let i = 0; i < ids.length; i++) {
|
|
6
|
+
const e = mapInstance.get(ids[i]);
|
|
7
|
+
if (e === undefined) throw new Error(errorNote + ":" + ids[i]);
|
|
8
|
+
result.push(e);
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/util/check/typecheck.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
// Generic
|
|
1
2
|
|
|
3
|
+
export const doesOwnProperties = (properties, errorMessage) => (object) => {
|
|
4
|
+
properties.array.forEach(element => {
|
|
5
|
+
if (!Object.hasOwn(object, element)) throw new TypeError(errorMessage + ':' + element);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
export const isHexColor = (hexColor) => /^#[0-9A-F]{6}$/i.test(hexColor);
|
|
4
10
|
export const isHexColorWithOpacity = (hexColor) => /^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(hexColor);
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
// Text Related
|
|
14
|
+
|
|
15
|
+
const fontCheckTypes = doesOwnProperties(["name", "textColor", "hollowColor", "size", "bold", "italic"], "font does not have");
|
|
16
|
+
const fontCheckColors = (textColor, hollowColor) => isHexColor(textColor) && isHexColor(hollowColor);
|
|
17
|
+
export const isTextFont = (textFont) => {
|
|
18
|
+
fontCheckTypes(textFont);
|
|
19
|
+
fontCheckColors(textFont.textColor, textFont.hollowColor);
|
|
20
|
+
if (!(textFont.size instanceof Number)) throw new TypeError("textFont size is not a number");
|
|
21
|
+
|
|
10
22
|
}
|
|
23
|
+
|
package/write-text/util.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { doesOwnProperties, isHexColor } from "../util/check/typecheck";
|
|
2
2
|
|
|
3
|
-
const fontCheckTypes = doesOwnProperties(["name", "textColor", "hollowColor", "size", "bold", "italic"], "font does not have");
|
|
4
|
-
const fontCheckColors = (textColor, hollowColor) => isHexColor(textColor) && isHexColor(hollowColor);
|
|
5
3
|
|
|
6
|
-
export const isTextFont = (textFont) => {
|
|
7
|
-
fontCheckTypes(textFont);
|
|
8
|
-
fontCheckColors(textFont.textColor, textFont.hollowColor);
|
|
9
|
-
if (!(textFont.size instanceof Number)) throw new TypeError("textFont size is not a number");
|
|
10
|
-
|
|
11
|
-
}
|
|
12
4
|
|