Initial
This commit is contained in:
commit
b43955e0d9
162 changed files with 15425 additions and 0 deletions
35
tests/unit/boundingBox.test.ts
Normal file
35
tests/unit/boundingBox.test.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { computeBoundingBox, boundingBoxRing } from '$domain';
|
||||
import type { LatLngTuple } from '$domain';
|
||||
|
||||
describe('computeBoundingBox', () => {
|
||||
it('returns null for an empty path', () => {
|
||||
expect(computeBoundingBox([])).toBeNull();
|
||||
});
|
||||
|
||||
it('wraps the extremes and expands by the margin', () => {
|
||||
const path: LatLngTuple[] = [
|
||||
[62.0, 129.0],
|
||||
[62.5, 130.0]
|
||||
];
|
||||
const box = computeBoundingBox(path, 0)!;
|
||||
expect(box.south).toBeCloseTo(62.0, 6);
|
||||
expect(box.north).toBeCloseTo(62.5, 6);
|
||||
expect(box.west).toBeCloseTo(129.0, 6);
|
||||
expect(box.east).toBeCloseTo(130.0, 6);
|
||||
|
||||
const padded = computeBoundingBox(path, 5)!;
|
||||
expect(padded.south).toBeLessThan(62.0);
|
||||
expect(padded.north).toBeGreaterThan(62.5);
|
||||
expect(padded.west).toBeLessThan(129.0);
|
||||
expect(padded.east).toBeGreaterThan(130.0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('boundingBoxRing', () => {
|
||||
it('is a closed ring of 5 corners (SW repeated)', () => {
|
||||
const ring = boundingBoxRing({ south: 1, west: 2, north: 3, east: 4 });
|
||||
expect(ring).toHaveLength(5);
|
||||
expect(ring[0]).toEqual(ring[4]);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue