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

@canetoad/grauss-kruger

v1.0.0

Published

Typed Gauss–Krüger (Transverse Mercator) forward/inverse projection utilities w/ MGA2020

Readme

Gauss-Krüger (Transverse Mercator) Projection

A TypeScript implementation of robust Gauss–Krüger (Transverse Mercator) forward/inverse projection utilities using the EPSG JHS formulation.

Features

  • Typed TypeScript - Full TypeScript support with comprehensive type definitions
  • EPSG JHS Formulation - Uses the robust IOGP/EPSG Guidance Note 7-2 method
  • MGA2020 Support - Built-in support for Australian Map Grid 2020 zones
  • High Precision - Stable to ~±40° longitude from central meridian
  • Zero Dependencies - Pure TypeScript implementation with no external dependencies
  • ESM/CJS Dual - Supports both ES modules and CommonJS

Installation

npm install gauss-kruger
# or
yarn add gauss-kruger
# or
pnpm add gauss-kruger

Quick Start

import { GaussKrugerProjection } from 'gauss-kruger';

// Create projection with WGS84/UTM-like defaults (Zone 33 style)
const proj = new GaussKrugerProjection();

// Forward projection: geographic → grid
const { northing, easting } = proj.geodeticToGrid(-33.86, 151.21);
console.log(`Easting: ${easting.toFixed(2)}m, Northing: ${northing.toFixed(2)}m`);

// Inverse projection: grid → geographic  
const { latitude, longitude } = proj.gridToGeodetic(northing, easting);
console.log(`Latitude: ${latitude.toFixed(6)}°, Longitude: ${longitude.toFixed(6)}°`);

MGA2020 (Australian Map Grid 2020)

Built-in support for Australian MGA2020 zones:

import { 
  projectMGA2020, 
  inverseMGA2020, 
  mga2020ZoneFromLongitude 
} from 'gauss-kruger';

// Project Sydney coordinates to MGA2020
const sydney = { latitude: -33.8688, longitude: 151.2093 };
const { zone, easting, northing } = projectMGA2020(sydney.latitude, sydney.longitude);
console.log(`MGA2020 Zone ${zone}: E=${easting}m, N=${northing}m`);

// Inverse projection
const back = inverseMGA2020(zone, easting, northing);
console.log(`Back to: ${back.latitude}°, ${back.longitude}°`);

API Reference

GaussKrugerProjection

Main class for Gauss-Krüger projections.

Constructor

new GaussKrugerProjection(options?: GaussKrugerProjectionOptions)

Options:

  • equatorialRadius?: number - Semi-major axis in meters (default: 6378137.0)
  • flattening?: number - Ellipsoid flattening (default: 1/298.257223563)
  • centralMeridian?: number - Central meridian in degrees (default: 15)
  • latitudeOfOrigin?: number - Latitude of origin in degrees (default: 0)
  • scale?: number - Scale factor at central meridian (default: 0.9996)
  • falseEasting?: number - False easting in meters (default: 500000)
  • falseNorthing?: number - False northing in meters (default: 0)

Methods

  • geodeticToGrid(latitude: number, longitude: number): { northing: number, easting: number }
  • gridToGeodetic(northing: number, easting: number): { latitude: number, longitude: number }

MGA2020 Functions

  • mga2020ZoneFromLongitude(longitude: number): MGA2020Zone - Get zone from longitude
  • mga2020CentralMeridian(zone: number): number - Get central meridian for zone
  • createMGA2020(zone: MGA2020Zone): GaussKrugerProjection - Create MGA2020 projection
  • projectMGA2020(latitude: number, longitude: number): { zone: MGA2020Zone, easting: number, northing: number }
  • inverseMGA2020(zone: MGA2020Zone, easting: number, northing: number): { latitude: number, longitude: number }

Examples

Custom Projection (UTM Zone 10)

import { GaussKrugerProjection } from 'gauss-kruger';

const utm10 = new GaussKrugerProjection({
  centralMeridian: -123,  // UTM Zone 10 central meridian
  scale: 0.9996,
  falseEasting: 500000,
  falseNorthing: 0
});

const point = utm10.geodeticToGrid(37.7749, -122.4194); // San Francisco
console.log(point);

British National Grid (OSGB36)

import { GaussKrugerProjection } from 'gauss-kruger';

const osgb36 = new GaussKrugerProjection({
  equatorialRadius: 6377563.396,
  flattening: 1 / 299.3249646,
  centralMeridian: -2,
  latitudeOfOrigin: 49,
  scale: 0.9996012717,
  falseEasting: 400000,
  falseNorthing: -100000
});

const london = osgb36.geodeticToGrid(51.5074, -0.1278);
console.log(london);

Coordinate Systems

Input/Output Units

  • Angles: Degrees (decimal)
  • Linear: Meters

Supported Ellipsoids

  • WGS84 (default)
  • GRS80 (used in MGA2020)
  • Custom ellipsoids via constructor parameters

Accuracy

  • Longitude range: Stable to ~±40° from central meridian
  • UTM usage: Designed for ±3° (standard UTM range)
  • Precision: Sub-millimeter precision for typical use cases
  • Round-trip: Forward → inverse returns original coordinates within numerical precision

TypeScript Support

Full TypeScript definitions included:

import { 
  GaussKrugerProjection, 
  GaussKrugerProjectionOptions,
  MGA2020Zone 
} from 'gauss-kruger';

const options: GaussKrugerProjectionOptions = {
  centralMeridian: 135,
  scale: 0.9996
};

const proj = new GaussKrugerProjection(options);
const zone: MGA2020Zone = 56; // Type-safe zone numbers

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Lint
npm run lint

References

  • IOGP/EPSG Guidance Note 7-2, "Transverse Mercator (JHS formulas)" (2019)
  • Lantmäteriet, "Gauss Conformal Projection (Transverse Mercator) — Krüger's formulas" (2008)
  • Geoscience Australia, "GDA2020 / MGA2020" technical documentation

License

MIT License - see LICENSE file for details.