vibes
This commit is contained in:
parent
39ef5c6646
commit
c995f12f8b
78 changed files with 4830 additions and 1619 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
DENSITY_GRADIENT,
|
||||
ENUM_PALETTE,
|
||||
FEATURE_GRADIENT,
|
||||
BUFFER_MULTIPLIER,
|
||||
MAP_BOUNDS,
|
||||
POI_CATEGORY_LOGOS,
|
||||
SMALLEST_VISIBLE_HEXAGON_RESOLUTION,
|
||||
|
|
@ -15,6 +16,7 @@ import {
|
|||
enumIndexToColor,
|
||||
getBoundsFromViewState,
|
||||
getBoundsWithBottomScreenInset,
|
||||
getVisibleBoundsFromViewState,
|
||||
getLatitudeAtVerticalPixelOffset,
|
||||
getFeatureFillColor,
|
||||
getMapCenterForTargetScreenPoint,
|
||||
|
|
@ -31,17 +33,33 @@ describe('map utilities', () => {
|
|||
expect(SMALLEST_VISIBLE_HEXAGON_RESOLUTION).toBe(9);
|
||||
});
|
||||
|
||||
it('computes buffered bounds around a view state', () => {
|
||||
const bounds = getBoundsFromViewState(
|
||||
{ latitude: 51.5, longitude: -0.1, zoom: 12, pitch: 0 },
|
||||
1200,
|
||||
800
|
||||
);
|
||||
it('computes exact viewport bounds by default', () => {
|
||||
const viewState = { latitude: 51.5, longitude: -0.1, zoom: 12, pitch: 0 };
|
||||
const bounds = getBoundsFromViewState(viewState, 1200, 800);
|
||||
const exactBounds = getBoundsFromViewState(viewState, 1200, 800, 1);
|
||||
const bufferedBounds = getBoundsFromViewState(viewState, 1200, 800, 1.5);
|
||||
|
||||
expect(BUFFER_MULTIPLIER).toBe(1);
|
||||
expect(bounds).toEqual(exactBounds);
|
||||
expect(bounds.south).toBeLessThan(51.5);
|
||||
expect(bounds.north).toBeGreaterThan(51.5);
|
||||
expect(bounds.west).toBeLessThan(-0.1);
|
||||
expect(bounds.east).toBeGreaterThan(-0.1);
|
||||
expect(bufferedBounds.south).toBeLessThan(bounds.south);
|
||||
expect(bufferedBounds.north).toBeGreaterThan(bounds.north);
|
||||
expect(bufferedBounds.west).toBeLessThan(bounds.west);
|
||||
expect(bufferedBounds.east).toBeGreaterThan(bounds.east);
|
||||
});
|
||||
|
||||
it('excludes mobile bottom-sheet covered map area from visible bounds', () => {
|
||||
const viewState = { latitude: 51.5, longitude: -0.1, zoom: 12, pitch: 0 };
|
||||
const fullBounds = getVisibleBoundsFromViewState(viewState, 390, 800, 0);
|
||||
const visibleBounds = getVisibleBoundsFromViewState(viewState, 390, 800, 352);
|
||||
|
||||
expect(visibleBounds.west).toBeCloseTo(fullBounds.west, 6);
|
||||
expect(visibleBounds.east).toBeCloseTo(fullBounds.east, 6);
|
||||
expect(visibleBounds.north).toBeCloseTo(fullBounds.north, 6);
|
||||
expect(visibleBounds.south).toBeGreaterThan(fullBounds.south);
|
||||
});
|
||||
|
||||
it('moves the map center so a target lands in the requested screen position', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue