fix(map): keep the world-copy fix inside the CI ratchets

Moves the Leaflet map's event bridges (click, context menu, viewport, POI drop
and the longitude-frame follower) out of MapView into leafletMapBridges, and
shares one POI drop target between the Leaflet and GL maps, so both map files
shrink instead of growing. The repair migration does its arithmetic in one
UPDATE per table, and the new tests drop their non-null assertions and loops.
This commit is contained in:
Maurice
2026-11-04 11:37:52 +01:00
parent 51af575c9a
commit 178df0fbe3
10 changed files with 205 additions and 178 deletions
@@ -6,16 +6,12 @@ import { Migration } from '@mikro-orm/migrations';
*/
const TABLES = ['places', 'reservation_endpoints', 'collection_places', 'place_contrib_outbox'] as const;
interface LngRow {
id: number;
lng: number;
}
/** Into [-180, 180], the same arithmetic as wrapLongitude in @trek/shared, kept here so this body never changes. */
function onTheRealWorld(lng: number): number {
const wrapped = ((((lng + 180) % 360) + 360) % 360) - 180;
return wrapped === 0 ? 0 : wrapped;
}
/**
* How many whole worlds `lng` lies east of the real one: floor((lng + 180) / 360),
* spelled with CAST, which truncates towards zero, because SQLite has no floor()
* without its math extension.
*/
const WORLDS = '(CAST((lng + 180) / 360.0 AS INTEGER) - ((lng + 180) / 360.0 < CAST((lng + 180) / 360.0 AS INTEGER)))';
/**
* Brings every stored longitude back onto the real world.
@@ -30,14 +26,9 @@ function onTheRealWorld(lng: number): number {
export class Migration20200101046350_a_place_lies_on_the_real_world extends Migration {
override name = 'Migration20200101046350_a_place_lies_on_the_real_world';
override async up(): Promise<void> {
override up(): void {
for (const table of TABLES) {
const rows = (await this.execute(
`SELECT id, lng FROM ${table} WHERE lng IS NOT NULL AND (lng < -180 OR lng > 180)`,
)) as LngRow[];
for (const row of rows) {
await this.execute(`UPDATE ${table} SET lng = ? WHERE id = ?`, [onTheRealWorld(row.lng), row.id]);
}
this.addSql(`UPDATE ${table} SET lng = lng - 360 * ${WORLDS} WHERE lng < -180 OR lng > 180`);
}
}
}