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

@maplat/transform

v0.4.1

Published

A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat.

Readme

Maplat Transform

CI

A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat. This is part of the Maplat project.

日本語のREADMEはこちら

Key Features

  • Import Transformation Definitions: Import and build internal structures from transformation definitions generated by Maplat
  • Bidirectional Coordinate Transformation: Convert coordinates between two planes in both directions
  • Topology Preservation: Maintains homeomorphic properties during transformation
  • Multiple Coordinate System Support: Handles transformations between various coordinate systems including standard orthogonal coordinates, Y-axis inverted coordinates, and distorted coordinates like bird's-eye views
  • State Management: Save and restore transformation states

Requirements

  • Node.js: >= 20
  • pnpm: >= 9 (for development)

Installation

pnpm (Recommended)

pnpm add @maplat/transform

npm

npm install @maplat/transform

Browser

<script src="https://unpkg.com/@maplat/transform/dist/maplat_transform.umd.js"></script>

Basic Usage

import { Transform } from '@maplat/transform';

// Import transformation definition
const transform = new Transform();
transform.setCompiled(compiledData);  // Apply transformation definition generated by Maplat

// Forward transformation (source → target coordinate system)
const transformed = transform.transform([100, 100], false);

// Backward transformation (target → source coordinate system)
const restored = transform.transform(transformed, true);

Error Handling

The library may throw errors in the following cases:

  • Transformation errors in strict mode
  • Attempting backward transformation when not allowed
  • Invalid data structure during transformation

If errors occur, the transformation definition data needs to be modified. Please use editor tools that incorporate @maplat/tin to modify transformation definitions.

API Reference

Transform Class

The main class for coordinate transformation.

Constructor

const transform = new Transform();

Methods

setCompiled(compiled: Compiled | CompiledLegacy): void

Import and apply a compiled transformation definition generated by Maplat.

  • Parameters:
    • compiled: Compiled transformation definition object
transform(apoint: number[], backward?: boolean, ignoreBounds?: boolean): number[] | false

Perform coordinate transformation.

  • Parameters:
    • apoint: Coordinate to transform [x, y]
    • backward: Whether to perform backward transformation (default: false)
    • ignoreBounds: Whether to ignore boundary checks (default: false)
  • Returns: Transformed coordinate or false if out of bounds
  • Throws: Error if backward transformation is attempted when strict_status == "strict_error"

Static Constants

Vertex Modes:

  • Transform.VERTEX_PLAIN: Standard plane coordinate system
  • Transform.VERTEX_BIRDEYE: Bird's-eye view coordinate system

Strict Modes:

  • Transform.MODE_STRICT: Strict transformation mode
  • Transform.MODE_AUTO: Automatic mode selection
  • Transform.MODE_LOOSE: Loose transformation mode

Strict Status:

  • Transform.STATUS_STRICT: Strict status
  • Transform.STATUS_ERROR: Error status (backward transformation not allowed)
  • Transform.STATUS_LOOSE: Loose status

Y-axis Modes:

  • Transform.YAXIS_FOLLOW: Follow Y-axis direction
  • Transform.YAXIS_INVERT: Invert Y-axis direction

Exported Types

  • PointSet, BiDirectionKey, WeightBufferBD, VertexMode, StrictMode, StrictStatus, YaxisMode
  • CentroidBD, TinsBD, KinksBD, VerticesParamsBD, IndexedTinsBD
  • Compiled, CompiledLegacy
  • Tins, Tri, PropertyTriKey
  • Edge, EdgeSet, EdgeSetLegacy

Exported Utility Functions

  • transformArr: Low-level coordinate transformation function
  • rotateVerticesTriangle: Rotate vertices of a triangle
  • counterTri: Counter triangle utility
  • normalizeEdges: Normalize edge definitions

Format Version

import { format_version } from '@maplat/transform';
console.log(format_version); // Current format version

Documentation

For detailed technical information about the transformation internals, see:

  • Transform Internals - Runtime notes on how Transform class reconstructs state and performs coordinate lookups

Development

Running Tests

pnpm test

Important Note

This library specializes in executing coordinate transformations and does not include functionality for generating or editing transformation definitions. If you need to create or edit transformation definitions, please use the @maplat/tin package.

License

Maplat Limited License 1.1

Copyright (c) 2025 Code for History

Developers

  • Kohei Otsuka
  • Code for History

We welcome your contributions! Feel free to submit issues and pull requests.