clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

main
atlas / analysis / test / conformance.test.ts
conformance.test.ts 4.2K
1// Every system, held to the same properties.2//3// Geohash and S2 are the two Atlas ships. `districts` is a third, written in4// the test tree for one run and never registered: issue #5 §5.4 says a third5// system is a registry entry plus a green conformance run, and the cheapest6// honest way to keep that promise true is to keep a third system passing.78import { describeConformance } from "./conformance.ts";9import { districtSystem } from "./districts.ts";10import { geohashSystem } from "../cellsystems/geohash.ts";11import { s2System } from "../cellsystems/s2.ts";12import type { Ground } from "../cellsystems/ground.ts";13import { anchored, sphere, square, squareFromBounds } from "./grounds.ts";1415/** The 1024 square, told it has districts. */16const districted: Ground = {17 ...square,18 world: { attrs: { "atlas.district.grid": "3x3" } },19};2021describeConformance("geohash on a plain square", {22 system: geohashSystem,23 ground: square,24 probe: [688, -688],25 // A plane's geohash divides the world square, which here is also the lens's26 // whole surface — but the root's top edge is the square's own 0, not the27 // surface ladder's -0.28 rootExtent: [0, -1024, 1024, 0],29 // A halved rectangle's corner is exactly on its own boundary, and geohash30 // decides containment on the same arithmetic that placed it there.31 boundaryProbes: [32 ["m6", [704, -672]],33 ["m6", [672, -704]],34 ["", [0, -1024]],35 ["", [1024, 0]],36 ],37});3839describeConformance("geohash on a lens that declares only bounds", {40 system: geohashSystem,41 ground: squareFromBounds,42 probe: [300, -400],43 // A plane's grid covers the FULL map area whatever window the lens fills,44 // so the ground divided here is the 1024 square, not the 512 × 256 window.45 rootExtent: [0, -1024, 1024, 0],46 boundaryProbes: [47 ["", [0, -1024]],48 ["", [1024, 0]],49 ],50});5152describeConformance("real geohash on an earth-anchored plane", {53 system: geohashSystem,54 ground: anchored,55 probe: [2048, -2048],56 // The root is the union of the twelve base cells the 0.8° × 0.5° window57 // intersects: columns 164–167 and rows 765–767 of the depth-4 grid, i.e.58 // -122.34375 … -120.9375 by 44.47265625 … 45. Through the window's own59 // formulas (x linear in longitude over 0.8° → 4096 px, y linear in60 // asinh(tan lat)) that is x = -0.34375/0.8·4096 … 1.0625/0.8·4096 and the61 // top row's north edge lands exactly on the window's own top, y = -0.62 rootExtent: [-1760.0000000000064, -4318.983024242055, 5440.000000000019, -0],63 // Declared empty, deliberately: a real cell's boundary is exact in64 // DEGREES — binary fractions of 360 — and a world-pixel probe reaches it65 // only through asinh(tan φ) and back, which can land the round-trip an ulp66 // to either side. The inclusive rule is a rule about the system's own67 // boundary arithmetic, and that arithmetic lives in degrees.68 boundaryProbes: [],69});7071describeConformance("geohash on a sphere", {72 system: geohashSystem,73 ground: sphere,74 probe: [4363.848398961777, -916.9692745045334],75 boundaryProbes: [76 ["", [0, -4096]],77 ["", [8192, 0]],78 ],79});8081describeConformance("s2 on an equirectangular sphere", {82 system: s2System,83 ground: sphere,84 probe: [4363.848398961777, -916.9692745045334],85 // Declared empty, deliberately. S2 decides containment on the leaf lattice —86 // thirty levels below anything this grid draws — so a ring vertex, which has87 // travelled through degrees and back, lands in whichever leaf the rounding88 // put it in and may belong to the neighbour. The inclusive rule is a rule89 // about a system's own boundary arithmetic, and S2's boundary is not90 // representable in the coordinates a caller can hand it.91 boundaryProbes: [],92});9394// S2 is deliberately NOT run over `mercatorCity`, and the reason is a real95// limit of the recorded design rather than an oversight: see96// `s2-limits.test.ts`, which pins the limit so nobody rediscovers it as a bug.9798describeConformance("a third system nobody designed the contract for", {99 system: districtSystem,100 ground: districted,101 probe: [688, -688],102 boundaryProbes: [103 ["4", [341.3333333333333, -682.6666666666666]],104 ["", [0, -1024]],105 ["", [1024, 0]],106 ],107});