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

@maplat/tin

v0.11.0

Published

JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.

Downloads

89

Readme

Maplat Tin

A JavaScript library that defines and executes homeomorphic conversion between two plane coordinate systems based on control points.
This is part of the Maplat project.

日本語のREADMEはこちら

Key Features

  • Generate Transformation Definitions: Create coordinate transformation definitions based on control points and edge constraints
  • Bidirectional Coordinate Transformation: Convert coordinates between two planes in both directions
  • Topology Preservation: Maintains homeomorphic properties during transformation
  • Flexible Configuration:
    • Vertex handling modes (normal/bird's-eye view)
    • Topology check modes (strict/auto/loose)
    • Y-axis direction control
  • Edge Constraints: Ability to specify constrained edges for more accurate transformation
  • State Management: Save and restore transformation definitions

Installation

npm

# Install the main package
npm install @maplat/tin

# Install required dependency
npm install delaunator

Browser

<!-- Required dependency -->
<script src="https://unpkg.com/delaunator/delaunator.min.js"></script>

<!-- Maplat Tin -->
<script src="https://unpkg.com/@maplat/tin/dist/maplat_tin.umd.js"></script>

Basic Usage

// Create a new instance with basic configuration
const tin = new Tin({
    wh: [500, 500],          // Width and height of the source plane
    yaxisMode: Tin.YAXIS_FOLLOW  // Y-axis direction handling
});

// Set control points: Array of [source, target] coordinates
tin.setPoints([
    [[100,100], [200, 200]], // Point 1
    [[200,200], [400, 400]], // Point 2
    [[150,150], [320, 350]], // Point 3
    [[200,100], [420, 220]]  // Point 4
]);

// Initialize the TIN network
tin.updateTin();

// Check topology status
if (tin.strict_status === Tin.STATUS_STRICT) {
    console.log('Topology OK: Roundtrip transform is guaranteed');
} else if (tin.strict_status === Tin.STATUS_LOOSE) {
    console.log('Topology warning: Roundtrip transform is not guaranteed');
}

// Forward transform: source to target
const transformed = tin.transform([160, 160], false);

// Backward transform: target to source
const restored = tin.transform(transformed, true);

Configuration

Constructor Options

| Option | Type | Description | Default | | ------------- | --------------------------- | ------------------------- | ------------- | | bounds | Position[] | Boundary polygon vertices | - | | wh | number[] | Width and height [w, h] | - | | vertexMode | "plain"|"birdeye" | Vertex handling mode | "plain" | | strictMode | "strict"|"auto"|"loose" | Topology check mode | "auto" | | yaxisMode | "follow"|"invert" | Y-axis direction | "invert" | | importance | number | Map importance | 0 | | priority | number | Map priority | 0 |

Either bounds or wh must be specified.

Methods

| Method | Description | | ---------------------------- | --------------------------------- | | setPoints(points) | Set control points | | setEdges(edges) | Set constrained edges | | updateTin() | Initialize/update TIN network | | transform(coords, inverse) | Execute coordinate transformation | | getCompiled() | Get serializable state | | setCompiled(state) | Restore from serialized state |

Error Handling

The library may throw errors in the following cases:

  • "TOO LINEAR1","TOO LINEAR2": Control points are too linear
  • "SOME POINTS OUTSIDE": Points outside boundary
  • Custom error when attempting backward transformation in a disallowed state

License

Maplat Limited License 1.1

Copyright (c) 2024 Code for History

Developers

  • Kohei Otsuka
  • Code for History

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