mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor(street-level): remove the remaining duplicated code and fakes
A duplicate scan of every module the PR adds (repeated 4-line blocks, normalised) after gekh's dedup round left these: - glyphs.js: the cone, ring and position glyphs share cachedGlyph(), wedge(), ring() and dot(). Checked with a recording canvas: all 20 draw calls keep the same path and fill/stroke state, so the glyphs are pixel-identical. - panelPositionControls.js: one placeAt() for the three places that pin a panel's top-left corner as a fixed window. - tiles.js: one warn() for the three background-failure logs. - Tests: src/testSupport/streetLevelFakes.mjs holds the provider snapshot (uiState + presentation tests), the stand-in provider (core + controls tests) and one real-ray pinhole camera (view + coverage tests, which had each written their own). The coverage line-of-sight test still fails when refresh() stops passing its focus. - qa-street-level.mjs: one waitForCoverage() for the five copies of the "on, drawn, settled, not key-gated" wait. No behaviour change: unit 5862 pass, fixture gate 16/16, panel gate 5/5. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
d70f468781
commit
c2f1b54d00
12 files changed
+281
-345
No files matched your search
@@ -72,6 +72,14 @@ function fitWindowExtent(value, minimum, viewportExtent) {
|
||||
* Only a mouse or pen lifts and resizes a portable panel. On a phone the
|
||||
* rail is a scroll container, so a finger on a header is a swipe.
|
||||
*/
|
||||
/** Pin a panel's top-left corner at (left, top) as a fixed window would sit. */
|
||||
function placeAt(panelEl, left, top) {
|
||||
panelEl.style.left = `${left}px`;
|
||||
panelEl.style.top = `${top}px`;
|
||||
panelEl.style.right = 'auto';
|
||||
panelEl.style.bottom = 'auto';
|
||||
}
|
||||
|
||||
function isPrecisePointer(event) {
|
||||
const pointerType = event.pointerType || 'mouse';
|
||||
return pointerType === 'mouse' || pointerType === 'pen';
|
||||
@@ -433,10 +441,7 @@ export class PanelPositionControls {
|
||||
Math.round(pos.top),
|
||||
panelEl,
|
||||
);
|
||||
panelEl.style.left = `${left}px`;
|
||||
panelEl.style.top = `${top}px`;
|
||||
panelEl.style.right = 'auto';
|
||||
panelEl.style.bottom = 'auto';
|
||||
placeAt(panelEl, left, top);
|
||||
if (panelId === 'pp-toggles') {
|
||||
this._pinPanelToRight(panelEl);
|
||||
}
|
||||
@@ -513,10 +518,7 @@ export class PanelPositionControls {
|
||||
*/
|
||||
_liftPanelOut(panelId, panelEl, rect = panelEl.getBoundingClientRect()) {
|
||||
if (panelEl.classList.contains('panel-floating')) return false;
|
||||
panelEl.style.left = `${Math.round(rect.left)}px`;
|
||||
panelEl.style.top = `${Math.round(rect.top)}px`;
|
||||
panelEl.style.right = 'auto';
|
||||
panelEl.style.bottom = 'auto';
|
||||
placeAt(panelEl, Math.round(rect.left), Math.round(rect.top));
|
||||
if (!panelEl.classList.contains('collapsed')) {
|
||||
panelEl.style.width = `${Math.round(rect.width)}px`;
|
||||
}
|
||||
@@ -580,10 +582,7 @@ export class PanelPositionControls {
|
||||
const offsetX = event.clientX - rect.left;
|
||||
const offsetY = event.clientY - rect.top;
|
||||
|
||||
panelEl.style.left = `${rect.left}px`;
|
||||
panelEl.style.top = `${rect.top}px`;
|
||||
panelEl.style.right = 'auto';
|
||||
panelEl.style.bottom = 'auto';
|
||||
placeAt(panelEl, rect.left, rect.top);
|
||||
panelEl.classList.add('panel-dragging');
|
||||
this._promotePanelZ(panelEl);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
REGISTERED_LAYER_IDS,
|
||||
encodeLayerStateParams,
|
||||
} from '../data/layerState.js';
|
||||
import { fakeStreetLevelProvider } from '../testSupport/streetLevelFakes.mjs';
|
||||
|
||||
/* ── A small DOM: just what the panel controls touch ───────────────────── */
|
||||
|
||||
@@ -296,47 +297,8 @@ const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
/* ── A Street Level layer with one stand-in provider ───────────────────── */
|
||||
|
||||
function standInProvider() {
|
||||
const filters = [];
|
||||
return {
|
||||
filters,
|
||||
def: {
|
||||
id: 'mapillary',
|
||||
name: 'Mapillary',
|
||||
label: 'MAPILLARY',
|
||||
requiresKeyId: null,
|
||||
pickPrefix: 'mly:',
|
||||
colors: { coverage: '#05cb63' },
|
||||
credit: { html: 'Mapillary' },
|
||||
create: () => ({
|
||||
status: async () => ({ configured: true }),
|
||||
init() {},
|
||||
activate() {},
|
||||
deactivate() {},
|
||||
destroy() {},
|
||||
refreshCoverage() {},
|
||||
setFilter: (filter) => filters.push(filter),
|
||||
coverageStats: () => ({
|
||||
count: 0,
|
||||
zoom: null,
|
||||
kind: null,
|
||||
loading: false,
|
||||
hint: '',
|
||||
error: null,
|
||||
keyRequired: false,
|
||||
}),
|
||||
handlePick: () => false,
|
||||
nearestImage: async () => null,
|
||||
viewer: {
|
||||
mount: async () => {},
|
||||
open: async () => {},
|
||||
close() {},
|
||||
unmount() {},
|
||||
resize() {},
|
||||
onPose: () => () => {},
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
const def = fakeStreetLevelProvider({ html: 'Mapillary' });
|
||||
return { filters: def.filters, def };
|
||||
}
|
||||
|
||||
/** Every other registered layer, as a module with no options. */
|
||||
|
||||
@@ -5,22 +5,9 @@ import {
|
||||
SINCE_STOPS,
|
||||
sinceStopIndex,
|
||||
} from './streetLevelPresentation.js';
|
||||
import { providerSnapshot } from '../testSupport/streetLevelFakes.mjs';
|
||||
|
||||
const provider = (overrides = {}) => ({
|
||||
id: 'mapillary',
|
||||
name: 'Mapillary',
|
||||
label: 'MAPILLARY',
|
||||
on: true,
|
||||
configured: true,
|
||||
keyRequired: false,
|
||||
requiresKeyId: 'mapillary',
|
||||
loading: false,
|
||||
count: 0,
|
||||
hint: '',
|
||||
error: null,
|
||||
color: '#05cb63',
|
||||
...overrides,
|
||||
});
|
||||
const provider = providerSnapshot;
|
||||
|
||||
function snapshot(overrides = {}) {
|
||||
const base = {
|
||||
|
||||
Reference in new issue
Block a user