lgtm
This commit is contained in:
parent
f7e0814a38
commit
fd2860070a
55 changed files with 4084 additions and 186 deletions
|
|
@ -21,9 +21,39 @@ import {
|
|||
getFeatureFillColor,
|
||||
getMapCenterForTargetScreenPoint,
|
||||
getPoiIconUrl,
|
||||
selectSpacedItems,
|
||||
zoomToResolution,
|
||||
} from './map-utils';
|
||||
|
||||
describe('selectSpacedItems', () => {
|
||||
const mk = (id: string, x: number, y: number) => ({ item: id, x, y });
|
||||
|
||||
it('keeps every item when none overlap', () => {
|
||||
const items = [mk('a', 0, 0), mk('b', 200, 0), mk('c', 0, 200)];
|
||||
const kept = selectSpacedItems(items, 130, 34, 40);
|
||||
expect(kept.map((k) => k.item)).toEqual(['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
it('culls items that fall within the spacing of an already-kept item', () => {
|
||||
// b and c sit on top of a; d is clear.
|
||||
const items = [mk('a', 100, 100), mk('b', 120, 110), mk('c', 150, 100), mk('d', 400, 400)];
|
||||
const kept = selectSpacedItems(items, 130, 34, 40);
|
||||
expect(kept.map((k) => k.item)).toEqual(['a', 'd']);
|
||||
});
|
||||
|
||||
it('treats dx and dy independently (far enough on either axis is kept)', () => {
|
||||
const items = [mk('a', 0, 0), mk('b', 10, 40)]; // dx<130 but dy>=34
|
||||
const kept = selectSpacedItems(items, 130, 34, 40);
|
||||
expect(kept.map((k) => k.item)).toEqual(['a', 'b']);
|
||||
});
|
||||
|
||||
it('stops at the max cap', () => {
|
||||
const items = Array.from({ length: 100 }, (_, i) => mk(String(i), i * 500, 0));
|
||||
const kept = selectSpacedItems(items, 130, 34, 40);
|
||||
expect(kept).toHaveLength(40);
|
||||
});
|
||||
});
|
||||
|
||||
describe('map utilities', () => {
|
||||
it('maps zoom levels to H3 resolutions at configured thresholds', () => {
|
||||
expect(zoomToResolution(6.9)).toBe(5);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue