npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mailwoman/gazetteer

v12.2.0

Published

Who's On First readers and the gazetteer build pipeline: placetypes, hierarchies, repo sync, and the admin, postcode, POI and address layers the resolver reads.

Readme

@mailwoman/gazetteer

This package reads Who's On First (WOF) records and builds the geographic data that Mailwoman's resolvers consume. Its library provides placetype definitions, record readers and hierarchy helpers. Its tools/ modules build administrative, postcode, POI and address layers, along with search indexes and coverage manifests.

For place lookup, use @mailwoman/resolver-wof-sqlite. For resolving spans in a parsed address, use @mailwoman/resolver. Gazetteer databases are built and distributed separately from this package's code.

Installation

npm install @mailwoman/gazetteer

The package requires Node.js ^24.22.3 || >=26.13.1. The mailwoman gazetteer commands described below come from the separate mailwoman package.

Compare placetypes

import {
	isAtLeastAsSpecific,
	isStrictlyFiner,
	placetypeSpecificity,
} from "@mailwoman/gazetteer/whosonfirst/placetypes/specificity"

isStrictlyFiner("locality", "region") // true
isAtLeastAsSpecific("locality", "locality") // true
placetypeSpecificity("custom") // null

Higher specificity ranks mean finer geographic units. WOF's numeric placetype IDs follow assignment order. Use these helpers when comparing geographic specificity. Both comparison functions return null when either placetype is unranked, leaving the caller to decide how to handle it.

The module also exports SETTLEMENT_PLACETYPES, SUB_LOCALITY_PLACETYPES and REGION_AND_COARSER_PLACETYPES. The static rank for postalcode describes the placetype ordering. The resolver applies additional rules when choosing between a postcode and a locality for an address.

Read a local WOF record

Given a cloned WOF repository under /data/wof-repos, resolve its data directory before reading a record:

import { readWOFFeature, resolveWOFDataDir } from "@mailwoman/gazetteer/whosonfirst/extract-repo"

const dataDir = await resolveWOFDataDir("/data/wof-repos", "admin", "US")

if (dataDir === null) {
	throw new Error("The US administrative repository is missing")
}

const feature = await readWOFFeature(85977539, [dataDir])

if (feature !== null) {
	console.log(feature.properties["wof:name"], feature.properties["wof:placetype"])
}

resolveWOFDataDir accepts both <root>/whosonfirst-data/<repo> and <root>/<repo> layouts. Country codes are lowercased when constructing repository names. readWOFFeature takes roots that already point into each repository's data directory. It derives 859/775/39/85977539.geojson from the example ID.

The reader returns null when no root contains the file or when the first existing file cannot be read or parsed. It doesn't distinguish those conditions or continue to another root after a read failure. Callers that need those distinctions must read the file directly.

WOFFeature, WOFProperties and ParsedWOFPlacetype describe the records. pluckPlacetypeSpec extracts identity, localized names, coordinates, population and lifecycle fields from WOF properties. These exports live at @mailwoman/gazetteer/whosonfirst/placetypes/admin and are also available from the package root.

Read multiple parent hierarchies

A WOF record can belong to several parent hierarchies. The two readers serve different purposes:

| Function | Result | Use | | ------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------- | | hierarchyAncestorsInAnyBranch | A Map<number, string> of ancestor IDs to placetypes, in first-seen order | Collect every ancestry relation for an index. | | agreedHierarchyAncestors | Ancestor IDs shared by every branch, nearest level first | Render only ancestors that apply to every branch. |

import { agreedHierarchyAncestors, hierarchyAncestorsInAnyBranch } from "@mailwoman/gazetteer/whosonfirst/hierarchy"

const branches = [
	{ country_id: 1, region_id: 2, county_id: 3, locality_id: 5 },
	{ country_id: 1, region_id: 2, county_id: 4, locality_id: 5 },
]

agreedHierarchyAncestors(5, branches) // [2, 1]
hierarchyAncestorsInAnyBranch(5, branches) // Map { 1 => "country", 2 => "region", 3 => "county", 4 => "county" }

Both readers exclude the record's own ID and non-positive or non-finite IDs. Import hierarchy helpers from the explicit subpath shown above. The package root doesn't export them.

Build gazetteer data

The build modules live under @mailwoman/gazetteer/tools/*. The CLI adapters live in mailwoman and expose them through mailwoman gazetteer.

| Command | Purpose | | ------------------------------------- | -------------------------------------------------------------------------------------------------------- | | mailwoman gazetteer inspect sync | Clone or refresh the WOF repositories from the mailwoman forks, one directory each under the root. | | mailwoman gazetteer build admin | Ingest WOF, Overture and GeoNames administrative data, enrich it, build indexes and verify the database. | | mailwoman gazetteer build candidate | Build the candidate database from administrative and supplementary layers. | | mailwoman gazetteer build fts | Build SQLite search indexes. | | mailwoman gazetteer build fst | Build the finite-state name index. | | mailwoman gazetteer verify | Check a gazetteer database. |

Use each command's --help for its input paths and options. Builds require the source datasets for the selected recipe. MAILWOMAN_DATA_ROOT selects the data root. Conventional WOF database paths live beneath db/wof/.

mailwoman gazetteer build runs the administrative build followed by the candidate build using the new administrative artifact. The administrative build writes a staging database and seals it after verification. Candidate defaults include only supplementary database files present on the machine, so available inputs affect the resulting coverage. Inspect the manifests when comparing builds.

Build replacement databases separately from the published artifacts. Verification, promotion and publication are separate operations. Follow the release procedure before replacing a deployed database. The layer interface defines manifests, coverage and data tiers. The POI runbook describes the POI build and publication procedure.

Related packages

License

The package declares AGPL-3.0-only OR LicenseRef-Commercial. Source datasets have their own licenses and attribution requirements. Consult each layer's manifest and source documentation before redistributing a built artifact.