Back to Atlas map viewer
SOURCE / PINNED RELEASE

Made of little things.

Atlas map viewer

Release
1d2807e80b44…
Author-recorded commit
43810ed2b368…
License
LICENSE
Author’s source reference
nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-4757dbabc86

Archive hash verified: 8db6876d96c460ac…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

packages/labels/src/places.ts
import type { Place } from "../../format/src/index";
export const PLACE_LABEL_KEY = "labels/places";
export function decodePlaces(bytes: Uint8Array): Place[] {
  const value = JSON.parse(new TextDecoder().decode(bytes));
  if (
    value?.schema !== "places-v1" ||
    !Array.isArray(value.places) ||
    value.places.length > 100000 ||
    value.places.some(
      (p: Place) =>
        !p ||
        typeof p.name !== "string" ||
        p.name.length > 500 ||
        !Array.isArray(p.coordinates) ||
        p.coordinates.length !== 2 ||
        !p.coordinates.every(Number.isFinite) ||
        Math.abs(p.coordinates[0]) > 180 ||
        Math.abs(p.coordinates[1]) > 85,
    )
  )
    throw new Error("Invalid settlement labels");
  return value.places;
}
export const encodePlaces = (places: Place[]) =>
  new TextEncoder().encode(JSON.stringify({ schema: "places-v1", places }));