@pirireis/webglobeplugins 0.15.32 → 0.15.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.15.32",
3
+ "version": "0.15.34",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -21,6 +21,7 @@ export class ChainListMap {
21
21
  * @param chainKey
22
22
  * @param theNodeKeyFront
23
23
  */
24
+ // TODO: Change name to insertNode
24
25
  addNode(node, chainKey, theNodeKeyFront = null) {
25
26
  const chain = this.getNodes(chainKey);
26
27
  if (!chain)
@@ -52,7 +52,7 @@ export class RangeRingPlugin {
52
52
  adativePaddingSize: true,
53
53
  },
54
54
  };
55
- constructor(id, { textDataPreAdaptor = (center) => center, textWritersMap = new Map(), }) {
55
+ constructor(id, { textWritersMap = new Map(), }) {
56
56
  this.id = id;
57
57
  this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle", {
58
58
  variativeColorsOn: true,
@@ -81,6 +81,12 @@ export class RangeRingPlugin {
81
81
  console.warn("Globe or WebGL context is not initialized, cannot insert items");
82
82
  return;
83
83
  }
84
+ items.forEach(item => {
85
+ if (item.hide == null)
86
+ item.hide = ENUM_HIDE.SHOW;
87
+ if (item.textHide == null)
88
+ item.textHide = ENUM_HIDE.SHOW;
89
+ });
84
90
  const visableItems = items.filter(item => item.hide !== ENUM_HIDE.HIDE);
85
91
  if (this.paddingPlugin) {
86
92
  const paddingInputs = visableItems.map(item => padding1DegreeInputAdapter(item)).flat();
@@ -203,7 +209,6 @@ export class RangeRingPlugin {
203
209
  console.warn("Globe or WebGL context is not initialized, cannot update centers hide");
204
210
  return;
205
211
  }
206
- console.log("updateCentersHide", items);
207
212
  const globe = this.globe;
208
213
  for (const item of items) {
209
214
  const { centerID, hide, textHide } = item;
package/types.js CHANGED
@@ -1 +1,13 @@
1
- export {};
1
+ export var CSMeasureTextPositionTypes;
2
+ (function (CSMeasureTextPositionTypes) {
3
+ CSMeasureTextPositionTypes["CENTER"] = "center";
4
+ CSMeasureTextPositionTypes["LEFT"] = "left";
5
+ CSMeasureTextPositionTypes["RIGHT"] = "right";
6
+ CSMeasureTextPositionTypes["TOP"] = "bottom";
7
+ CSMeasureTextPositionTypes["BOTTOM"] = "top";
8
+ CSMeasureTextPositionTypes["TOP_LEFT"] = "bottom_left";
9
+ CSMeasureTextPositionTypes["TOP_RIGHT"] = "bottom_right";
10
+ CSMeasureTextPositionTypes["BOTTOM_LEFT"] = "top_left";
11
+ CSMeasureTextPositionTypes["BOTTOM_RIGHT"] = "top_right";
12
+ })(CSMeasureTextPositionTypes || (CSMeasureTextPositionTypes = {}));
13
+ ;
@@ -16,7 +16,7 @@ const defaultStyle = {
16
16
  hollowColor: '#000000', // siyah
17
17
  size: 12, // piksel
18
18
  hollow: true,
19
- bold: true,
19
+ bold: false,
20
20
  italic: false,
21
21
  },
22
22
  opacity: 1.0,
@@ -25,25 +25,25 @@ const defaultStyle = {
25
25
  // xOffset = 0,
26
26
  // yOffset = 0,
27
27
  // doDraw = true,
28
- // textAdaptor = null,
29
- // coordinatesAdaptor = null,
30
- // keyAdaptor = null,
31
- // opacityAdaptor = null,
32
- // angleAdaptor = null,
28
+ // textAdapter = null,
29
+ // coordinatesAdapter = null,
30
+ // keyAdapter = null,
31
+ // opacityAdapter = null,
32
+ // angleAdapter = null,
33
33
  // angleOnSphere = false,
34
- // positionAdaptor = (item: any, i: number, container: any[], properties?: any): string => "left",
34
+ // positionAdapter = (item: any, i: number, container: any[], properties?: any): string => "left",
35
35
  export class ContextTextWriter4 {
36
36
  globe;
37
37
  itemMap;
38
38
  style;
39
39
  doDraw;
40
- textAdaptor;
41
- deleteAdaptor;
42
- zoomLevelAdaptor;
40
+ textAdapter;
41
+ deleteAdapter;
42
+ zoomLevelAdapter;
43
43
  xOffset;
44
44
  yOffset;
45
45
  angleOptions;
46
- constructor(globe, textAdaptor, deleteAdaptor, zoomLevelAdaptor = (zoomLevel) => (item) => {
46
+ constructor(globe, textAdapter, deleteAdapter, zoomLevelAdapter = (zoomLevel) => (item) => {
47
47
  return {
48
48
  opacityMultiplier: 1,
49
49
  sizeMultiplier: 1
@@ -54,14 +54,15 @@ export class ContextTextWriter4 {
54
54
  }, doDraw = true, offset = { x: 0, y: 0 }) {
55
55
  this.globe = globe;
56
56
  this.itemMap = new Map();
57
- this.setStyle(style);
57
+ isTextFont(style.textFont);
58
+ opacityCheck(style.opacity);
59
+ this.style = { ...style, textFont: { ...style.textFont } };
58
60
  this.angleOptions = angleOptions;
59
61
  this.doDraw = doDraw;
60
- this.style = style;
61
62
  this.angleOptions = angleOptions;
62
- this.textAdaptor = textAdaptor;
63
- this.deleteAdaptor = deleteAdaptor;
64
- this.zoomLevelAdaptor = zoomLevelAdaptor;
63
+ this.textAdapter = textAdapter;
64
+ this.deleteAdapter = deleteAdapter;
65
+ this.zoomLevelAdapter = zoomLevelAdapter;
65
66
  this.xOffset = offset.x;
66
67
  this.yOffset = offset.y;
67
68
  }
@@ -71,8 +72,8 @@ export class ContextTextWriter4 {
71
72
  }
72
73
  setStyle(style) {
73
74
  isTextFont(style.textFont);
74
- opacityCheck(style.opacity); //TODO: use shallow copy
75
- this.style = style;
75
+ opacityCheck(style.opacity);
76
+ this.style = { ...style, textFont: { ...style.textFont } };
76
77
  this.globe.DrawRender();
77
78
  }
78
79
  setOpacity(opacity) {
@@ -88,25 +89,25 @@ export class ContextTextWriter4 {
88
89
  const is3D = globe.api_GetCurrentGeometry() === 0;
89
90
  const angleIsOn = is3D ? (this.angleOptions.angleIsOn && this.angleOptions.angleOnSphere) : (this.angleOptions.angleIsOn);
90
91
  const zoomLevel = globe.api_GetCurrentLODWithDecimal();
91
- const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
92
+ const zoomAdapter = this.zoomLevelAdapter(zoomLevel);
92
93
  for (const item of itemMap.values()) {
93
- const { lat, long, text, opacity = null, angle = null, zPayload, anchor } = item;
94
+ const { lat, long, text, opacity = null, angle = null, zPayload, position } = item;
94
95
  const { x, y } = globe.api_GetScreenPointFromGeo({
95
96
  long: long,
96
97
  lat: lat,
97
98
  z: 0,
98
99
  }, style.zMode === CSZMode.Z_MSL);
99
- const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(zPayload);
100
+ const { opacityMultiplier, sizeMultiplier } = zoomAdapter(zPayload);
100
101
  const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
101
102
  textFont.size = sizeMultiplier * textSize;
102
- textFont.position = anchor;
103
+ textFont.position = position;
103
104
  if (x !== null && y !== null)
104
105
  globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
105
106
  }
106
107
  textFont.size = textSize;
107
108
  }
108
109
  insertText(data) {
109
- const textDatas = this.textAdaptor(data);
110
+ const textDatas = this.textAdapter(data);
110
111
  for (const textData of textDatas) {
111
112
  this.itemMap.set(textData.key, textData);
112
113
  }
@@ -117,7 +118,7 @@ export class ContextTextWriter4 {
117
118
  }
118
119
  }
119
120
  deleteText(data) {
120
- const keys = this.deleteAdaptor(data);
121
+ const keys = this.deleteAdapter(data);
121
122
  for (const key of keys) {
122
123
  if (this.itemMap.has(key)) {
123
124
  this.itemMap.delete(key);