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 🙏

© 2024 – Pkg Stats / Ryan Hefner

maplat_tin

v0.6.1

Published

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

Downloads

17

Readme

Maplat Tin library

JavaScript library which performs bijective conversion mutually between the coordinate systems of two planes based on the control points.
This is part of Maplat project.

Important Notice - deprecated

maplat_tin module is renamed as @maplat/tin.
Please use @maplat/tin module instead.

Installation

node.js

The easiest way to install maplat_tin is with npm.

npm install maplat_tin

Browser

Use maplat_tin.js

<script type="text/javascript" src="maplat_tin.js"></script>

How to use (node.js case)

var Tin = require('maplat_tin');

var tin = new Tin({
    wh: [500, 500],
    yaxisMode: Tin.YAXIS_FOLLOW
});

tin.setPoints([
  [[100,100], [200, 200]],
  [[200,200], [400, 400]],
  [[150,150], [320, 350]],
  [[200,100], [420, 220]]
]);
tin.updateTinAsync().then(function() {
  if (tin.strict_status == Tin.STATUS_STRICT) {
    console.log('Topology OK: In this case, roundtrip transform is guaranteed');
  } else if (tin.strict_status == Tin.STATUS_LOOSE) {
    console.log('Topology error: In this case, roundtrip transform is not guaranteed');
  } else {
    console.log('Something wrong');
  }

  //Forward transform
  var ord = tin.transform([160, 160], false);
  console.log(ord);
  //ord => [336.0769755832048, 360.048109739503]

  //Backward transform
  var rev = tin.transform(ord, true);
  console.log(rev);
  //rev => [160, 160]

  //Solving triangulated irregular network from many points by scrach takes too many time.
  //So, there are object-serialization method to store solved instance.

  var compiled = tin.getCompiled();

  var tin2 = new Tin();
  tin2.setCompiled(compiled);
  // Compiled triangulated irregular network was set. no "updateTinAsync" call is need.

  var ord2 = tin.transform([160, 160], false);
  console.log(ord2);
  var rev2 = tin.transform(ord2, true);
  console.log(rev2);
  //Same results with ord, rev
}).catch(function(e) {
  if (e == 'TOO LINEAR1' || e == 'TOO LINEAR2') {
    console.log('Given GCP points are too linear, fail to create triangulated irregular network.');
  } else {
    console.log('Something wrong');
  }
});

Options

wh (method: setWh)

Set width and height of the first coordinate system.
NOTE: If setWh was called, TIN network is reset. So need to call updateTinAsync() again.

yaxisMode

Set Tin.YAXIS_FOLLOW if the y coordinate of the first coordinate system is the same as the direction of the y axis of the second coordinate system, and set Tin.YAXIS_INVERT if it is in the opposite direction.
Default value is Tin.YAXIS_INVERT.

points (method: setPoints)

A set of corresponding points in the first coordinate system and the second coordinate system is specified as an array. Minimum 3 points required. Also, if the alignment of points is too linear, TIN can not be calculated at updateTinAsync and an error occurs.
NOTE: If setPoints was called, TIN network is reset. So need to call updateTinAsync() again.

Methods

updateTinAsync()

Return value is Promise. Calcurate TIN asynchronously. Before calling transform, this method needs to be completed.

transform(xy, inverse)

Convert the coordinates. If the value of inverse is false, the direction of conversion is from the first coordinate system to the second one, if it is true, the direction of conversion is reverse direction.

Properties

strict_status

Confirm after completion of updateTinAsync(). When the value is Tin.STATUS_STRICT, bijection conversion is guaranteed. In the case of Tin.STATUS_LOOSE it is not guaranteed.