@things-factory/weather 9.0.0-9.0.0-beta.59.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/CHANGELOG.md +8 -0
- package/assets/images/wind.png +0 -0
- package/assets/images/wind2.png +0 -0
- package/client/bootstrap.ts +1 -0
- package/client/index.ts +0 -0
- package/client/ol-components/webgl-canvas-layer.ts +413 -0
- package/client/ol-components/wind-data-tile-layer.ts +485 -0
- package/client/ol-components/wind-rasterized-layer.ts +437 -0
- package/client/pages/weather-page.ts +353 -0
- package/client/route.ts +7 -0
- package/client/tsconfig.json +11 -0
- package/config/config.development.js +28 -0
- package/config/config.production.js +10 -0
- package/data/geo-json/countries-max-geo.json +1 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/ol-components/webgl-canvas-layer.d.ts +61 -0
- package/dist-client/ol-components/webgl-canvas-layer.js +364 -0
- package/dist-client/ol-components/webgl-canvas-layer.js.map +1 -0
- package/dist-client/ol-components/wind-data-tile-layer.d.ts +59 -0
- package/dist-client/ol-components/wind-data-tile-layer.js +414 -0
- package/dist-client/ol-components/wind-data-tile-layer.js.map +1 -0
- package/dist-client/ol-components/wind-rasterized-layer.d.ts +59 -0
- package/dist-client/ol-components/wind-rasterized-layer.js +363 -0
- package/dist-client/ol-components/wind-rasterized-layer.js.map +1 -0
- package/dist-client/pages/weather-page.d.ts +23 -0
- package/dist-client/pages/weather-page.js +348 -0
- package/dist-client/pages/weather-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +8 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/controllers/open-meteo-adapter.d.ts +4 -0
- package/dist-server/controllers/open-meteo-adapter.js +87 -0
- package/dist-server/controllers/open-meteo-adapter.js.map +1 -0
- package/dist-server/controllers/types.d.ts +55 -0
- package/dist-server/controllers/types.js +3 -0
- package/dist-server/controllers/types.js.map +1 -0
- package/dist-server/controllers/weather-controller.d.ts +12 -0
- package/dist-server/controllers/weather-controller.js +179 -0
- package/dist-server/controllers/weather-controller.js.map +1 -0
- package/dist-server/index.d.ts +1 -0
- package/dist-server/index.js +4 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/routers/geo-router.d.ts +59 -0
- package/dist-server/routers/geo-router.js +277 -0
- package/dist-server/routers/geo-router.js.map +1 -0
- package/dist-server/routers/weather-router.d.ts +1 -0
- package/dist-server/routers/weather-router.js +10 -0
- package/dist-server/routers/weather-router.js.map +1 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/routes.js +11 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/services/chrome-renderer.d.ts +13 -0
- package/dist-server/services/chrome-renderer.js +162 -0
- package/dist-server/services/chrome-renderer.js.map +1 -0
- package/dist-server/services/headless-pool.d.ts +4 -0
- package/dist-server/services/headless-pool.js +89 -0
- package/dist-server/services/headless-pool.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/dist-server/utils/svg-utils.d.ts +35 -0
- package/dist-server/utils/svg-utils.js +89 -0
- package/dist-server/utils/svg-utils.js.map +1 -0
- package/dist-server/utils/tile-utils.d.ts +38 -0
- package/dist-server/utils/tile-utils.js +64 -0
- package/dist-server/utils/tile-utils.js.map +1 -0
- package/package.json +46 -0
- package/server/controllers/open-meteo-adapter.ts +96 -0
- package/server/controllers/types.ts +63 -0
- package/server/controllers/weather-controller.ts +192 -0
- package/server/index.ts +1 -0
- package/server/routers/geo-router.ts +297 -0
- package/server/routers/weather-router.ts +8 -0
- package/server/routes.ts +10 -0
- package/server/services/chrome-renderer.ts +206 -0
- package/server/services/data.json +8438 -0
- package/server/services/headless-pool.ts +97 -0
- package/server/tsconfig.json +10 -0
- package/server/utils/svg-utils.ts +108 -0
- package/server/utils/tile-utils.ts +77 -0
- package/things-factory.config.js +8 -0
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function bootstrap(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../client/bootstrap.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,KAAI,CAAC","sourcesContent":["export default function bootstrap() {}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import ImageLayer from 'ol/layer/Image.js';
|
|
2
|
+
import ImageCanvasSource from 'ol/source/ImageCanvas.js';
|
|
3
|
+
/**
|
|
4
|
+
* WebGLμ μ¬μ©νμ¬ λ μ¨ λ°μ΄ν° μ΄λ―Έμ§λ₯Ό μ§λμ μ€λ²λ μ΄νλ λ μ΄μ΄
|
|
5
|
+
* μ΄λ―Έμ§μ RGBA μ±λμλ μ¨λ, μ΅λ, λ°λ, κ°μλ λ°μ΄ν°κ° μΈμ½λ©λμ΄ μμ
|
|
6
|
+
*/
|
|
7
|
+
declare class WebGLCanvasLayer extends ImageLayer<ImageCanvasSource> {
|
|
8
|
+
private canvas;
|
|
9
|
+
private gl;
|
|
10
|
+
private program;
|
|
11
|
+
private texture;
|
|
12
|
+
private buffer;
|
|
13
|
+
private imageLoaded;
|
|
14
|
+
private pendingRender;
|
|
15
|
+
private imageUrl;
|
|
16
|
+
private dataType;
|
|
17
|
+
/**
|
|
18
|
+
* WebGL μΊλ²μ€ λ μ΄μ΄ μμ±μ
|
|
19
|
+
* @param imageUrl λ μ¨ λ°μ΄ν°κ° μΈμ½λ©λ μ΄λ―Έμ§ URL
|
|
20
|
+
* @param dataType μκ°νν λ°μ΄ν° μ ν (temperature, humidity, wind, precipitation)
|
|
21
|
+
*/
|
|
22
|
+
constructor(imageUrl: string, dataType?: string);
|
|
23
|
+
/**
|
|
24
|
+
* λ°μ΄ν° μκ°ν μ ν λ³κ²½
|
|
25
|
+
*/
|
|
26
|
+
updateDataType(type: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* 리μμ€ ν΄μ
|
|
29
|
+
*/
|
|
30
|
+
dispose(): void;
|
|
31
|
+
/**
|
|
32
|
+
* μ΄λ―Έμ§ URL μ
λ°μ΄νΈ
|
|
33
|
+
*/
|
|
34
|
+
updateImageUrl(newUrl: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* WebGL 컨ν
μ€νΈ μ΄κΈ°ν
|
|
37
|
+
*/
|
|
38
|
+
private _initializeWebGL;
|
|
39
|
+
/**
|
|
40
|
+
* λ²ν
μ€ λ²νΌ μ΄κΈ°ν
|
|
41
|
+
*/
|
|
42
|
+
private _initializeBuffers;
|
|
43
|
+
/**
|
|
44
|
+
* μ΄λ―Έμ§ λ‘λ λ° ν
μ€μ² μμ±
|
|
45
|
+
*/
|
|
46
|
+
private _loadImage;
|
|
47
|
+
/**
|
|
48
|
+
* ν
μ€μ² λ λλ§
|
|
49
|
+
*/
|
|
50
|
+
private _renderTexture;
|
|
51
|
+
/**
|
|
52
|
+
* μ
°μ΄λ νλ‘κ·Έλ¨ μμ±
|
|
53
|
+
*/
|
|
54
|
+
private _createShaderProgram;
|
|
55
|
+
/**
|
|
56
|
+
* μ
°μ΄λ μ»΄νμΌ
|
|
57
|
+
*/
|
|
58
|
+
private _compileShader;
|
|
59
|
+
private _updateWebGLUniforms;
|
|
60
|
+
}
|
|
61
|
+
export default WebGLCanvasLayer;
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import ImageLayer from 'ol/layer/Image.js';
|
|
2
|
+
import ImageCanvasSource from 'ol/source/ImageCanvas.js';
|
|
3
|
+
import { transformExtent } from 'ol/proj.js';
|
|
4
|
+
/**
|
|
5
|
+
* WebGLμ μ¬μ©νμ¬ λ μ¨ λ°μ΄ν° μ΄λ―Έμ§λ₯Ό μ§λμ μ€λ²λ μ΄νλ λ μ΄μ΄
|
|
6
|
+
* μ΄λ―Έμ§μ RGBA μ±λμλ μ¨λ, μ΅λ, λ°λ, κ°μλ λ°μ΄ν°κ° μΈμ½λ©λμ΄ μμ
|
|
7
|
+
*/
|
|
8
|
+
class WebGLCanvasLayer extends ImageLayer {
|
|
9
|
+
/**
|
|
10
|
+
* WebGL μΊλ²μ€ λ μ΄μ΄ μμ±μ
|
|
11
|
+
* @param imageUrl λ μ¨ λ°μ΄ν°κ° μΈμ½λ©λ μ΄λ―Έμ§ URL
|
|
12
|
+
* @param dataType μκ°νν λ°μ΄ν° μ ν (temperature, humidity, wind, precipitation)
|
|
13
|
+
*/
|
|
14
|
+
constructor(imageUrl, dataType = 'temperature') {
|
|
15
|
+
super({
|
|
16
|
+
source: new ImageCanvasSource({
|
|
17
|
+
canvasFunction: (extent, resolution, pixelRatio, size, projection) => {
|
|
18
|
+
this._initializeWebGL(size, pixelRatio);
|
|
19
|
+
if (this.gl && this.program) {
|
|
20
|
+
// νμ¬ μ§λ λ·°μ extentλ₯Ό μ§λ¦¬ μ’ν(EPSG:4326)λ‘ λ³ν
|
|
21
|
+
const worldExtent = transformExtent(extent, projection.getCode(), 'EPSG:4326');
|
|
22
|
+
// μ΄λ―Έμ§κ° λ‘λλ κ²½μ° λ λλ§
|
|
23
|
+
if (this.imageLoaded && this.texture) {
|
|
24
|
+
this._updateWebGLUniforms(worldExtent, resolution, size, pixelRatio);
|
|
25
|
+
this._renderTexture(worldExtent, size, resolution, pixelRatio);
|
|
26
|
+
}
|
|
27
|
+
else if (!this.pendingRender) {
|
|
28
|
+
this.pendingRender = true;
|
|
29
|
+
this._loadImage(this.imageUrl, worldExtent, size, resolution, pixelRatio);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return this.canvas;
|
|
33
|
+
},
|
|
34
|
+
projection: 'EPSG:3857'
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
this.canvas = null;
|
|
38
|
+
this.gl = null;
|
|
39
|
+
this.program = null;
|
|
40
|
+
this.texture = null;
|
|
41
|
+
this.buffer = null;
|
|
42
|
+
this.imageLoaded = false;
|
|
43
|
+
this.pendingRender = false;
|
|
44
|
+
this.imageUrl = imageUrl;
|
|
45
|
+
this.dataType = dataType;
|
|
46
|
+
this.on('change:visible', () => this.changed());
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* λ°μ΄ν° μκ°ν μ ν λ³κ²½
|
|
50
|
+
*/
|
|
51
|
+
updateDataType(type) {
|
|
52
|
+
this.dataType = type;
|
|
53
|
+
this.changed();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 리μμ€ ν΄μ
|
|
57
|
+
*/
|
|
58
|
+
dispose() {
|
|
59
|
+
if (this.gl) {
|
|
60
|
+
if (this.buffer)
|
|
61
|
+
this.gl.deleteBuffer(this.buffer);
|
|
62
|
+
if (this.texture)
|
|
63
|
+
this.gl.deleteTexture(this.texture);
|
|
64
|
+
if (this.program)
|
|
65
|
+
this.gl.deleteProgram(this.program);
|
|
66
|
+
}
|
|
67
|
+
super.dispose();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* μ΄λ―Έμ§ URL μ
λ°μ΄νΈ
|
|
71
|
+
*/
|
|
72
|
+
updateImageUrl(newUrl) {
|
|
73
|
+
if (this.imageUrl === newUrl)
|
|
74
|
+
return;
|
|
75
|
+
this.imageUrl = newUrl;
|
|
76
|
+
this.imageLoaded = false;
|
|
77
|
+
this.pendingRender = false;
|
|
78
|
+
if (this.texture && this.gl) {
|
|
79
|
+
this.gl.deleteTexture(this.texture);
|
|
80
|
+
this.texture = null;
|
|
81
|
+
}
|
|
82
|
+
this.changed();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* WebGL 컨ν
μ€νΈ μ΄κΈ°ν
|
|
86
|
+
*/
|
|
87
|
+
_initializeWebGL(size, pixelRatio = 1) {
|
|
88
|
+
const width = Math.round(size[0] * pixelRatio);
|
|
89
|
+
const height = Math.round(size[1] * pixelRatio);
|
|
90
|
+
if (!this.canvas) {
|
|
91
|
+
// μΊλ²μ€ μμ± λ° WebGL μ΄κΈ°ν
|
|
92
|
+
this.canvas = document.createElement('canvas');
|
|
93
|
+
this.canvas.width = width;
|
|
94
|
+
this.canvas.height = height;
|
|
95
|
+
this.gl = this.canvas.getContext('webgl', {
|
|
96
|
+
alpha: true,
|
|
97
|
+
antialias: false,
|
|
98
|
+
depth: false
|
|
99
|
+
});
|
|
100
|
+
if (!this.gl)
|
|
101
|
+
return;
|
|
102
|
+
this.program = this._createShaderProgram();
|
|
103
|
+
if (this.program) {
|
|
104
|
+
this._initializeBuffers();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (this.canvas.width !== width || this.canvas.height !== height) {
|
|
108
|
+
// μΊλ²μ€ ν¬κΈ° μ‘°μ
|
|
109
|
+
this.canvas.width = width;
|
|
110
|
+
this.canvas.height = height;
|
|
111
|
+
if (this.gl)
|
|
112
|
+
this.gl.viewport(0, 0, width, height);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* λ²ν
μ€ λ²νΌ μ΄κΈ°ν
|
|
117
|
+
*/
|
|
118
|
+
_initializeBuffers() {
|
|
119
|
+
if (!this.gl)
|
|
120
|
+
return;
|
|
121
|
+
// μ¬κ°ν λ²ν
μ€ (μμΉ(x,y) + ν
μ€μ² μ’ν(s,t))
|
|
122
|
+
const vertices = new Float32Array([
|
|
123
|
+
-1,
|
|
124
|
+
-1,
|
|
125
|
+
0,
|
|
126
|
+
1, // μ’νλ¨
|
|
127
|
+
1,
|
|
128
|
+
-1,
|
|
129
|
+
1,
|
|
130
|
+
1, // μ°νλ¨
|
|
131
|
+
-1,
|
|
132
|
+
1,
|
|
133
|
+
0,
|
|
134
|
+
0, // μ’μλ¨
|
|
135
|
+
1,
|
|
136
|
+
1,
|
|
137
|
+
1,
|
|
138
|
+
0 // μ°μλ¨
|
|
139
|
+
]);
|
|
140
|
+
this.buffer = this.gl.createBuffer();
|
|
141
|
+
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffer);
|
|
142
|
+
this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* μ΄λ―Έμ§ λ‘λ λ° ν
μ€μ² μμ±
|
|
146
|
+
*/
|
|
147
|
+
_loadImage(url, worldExtent, size, resolution, pixelRatio) {
|
|
148
|
+
const img = new Image();
|
|
149
|
+
img.crossOrigin = 'anonymous';
|
|
150
|
+
img.onload = () => {
|
|
151
|
+
if (!this.gl)
|
|
152
|
+
return;
|
|
153
|
+
try {
|
|
154
|
+
// ν
μ€μ² μμ± λ° μ€μ
|
|
155
|
+
this.texture = this.gl.createTexture();
|
|
156
|
+
this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture);
|
|
157
|
+
// κ²½λ λ°©ν₯μΌλ‘ λν (λ μ§ λ³κ²½μ μ²λ¦¬)
|
|
158
|
+
// this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.REPEAT)
|
|
159
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
|
160
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
|
161
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
|
|
162
|
+
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
|
|
163
|
+
// ν
μ€μ² λ°μ΄ν° μ
λ‘λ
|
|
164
|
+
this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); // μνκ° μμ€ λ°©μ§
|
|
165
|
+
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, img);
|
|
166
|
+
this.imageLoaded = true;
|
|
167
|
+
this.pendingRender = false;
|
|
168
|
+
// μ΄λ―Έμ§ λ‘λ ν λ λλ§
|
|
169
|
+
this._renderTexture(worldExtent, size, resolution, pixelRatio);
|
|
170
|
+
this.changed();
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
console.error('ν
μ€μ² μμ± μ€ν¨:', err);
|
|
174
|
+
this.pendingRender = false;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
img.onerror = () => {
|
|
178
|
+
console.error('μ΄λ―Έμ§ λ‘λ μ€ν¨:', url);
|
|
179
|
+
this.pendingRender = false;
|
|
180
|
+
};
|
|
181
|
+
img.src = url;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* ν
μ€μ² λ λλ§
|
|
185
|
+
*/
|
|
186
|
+
_renderTexture(worldExtent, size, resolution, pixelRatio) {
|
|
187
|
+
if (!this.gl || !this.program || !this.texture || !this.buffer)
|
|
188
|
+
return;
|
|
189
|
+
const gl = this.gl;
|
|
190
|
+
const width = Math.round(size[0] * pixelRatio);
|
|
191
|
+
const height = Math.round(size[1] * pixelRatio);
|
|
192
|
+
this._updateWebGLUniforms(worldExtent, resolution, size, pixelRatio);
|
|
193
|
+
// κΈ°λ³Έ WebGL μν μ€μ
|
|
194
|
+
gl.viewport(0, 0, width, height);
|
|
195
|
+
gl.clearColor(0, 0, 0, 0);
|
|
196
|
+
gl.enable(gl.BLEND);
|
|
197
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
198
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
199
|
+
// μ
°μ΄λ νλ‘κ·Έλ¨ νμ±ν
|
|
200
|
+
gl.useProgram(this.program);
|
|
201
|
+
// ν
μ€μ² λ°μΈλ©
|
|
202
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
203
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
204
|
+
// μ λνΌ μ€μ
|
|
205
|
+
const dataTypeVal = ['temperature', 'humidity', 'wind', 'precipitation'].indexOf(this.dataType);
|
|
206
|
+
gl.uniform1i(gl.getUniformLocation(this.program, 'u_texture'), 0);
|
|
207
|
+
gl.uniform1f(gl.getUniformLocation(this.program, 'u_opacity'), 0.8 * pixelRatio);
|
|
208
|
+
gl.uniform1i(gl.getUniformLocation(this.program, 'u_dataType'), dataTypeVal >= 0 ? dataTypeVal : 0);
|
|
209
|
+
gl.uniform4fv(gl.getUniformLocation(this.program, 'u_worldExtent'), new Float32Array([worldExtent[0], worldExtent[1], worldExtent[2], worldExtent[3]]));
|
|
210
|
+
// λ²νΌ λ°μΈλ© λ° μμ± μ€μ
|
|
211
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
212
|
+
const a_position = gl.getAttribLocation(this.program, 'a_position');
|
|
213
|
+
const a_texCoord = gl.getAttribLocation(this.program, 'a_texCoord');
|
|
214
|
+
gl.enableVertexAttribArray(a_position);
|
|
215
|
+
gl.enableVertexAttribArray(a_texCoord);
|
|
216
|
+
gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 16, 0);
|
|
217
|
+
gl.vertexAttribPointer(a_texCoord, 2, gl.FLOAT, false, 16, 8);
|
|
218
|
+
// μ¬κ°ν λ λλ§
|
|
219
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* μ
°μ΄λ νλ‘κ·Έλ¨ μμ±
|
|
223
|
+
*/
|
|
224
|
+
_createShaderProgram() {
|
|
225
|
+
if (!this.gl)
|
|
226
|
+
return null;
|
|
227
|
+
// λ²ν
μ€ μ
°μ΄λ: μ§λ¦¬ μ’νμ ν
μ€μ² μ’ν κ° λ³ν
|
|
228
|
+
const vertexShaderSource = `
|
|
229
|
+
precision highp float;
|
|
230
|
+
|
|
231
|
+
attribute vec4 a_position; // Rectangle coordinates
|
|
232
|
+
attribute vec2 a_texCoord; // Texture coordinates
|
|
233
|
+
varying vec2 v_texCoord;
|
|
234
|
+
|
|
235
|
+
uniform vec2 u_resolution; // Resolution (meters per pixel)
|
|
236
|
+
uniform vec2 u_offset; // Offset in map coordinates
|
|
237
|
+
uniform float u_zoomResolution; // π This will store the resolution passed from JS
|
|
238
|
+
|
|
239
|
+
void main() {
|
|
240
|
+
float x = ((a_position.x - u_offset.x * u_zoomResolution) / u_resolution.x) * 2.0 - 1.0;
|
|
241
|
+
float y = ((a_position.y - u_offset.y * u_zoomResolution) / u_resolution.y) * 2.0 - 1.0;
|
|
242
|
+
|
|
243
|
+
gl_Position = vec4(x, y, 0.0, 1.0);
|
|
244
|
+
v_texCoord = a_texCoord;
|
|
245
|
+
}
|
|
246
|
+
`;
|
|
247
|
+
// νλκ·Έλ¨ΌνΈ μ
°μ΄λ: λ°μ΄ν° μκ°ν
|
|
248
|
+
const fragmentShaderSource = `
|
|
249
|
+
precision highp float;
|
|
250
|
+
|
|
251
|
+
uniform sampler2D u_texture;
|
|
252
|
+
uniform float u_opacity;
|
|
253
|
+
uniform int u_dataType;
|
|
254
|
+
varying vec2 v_texCoord;
|
|
255
|
+
|
|
256
|
+
// μμ κ·ΈλΌλ°μ΄μ
μμ±
|
|
257
|
+
vec3 getColorForData(float value) {
|
|
258
|
+
// κ° λ²μ νμ₯
|
|
259
|
+
value = clamp(value * 1.2, 0.0, 1.0);
|
|
260
|
+
|
|
261
|
+
if (u_dataType == 0) { // μ¨λ
|
|
262
|
+
// νλ(μ μ¨) -> λΉ¨κ°(κ³ μ¨)
|
|
263
|
+
return mix(vec3(0.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), value);
|
|
264
|
+
}
|
|
265
|
+
else if (u_dataType == 1) { // μ΅λ
|
|
266
|
+
// νλμ(건쑰) -> μ§ν νλ(μ΅ν¨)
|
|
267
|
+
return mix(vec3(0.5, 0.5, 1.0), vec3(0.0, 0.0, 0.8), value);
|
|
268
|
+
}
|
|
269
|
+
else if (u_dataType == 2) { // λ°λ
|
|
270
|
+
// λ
Ήμ(μ½ν¨) -> λ
Έλ(κ°ν¨)
|
|
271
|
+
return mix(vec3(0.0, 0.5, 0.0), vec3(1.0, 1.0, 0.0), value);
|
|
272
|
+
}
|
|
273
|
+
else { // κ°μλ
|
|
274
|
+
// ν¬λͺ
(μμ) -> 보λΌ(λ§μ)
|
|
275
|
+
float intensity = value * 1.5;
|
|
276
|
+
return vec3(0.5, 0.0, 0.5) * intensity;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
void main() {
|
|
281
|
+
// ν
μ€μ²μμ λ°μ΄ν° κ°μ Έμ€κΈ°
|
|
282
|
+
vec4 texColor = texture2D(u_texture, v_texCoord);
|
|
283
|
+
|
|
284
|
+
// λ°μ΄ν°κ° μλ κ²½μ° λ¬΄μ
|
|
285
|
+
if (texColor.a < 0.01) {
|
|
286
|
+
discard;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// λ°μ΄ν° μ±λ μ ν
|
|
290
|
+
float value = 0.0;
|
|
291
|
+
if (u_dataType == 0) value = texColor.r; // μ¨λ
|
|
292
|
+
else if (u_dataType == 1) value = texColor.g; // μ΅λ
|
|
293
|
+
else if (u_dataType == 2) value = texColor.b; // λ°λ
|
|
294
|
+
else value = texColor.a; // κ°μλ
|
|
295
|
+
|
|
296
|
+
// λ°μ΄ν° μκ°ν
|
|
297
|
+
vec3 color = getColorForData(value);
|
|
298
|
+
float alpha = u_dataType == 3 ? value * u_opacity : u_opacity;
|
|
299
|
+
|
|
300
|
+
gl_FragColor = vec4(color, alpha);
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
// μ
°μ΄λ μ»΄νμΌ
|
|
304
|
+
const vertexShader = this._compileShader(this.gl.VERTEX_SHADER, vertexShaderSource);
|
|
305
|
+
const fragmentShader = this._compileShader(this.gl.FRAGMENT_SHADER, fragmentShaderSource);
|
|
306
|
+
if (!vertexShader || !fragmentShader)
|
|
307
|
+
return null;
|
|
308
|
+
// νλ‘κ·Έλ¨ μμ± λ° λ§ν¬
|
|
309
|
+
const program = this.gl.createProgram();
|
|
310
|
+
this.gl.attachShader(program, vertexShader);
|
|
311
|
+
this.gl.attachShader(program, fragmentShader);
|
|
312
|
+
this.gl.linkProgram(program);
|
|
313
|
+
if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {
|
|
314
|
+
console.error('WebGL νλ‘κ·Έλ¨ λ§ν¬ μ€ν¨:', this.gl.getProgramInfoLog(program));
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
return program;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* μ
°μ΄λ μ»΄νμΌ
|
|
321
|
+
*/
|
|
322
|
+
_compileShader(type, source) {
|
|
323
|
+
if (!this.gl)
|
|
324
|
+
return null;
|
|
325
|
+
const shader = this.gl.createShader(type);
|
|
326
|
+
this.gl.shaderSource(shader, source);
|
|
327
|
+
this.gl.compileShader(shader);
|
|
328
|
+
if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
|
|
329
|
+
console.error('μ
°μ΄λ μ»΄νμΌ μ€λ₯:', this.gl.getShaderInfoLog(shader));
|
|
330
|
+
this.gl.deleteShader(shader);
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return shader;
|
|
334
|
+
}
|
|
335
|
+
_updateWebGLUniforms(worldExtent, resolution, size, pixelRatio) {
|
|
336
|
+
if (!this.gl || !this.program)
|
|
337
|
+
return;
|
|
338
|
+
const gl = this.gl;
|
|
339
|
+
gl.useProgram(this.program);
|
|
340
|
+
const textureWidth = size[0] * pixelRatio;
|
|
341
|
+
const textureHeight = size[1] * pixelRatio;
|
|
342
|
+
// β
Apply resolution correctly (fixing zoom scaling issue)
|
|
343
|
+
const u_resolution = [
|
|
344
|
+
(worldExtent[2] - worldExtent[0]) / textureWidth,
|
|
345
|
+
(worldExtent[3] - worldExtent[1]) / textureHeight
|
|
346
|
+
];
|
|
347
|
+
// β
Convert u_offset to OpenGL coordinates
|
|
348
|
+
const u_offset = [
|
|
349
|
+
(worldExtent[0] - (worldExtent[2] + worldExtent[0]) / 2) / (worldExtent[2] - worldExtent[0]),
|
|
350
|
+
(worldExtent[1] - (worldExtent[3] + worldExtent[1]) / 2) / (worldExtent[3] - worldExtent[1])
|
|
351
|
+
];
|
|
352
|
+
console.log('π _updateWebGLUniforms called');
|
|
353
|
+
console.log('π’ resolution:', resolution);
|
|
354
|
+
console.log('π’ pixelRatio:', pixelRatio);
|
|
355
|
+
console.log('π’ textureWidth:', textureWidth, 'textureHeight:', textureHeight);
|
|
356
|
+
console.log('π’ u_resolution:', u_resolution);
|
|
357
|
+
console.log('π’ u_offset:', u_offset);
|
|
358
|
+
gl.uniform2fv(gl.getUniformLocation(this.program, 'u_resolution'), u_resolution);
|
|
359
|
+
gl.uniform2fv(gl.getUniformLocation(this.program, 'u_offset'), u_offset);
|
|
360
|
+
gl.uniform1f(gl.getUniformLocation(this.program, 'u_zoomResolution'), resolution); // π Pass resolution!
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
export default WebGLCanvasLayer;
|
|
364
|
+
//# sourceMappingURL=webgl-canvas-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-canvas-layer.js","sourceRoot":"","sources":["../../client/ol-components/webgl-canvas-layer.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,mBAAmB,CAAA;AAC1C,OAAO,iBAAiB,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C;;;GAGG;AACH,MAAM,g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AAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;QACzC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;QACzC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAA;QAC9E,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAA;QAC7C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;QAErC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,YAAY,CAAC,CAAA;QAChF,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;QACxE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAA,CAAC,sBAAsB;IAC1G,CAAC;CACF;AAED,eAAe,gBAAgB,CAAA","sourcesContent":["import ImageLayer from 'ol/layer/Image.js'\nimport ImageCanvasSource from 'ol/source/ImageCanvas.js'\nimport { transformExtent } from 'ol/proj.js'\n\n/**\n * WebGLμ μ¬μ©νμ¬ λ μ¨ λ°μ΄ν° μ΄λ―Έμ§λ₯Ό μ§λμ μ€λ²λ μ΄νλ λ μ΄μ΄\n * μ΄λ―Έμ§μ RGBA μ±λμλ μ¨λ, μ΅λ, λ°λ, κ°μλ λ°μ΄ν°κ° μΈμ½λ©λμ΄ μμ\n */\nclass WebGLCanvasLayer extends ImageLayer<ImageCanvasSource> {\n private canvas: HTMLCanvasElement | null = null\n private gl: WebGLRenderingContext | null = null\n private program: WebGLProgram | null = null\n private texture: WebGLTexture | null = null\n private buffer: WebGLBuffer | null = null\n private imageLoaded: boolean = false\n private pendingRender: boolean = false\n private imageUrl: string\n private dataType: string\n\n /**\n * WebGL μΊλ²μ€ λ μ΄μ΄ μμ±μ\n * @param imageUrl λ μ¨ λ°μ΄ν°κ° μΈμ½λ©λ μ΄λ―Έμ§ URL\n * @param dataType μκ°νν λ°μ΄ν° μ ν (temperature, humidity, wind, precipitation)\n */\n constructor(imageUrl: string, dataType: string = 'temperature') {\n super({\n source: new ImageCanvasSource({\n canvasFunction: (extent, resolution, pixelRatio, size, projection) => {\n this._initializeWebGL(size, pixelRatio)\n\n if (this.gl && this.program) {\n // νμ¬ μ§λ λ·°μ extentλ₯Ό μ§λ¦¬ μ’ν(EPSG:4326)λ‘ λ³ν\n const worldExtent = transformExtent(extent, projection.getCode(), 'EPSG:4326')\n\n // μ΄λ―Έμ§κ° λ‘λλ κ²½μ° λ λλ§\n if (this.imageLoaded && this.texture) {\n this._updateWebGLUniforms(worldExtent, resolution, size, pixelRatio)\n this._renderTexture(worldExtent, size, resolution, pixelRatio)\n } else if (!this.pendingRender) {\n this.pendingRender = true\n this._loadImage(this.imageUrl, worldExtent, size, resolution, pixelRatio)\n }\n }\n\n return this.canvas!\n },\n projection: 'EPSG:3857'\n })\n })\n\n this.imageUrl = imageUrl\n this.dataType = dataType\n this.on('change:visible', () => this.changed())\n }\n\n /**\n * λ°μ΄ν° μκ°ν μ ν λ³κ²½\n */\n updateDataType(type: string) {\n this.dataType = type\n this.changed()\n }\n\n /**\n * 리μμ€ ν΄μ \n */\n dispose() {\n if (this.gl) {\n if (this.buffer) this.gl.deleteBuffer(this.buffer)\n if (this.texture) this.gl.deleteTexture(this.texture)\n if (this.program) this.gl.deleteProgram(this.program)\n }\n super.dispose()\n }\n\n /**\n * μ΄λ―Έμ§ URL μ
λ°μ΄νΈ\n */\n updateImageUrl(newUrl: string) {\n if (this.imageUrl === newUrl) return\n\n this.imageUrl = newUrl\n this.imageLoaded = false\n this.pendingRender = false\n\n if (this.texture && this.gl) {\n this.gl.deleteTexture(this.texture)\n this.texture = null\n }\n\n this.changed()\n }\n\n /**\n * WebGL 컨ν
μ€νΈ μ΄κΈ°ν\n */\n private _initializeWebGL(size: number[], pixelRatio: number = 1) {\n const width = Math.round(size[0] * pixelRatio)\n const height = Math.round(size[1] * pixelRatio)\n\n if (!this.canvas) {\n // μΊλ²μ€ μμ± λ° WebGL μ΄κΈ°ν\n this.canvas = document.createElement('canvas')\n this.canvas.width = width\n this.canvas.height = height\n\n this.gl = this.canvas.getContext('webgl', {\n alpha: true,\n antialias: false,\n depth: false\n })\n\n if (!this.gl) return\n\n this.program = this._createShaderProgram()\n if (this.program) {\n this._initializeBuffers()\n }\n } else if (this.canvas.width !== width || this.canvas.height !== height) {\n // μΊλ²μ€ ν¬κΈ° μ‘°μ \n this.canvas.width = width\n this.canvas.height = height\n if (this.gl) this.gl.viewport(0, 0, width, height)\n }\n }\n\n /**\n * λ²ν
μ€ λ²νΌ μ΄κΈ°ν\n */\n private _initializeBuffers() {\n if (!this.gl) return\n\n // μ¬κ°ν λ²ν
μ€ (μμΉ(x,y) + ν
μ€μ² μ’ν(s,t))\n const vertices = new Float32Array([\n -1,\n -1,\n 0,\n 1, // μ’νλ¨\n 1,\n -1,\n 1,\n 1, // μ°νλ¨\n -1,\n 1,\n 0,\n 0, // μ’μλ¨\n 1,\n 1,\n 1,\n 0 // μ°μλ¨\n ])\n\n this.buffer = this.gl.createBuffer()\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffer)\n this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW)\n }\n\n /**\n * μ΄λ―Έμ§ λ‘λ λ° ν
μ€μ² μμ±\n */\n private _loadImage(url: string, worldExtent: number[], size: number[], resolution: number, pixelRatio: number) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n\n img.onload = () => {\n if (!this.gl) return\n\n try {\n // ν
μ€μ² μμ± λ° μ€μ \n this.texture = this.gl.createTexture()\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture)\n\n // κ²½λ λ°©ν₯μΌλ‘ λν (λ μ§ λ³κ²½μ μ²λ¦¬)\n // this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.REPEAT)\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE)\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE)\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR)\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR)\n\n // ν
μ€μ² λ°μ΄ν° μ
λ‘λ\n this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false) // μνκ° μμ€ λ°©μ§\n this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, img)\n\n this.imageLoaded = true\n this.pendingRender = false\n\n // μ΄λ―Έμ§ λ‘λ ν λ λλ§\n this._renderTexture(worldExtent, size, resolution, pixelRatio)\n this.changed()\n } catch (err) {\n console.error('ν
μ€μ² μμ± μ€ν¨:', err)\n this.pendingRender = false\n }\n }\n\n img.onerror = () => {\n console.error('μ΄λ―Έμ§ λ‘λ μ€ν¨:', url)\n this.pendingRender = false\n }\n\n img.src = url\n }\n\n /**\n * ν
μ€μ² λ λλ§\n */\n private _renderTexture(worldExtent: number[], size: number[], resolution: number, pixelRatio: number) {\n if (!this.gl || !this.program || !this.texture || !this.buffer) return\n\n const gl = this.gl\n const width = Math.round(size[0] * pixelRatio)\n const height = Math.round(size[1] * pixelRatio)\n\n this._updateWebGLUniforms(worldExtent, resolution, size, pixelRatio)\n\n // κΈ°λ³Έ WebGL μν μ€μ \n gl.viewport(0, 0, width, height)\n gl.clearColor(0, 0, 0, 0)\n gl.enable(gl.BLEND)\n gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)\n gl.clear(gl.COLOR_BUFFER_BIT)\n\n // μ
°μ΄λ νλ‘κ·Έλ¨ νμ±ν\n gl.useProgram(this.program)\n\n // ν
μ€μ² λ°μΈλ©\n gl.activeTexture(gl.TEXTURE0)\n gl.bindTexture(gl.TEXTURE_2D, this.texture)\n\n // μ λνΌ μ€μ \n const dataTypeVal = ['temperature', 'humidity', 'wind', 'precipitation'].indexOf(this.dataType)\n\n gl.uniform1i(gl.getUniformLocation(this.program, 'u_texture'), 0)\n gl.uniform1f(gl.getUniformLocation(this.program, 'u_opacity'), 0.8 * pixelRatio)\n gl.uniform1i(gl.getUniformLocation(this.program, 'u_dataType'), dataTypeVal >= 0 ? dataTypeVal : 0)\n gl.uniform4fv(\n gl.getUniformLocation(this.program, 'u_worldExtent'),\n new Float32Array([worldExtent[0], worldExtent[1], worldExtent[2], worldExtent[3]])\n )\n\n // λ²νΌ λ°μΈλ© λ° μμ± μ€μ \n gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer)\n\n const a_position = gl.getAttribLocation(this.program, 'a_position')\n const a_texCoord = gl.getAttribLocation(this.program, 'a_texCoord')\n\n gl.enableVertexAttribArray(a_position)\n gl.enableVertexAttribArray(a_texCoord)\n gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 16, 0)\n gl.vertexAttribPointer(a_texCoord, 2, gl.FLOAT, false, 16, 8)\n\n // μ¬κ°ν λ λλ§\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)\n }\n\n /**\n * μ
°μ΄λ νλ‘κ·Έλ¨ μμ±\n */\n private _createShaderProgram(): WebGLProgram | null {\n if (!this.gl) return null\n\n // λ²ν
μ€ μ
°μ΄λ: μ§λ¦¬ μ’νμ ν
μ€μ² μ’ν κ° λ³ν\n const vertexShaderSource = `\nprecision highp float;\n\nattribute vec4 a_position; // Rectangle coordinates\nattribute vec2 a_texCoord; // Texture coordinates\nvarying vec2 v_texCoord;\n\nuniform vec2 u_resolution; // Resolution (meters per pixel)\nuniform vec2 u_offset; // Offset in map coordinates\nuniform float u_zoomResolution; // π This will store the resolution passed from JS\n\nvoid main() {\n float x = ((a_position.x - u_offset.x * u_zoomResolution) / u_resolution.x) * 2.0 - 1.0;\n float y = ((a_position.y - u_offset.y * u_zoomResolution) / u_resolution.y) * 2.0 - 1.0;\n\n gl_Position = vec4(x, y, 0.0, 1.0);\n v_texCoord = a_texCoord;\n}\n `\n\n // νλκ·Έλ¨ΌνΈ μ
°μ΄λ: λ°μ΄ν° μκ°ν\n const fragmentShaderSource = `\n precision highp float;\n \n uniform sampler2D u_texture;\n uniform float u_opacity;\n uniform int u_dataType;\n varying vec2 v_texCoord;\n \n // μμ κ·ΈλΌλ°μ΄μ
μμ±\n vec3 getColorForData(float value) {\n // κ° λ²μ νμ₯\n value = clamp(value * 1.2, 0.0, 1.0);\n \n if (u_dataType == 0) { // μ¨λ\n // νλ(μ μ¨) -> λΉ¨κ°(κ³ μ¨)\n return mix(vec3(0.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), value);\n } \n else if (u_dataType == 1) { // μ΅λ\n // νλμ(건쑰) -> μ§ν νλ(μ΅ν¨)\n return mix(vec3(0.5, 0.5, 1.0), vec3(0.0, 0.0, 0.8), value);\n }\n else if (u_dataType == 2) { // λ°λ\n // λ
Ήμ(μ½ν¨) -> λ
Έλ(κ°ν¨)\n return mix(vec3(0.0, 0.5, 0.0), vec3(1.0, 1.0, 0.0), value);\n }\n else { // κ°μλ\n // ν¬λͺ
(μμ) -> 보λΌ(λ§μ)\n float intensity = value * 1.5;\n return vec3(0.5, 0.0, 0.5) * intensity;\n }\n }\n \n void main() {\n // ν
μ€μ²μμ λ°μ΄ν° κ°μ Έμ€κΈ°\n vec4 texColor = texture2D(u_texture, v_texCoord);\n \n // λ°μ΄ν°κ° μλ κ²½μ° λ¬΄μ\n if (texColor.a < 0.01) {\n discard;\n }\n \n // λ°μ΄ν° μ±λ μ ν\n float value = 0.0;\n if (u_dataType == 0) value = texColor.r; // μ¨λ\n else if (u_dataType == 1) value = texColor.g; // μ΅λ\n else if (u_dataType == 2) value = texColor.b; // λ°λ\n else value = texColor.a; // κ°μλ\n \n // λ°μ΄ν° μκ°ν\n vec3 color = getColorForData(value);\n float alpha = u_dataType == 3 ? value * u_opacity : u_opacity;\n \n gl_FragColor = vec4(color, alpha);\n }\n `\n\n // μ
°μ΄λ μ»΄νμΌ\n const vertexShader = this._compileShader(this.gl.VERTEX_SHADER, vertexShaderSource)\n const fragmentShader = this._compileShader(this.gl.FRAGMENT_SHADER, fragmentShaderSource)\n\n if (!vertexShader || !fragmentShader) return null\n\n // νλ‘κ·Έλ¨ μμ± λ° λ§ν¬\n const program = this.gl.createProgram()!\n this.gl.attachShader(program, vertexShader)\n this.gl.attachShader(program, fragmentShader)\n this.gl.linkProgram(program)\n\n if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {\n console.error('WebGL νλ‘κ·Έλ¨ λ§ν¬ μ€ν¨:', this.gl.getProgramInfoLog(program))\n return null\n }\n\n return program\n }\n\n /**\n * μ
°μ΄λ μ»΄νμΌ\n */\n private _compileShader(type: number, source: string): WebGLShader | null {\n if (!this.gl) return null\n\n const shader = this.gl.createShader(type)!\n this.gl.shaderSource(shader, source)\n this.gl.compileShader(shader)\n\n if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {\n console.error('μ
°μ΄λ μ»΄νμΌ μ€λ₯:', this.gl.getShaderInfoLog(shader))\n this.gl.deleteShader(shader)\n return null\n }\n\n return shader\n }\n\n private _updateWebGLUniforms(worldExtent: number[], resolution: number, size: number[], pixelRatio: number) {\n if (!this.gl || !this.program) return\n\n const gl = this.gl\n gl.useProgram(this.program)\n\n const textureWidth = size[0] * pixelRatio\n const textureHeight = size[1] * pixelRatio\n\n // β
Apply resolution correctly (fixing zoom scaling issue)\n const u_resolution = [\n (worldExtent[2] - worldExtent[0]) / textureWidth,\n (worldExtent[3] - worldExtent[1]) / textureHeight\n ]\n\n // β
Convert u_offset to OpenGL coordinates\n const u_offset = [\n (worldExtent[0] - (worldExtent[2] + worldExtent[0]) / 2) / (worldExtent[2] - worldExtent[0]),\n (worldExtent[1] - (worldExtent[3] + worldExtent[1]) / 2) / (worldExtent[3] - worldExtent[1])\n ]\n\n console.log('π _updateWebGLUniforms called')\n console.log('π’ resolution:', resolution)\n console.log('π’ pixelRatio:', pixelRatio)\n console.log('π’ textureWidth:', textureWidth, 'textureHeight:', textureHeight)\n console.log('π’ u_resolution:', u_resolution)\n console.log('π’ u_offset:', u_offset)\n\n gl.uniform2fv(gl.getUniformLocation(this.program, 'u_resolution'), u_resolution)\n gl.uniform2fv(gl.getUniformLocation(this.program, 'u_offset'), u_offset)\n gl.uniform1f(gl.getUniformLocation(this.program, 'u_zoomResolution'), resolution) // π Pass resolution!\n }\n}\n\nexport default WebGLCanvasLayer\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import BaseLayer from 'ol/layer/Base.js';
|
|
2
|
+
import Map from 'ol/Map.js';
|
|
3
|
+
import { WeatherLayerType } from '@hyperviz/weather';
|
|
4
|
+
export declare class WindDataTileLayer {
|
|
5
|
+
private source;
|
|
6
|
+
private layer;
|
|
7
|
+
private map;
|
|
8
|
+
private useEnhancedColors;
|
|
9
|
+
private __disposed;
|
|
10
|
+
/**
|
|
11
|
+
* λ°λ λ°μ΄ν° νμΌ λ μ΄μ΄ μμ±
|
|
12
|
+
* @param options μ΅μ
κ°μ²΄
|
|
13
|
+
*/
|
|
14
|
+
constructor(options?: {
|
|
15
|
+
useEnhancedColors?: boolean;
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* νμΌ λ°μ΄ν° λ‘λ© ν¨μ
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
private _tileLoader;
|
|
22
|
+
/**
|
|
23
|
+
* λ μ΄μ΄ νμ
λ°ν (νΈνμ±μ©)
|
|
24
|
+
*/
|
|
25
|
+
getType(): WeatherLayerType;
|
|
26
|
+
/**
|
|
27
|
+
* ν₯μλ μμ λ§€ν μ¬μ© μ¬λΆ μ€μ
|
|
28
|
+
*/
|
|
29
|
+
setUseEnhancedColors(use: boolean): void;
|
|
30
|
+
/**
|
|
31
|
+
* OpenLayers λ μ΄μ΄ κ°μ²΄ μμ± λλ λ°ν
|
|
32
|
+
*/
|
|
33
|
+
createLayer(): BaseLayer;
|
|
34
|
+
/**
|
|
35
|
+
* μμ² μ€μΈ λ°μ΄ν° λ‘λ μ€λ¨ λ° μμ€ λ¬΄ν¨ν
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private _clearSourceData;
|
|
39
|
+
/**
|
|
40
|
+
* λ μ΄μ΄λ₯Ό λ§΅μ μΆκ°
|
|
41
|
+
*/
|
|
42
|
+
addToMap(map: Map): void;
|
|
43
|
+
/**
|
|
44
|
+
* λ μ΄μ΄λ₯Ό λ§΅μμ μ κ±°
|
|
45
|
+
*/
|
|
46
|
+
removeFromMap(): void;
|
|
47
|
+
/**
|
|
48
|
+
* λ μ΄μ΄ κ΄λ ¨ 리μμ€ ν΄μ
|
|
49
|
+
*/
|
|
50
|
+
dispose(): void;
|
|
51
|
+
/**
|
|
52
|
+
* λ μ΄μ΄ μ
λ°μ΄νΈ μμ² (λ°μ΄ν° λ³κ²½ μ)
|
|
53
|
+
*/
|
|
54
|
+
updateLayer(): void;
|
|
55
|
+
/**
|
|
56
|
+
* λ°μ΄ν° μ€μ λ©μλ (νΈνμ±μ©, μ€μ λ°μ΄ν°λ PNG μ΄λ―Έμ§μ κ³ μ λ¨)
|
|
57
|
+
*/
|
|
58
|
+
setWeatherData(data: any): void;
|
|
59
|
+
}
|