continue work on glrender
This commit is contained in:
parent
3c94d3a32a
commit
d645f9e197
2 changed files with 18 additions and 17 deletions
|
@ -157,11 +157,11 @@
|
|||
popup.remove();
|
||||
});
|
||||
|
||||
let r = await fetch('http://localhost:3000/v2/nexrad/l2/KLZK/1/REF');
|
||||
let r = await fetch('http://localhost:3000/v2/nexrad/l2/KLWX/1/REF');
|
||||
const buf = await r.arrayBuffer();
|
||||
|
||||
const container = CifContainer.fromBinary(new Uint8Array(buf));
|
||||
console.log('wxrad http://localhost:3000/v2/nexrad/l2/KLZK/1/REF: ', container);
|
||||
console.log('wxrad http://localhost:3000/v2/nexrad/l2/KLWX/1/REF: ', container);
|
||||
if (container.messageType.oneofKind == 'digitalRadarData') {
|
||||
const drd: DigitalRadarData = container.messageType.digitalRadarData;
|
||||
|
||||
|
@ -192,9 +192,9 @@
|
|||
|
||||
*/
|
||||
gl.useProgram(this.program);
|
||||
const lat = 34.8365;
|
||||
const lat = 38.976111;
|
||||
gl.uniform1f(gl.getUniformLocation(this.program, 'radarLat'), lat);
|
||||
const long = -92.262194;
|
||||
const long = -77.4875;
|
||||
gl.uniform1f(gl.getUniformLocation(this.program, 'radarLng'), long);
|
||||
|
||||
const radar_range_maximum = 560; // ish km
|
||||
|
@ -269,7 +269,8 @@
|
|||
}
|
||||
}
|
||||
const rdata: number[] = [];
|
||||
for (const radial of drd.radials) {
|
||||
for (let i = 0; i < drd.radials.length; i++) {
|
||||
const radial = drd.radials[drd.radials.length - 1 - i];
|
||||
for (const tdata of radial.product.data.data) {
|
||||
rdata.push(scaleMomentData(radial, tdata));
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ LocateRadialResult locateRadial(float forAzimuth) {
|
|||
for (int i = 0; i < azimuthCount; i++) {
|
||||
float angle = azimuthAngles[i];
|
||||
float this_dist = abs(angle - forAzimuth);
|
||||
//if (this_dist > azimuthSpacing) {
|
||||
// continue;
|
||||
//}
|
||||
if (this_dist > azimuthSpacing) {
|
||||
continue;
|
||||
}
|
||||
if (foundAnything) {
|
||||
if (this_dist < bestDistance) {
|
||||
closestRadial = i;
|
||||
|
@ -70,24 +70,24 @@ void main() {
|
|||
return;
|
||||
}
|
||||
|
||||
float R = 6371.0 * pow(10.0, 3.0); // meters
|
||||
float R = 6371000.0; // meters
|
||||
float phi1 = radians(radarLat);
|
||||
float phi2 = radians(lat);
|
||||
float lambda1 = radians(radarLng);
|
||||
float lambda2 = radians(lng);
|
||||
|
||||
float deltaPhi = radians(lat - radarLat);
|
||||
float lambda1 = radians(radarLng);
|
||||
float deltaLambda = radians(lng - radarLng);
|
||||
float a = sin(deltaPhi / 2.0) * sin(deltaPhi / 2.0) + cos(phi1) * cos(phi2) * sin(deltaLambda / 2.0) * sin(deltaLambda / 2.0);
|
||||
float c = 2.0 * atan(sqrt(a), sqrt(1.0 - a));
|
||||
float d = R * c; // meters
|
||||
float d_m = acos(sin(phi1) * sin(phi2) + cos(phi1) * cos(phi2) * cos(deltaLambda)) * R;
|
||||
|
||||
float d_m = d;
|
||||
//fragColor = vec4(d_m / 459296.0, 0.0, 0.0, 1.0);
|
||||
//return;
|
||||
|
||||
float y = sin(lambda2 - lambda1) * cos(phi2);
|
||||
float x = cos(phi1) * sin(phi2) - sin(phi1) * cos(phi2) * cos(lambda2 - lambda1);
|
||||
float theta = atan(y, x);
|
||||
float azimuth = (theta * 180.0 / PI + 360.0); // degrees
|
||||
float azimuth = mod((theta * 180.0 / PI + 360.0), 360.0);
|
||||
|
||||
fragColor = vec4(azimuth / 360.0, 0.0, 0.0, 1.0);
|
||||
return;
|
||||
|
||||
LocateRadialResult maybeRadial = locateRadial(azimuth);
|
||||
if (!maybeRadial.didFindRadial) {
|
||||
|
|
Loading…
Add table
Reference in a new issue