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

proj4rs

v0.1.6

Published

Rust adaptation of Proj4

Downloads

5

Readme

Crates.io Documentation Demo


Rust library for transforming geographic point coordinates from one coordinate system to another. This is a pure Rust implementation of the PROJ.4 project.

The documentation is available on docs.rs and the demo on docs.3liz.org.

Features and Limitations

  • The aim of Proj4rs is to provide the same functionality as the proj4js library.
  • This port implements the PROJ.4 API, which means there's no 3D/4D/orthometric transformation ATM.
  • The goal of Proj4rs is not to be a replacement of PROJ, but instead being a lightweight implementation of transformations from CRS to CRS that could be used in Rust and WASM environments.
  • This crate does not provide support for WKT. Instead, there is a dedicated crate for transforming WKT strings to proj string.
  • It aims to be WASM compatible for the wasm32-unknown-unknown target.
  • No installation of external C libraries such as libproj or sqlite3 is needed.

Basic usage in Rust

Define the coordinate system with proj strings and use the transform function. You can easily get the projection string of any coordinate system from EPSG.io.

Note: Proj4rs use radians as natural angular unit (as does the original proj library)

Example:

use proj4rs;
use proj4rs::proj::Proj;

// EPSG:5174 - Example
let from = Proj::from_proj_string(concat!(
    "+proj=tmerc +lat_0=38 +lon_0=127.002890277778",
    " +k=1 +x_0=200000 +y_0=500000 +ellps=bessel",
    " +towgs84=-145.907,505.034,685.756,-1.162,2.347,1.592,6.342",
    " +units=m +no_defs +type=crs"
))
.unwrap();

// EPSG:4326 - WGS84, known to us as basic longitude and latitude.
let to = Proj::from_proj_string(concat!(
    "+proj=longlat +ellps=WGS84",
    " +datum=WGS84 +no_defs"
))
.unwrap();

let mut point_3d = (198236.3200000003, 453407.8560000006, 0.0);
proj4rs::transform::transform(&from, &to, &mut point_3d).unwrap();

// Note that WGS84 output from this library is in radians, not degrees.
point_3d.0 = point_3d.0.to_degrees();
point_3d.1 = point_3d.1.to_degrees();

// Output in longitude, latitude, and height.
println!("{} {}",point_3d.0, point_3d.1); // 126.98069676435814, 37.58308534678718

WKT support

If you need full support for WKT, please rely on proj which provides a great implementation of the standards.

If you want WKT support in WASM, please have a look at:

  • https://github.com/3liz/proj4wkt-rs
  • https://github.com/frewsxcv/crs-definitions

Grid shift supports

Nadgrid support is still experimental. Currently, only Ntv2 multi grids are supported for native build and WASM.

JavaScript API

When compiled for WASM, the library exposes JavaScript API that is very similar to that of proj4js. A thin JavaScript layer provides full compatibility with proj4js and thus can be used as a proj4js replacement.

Example:

let from = new Proj.Projection("+proj=latlong +ellps=GRS80");
let to = new Proj.Projection("+proj=etmerc +ellps=GRS80");
let point = new Proj.Point(2.0, 1.0, 0.0);

// Point is transformed in place
Proj.transform(from, to, point);

Contributing

You can contribute to this library by going on the proj4rs repository