[][src]Crate proj

proj provides bindings to the PROJ v7.1.x API

Two coordinate transformation operations are currently provided: projection (and inverse projection) and conversion. Projection is intended for transformations between geodetic and projected coordinates and vice versa (inverse projection), while conversion is intended for transformations between projected coordinate systems. The PROJ documentation explains the distinction between these operations in more detail.

Anything that can be converted into a geo-types Point via the Into trait can be used as input for the projection and conversion functions, and methods for conversion and projection of slices of Points are available.

Usage

There are two options for creating a transformation:

  1. If you don't require additional grids or other customisation:
    • Call Proj::new or Proj::new_known_crs. This creates a transformation instance (Proj)
  2. If you require a grid for the transformation you wish to carry out, or you need to customise the search path or the grid endpoint:

Note:

  1. Both ProjBuilder and Proj implement the Info trait, which can be used to get information about the current state of the PROJ instance;
  2. Proj::new() and ProjBuilder::proj() have the same signature;
  3. Proj::new_known_crs() and ProjBuilder::proj_known_crs() have the same signature.

Network, Cache, and Search Path Functionality

Grid File Download

proj supports network grid download functionality. Network access is disabled by default, and can be activated by passing a true bool to enable_network(). Network functionality status can be queried with network_enabled, and the download endpoint can be queried and set using get_url_endpoint and set_url_endpoint.

Grid File Cache

Up to 300 mb of downloaded grids are cached to save bandwidth: This cache can be enabled or disabled using grid_cache_enable.

Search Path Modification

The path used to search for resource files can be modified using set_search_paths

Requirements

By default, the crate requires libproj 7.1.x to be present on your system. While it may be backwards-compatible with older PROJ 6 versions, this is neither tested nor supported.

Two features are available:

proj = { version = "0.16.1", features = ["pkg_config"] }
proj = = { version = "0.16.1", features = ["bundled_proj"] }

The pkg_config feature enables the use of pkg-config when linking against libproj – note that pkg-config must be available on your system.

The bundled_proj feature statically links against a libproj included with (and built from source by) the proj-sys crate. Note that this feature requires Sqlite3 and libtiff to be available on your system.

Example

use assert_approx_eq::assert_approx_eq;
extern crate proj;
use proj::Proj;

extern crate geo_types;
use geo_types::Point;

let from = "EPSG:2230";
let to = "EPSG:26946";
let nad_ft_to_m = Proj::new_known_crs(&from, &to, None).unwrap();
let result = nad_ft_to_m
    .convert(Point::new(4760096.421921f64, 3744293.729449f64))
    .unwrap();
assert_approx_eq!(result.x(), 1450880.29f64, 1.0e-2);
assert_approx_eq!(result.y(), 1141263.01f64, 1.0e-2);

Structs

Area

The bounding box of an area of use

Proj

A coordinate transformation object

ProjBuilder

A PROJ Context instance, used to create a transformation object.

Projinfo

Information about PROJ

Enums

ProjError

Errors originating in PROJ which can occur during projection and conversion

Traits

Info

Read-only utility methods for providing information about the current PROJ instance