@maschinenlesbar.org/regionalatlas-cli
    Preparing search index...

    Function matchRegion

    • Pick the rows a region names, and say how (RegionMatch.by).

      • A numeric region is a key: the rows whose ags equals it, leading zeros ignored on both sides (by: "ags"). When none does, a row whose shorter key the region pads with zeros (by: "ags-filled"): a level fills in with coarser units, so at gemeinde München is the row 09162 and Berlin 11, and the official 8-digit keys 09162000 and 11000000 (or 11000 at kreis) used to match nothing. The longest such key wins.
      • Otherwise a name, compared case-insensitively in NFC (foldText): the rows whose whole name equals it (by: "name"), with the rows that only contain it in others; when no name equals it, every row whose name contains it (by: "substring"). A substring alone picked the wrong place first: Sachsen gave Niedersachsen, Sachsen and Sachsen-Anhalt in that order, Gera Groß-Gerau before Gera, Berlin at gemeinde level Berlingen. Several rows can still match — a name two regions share (two Gemeinden called Halle; Hannover twice in the Kreis rows of 2000), or a text that is no whole name (Neustadt at gemeinde level: 21 rows) — so check rows.length, and pick one region by its ags.
      • When nothing matched: the same with the umlauts and ß spelled out on both sides (Muenchen), then a name in the order users write it (by: "name-form"): Landkreis München or Kreis Lippe is the region the data names München, Landkreis (or Verden, long name Verden, Landkreis), Stadt Kassel or Kreisfreie Stadt Kassel the city Kassel, by the kind the long name (RegionRow.longName, the data's gen2) gives.

      A blank region throws RegionalatlasValidationError rather than matching every row.

      Parameters

      Returns RegionMatch