@pirireis/webglobeplugins 0.0.9 → 0.1.0
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 +1 -1
- package/partialrings/plugin.js +1 -4
- package/partialrings/program.js +2 -3
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +5 -1
- package/programs/rings/distancering/circlepaddysharedbuffer.js +2 -1
- package/programs/rings/distancering/paddyflatprogram.js +2 -0
- package/rangerings/enum.js +7 -0
- package/rangerings/index.js +3 -3
- package/rangerings/rangeringangletext.js +434 -0
- package/rangerings/rangerings.js +34 -16
- package/util/shaderfunctions/geometrytransformations.js +30 -6
package/package.json
CHANGED
package/partialrings/plugin.js
CHANGED
|
@@ -44,7 +44,6 @@ export default class {
|
|
|
44
44
|
this.gl = gl;
|
|
45
45
|
this.globe = globe;
|
|
46
46
|
this.program = programCache.get(globe);
|
|
47
|
-
console.log(this.program);
|
|
48
47
|
const { vao, buffer } = this.program.getVaoBuffer();
|
|
49
48
|
this.vao = vao;
|
|
50
49
|
this.buffer = buffer;
|
|
@@ -107,7 +106,6 @@ class BufferManager extends BufferOffsetManager {
|
|
|
107
106
|
|
|
108
107
|
|
|
109
108
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
110
|
-
console.log(bufferType, gl[bufferType], initialCapacity * ITEM_SIZE * 4);
|
|
111
109
|
gl.bufferData(gl.ARRAY_BUFFER, initialCapacity * ITEM_SIZE * 4, gl[bufferType]);
|
|
112
110
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
113
111
|
}
|
|
@@ -130,7 +128,6 @@ class BufferManager extends BufferOffsetManager {
|
|
|
130
128
|
}
|
|
131
129
|
const block = new Float32Array([
|
|
132
130
|
...center, startAngle, tailAngle, ...color, radius, colorMode]);
|
|
133
|
-
console.log(offset, block);
|
|
134
131
|
gl.bufferSubData(gl.ARRAY_BUFFER, offset, block);
|
|
135
132
|
// 2 1 1 1 4 1 = 10
|
|
136
133
|
}
|
|
@@ -161,7 +158,7 @@ class BufferManager extends BufferOffsetManager {
|
|
|
161
158
|
|
|
162
159
|
_autoExtendBuffer(payloadSize) {
|
|
163
160
|
const { gl, buffer, bufferType, extendRatio } = this;
|
|
164
|
-
if (payloadSize <= this.spaceLeft
|
|
161
|
+
if (payloadSize <= this.spaceLeft) return;
|
|
165
162
|
const newCapacity = Math.ceil((payloadSize + this.length) * extendRatio);
|
|
166
163
|
this.extendBuffer(gl, buffer, bufferType, newCapacity);
|
|
167
164
|
}
|
package/partialrings/program.js
CHANGED
|
@@ -72,7 +72,7 @@ void main() {
|
|
|
72
72
|
float phase = ( vertexID / edge_count);
|
|
73
73
|
|
|
74
74
|
if ( color_mode == 1.0 ) {
|
|
75
|
-
if ( tail_angle
|
|
75
|
+
if ( tail_angle < 0.0 ) {
|
|
76
76
|
v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
|
|
77
77
|
} else {
|
|
78
78
|
v_color = vec4( color.rgb , color.a * (phase ) * alpha );
|
|
@@ -82,7 +82,7 @@ void main() {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
float angle;
|
|
85
|
-
if ( tail_angle
|
|
85
|
+
if ( tail_angle > 0.0 ) {
|
|
86
86
|
angle = tail_angle * (-phase + 1.0) + start_angle;
|
|
87
87
|
} else {
|
|
88
88
|
angle = tail_angle * phase + start_angle;
|
|
@@ -163,7 +163,6 @@ export class Logic {
|
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
draw(bufferManager, vao, edgeCount, alphaMultiplier, drawMode) {
|
|
166
|
-
if (alphaMultiplier === 0) { console.log("no draw"); return };
|
|
167
166
|
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this
|
|
168
167
|
|
|
169
168
|
gl.disable(gl.DEPTH_TEST);
|
|
@@ -14,6 +14,7 @@ const vertexShader = `#version 300 es ` +
|
|
|
14
14
|
shaderfunctions.longLatRadToCartesian3D +
|
|
15
15
|
shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
16
16
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
17
|
+
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
|
|
17
18
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
18
19
|
|
|
19
20
|
in vec2 center;
|
|
@@ -32,6 +33,7 @@ out vec4 v_color;
|
|
|
32
33
|
void main() {
|
|
33
34
|
if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide
|
|
34
35
|
v_color = color;
|
|
36
|
+
if ( pad_angle == 0.0 ) v_color.rgb += 0.2;
|
|
35
37
|
gl_PointSize = 2.0;
|
|
36
38
|
|
|
37
39
|
float odd = mod(float(gl_VertexID), 2.0);
|
|
@@ -49,6 +51,7 @@ void main() {
|
|
|
49
51
|
if ( compass == 1 ){
|
|
50
52
|
limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
51
53
|
} else {
|
|
54
|
+
// limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
|
|
52
55
|
limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
53
56
|
}
|
|
54
57
|
v_limp = limp;
|
|
@@ -267,7 +270,8 @@ export class BufferManager extends BufferOffsetManager {
|
|
|
267
270
|
updateCentersHide(data) {
|
|
268
271
|
const { gl, buffer } = this;
|
|
269
272
|
const items = [];
|
|
270
|
-
for (const { centerID, hide } of data) {
|
|
273
|
+
for (const { centerID, hide = null } of data) {
|
|
274
|
+
if (hide === null) continue;
|
|
271
275
|
const block = new Float32Array([hide]);
|
|
272
276
|
const center = this._centerMaps.get(centerID);
|
|
273
277
|
if (!center) continue;
|
|
@@ -227,7 +227,8 @@ export default class {
|
|
|
227
227
|
updateCentersHide(data) {
|
|
228
228
|
const { gl, buffer } = this;
|
|
229
229
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
230
|
-
for (let { centerID, hide } of data) {
|
|
230
|
+
for (let { centerID, hide = null } of data) {
|
|
231
|
+
if (hide === null) continue;
|
|
231
232
|
const rings = this._centerMap.get(centerID).get("rings");
|
|
232
233
|
for (let i = 0; i < rings.length; i++) {
|
|
233
234
|
const offset = this._ringOffsets.get(rings[i]);
|
|
@@ -12,6 +12,7 @@ const vertexShader = `#version 300 es ` +
|
|
|
12
12
|
shaderfunctions.longLatRadToCartesian3D +
|
|
13
13
|
shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
|
|
14
14
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
|
|
15
|
+
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
|
|
15
16
|
shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
|
|
16
17
|
|
|
17
18
|
in vec2 center;
|
|
@@ -50,6 +51,7 @@ void main() {
|
|
|
50
51
|
if ( compass == 1 ){
|
|
51
52
|
limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
|
|
52
53
|
} else {
|
|
54
|
+
// limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
|
|
53
55
|
limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
|
|
54
56
|
}
|
|
55
57
|
v_limp = limp;
|
package/rangerings/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import RangeRings
|
|
2
|
-
|
|
3
|
-
export { RangeRings, ENUM_HIDE };
|
|
1
|
+
import RangeRings from './rangerings';
|
|
2
|
+
import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from './enum';
|
|
3
|
+
export { RangeRings, ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES };
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
CSGlobe,
|
|
4
|
+
CSObjectTypes,
|
|
5
|
+
CSIconTypes,
|
|
6
|
+
CSObjectArrayUpdateTypes,
|
|
7
|
+
GlobeManager
|
|
8
|
+
} from "@pirireis/webglobe";
|
|
9
|
+
import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from "./enum";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const Degree = 180 / Math.PI;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const fidKey = "__fid__";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const object = {
|
|
20
|
+
"displayName": "CompassRose",
|
|
21
|
+
"layerType": 3,
|
|
22
|
+
|
|
23
|
+
"wkbGeom": null,
|
|
24
|
+
"wfsLayerName": null,
|
|
25
|
+
"objectType": "point",
|
|
26
|
+
"bbox": null,
|
|
27
|
+
"startLod": 2,
|
|
28
|
+
"endLod": 30,
|
|
29
|
+
"continuousLOD": true,
|
|
30
|
+
"MVTXYZName": "hd_seyp",
|
|
31
|
+
"rasterize": false,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export default class RangeRingAngleText {
|
|
36
|
+
constructor(globe, { style = null, flatCompassMode = COMPASS_MODES.REAL } = {}) {
|
|
37
|
+
this.globe = globe;
|
|
38
|
+
this.ObjectArray = globe.ObjectArray;
|
|
39
|
+
|
|
40
|
+
this._flatCompassMode = flatCompassMode;
|
|
41
|
+
this._lastImplicitCompassMode = this.__implicitCompassMode();
|
|
42
|
+
if (style) {
|
|
43
|
+
this.style = style;
|
|
44
|
+
} else {
|
|
45
|
+
this.style = this.ObjectArray.GetDefaultStyle();
|
|
46
|
+
const { labels } = this.style;
|
|
47
|
+
const label = labels[0];
|
|
48
|
+
label.offset = { x: 0, y: 0 };
|
|
49
|
+
label.fontFamily.hollowWidth = 1;
|
|
50
|
+
label.vAlignment = 2;
|
|
51
|
+
label.hAlignment = 2;
|
|
52
|
+
label.size = 17;
|
|
53
|
+
// this.style.filter = [
|
|
54
|
+
// {
|
|
55
|
+
// rule: ["any", ["<", "startLod", "LOD"]],
|
|
56
|
+
// name: "startLODRule",
|
|
57
|
+
// style: {
|
|
58
|
+
// opacity: 0
|
|
59
|
+
// }
|
|
60
|
+
|
|
61
|
+
// }
|
|
62
|
+
// ];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.style.labels[0].text = "`${aci}`"
|
|
66
|
+
this.style.fidKey = fidKey;
|
|
67
|
+
this.object = Object.assign({}, object, { style: this.style });
|
|
68
|
+
|
|
69
|
+
this._centerCollection = new Map();
|
|
70
|
+
// new inner MAP params
|
|
71
|
+
// hide
|
|
72
|
+
// textHide
|
|
73
|
+
|
|
74
|
+
this.ObjectArray.Add(this.object);
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
setCompass(mode) {
|
|
80
|
+
if (mode === this._flatCompassMode) return;
|
|
81
|
+
this._flatCompassMode = mode;
|
|
82
|
+
this.__onCompassChange();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
free() {
|
|
87
|
+
this.flush();
|
|
88
|
+
this.ObjectArray.RemoveObject(this.object);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {Array<{centerID,stepAngle, x, y, rings>} ringDatas
|
|
95
|
+
* centerID: string | ObjectArray fidKey de kullanilir
|
|
96
|
+
* stepAngle: number | 0-360 arasinda
|
|
97
|
+
* x, y: number | merkez koordinatlari lat long radian. Globe icin dereceye iceride cevrilir
|
|
98
|
+
* rings: Array<{radius: number}> | En buyuk halkaya centik acilari yazilir, Sonraki adim yaricaplarin uzunlugunu yazdirmak
|
|
99
|
+
*
|
|
100
|
+
* eger bir centerID zaten var ise: Onceki noktalar dusurulur ve yeniden eklenir
|
|
101
|
+
*
|
|
102
|
+
* */
|
|
103
|
+
insertBulk(ringDatas) {
|
|
104
|
+
|
|
105
|
+
const addBucket = {
|
|
106
|
+
coords: [],
|
|
107
|
+
coordsZ: [],
|
|
108
|
+
attribs: []
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const deleteBucket = {
|
|
112
|
+
coords: [],
|
|
113
|
+
coordsZ: [],
|
|
114
|
+
attribs: []
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
for (const { centerID, x, y, rings, stepAngle, hide = ENUM_HIDE.SHOW, textHide = ENUM_TEXT_HIDE.SHOW } of ringDatas) {
|
|
118
|
+
if (this._centerCollection.has(centerID)) {
|
|
119
|
+
const stepAngle = this._centerCollection.get(centerID).get("stepAngle");
|
|
120
|
+
this._fillDeleteBucket(centerID, stepAngle, deleteBucket);
|
|
121
|
+
}
|
|
122
|
+
const maxRadius = rings.reduce((acc, { radius }) => Math.max(acc, radius), 0);
|
|
123
|
+
this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
|
|
124
|
+
this._centerCollection.set(centerID,
|
|
125
|
+
new Map([
|
|
126
|
+
["stepAngle", stepAngle],
|
|
127
|
+
["maxRadius", maxRadius],
|
|
128
|
+
["x", x],
|
|
129
|
+
["y", y],
|
|
130
|
+
["hide", hide],
|
|
131
|
+
["textHide", textHide]
|
|
132
|
+
]));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
|
|
136
|
+
if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param {Array<{centerID, x,y}>} centerDatas
|
|
142
|
+
* aci ve radiuslarin tutulmasi gereklidir.
|
|
143
|
+
* */
|
|
144
|
+
updateCentersXY(centerDatas) {
|
|
145
|
+
const updateBucket = {
|
|
146
|
+
coords: [],
|
|
147
|
+
coordsZ: [],
|
|
148
|
+
attribs: []
|
|
149
|
+
}
|
|
150
|
+
for (const { centerID, x, y } of centerDatas) {
|
|
151
|
+
if (this._centerCollection.has(centerID)) {
|
|
152
|
+
const centerMap = this._centerCollection.get(centerID);
|
|
153
|
+
const maxRadius = centerMap.get("maxRadius");
|
|
154
|
+
const stepAngle = centerMap.get("stepAngle");
|
|
155
|
+
// long, lat, radius, step, centerID, outBucket
|
|
156
|
+
this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
|
|
157
|
+
centerMap.set("x", x);
|
|
158
|
+
centerMap.set("y", y);
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
for (const attribs of updateBucket.attribs) {
|
|
163
|
+
delete attribs["aci"];
|
|
164
|
+
}
|
|
165
|
+
if (updateBucket.coords.length > 0) {
|
|
166
|
+
this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @param {Array<{centerID:string, hide: bool}} centerHides
|
|
175
|
+
*/
|
|
176
|
+
updateCentersHide(centerHides) {
|
|
177
|
+
const addBucket = {
|
|
178
|
+
coords: [],
|
|
179
|
+
coordsZ: [],
|
|
180
|
+
attribs: []
|
|
181
|
+
};
|
|
182
|
+
const deleteBucket = {
|
|
183
|
+
coords: [],
|
|
184
|
+
coordsZ: [],
|
|
185
|
+
attribs: []
|
|
186
|
+
};
|
|
187
|
+
for (const { centerID, textHide = null, hide = null } of centerHides) {
|
|
188
|
+
if (!this._centerCollection.has(centerID)) continue;
|
|
189
|
+
const centerMap = this._centerCollection.get(centerID);
|
|
190
|
+
|
|
191
|
+
const isHidden = centerMap.get("hide") === ENUM_HIDE.HIDE || centerMap.get("textHide") === ENUM_TEXT_HIDE.HIDE;
|
|
192
|
+
|
|
193
|
+
const _hide = hide !== null ? hide : centerMap.get("hide");
|
|
194
|
+
const _textHide = textHide !== null ? textHide : centerMap.get("textHide");
|
|
195
|
+
|
|
196
|
+
const show = _hide !== ENUM_HIDE.HIDE && _textHide === ENUM_TEXT_HIDE.SHOW;
|
|
197
|
+
if (!isHidden && !show) {
|
|
198
|
+
this._fillDeleteBucket(centerID, deleteBucket);
|
|
199
|
+
} else if (isHidden && show) {
|
|
200
|
+
this._appendCircle(centerMap.get("x"), centerMap.get("y"), centerMap.get("maxRadius"), centerMap.get("stepAngle"), centerID, addBucket);
|
|
201
|
+
}
|
|
202
|
+
if (hide !== null) centerMap.set("hide", hide);
|
|
203
|
+
if (textHide !== null) centerMap.set("textHide", textHide);
|
|
204
|
+
}
|
|
205
|
+
if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
|
|
206
|
+
if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
// TODO : Implement this
|
|
211
|
+
deleteCenters(centerIDs) {
|
|
212
|
+
const deleteBucket = {
|
|
213
|
+
coords: [],
|
|
214
|
+
coordsZ: [],
|
|
215
|
+
attribs: []
|
|
216
|
+
}
|
|
217
|
+
for (const centerID of centerIDs) {
|
|
218
|
+
if (this._centerCollection.has(centerID)) {
|
|
219
|
+
this._fillDeleteBucket(centerID, deleteBucket);
|
|
220
|
+
this._centerCollection.delete(centerID);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
flush() {
|
|
231
|
+
const data = {
|
|
232
|
+
coords: [],
|
|
233
|
+
coordsZ: [],
|
|
234
|
+
attribs: []
|
|
235
|
+
};
|
|
236
|
+
this._idCollector = new Set();
|
|
237
|
+
this.ObjectArray.SetData(this.object, data);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//------------------GLOBE EVENTS------------------//
|
|
241
|
+
|
|
242
|
+
setGeometry() {
|
|
243
|
+
this.__onCompassChange();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
//------------------PRIVATE METHODS------------------//
|
|
248
|
+
|
|
249
|
+
__implicitCompassMode() {
|
|
250
|
+
const is3D = this.globe.api_GetCurrentGeometry() === 0;
|
|
251
|
+
if (is3D) {
|
|
252
|
+
return COMPASS_MODES.REAL;
|
|
253
|
+
} else {
|
|
254
|
+
return this._flatCompassMode;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
__onCompassChange() {
|
|
260
|
+
if (this._lastImplicitCompassMode === this.__implicitCompassMode()) return;
|
|
261
|
+
this._lastImplicitCompassMode = this.__implicitCompassMode();
|
|
262
|
+
this._updateAll();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
// TODO: compass ve gercek mesafeye gore farkli hesaplamalar yapilacak __implicitCompassMode
|
|
268
|
+
_appendCircle(long, lat, radius, step, centerID, outBucket) {
|
|
269
|
+
const currentCompassMode = this.__implicitCompassMode();
|
|
270
|
+
if (currentCompassMode == COMPASS_MODES.REAL) {
|
|
271
|
+
this.__realCoords(long, lat, radius, step, centerID, outBucket);
|
|
272
|
+
} else if (currentCompassMode == COMPASS_MODES.COMPASS) {
|
|
273
|
+
// throw new Error("Not implemented yet");
|
|
274
|
+
this.__compassCoords(long, lat, radius, step, centerID, outBucket);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
__realCoords(long, lat, radius, stepAngle, centerID, outBucket) {
|
|
280
|
+
const { coords, coordsZ, attribs } = outBucket;
|
|
281
|
+
|
|
282
|
+
const coords_ = realCircle(long, lat, radius, stepAngle / Degree);
|
|
283
|
+
{ // add 0
|
|
284
|
+
const { long, lat } = coords_[0];
|
|
285
|
+
coords.push(long, lat);
|
|
286
|
+
coordsZ.push(0);
|
|
287
|
+
const key = this._key(centerID, 0);
|
|
288
|
+
// fidkey is the key
|
|
289
|
+
attribs.push({
|
|
290
|
+
"__fid__": key,
|
|
291
|
+
"aci": "K"
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
let aci = stepAngle;
|
|
295
|
+
const cutAway = 0 == (360 % stepAngle) ? 1 : 0;
|
|
296
|
+
for (let i = 1; i < coords_.length - cutAway; i++) {
|
|
297
|
+
const { long, lat } = coords_[i];
|
|
298
|
+
coords.push(long, lat);
|
|
299
|
+
coordsZ.push(0);
|
|
300
|
+
const key = this._key(centerID, i);
|
|
301
|
+
// fidkey is the key
|
|
302
|
+
attribs.push({
|
|
303
|
+
"__fid__": key,
|
|
304
|
+
"aci": aci.toString()
|
|
305
|
+
})
|
|
306
|
+
aci += stepAngle;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
__compassCoords(long, lat, radius, stepAngle, centerID, outBucket) {
|
|
312
|
+
|
|
313
|
+
const Dlong = Degree * long;
|
|
314
|
+
const Dlat = Degree * lat;
|
|
315
|
+
|
|
316
|
+
const R = 6371.0 * 1000;
|
|
317
|
+
const { coords, coordsZ, attribs } = outBucket;
|
|
318
|
+
const { globe } = this;
|
|
319
|
+
const radianRadius = radius / R;
|
|
320
|
+
const scale = Math.cos(lat);
|
|
321
|
+
{ // add 0
|
|
322
|
+
const x = Dlong + Degree * (radianRadius * Math.cos(Math.PI / 2));
|
|
323
|
+
const y = Dlat + Degree * (radianRadius * Math.sin(Math.PI / 2) * scale);
|
|
324
|
+
coords.push(x, y);
|
|
325
|
+
coordsZ.push(0);
|
|
326
|
+
const key = this._key(centerID, 0);
|
|
327
|
+
attribs.push({
|
|
328
|
+
"__fid__": key,
|
|
329
|
+
"aci": "K"
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
let aci = stepAngle;
|
|
333
|
+
let i = 1;
|
|
334
|
+
const RStep = stepAngle / Degree;
|
|
335
|
+
for (let cstep = Math.PI / 2 - RStep; cstep > -Math.PI * 1.5; cstep -= RStep) {
|
|
336
|
+
if (aci >= 360) break;
|
|
337
|
+
const x = Dlong + Degree * (radianRadius * Math.cos(cstep));
|
|
338
|
+
const y = Dlat + Degree * (radianRadius * Math.sin(cstep) * scale);
|
|
339
|
+
coords.push(x, y);
|
|
340
|
+
coordsZ.push(0);
|
|
341
|
+
const key = this._key(centerID, i++);
|
|
342
|
+
attribs.push({
|
|
343
|
+
"__fid__": key,
|
|
344
|
+
"aci": Math.floor(aci).toString()
|
|
345
|
+
})
|
|
346
|
+
aci += stepAngle;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
_updateData(bucket, mode) {
|
|
352
|
+
this.ObjectArray.UpdateData(this.object, mode, [bucket], { attribs: false, icon: false, text: false });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
_key(centerRingKey, limpIndex) {
|
|
357
|
+
return `${centerRingKey}_${limpIndex}`;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
_fillDeleteBucket(centerID, outDeleteBucket) {
|
|
361
|
+
|
|
362
|
+
const centerMap = this._centerCollection.get(centerID);
|
|
363
|
+
const stepAngle = centerMap.get("stepAngle");
|
|
364
|
+
const { coords, coordsZ, attribs } = outDeleteBucket;
|
|
365
|
+
let i = 0;
|
|
366
|
+
for (let aci = 0; aci < 360; aci += stepAngle) {
|
|
367
|
+
const key = this._key(centerID, i++);
|
|
368
|
+
coords.push(0, 0);
|
|
369
|
+
coordsZ.push(0);
|
|
370
|
+
attribs.push({
|
|
371
|
+
"__fid__": key,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
_updateAll() {
|
|
377
|
+
const updateBucket = {
|
|
378
|
+
coords: [],
|
|
379
|
+
coordsZ: [],
|
|
380
|
+
attribs: []
|
|
381
|
+
}
|
|
382
|
+
for (const [centerID, centerMap] of this._centerCollection) {
|
|
383
|
+
const isHidden = centerMap.get("hide") === ENUM_HIDE.HIDE || centerMap.get("textHide") === ENUM_TEXT_HIDE.HIDE;
|
|
384
|
+
if (isHidden) continue;
|
|
385
|
+
const x = centerMap.get("x");
|
|
386
|
+
const y = centerMap.get("y");
|
|
387
|
+
const maxRadius = centerMap.get("maxRadius");
|
|
388
|
+
const stepAngle = centerMap.get("stepAngle");
|
|
389
|
+
this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
|
|
390
|
+
}
|
|
391
|
+
this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
const readCoords = (long, lat, radius, stepAngle) => {
|
|
398
|
+
|
|
399
|
+
const result = []
|
|
400
|
+
const degree = radius / R;
|
|
401
|
+
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
const R = 6371.0;
|
|
409
|
+
|
|
410
|
+
const flatCircle = (longitude, latitude, radius, paddingAngles) => {
|
|
411
|
+
const degree = radius / R;
|
|
412
|
+
const points = [];
|
|
413
|
+
|
|
414
|
+
for (const angle of paddingAngles) {
|
|
415
|
+
const x = longitude + degree * Math.cos(angle);
|
|
416
|
+
const y = latitude + degree * Math.sin(angle);
|
|
417
|
+
points.push({ long: x, lat: y });
|
|
418
|
+
}
|
|
419
|
+
return points;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const realCircle = (longitude, latitude, radius, stepAngle) => {
|
|
423
|
+
const R = 6371000;
|
|
424
|
+
|
|
425
|
+
const degree = radius / R;
|
|
426
|
+
const points = [];
|
|
427
|
+
for (let step = Math.PI / 2.0; step > -Math.PI * 1.5; step -= stepAngle) {
|
|
428
|
+
const y = latitude + degree * Math.sin(step);
|
|
429
|
+
const x = longitude + degree * Math.cos(step) / Math.cos(y);
|
|
430
|
+
|
|
431
|
+
points.push({ long: Degree * x, lat: Degree * y });
|
|
432
|
+
}
|
|
433
|
+
return points;
|
|
434
|
+
}
|
package/rangerings/rangerings.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { rings } from "../programs";
|
|
2
|
-
|
|
2
|
+
import { COMPASS_MODES } from "./enum";
|
|
3
3
|
import { PaddingFreeAngleCache } from "../programs/rings/distancering";
|
|
4
|
-
const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
|
|
5
4
|
|
|
5
|
+
import RangeRingAngleText from "./rangeringangletext";
|
|
6
|
+
const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @typedef RangeRingData
|
|
@@ -18,14 +19,13 @@ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
|
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
export const ENUM_HIDE = Object.freeze({ SHOW: 0, HIDE: 1, HIDE_1_DEGREE_PADDINGS: 2 });
|
|
22
|
-
|
|
23
22
|
|
|
24
23
|
export default class {
|
|
25
24
|
|
|
26
|
-
constructor(id, oneDegreePadding = true, compass =
|
|
25
|
+
constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.COMPASS, circleEdgeCount = 360, showNumbers = true } = {}) {
|
|
27
26
|
this.id = id;
|
|
28
27
|
this.compass = compass;
|
|
28
|
+
this._showNumbers = showNumbers;
|
|
29
29
|
this.circleEdgeCount = circleEdgeCount;
|
|
30
30
|
this._onedegreepaddingOn = oneDegreePadding;
|
|
31
31
|
this.bufferManager = null;
|
|
@@ -40,10 +40,13 @@ export default class {
|
|
|
40
40
|
this.globe = globe;
|
|
41
41
|
this.circleFlatProgram = new CircleFlatProgram(globe, gl);
|
|
42
42
|
this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
|
|
43
|
-
|
|
44
43
|
this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
|
|
44
|
+
if (this._showNumbers) {
|
|
45
|
+
this._textPlugin = new RangeRingAngleText(globe, { flatCompassMode: this.compass });
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
// TODO: Add text free
|
|
47
50
|
free() {
|
|
48
51
|
this.circleFlatProgram.free();
|
|
49
52
|
this.paddyFlatProgram.free();
|
|
@@ -53,8 +56,25 @@ export default class {
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
|
|
59
|
+
|
|
60
|
+
// // TODO: Client should reinsert all data to be able to see numbers. Think Better Solution.
|
|
61
|
+
// setShowNumbers(showNumbers) {
|
|
62
|
+
// this._showNumbers = showNumbers;
|
|
63
|
+
// if (this._showNumbers) {
|
|
64
|
+
// this._textPlugin = new RangeRingAngleText(this.globe);
|
|
65
|
+
// } else {
|
|
66
|
+
// this._textPlugin?.free();
|
|
67
|
+
// this._textPlugin = null;
|
|
68
|
+
// }
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
setGeometry() {
|
|
72
|
+
this._textPlugin?.setGeometry();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
56
76
|
draw3D() {
|
|
57
|
-
const { circleFlatProgram, paddyFlatProgram,
|
|
77
|
+
const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager } = this;
|
|
58
78
|
// if (globe.api_GetCurrentGeometry() === 0) return; // do not draw in 3D mode
|
|
59
79
|
if (this.bufferManager !== null && bufferManager.length > 0) {
|
|
60
80
|
gl.disable(gl.DEPTH_TEST);
|
|
@@ -68,9 +88,7 @@ export default class {
|
|
|
68
88
|
}
|
|
69
89
|
}
|
|
70
90
|
|
|
71
|
-
|
|
72
|
-
this.padCount = padCount;
|
|
73
|
-
}
|
|
91
|
+
|
|
74
92
|
|
|
75
93
|
/**
|
|
76
94
|
* @param {RangeRingData} rangeRingData
|
|
@@ -79,6 +97,7 @@ export default class {
|
|
|
79
97
|
*/
|
|
80
98
|
setCampass(compass) {
|
|
81
99
|
this.compass = compass;
|
|
100
|
+
this._textPlugin?.setCompass(compass);
|
|
82
101
|
}
|
|
83
102
|
|
|
84
103
|
initilizeBufferManager(initialRingCapacity, bufferDrawType) {
|
|
@@ -88,11 +107,6 @@ export default class {
|
|
|
88
107
|
this.paddingBufferManager = this.paddingFreeAngleProgram.initilizeBufferManager({ bufferType: bufferDrawType, initialRingCapacity });
|
|
89
108
|
}
|
|
90
109
|
|
|
91
|
-
// getBufferManager() {
|
|
92
|
-
// return this.bufferManager;
|
|
93
|
-
// }
|
|
94
|
-
|
|
95
|
-
|
|
96
110
|
|
|
97
111
|
/**
|
|
98
112
|
* @typedef {Array<{ringID, radius, paddingRange}>} rings
|
|
@@ -103,6 +117,7 @@ export default class {
|
|
|
103
117
|
|
|
104
118
|
this.bufferManager.insertBulk(insertData);
|
|
105
119
|
this.paddingBufferManager.insertBulk(items);
|
|
120
|
+
this._textPlugin?.insertBulk(items);
|
|
106
121
|
this.globe.DrawRender();
|
|
107
122
|
}
|
|
108
123
|
|
|
@@ -110,6 +125,7 @@ export default class {
|
|
|
110
125
|
updateCentersXY(items) {
|
|
111
126
|
this.bufferManager.updateCentersXY(items);
|
|
112
127
|
this.paddingBufferManager.updateCentersXY(items);
|
|
128
|
+
this._textPlugin?.updateCentersXY(items);
|
|
113
129
|
this.globe.DrawRender();
|
|
114
130
|
}
|
|
115
131
|
|
|
@@ -126,6 +142,7 @@ export default class {
|
|
|
126
142
|
|
|
127
143
|
this.bufferManager.removeCenters(centerIds);
|
|
128
144
|
this.paddingBufferManager.removeCenters(centerIds);
|
|
145
|
+
this._textPlugin?.removeCenters(centerIds);
|
|
129
146
|
// this.bufferManager.defrag();
|
|
130
147
|
// this.paddingBufferManager.defrag();
|
|
131
148
|
this.globe.DrawRender();
|
|
@@ -136,6 +153,7 @@ export default class {
|
|
|
136
153
|
updateCentersHide(centerHides) {
|
|
137
154
|
this.bufferManager.updateCentersHide(centerHides);
|
|
138
155
|
this.paddingBufferManager.updateCentersHide(centerHides);
|
|
156
|
+
this._textPlugin?.updateCentersHide(centerHides);
|
|
139
157
|
this.globe.DrawRender();
|
|
140
158
|
}
|
|
141
159
|
}
|
|
@@ -150,7 +168,7 @@ const ringItemsToCircleBufferInsertDataAdaptor = (ringItems) => {
|
|
|
150
168
|
resultRings.push({
|
|
151
169
|
ringID,
|
|
152
170
|
radius,
|
|
153
|
-
padding: padding /
|
|
171
|
+
padding: padding / 5,
|
|
154
172
|
rgba,
|
|
155
173
|
});
|
|
156
174
|
}
|
|
@@ -73,8 +73,6 @@ vec4 cartesian3DToGLPosition( vec3 position) {
|
|
|
73
73
|
|
|
74
74
|
// pi / pole = 2 / R
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
76
|
export const longLatRadToMercator = R + PI + `
|
|
79
77
|
vec2 longLatRadToMercator( vec2 longLatRad) {
|
|
80
78
|
float x = R * longLatRad.x;
|
|
@@ -94,7 +92,7 @@ vec3 longLatRadToCartesian3D( vec2 longLat) {
|
|
|
94
92
|
`;
|
|
95
93
|
|
|
96
94
|
|
|
97
|
-
|
|
95
|
+
// TODO: Make it precise. It doesnt use haversine formula. If this changes, change the formmula which calculates text position.
|
|
98
96
|
export const circleLimpFromLongLatRadCenterCartesian3D = R + `
|
|
99
97
|
vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float angle) {
|
|
100
98
|
vec3 geoW = longLatRadToCartesian3D(center);
|
|
@@ -108,13 +106,11 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
|
|
|
108
106
|
}
|
|
109
107
|
`;
|
|
110
108
|
|
|
111
|
-
// TODO: Make it precise
|
|
109
|
+
// TODO: Make it precise. Y axis is not correct.
|
|
112
110
|
export const circleLimpFromLongLatRadCenterMercatorRealDistance = `
|
|
113
111
|
vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
|
|
114
|
-
|
|
115
112
|
float radius_radian = radius / R;
|
|
116
113
|
float lat = center.y - radius_radian * sin(angle);
|
|
117
|
-
|
|
118
114
|
float scale = 1.0/abs( cos( lat ) );
|
|
119
115
|
vec2 center_ = longLatRadToMercator(center);
|
|
120
116
|
float x = center_.x + scale * radius * cos(angle);
|
|
@@ -123,6 +119,34 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radiu
|
|
|
123
119
|
}
|
|
124
120
|
`;
|
|
125
121
|
|
|
122
|
+
// TODO: reconstruct this function
|
|
123
|
+
export const circleLimpFromLongLatRadCenterMercatorRealDistancePadding = `
|
|
124
|
+
vec2 circleLimpFromLongLatRadCenterMercatorRealDistancePadding(vec2 center, float radius, float angle){
|
|
125
|
+
float radius_radian = radius / R;
|
|
126
|
+
float new_angle;
|
|
127
|
+
if ( angle != - 1.5707963267948966192313216916398){
|
|
128
|
+
float section = floor(angle / ( PI / 2.0)) + 1.0;
|
|
129
|
+
float lat = center.y - radius_radian * sin(angle);
|
|
130
|
+
float scale = 1.0/abs( cos( lat ) );
|
|
131
|
+
new_angle = atan( tan(angle) * scale );
|
|
132
|
+
if ( section == 2.0 ){
|
|
133
|
+
new_angle = mod( new_angle, PI );
|
|
134
|
+
} else if ( section == 3.0 ){
|
|
135
|
+
new_angle = new_angle + PI;
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
new_angle = angle;
|
|
139
|
+
}
|
|
140
|
+
float new_lat = center.y - radius_radian * sin(new_angle);
|
|
141
|
+
float new_scale = 1.0/abs( cos( new_lat ) );
|
|
142
|
+
|
|
143
|
+
vec2 center_ = longLatRadToMercator(center);
|
|
144
|
+
float x = center_.x + new_scale * radius * cos(new_angle);
|
|
145
|
+
float y = center_.y - new_scale * radius * sin(new_angle);
|
|
146
|
+
return vec2(x, y);
|
|
147
|
+
}
|
|
148
|
+
`
|
|
149
|
+
|
|
126
150
|
|
|
127
151
|
export const circleLimpFromLongLatRadCenterMercatorCompass = `
|
|
128
152
|
vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, float angle){
|