Keep a lookup's places when one tile fails, and ship every tile as its own file

- A tile that cannot be read is left out of placesNear's answer instead of
  failing it; without the pack's index the cities are still the answer.
- The build no longer inlines the small tiles into one chunk that loaded
  with the first lookup: all 732 are their own files.
- A row at latitude 90 or longitude 180 is tiled where the lookups read it.
- --min-population 0 is taken as 0, not as the default.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 12:36:16 -08:00
1 parent 2a01269b87
commit 88919f760f
6 files changed
+40 -9

No files matched your search

+4 -5
View File
@@ -53,12 +53,11 @@ const LABEL_BATCH = 400;
const args = process.argv.slice(2);
const flag = (name) =>
args.includes(name) ? Number(args[args.indexOf(name) + 1]) : NaN;
args.includes(name) ? Number(args[args.indexOf(name) + 1]) : undefined;
const tilesMode = args.includes('--tiles');
const minPopulation = flag('--min-population') || (tilesMode ? 1000 : 15000);
const maxPopulation = tilesMode
? flag('--max-population') || 15000
: flag('--max-population') || Infinity;
const minPopulation = flag('--min-population') ?? (tilesMode ? 1000 : 15000);
const maxPopulation =
flag('--max-population') ?? (tilesMode ? 15000 : Infinity);
if (!(maxPopulation > minPopulation))
throw new Error('--max-population must be above --min-population');
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+4 -1
View File
@@ -33,7 +33,10 @@ export function withoutCities(rows, cityIds) {
/** The tile a point falls in, named by its south-west corner. */
export function tileKey(lat, lon) {
const corner = (value) => Math.floor(value / TILE_DEGREES) * TILE_DEGREES;
return `${corner(lat)}_${corner(lon)}`;
// As the lookups read them: latitude 90 is in the top row of tiles, and
// longitude 180 is longitude -180.
const top = 90 - TILE_DEGREES;
return `${Math.min(top, corner(lat))}_${corner((((lon % 360) + 540) % 360) - 180)}`;
}
/**