mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Draw submarine cables through the renderer's draw and camera ports
Cable lines, landing pins, polygon fills, reference stems and reference points are now five draw sets per layer (submarine-cables:N:lines and so on) instead of GeoJSON data sources and entities. Clicks resolve through the draw hit; flights and the sweep's eye go through the camera port. The layer keeps the styling the GeoJSON loader gave it: cable colours, widths and alphas, simplestyle stroke, fill and marker properties, fills that keep the source's alpha, raised polygons at their heights, the default pin image, and features without a reference drawn but neither picked nor culled. Lines are densified along rhumb lines at the renderer's own granularity, so the draped geodesic arcs land on the same vertices the rhumb-line polylines did. Supporting pieces: - geo/rhumb, geo/horizon and geo/geodesic port the default renderer's rhumb line, ellipsoidal occluder and Vincenty inverse; the stub renderer now uses the shared horizon test and Vincenty inverse instead of its own copies. render/color gains cssColor, which reads CSS colours as the renderer does (hex, rgb, hsl; not named colours). - The Cesium draw port changes a line in place when only whether it shows changes (draped, on its ground primitive, waiting for it to be ready rather than restarting its build) or where an undraped line runs; anything else still rebuilds. Icon sets honour their blend. Ingestion, interaction, overlay, policy, rendering, state and surface no longer import Cesium and leave the allow-list. Pins are culled at the horizon each frame by the draw port instead of on the sweep, and marker-symbol glyphs are not drawn inside pins.
This commit is contained in:
1 parent
f24b66d80d
commit
e74c7c1f44
29 files changed
+2260
-2064
No files matched your search
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* The map pin GeoJSON points have always been drawn with: a rounded box on
|
||||
* a pointed stem, filled with the pin's colour and stroked a brighter
|
||||
* shade, drawn the way the default renderer's pin builder draws it (its
|
||||
* path, scaled from a 24-pixel design).
|
||||
*/
|
||||
|
||||
/** A colour byte as the default renderer writes it into CSS. */
|
||||
const byte = (value) => (value === 1 ? 255 : (value * 256) | 0);
|
||||
|
||||
/** A renderer colour `[r, g, b, a]` as the default renderer writes it in CSS. */
|
||||
function css([r, g, b, a = 1]) {
|
||||
return a === 1
|
||||
? `rgb(${byte(r)},${byte(g)},${byte(b)})`
|
||||
: `rgba(${byte(r)},${byte(g)},${byte(b)},${a})`;
|
||||
}
|
||||
|
||||
/** The colour brightened by `amount` (0..1) toward white, alpha kept. */
|
||||
function brighten([r, g, b, a = 1], amount) {
|
||||
const keep = 1 - amount;
|
||||
return [1 - (1 - r) * keep, 1 - (1 - g) * keep, 1 - (1 - b) * keep, a];
|
||||
}
|
||||
|
||||
/** The default renderer's pin outline (`PinBuilder`), on a 24 px square. */
|
||||
const PIN_PATH =
|
||||
'M6.72 0.422L17.28 0.422C18.553 0.422 19.577 1.758 19.577 3.415' +
|
||||
'L19.577 10.973C19.577 12.63 18.553 13.966 17.282 13.966L14.386 14.008' +
|
||||
'L11.826 23.578L9.614 14.008L6.719 13.965' +
|
||||
'C5.446 13.983 4.422 12.629 4.422 10.972L4.422 3.416' +
|
||||
'C4.423 1.76 5.447 0.423 6.718 0.423Z';
|
||||
|
||||
const pins = new Map();
|
||||
|
||||
/**
|
||||
* The pin image for a colour and size (pixels square), one per look: a
|
||||
* canvas where there is a document, else the same pin as SVG.
|
||||
* @param {[number, number, number, number]} color Renderer colour.
|
||||
* @param {number} size
|
||||
* @returns {import('../../render/contract/draw').ImageRef}
|
||||
*/
|
||||
export function cablePinImage(color, size) {
|
||||
const fill = css(color);
|
||||
const stroke = css(brighten(color, 0.6));
|
||||
const key = `cable-pin:${fill}:${stroke}:${size}`;
|
||||
let image = pins.get(key);
|
||||
if (image) return image;
|
||||
if (typeof document !== 'undefined' && document.createElement) {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = size;
|
||||
canvas.height = size;
|
||||
const context = canvas.getContext('2d');
|
||||
context.save();
|
||||
context.scale(size / 24, size / 24);
|
||||
context.fillStyle = fill;
|
||||
context.strokeStyle = stroke;
|
||||
context.lineWidth = 0.846;
|
||||
const path = new Path2D(PIN_PATH);
|
||||
context.fill(path);
|
||||
context.stroke(path);
|
||||
context.restore();
|
||||
image = { canvas, key };
|
||||
} else {
|
||||
image = {
|
||||
svg:
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24">` +
|
||||
`<path d="${PIN_PATH}" fill="${fill}" stroke="${stroke}" stroke-width="0.846"/></svg>`,
|
||||
};
|
||||
}
|
||||
pins.set(key, image);
|
||||
return image;
|
||||
}
|
||||
Reference in new issue
Block a user