mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
fix(cctv): count a lone camera in the marker it sits against
A ground cell with one camera always drew its icon, so at some zooms a camera poked out from under a count marker with its own callout. An icon closer than the merge gap to a count marker now joins that marker: the count grows by one and the icon, its callout and its card are not drawn. Two lone cameras with no count beside them stay two icons, and the active camera always keeps its own icon.
This commit is contained in:
1 parent
c536d22ff0
commit
65942008bf
8 files changed
+125
-24
No files matched your search
@@ -19,6 +19,7 @@ import {
|
||||
COUNT_GLYPH_PADDING_PX,
|
||||
COUNT_LABEL_DROP,
|
||||
COUNT_MERGE_GAP_PX,
|
||||
COUNT_SINGLE_ICON_PX,
|
||||
COUNT_MERGE_PASSES,
|
||||
} from './policy.js';
|
||||
|
||||
@@ -28,6 +29,10 @@ const GLYPH_ASPECT = 1.5;
|
||||
const RING_PX = 2;
|
||||
const RIM_PX = 1;
|
||||
const STROKE_INSET = RIM_PX + RING_PX / 2;
|
||||
const SINGLE_ICON = Object.freeze({
|
||||
width: COUNT_SINGLE_ICON_PX,
|
||||
height: COUNT_SINGLE_ICON_PX,
|
||||
});
|
||||
|
||||
/** Apply the billboard's RGB tint to the sprite and find its painted bounds. */
|
||||
function rasterizeGlyph(canvas, image, size, dpr, color) {
|
||||
@@ -198,9 +203,9 @@ export function createCountMarkers(
|
||||
|
||||
/** Reuse marker slots in ground-key order, and invalidate only changed frames. */
|
||||
function update(cells, project) {
|
||||
let visible = cells
|
||||
.filter((cell) => cell.count > 1)
|
||||
.sort((a, b) => a.key.localeCompare(b.key));
|
||||
// Lone cameras take part so that one beside a count joins it.
|
||||
let visible = cells.slice().sort((a, b) => a.key.localeCompare(b.key));
|
||||
const footprint = (count) => (count > 1 ? sizeFor(count) : SINGLE_ICON);
|
||||
for (
|
||||
let pass = 0;
|
||||
pass < COUNT_MERGE_PASSES && visible.length > 1;
|
||||
@@ -209,12 +214,17 @@ export function createCountMarkers(
|
||||
const merged = mergeCountCells(
|
||||
visible,
|
||||
project,
|
||||
sizeFor,
|
||||
footprint,
|
||||
COUNT_MERGE_GAP_PX,
|
||||
);
|
||||
if (merged.length === visible.length) break;
|
||||
visible = merged;
|
||||
}
|
||||
// A lone camera that is no longer its own entry now counts in a marker.
|
||||
const apart = new Set(visible);
|
||||
for (const cell of cells)
|
||||
if (cell.count === 1) cell.absorbed = !apart.has(cell);
|
||||
visible = visible.filter((cell) => cell.count > 1);
|
||||
let changed = visible.length !== markers.length;
|
||||
for (let i = 0; i < visible.length; i++) {
|
||||
const cell = visible[i];
|
||||
|
||||
@@ -104,6 +104,10 @@ export const COUNT_LABEL_DROP = 0.2;
|
||||
// Minimum gap between the outer rims of two separate markers.
|
||||
export const COUNT_MERGE_GAP_PX = 4;
|
||||
|
||||
// On-screen size of a lone camera's icon when testing it against a count
|
||||
// marker: an icon closer than the merge gap joins that count.
|
||||
export const COUNT_SINGLE_ICON_PX = 24;
|
||||
|
||||
// Recheck moved centres and wider labels while bounding work on motion ticks.
|
||||
export const COUNT_MERGE_PASSES = 3;
|
||||
|
||||
|
||||
@@ -435,23 +435,26 @@ export function createRendering({
|
||||
cell.rank = rank;
|
||||
}
|
||||
}
|
||||
// Marks each lone camera that a count marker beside it has taken in.
|
||||
layerState._counts?.update(visibleCells, project);
|
||||
for (const cell of visibleCells) {
|
||||
const record = cell.winner;
|
||||
picker.push(record);
|
||||
record.pickerPass = pass;
|
||||
if (cell.count === 1) {
|
||||
if (cell.count === 1 && !cell.absorbed) {
|
||||
record.viewPass = pass;
|
||||
shown.push(record);
|
||||
}
|
||||
}
|
||||
layerState._counts?.update(visibleCells, project);
|
||||
const writes = [];
|
||||
let coverageChanged = false;
|
||||
let cardsChanged = false;
|
||||
for (const record of layerState._records) {
|
||||
const cell = record.viewCell;
|
||||
record.viewCell = null;
|
||||
const grouped = Boolean(cell?.winner && cell.count > 1);
|
||||
const grouped = Boolean(
|
||||
cell?.winner && (cell.count > 1 || cell.absorbed),
|
||||
);
|
||||
if (grouped !== !!record.viewGrouped) {
|
||||
const id = record.camera.id;
|
||||
coverageChanged ||= layerState._coverageCohort?.has(id);
|
||||
|
||||
Reference in new issue
Block a user