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

mproj

v0.0.40

Published

A JavaScript port of the Proj.4 cartographic projections library

Downloads

46,943

Readme

mapshaper-proj

This software is a JavaScript port of v4.9.3 of the Proj.4 map projection library. Although it was created to be used by mapshaper, all are welcome to use and improve it.

Why create another Proj.4 port, when there is already proj4js? Unlike proj4js, this port is a very literal translation to JavaScript, so staying up-to-date with future changes to Proj.4 should be relatively simple. Also, this software's output is more consistent with Proj.4's output.

Missing features
  • No support for datum transformations using grid files.

  • About 1/5 of Proj.4's 130-odd projections have not been ported.

Command line programs: mproj and mcs2cs

These are workalike versions of the proj and cs2cs programs from Proj.4.

To install the current versions system-wide, run npm install -g mproj.

Node API

The software can be used in either the Proj.4 style or the proj4js style.

proj4js style
var proj = require('mproj');
# create functions for translating between two coordinate systems
# returned object has forward() and inverse() functions
var obj = proj(<source definition>, <dest definition>);

# WGS84 is assumed if a source definition is not given
var obj = proj(<dest definition>);

# a shortcut for translating a single point
# <point> is an [x, y] array or an object with x and y properties
var xy = proj([<source definition>,] dest definition, <point>);

See the proj4js.org website for more detailed help.

Proj.4 style
var proj = require('mproj');
# create a projection object from a proj4 string
var P = proj.pj_init(<proj4 crs definition>);

# project and inverse-project geographical coordinates
var xy = proj.pj_fwd({lam: <longitude in radians>, phi: <latitude in radians>}, P);
var lp = proj.pj_inv({x: <easting in meters>, y: <northing in meters>}, P);

# transform arrays of coordinates from one coordinate system to another
proj.pj_transform(<source crs>, <dest crs>, <x array>, <y array>[, <z array>]);
Error handling

The x and y coordinates of unprojectable points are set to Infinity. Other errors cause an Error to be thrown containing an appropriate message.

Building

mapshaper-proj uses the (old-fashioned) technique of concatenating source files and wrapping them in a function to create a module with a shared scope. This method allows for global variables that are invisible outside of the program, making porting from the original C much simpler than if we were to make each source file a separate module.

Running build creates a build containing all supported projections in the dist/ directory.

Running build merc,lcc,aea creates a build containing only the listed projections. You can customize the comma-separated list to include only the projections that you want. Run mproj -l to see a list of all supported projections.