159 lines
6.3 KiB
TypeScript
159 lines
6.3 KiB
TypeScript
|
|
import {
|
||
|
|
LEGACY_CODE_COLORS_RGB,
|
||
|
|
OVERLAY_RGB,
|
||
|
|
rgba as rgbaCss,
|
||
|
|
} from '../../shared/lib/map/palette';
|
||
|
|
import type { BathyZoomRange } from './types';
|
||
|
|
|
||
|
|
// ── Re-export palette aliases used throughout Map3D ──
|
||
|
|
|
||
|
|
export const LEGACY_CODE_COLORS = LEGACY_CODE_COLORS_RGB;
|
||
|
|
|
||
|
|
const OVERLAY_PAIR_NORMAL_RGB = OVERLAY_RGB.pairNormal;
|
||
|
|
const OVERLAY_PAIR_WARN_RGB = OVERLAY_RGB.pairWarn;
|
||
|
|
const OVERLAY_FC_TRANSFER_RGB = OVERLAY_RGB.fcTransfer;
|
||
|
|
const OVERLAY_FLEET_RANGE_RGB = OVERLAY_RGB.fleetRange;
|
||
|
|
const OVERLAY_SUSPICIOUS_RGB = OVERLAY_RGB.suspicious;
|
||
|
|
|
||
|
|
// ── Ship icon mapping (Deck.gl IconLayer) ──
|
||
|
|
|
||
|
|
export const SHIP_ICON_MAPPING = {
|
||
|
|
ship: {
|
||
|
|
x: 0,
|
||
|
|
y: 0,
|
||
|
|
width: 128,
|
||
|
|
height: 128,
|
||
|
|
anchorX: 64,
|
||
|
|
anchorY: 64,
|
||
|
|
mask: true,
|
||
|
|
},
|
||
|
|
} as const;
|
||
|
|
|
||
|
|
// ── Ship constants ──
|
||
|
|
|
||
|
|
export const ANCHOR_SPEED_THRESHOLD_KN = 1;
|
||
|
|
export const ANCHORED_SHIP_ICON_ID = 'ship-globe-anchored-icon';
|
||
|
|
|
||
|
|
// ── Geometry constants ──
|
||
|
|
|
||
|
|
export const DEG2RAD = Math.PI / 180;
|
||
|
|
export const RAD2DEG = 180 / Math.PI;
|
||
|
|
export const EARTH_RADIUS_M = 6371008.8; // MapLibre's `earthRadius`
|
||
|
|
export const GLOBE_ICON_HEADING_OFFSET_DEG = 0;
|
||
|
|
|
||
|
|
// ── Ship color constants ──
|
||
|
|
|
||
|
|
export const MAP_SELECTED_SHIP_RGB: [number, number, number] = [34, 211, 238];
|
||
|
|
export const MAP_HIGHLIGHT_SHIP_RGB: [number, number, number] = [245, 158, 11];
|
||
|
|
export const MAP_DEFAULT_SHIP_RGB: [number, number, number] = [100, 116, 139];
|
||
|
|
|
||
|
|
// ── Flat map icon sizes ──
|
||
|
|
|
||
|
|
export const FLAT_SHIP_ICON_SIZE = 19;
|
||
|
|
export const FLAT_SHIP_ICON_SIZE_SELECTED = 28;
|
||
|
|
export const FLAT_SHIP_ICON_SIZE_HIGHLIGHTED = 25;
|
||
|
|
export const FLAT_LEGACY_HALO_RADIUS = 14;
|
||
|
|
export const FLAT_LEGACY_HALO_RADIUS_SELECTED = 18;
|
||
|
|
export const FLAT_LEGACY_HALO_RADIUS_HIGHLIGHTED = 16;
|
||
|
|
export const EMPTY_MMSI_SET = new Set<number>();
|
||
|
|
|
||
|
|
// ── Deck.gl view ID ──
|
||
|
|
|
||
|
|
export const DECK_VIEW_ID = 'mapbox';
|
||
|
|
|
||
|
|
// ── Depth params ──
|
||
|
|
|
||
|
|
export const DEPTH_DISABLED_PARAMS = {
|
||
|
|
depthCompare: 'always',
|
||
|
|
depthWriteEnabled: false,
|
||
|
|
} as const;
|
||
|
|
|
||
|
|
export const GLOBE_OVERLAY_PARAMS = {
|
||
|
|
depthCompare: 'less-equal',
|
||
|
|
depthWriteEnabled: false,
|
||
|
|
} as const;
|
||
|
|
|
||
|
|
// ── Deck.gl color constants (avoid per-object allocations inside accessors) ──
|
||
|
|
|
||
|
|
export const PAIR_RANGE_NORMAL_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 110,
|
||
|
|
];
|
||
|
|
export const PAIR_RANGE_WARN_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 170,
|
||
|
|
];
|
||
|
|
export const PAIR_LINE_NORMAL_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 85,
|
||
|
|
];
|
||
|
|
export const PAIR_LINE_WARN_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 220,
|
||
|
|
];
|
||
|
|
export const FC_LINE_NORMAL_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_FC_TRANSFER_RGB[0], OVERLAY_FC_TRANSFER_RGB[1], OVERLAY_FC_TRANSFER_RGB[2], 200,
|
||
|
|
];
|
||
|
|
export const FC_LINE_SUSPICIOUS_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_SUSPICIOUS_RGB[0], OVERLAY_SUSPICIOUS_RGB[1], OVERLAY_SUSPICIOUS_RGB[2], 220,
|
||
|
|
];
|
||
|
|
export const FLEET_RANGE_LINE_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 140,
|
||
|
|
];
|
||
|
|
export const FLEET_RANGE_FILL_DECK: [number, number, number, number] = [
|
||
|
|
OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 6,
|
||
|
|
];
|
||
|
|
|
||
|
|
// ── Highlighted variants ──
|
||
|
|
|
||
|
|
export const PAIR_RANGE_NORMAL_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 200,
|
||
|
|
];
|
||
|
|
export const PAIR_RANGE_WARN_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 240,
|
||
|
|
];
|
||
|
|
export const PAIR_LINE_NORMAL_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 245,
|
||
|
|
];
|
||
|
|
export const PAIR_LINE_WARN_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 245,
|
||
|
|
];
|
||
|
|
export const FC_LINE_NORMAL_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_FC_TRANSFER_RGB[0], OVERLAY_FC_TRANSFER_RGB[1], OVERLAY_FC_TRANSFER_RGB[2], 235,
|
||
|
|
];
|
||
|
|
export const FC_LINE_SUSPICIOUS_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_SUSPICIOUS_RGB[0], OVERLAY_SUSPICIOUS_RGB[1], OVERLAY_SUSPICIOUS_RGB[2], 245,
|
||
|
|
];
|
||
|
|
export const FLEET_RANGE_LINE_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 220,
|
||
|
|
];
|
||
|
|
export const FLEET_RANGE_FILL_DECK_HL: [number, number, number, number] = [
|
||
|
|
OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 42,
|
||
|
|
];
|
||
|
|
|
||
|
|
// ── MapLibre overlay colors ──
|
||
|
|
|
||
|
|
export const PAIR_LINE_NORMAL_ML = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.55);
|
||
|
|
export const PAIR_LINE_WARN_ML = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.95);
|
||
|
|
export const PAIR_LINE_NORMAL_ML_HL = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.95);
|
||
|
|
export const PAIR_LINE_WARN_ML_HL = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.98);
|
||
|
|
|
||
|
|
export const PAIR_RANGE_NORMAL_ML = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.45);
|
||
|
|
export const PAIR_RANGE_WARN_ML = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.75);
|
||
|
|
export const PAIR_RANGE_NORMAL_ML_HL = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.92);
|
||
|
|
export const PAIR_RANGE_WARN_ML_HL = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.92);
|
||
|
|
|
||
|
|
export const FC_LINE_NORMAL_ML = rgbaCss(OVERLAY_FC_TRANSFER_RGB, 0.92);
|
||
|
|
export const FC_LINE_SUSPICIOUS_ML = rgbaCss(OVERLAY_SUSPICIOUS_RGB, 0.95);
|
||
|
|
export const FC_LINE_NORMAL_ML_HL = rgbaCss(OVERLAY_FC_TRANSFER_RGB, 0.98);
|
||
|
|
export const FC_LINE_SUSPICIOUS_ML_HL = rgbaCss(OVERLAY_SUSPICIOUS_RGB, 0.98);
|
||
|
|
|
||
|
|
export const FLEET_FILL_ML = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.02);
|
||
|
|
export const FLEET_FILL_ML_HL = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.16);
|
||
|
|
export const FLEET_LINE_ML = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.65);
|
||
|
|
export const FLEET_LINE_ML_HL = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.95);
|
||
|
|
|
||
|
|
// ── Bathymetry zoom ranges ──
|
||
|
|
|
||
|
|
export const BATHY_ZOOM_RANGES: BathyZoomRange[] = [
|
||
|
|
{ id: 'bathymetry-fill', mercator: [6, 24], globe: [8, 24] },
|
||
|
|
{ id: 'bathymetry-borders', mercator: [6, 24], globe: [8, 24] },
|
||
|
|
{ id: 'bathymetry-borders-major', mercator: [4, 24], globe: [8, 24] },
|
||
|
|
];
|