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

@allmaps/bearing

v1.0.0-beta.12

Published

Compute bearing of georeferenced map

Readme

@allmaps/bearing

Computes the bearing of a Georeferenced Map or Warped Map.

The bearing is returned in degrees, measured from the north line (by default) in the clockwise direction.

Example of a map with a bearing of 30°

How it works

The bearing is computed by taking a vertical and horizontal straight line between two points in resource space, transforming these to projected geographic space, and computing the clockwise (a.k.a. negative) angle they form with the respective vertical and horizontal axis in projected geographic space.

From the description above it follows that the bearing computed in this package is a grid bearing, computed relative to the map projection's vertical line. Since the default projection for warped maps (and their projected transformers) is WebMercator (see @allmaps/render) this vertical axis points to the true north and the resulting bearing is a classical absolute true bearing (clockwise angles from true north). For non-standard projections, specify a projection in the options to obtain the grid bearing in that projection, and correct with the true north bearing at the maps center to obtain the absolute true bearing.

For rendering purposes it is desirable to consider how both horizontal and vertical resource space lines are transformed and define the bearing as the (angular) mean between both angles. In some contexts, e.g. for skewed maps with polynomial transformation where vertical resource axis pointed north, one might be interested in only considering the vertical resource line. This can be specified in the options.

Installation

This package works in browsers and in Node.js as an ESM module.

Install with pnpm:

pnpm install @allmaps/bearing

Usage

import { parseAnnotation } from '@allmaps/annotation'
import { computeGeoreferencedMapBearing } from '@allmaps/bearing'

const annotation = await fetch(
  'https://annotations.allmaps.org/maps/95eeba91177d2a1d'
).then((response) => response.json())

const georeferencedMaps = parseAnnotation(annotation)
const georeferencedMap = georeferencedMaps[0]
const bearing = computeGeoreferencedMapBearing(georeferencedMap)
// bearing = 30.48243288240172

License

MIT

API

BearingOptions

Type
Partial<MaskOptions> & {orientation?: 'horizontal' | 'vertical'}

DEFAULT_BEARING_OPTIONS

Type
any

computeGeoreferencedMapBearing(georeferencedMap, options)

Compute the bearing of a Georeferenced Map.

Parameters
  • georeferencedMap ({ type: "GeoreferencedMap"; resource: { id: string; type: "ImageService1" | "ImageService2" | "ImageService3" | "Canvas"; height?: number | undefined; width?: number | undefined; partOf?: Array<PartOfItemType> | undefined; provider?: Array<{ ...; }> | undefined; }; ... 8 more ...; _allmaps?: unknown; })
    • Georeferenced Map
  • options? (Partial<Partial<MaskOptions> & { orientation?: "horizontal" | "vertical"; } & { internalProjection: Projection; projection: Projection; } & { ...; } & { ...; } & MultiGeometryOptions & TransformationTypeInputs> | undefined)
Returns

The bearing of the map in degrees, measured in degrees from the north line in the clockwise (negative) direction (number).

computeWarpedMapBearing(warpedMap, options)

Compute the bearing of a Warped Map.

Parameters
  • warpedMap (WarpedMap)
    • Warped Map
  • options? (Partial<Partial<MaskOptions> & { orientation?: "horizontal" | "vertical"; } & { internalProjection: Projection; projection: Projection; } & { ...; } & { ...; } & MultiGeometryOptions & TransformationTypeInputs> | undefined)
Returns

The bearing of the map in degrees, measured in degrees from the north line in the clockwise (negative) direction (number).