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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wonderlandlabs/atmo-utils

v0.1.0

Published

Utility functions for Atmo projects

Downloads

4

Readme

H3 Utilities for Atmo

This module provides a comprehensive set of utilities for working with the H3 geospatial indexing system in the Atmo project. It wraps and extends the functionality of the h3-js library.

Installation

The H3 utilities are part of the @wonderlandlabs/atmo-utils package. The h3-js library is included as a dependency.

Terminology

This library follows the official H3 terminology:

  • Cell: A hexagonal (or pentagonal) grid cell in the H3 system
  • Resolution: The level of detail in the H3 grid system (0-15)
  • H3Index: A string representation of an H3 cell index

Core Functions

Cell Creation and Conversion

// Convert lat/lng to an H3 cell index
const h3Index = latLngToCell(37.7749, -122.4194, 9);

// Get the center coordinates of a cell
const { lat, lng } = cellToLatLng(h3Index);

// Get the boundary vertices of a cell
const boundary = cellToBoundary(h3Index);

Cell Properties

// Get the resolution of a cell
const resolution = getResolution(h3Index);

// Check if a cell index is valid
const isValid = isValidCell(h3Index);

// Get the area of a cell in square meters
const area = cellArea(h3Index);

// Get the edge length of a cell in meters
const edgeLength = getEdgeLengthAvg(h3Index);

Cell Relationships

// Get the neighbors of a cell
const neighbors = getNeighbors(h3Index);

// Get all cells within a certain distance
const cellsInRange = getCellsInRange(h3Index, 2);

// Check if two cells are neighbors
const areNeighbors = areNeighborCells(h3Index1, h3Index2);

// Get the grid distance between two cells
const distance = gridDistance(h3Index1, h3Index2);

Hierarchical Operations

// Get the parent cell at a lower resolution
const parent = cellToParent(h3Index, 8);

// Get all child cells at a higher resolution
const children = cellToChildren(h3Index, 10);

// Compact a set of cells (represent the same area with fewer cells)
const compacted = compactCells(cellArray);

// Uncompact a set of cells to a specific resolution
const uncompacted = uncompactCells(compactedArray, 10);

Geometric Calculations

// Calculate the radius of a cell at a specific resolution for a planet
const radius = h3HexRadiusAtResolution(planetRadius, resolution);

// Calculate the area of a cell at a specific resolution for a planet
const area = h3HexArea(resolution, planetRadius);

// Convert multiple points to cell indices
const cellIndices = pointsToCell(points, resolution);

Planetary System Integration

These utilities are particularly useful for the planetary system in the atmo-sim package, allowing for efficient spatial indexing and operations on planetary surfaces with different radii.

// Example: Calculate cell area for Mars
const marsRadius = 3389500; // meters
const cellArea = h3HexArea(9, marsRadius);

Consistency with H3 Library

This utility module maintains consistency with the official H3 library terminology and function naming conventions, making it easier to reference the official H3 documentation.

Performance Considerations

  • The H3 utilities include caching for frequently used calculations like cell radius
  • For operations on large numbers of cells, consider using the compact/uncompact functions to reduce the number of cells being processed
  • When working with planetary systems, pre-calculate and cache values for specific resolutions when possible