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

@atlas-composer/preset-library

v2.7.0

Published

Curated collection of composite map projection presets for Atlas Composer

Readme

@atlas-composer/preset-library

Composite map presets of Atlas Composer.

This package publishes the presets of the Atlas Composer app, such as France with its overseas territories or the USA with Alaska and Hawaii, and a catalog that describes them. A composite-custom preset is a configuration of @atlas-composer/specification, which @atlas-composer/projection-loader turns into a d3 projection.

Installation

npm install @atlas-composer/preset-library @atlas-composer/projection-loader d3-geo

Usage

import { getPreset } from '@atlas-composer/preset-library'
import { ProjectionLoader } from '@atlas-composer/projection-loader'
import { d3ProjectionFactories } from '@atlas-composer/projection-loader/helpers'
import * as d3 from 'd3-geo'

const loader = new ProjectionLoader()
loader.registerAll(d3ProjectionFactories)

const config = await getPreset('france-standard')

if (config) {
  const projection = loader.load(config, { width: 800, height: 600 })
  const path = d3.geoPath(projection)
}

loader.load validates the configuration and throws a ConfigValidationError for a configuration that the format refuses. validateConfig of the loader returns { valid, errors, warnings } without throwing.

listPresets() returns the composite-custom presets, and listPresets({ includeViewModes: true }) returns every preset:

import { listPresets } from '@atlas-composer/preset-library'

for (const preset of listPresets({ atlasId: 'france' }))
  console.log(preset.id, preset.name)

Each preset file is also published by its path, @atlas-composer/preset-library/<atlas>/<identifier>:

import config from '@atlas-composer/preset-library/france/france-standard' with { type: 'json' }

Catalog

catalog.presets has an entry for each preset, keyed by its identifier. An entry has:

  • id, the identifier of the preset, such as france-standard;
  • name and description, in English;
  • atlasId and region, the identifier of the atlas, such as france;
  • type: composite-custom, built-in-composite, split or unified;
  • tags: ['default'] for the default preset of the atlas, [] for the others.

catalog.version is the version of the package.

The built-in-composite, split and unified presets describe the views of the Atlas Composer app. getPreset loads a composite-custom preset, and returns undefined for the other types.

Atlases

The package serves the configuration of each atlas at @atlas-composer/preset-library/atlases/<atlas>, and its schema at @atlas-composer/preset-library/schemas/atlas.schema. An atlas configuration names the territories, their codes, bounds and centers, the rules that cut them out of Natural Earth, and the territory collections. dataSources names the files that the app loads.

buildTerritories(config, source) builds one GeoJSON feature per territory of an atlas. The example reads world-atlas with topojson-client, @types/topojson-client and @types/topojson-specification:

import type { Topology } from 'topojson-specification'
import { readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { buildTerritories, createNaturalEarthSource } from '@atlas-composer/preset-library'
import config from '@atlas-composer/preset-library/atlases/france' with { type: 'json' }
import { feature } from 'topojson-client'

const require = createRequire(import.meta.url)
const topology: Topology = JSON.parse(readFileSync(require.resolve('world-atlas/countries-50m.json'), 'utf8'))

const source = createNaturalEarthSource(feature(topology, topology.objects.countries), '50m')
const { collection } = buildTerritories(config, source)
  • A Natural Earth source goes through the extraction rules of the atlas. The polygon indices of these rules count the polygons of countries-50m.json of world-atlas 2.0.2, and another version of world-atlas cuts the territories at the wrong polygons. An atlas of every country, such as world, reads any resolution, and the code of each territory is WD-<id>.
  • At another resolution, such as 10m, createNaturalEarthSource(features, '10m', features50m) takes the features of countries-50m.json too, and buildTerritories refuses an atlas with rules without them. Each polygon of the source goes to the territory of the 50m polygon of the same id that contains its centroid or, without one, of the 50m polygon with the nearest vertex. A polygon farther than 50 km from it and outside the bounds of its territory, such as an islet that Natural Earth draws at 10m only, is left out of the geometry and listed in leftOutPolygons.
  • A source { kind: 'by-code', features } takes features that carry the code of a territory in properties.code, such as FR-GF, and gathers them by code.
  • The rings of the features are oriented as d3-geo reads them, exterior rings clockwise. rewindToRfc7946 orients a planar geometry as RFC 7946 asks.
  • buildTerritories throws a TerritoryBuildError whose issues name the missing or unknown codes, the indices out of range, the duplicated territories without source, the rings that cross the antimeridian, a source by code for an atlas of every country, and the refused resolution.

API

  • getPreset(id) - Load the configuration of a composite-custom preset
  • getPresetMetadata(id) - Get the catalog entry of a preset
  • getPresetPath(id) - Get the path of the preset file, such as france/france-standard.json
  • getAllPresets() - Get every catalog entry
  • listPresets(options) - Filter the presets by atlasId, type, region and tags; includeViewModes adds the built-in-composite, split and unified presets
  • getPresetsForAtlas(atlasId) - List the composite-custom presets of an atlas
  • getDefaultPreset(atlasId) - Get the composite-custom preset tagged default of an atlas, else its first composite-custom preset
  • listCompositePresets() - List the composite-custom presets
  • listViewModePresets() - List the built-in-composite, split and unified presets
  • buildTerritories(config, source) - Build one feature per territory of an atlas
  • createNaturalEarthSource(features, resolution, ruleFeatures?) - Build a source from the features of a Natural Earth topology, with the features of the 50m topology for another resolution
  • RULES_RESOLUTION - The resolution whose polygons the indices of the extraction rules count, 50m
  • listAtlases() - List the atlas identifiers, in alphabetical order
  • listRegions() - List the atlas identifiers, in the order of the registry of the Atlas Composer app, configs/atlas-registry.json
  • listTypes() - List the preset types
  • isViewModeType(type) - Check if a type is built-in-composite, split or unified

License

MIT © ShallowRed