mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
Add a Global (RainViewer) option to Rain radar beside the US MRMS radar. The proxy pins RainViewer's tile host, validates frames and Web Mercator tile coordinates, and limits upstream tile requests to 80 a minute. Globe basemaps draw the tiles; on 3D Tiles the shell composes them into one equirectangular image per frame and detail window. Co-authored-by: Sandiv Dathunarachchi <[email protected]>
13 lines
475 B
JavaScript
13 lines
475 B
JavaScript
/** Admit at most 80 requests in a rolling minute; return retry seconds or zero.
|
|
* Call only at the upstream boundary, after cache lookup and coalescing. */
|
|
export function createRainViewerGovernor() {
|
|
const attempts = [];
|
|
return (now) => {
|
|
while (attempts.length && now - attempts[0] >= 60_000) attempts.shift();
|
|
if (attempts.length >= 80)
|
|
return Math.max(1, Math.ceil((60_000 - (now - attempts[0])) / 1000));
|
|
attempts.push(now);
|
|
return 0;
|
|
};
|
|
}
|