mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 15:51:00 +00:00
51af575c9a
A right-click, click or drag on a repeated world copy reported the longitude it has on that copy (274.9 for -85.1). The place was saved there, the geocoder found nothing, and a route to a place on the real world ran across the whole map (#2976). Longitudes are now brought back onto [-180, 180] where the map hands them out (Leaflet and GL), where they are stored (places, booking endpoints, collection places, so REST, MCP, plugin RPC and importers alike) and before reverse geocoding. A migration moves the ones already stored. Leaflet draws a layer at its literal longitude only, so a trip from Los Angeles to Auckland had its pins at opposite ends of the world while the flight ran off the edge to the next copy (#2975). A trip that crosses the antimeridian is now drawn in one longitude frame, seamed in the widest stretch it leaves empty, so pins, routes, flights and every overlay lie on one copy and the map opens across the Pacific. Every other trip has no frame and draws exactly as before. The GL day fit also takes the short way. A new install now starts with Journey and Collections switched on, next to the trip addons (all but Road trip), Atlas, Vacay and the Naver import that already were. Existing installs keep their addons as they are. Closes #2975 Closes #2976
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { bboxOnRealWorld, onRealWorld } from './worldCopy';
|
|
|
|
describe('onRealWorld', () => {
|
|
it('brings a right-click on the copy east of the real world back to the real point (#2976)', () => {
|
|
const at = onRealWorld({ lat: 10.14, lng: 274.921875 });
|
|
expect(at.lat).toBe(10.14);
|
|
expect(at.lng).toBeCloseTo(-85.078125, 9);
|
|
});
|
|
|
|
it('brings a point on the copy west of it back too', () => {
|
|
expect(onRealWorld({ lat: 35.68, lng: -220.3 }).lng).toBeCloseTo(139.7, 9);
|
|
});
|
|
|
|
it('hands a point already on the real world back as it is', () => {
|
|
const point = { lat: 34, lng: -118.4, extra: 1 };
|
|
expect(onRealWorld(point)).toBe(point);
|
|
});
|
|
|
|
it('keeps any other field of the point', () => {
|
|
expect(onRealWorld({ lat: 1, lng: 365, name: 'x' })).toEqual({ lat: 1, lng: 5, name: 'x' });
|
|
});
|
|
});
|
|
|
|
describe('bboxOnRealWorld', () => {
|
|
it('moves a box looking at a copy of Japan onto Japan', () => {
|
|
const box = bboxOnRealWorld({ south: 34, west: -225, north: 37, east: -215 });
|
|
expect(box.west).toBeCloseTo(135, 9);
|
|
expect(box.east).toBeCloseTo(145, 9);
|
|
expect([box.south, box.north]).toEqual([34, 37]);
|
|
});
|
|
|
|
it('leaves a box on the real world alone', () => {
|
|
const box = { south: 40, west: 0, north: 50, east: 20 };
|
|
expect(bboxOnRealWorld(box)).toBe(box);
|
|
});
|
|
|
|
it('keeps a box across the antimeridian across it', () => {
|
|
expect(bboxOnRealWorld({ south: -20, west: 170, north: -10, east: 190 })).toEqual({
|
|
south: -20,
|
|
west: 170,
|
|
north: -10,
|
|
east: 190,
|
|
});
|
|
});
|
|
});
|