Skip to main content

Crate proj_wkt

Crate proj_wkt 

Source
Expand description

Parser for WKT and PROJ format CRS strings.

Converts CRS definition strings into proj_core::CrsDef values that can be used with proj_core::Transform::from_crs_defs().

§Supported formats

  • Authority codes: "EPSG:4326" — delegates to proj-core’s registry
  • PROJ strings: "+proj=utm +zone=18 +datum=WGS84" — parsed into CrsDef
  • WKT1: GEOGCS[...] / PROJCS[...] / COMPD_CS[...] — extracts an AUTHORITY tag when present, otherwise parses projection parameters
  • WKT1/WKT2/PROJJSON compound CRS: parses explicit vertical CRS components for equality-checked z preservation and same-reference vertical unit conversion
  • WKT output: serializes proj_core::CrsDef values to WKT1-style GEOGCS[...], PROJCS[...], and COMPD_CS[...] definitions

Custom CRS definitions are only accepted when their semantics fit the proj_core::CrsDef model: longitude/latitude geographic coordinates in degrees with a Greenwich prime meridian, projected coordinates with easting/northing axis order, and compound vertical components that can be preserved or unit-converted only when source and target vertical CRS definitions use the same vertical reference frame. Parsed PROJ +nadgrids metadata is applied by transform_from_crs_strings, transform_from_crs_strings_with_selection_options, and the Proj facade as explicit custom coordinate operations; plain parse_crs returns only the CRS definition. Unsupported axis-order, prime-meridian, geographic angular-unit, and vertical transformation semantics are rejected. EPSG-tagged WKT1 definitions with an authority-native axis permutation are validated and canonicalized to the library’s longitude/latitude or easting/northing coordinate order.

§Example

use proj_wkt::parse_crs;
use proj_core::Transform;

let from = parse_crs("+proj=longlat +datum=WGS84").unwrap();
let to = parse_crs("EPSG:3857").unwrap();
let t = Transform::from_crs_defs(&from, &to).unwrap();
let (x, y) = t.convert((-74.006, 40.7128)).unwrap();

Structs§

Proj
Lightweight compatibility facade for downstream code that currently expects a proj::Proj-like flow:

Enums§

ParseError
Parse error.

Functions§

parse_crs
Parse a CRS definition string in any supported format.
to_projjson
Serialize a CRS definition as PROJJSON.
to_wkt
Serialize a CRS definition as WKT1-style GEOGCS, PROJCS, or COMPD_CS.
to_wkt2
Serialize a CRS definition as WKT2 (ISO 19162) GEOGCRS, PROJCRS, or COMPOUNDCRS.
transform_from_crs_strings
Create a Transform from two CRS strings in any format.
transform_from_crs_strings_horizontal
Create a horizontal-only Transform from two CRS strings in any format.
transform_from_crs_strings_horizontal_with_selection_options
Create a horizontal-only Transform from two CRS strings using explicit selection options.
transform_from_crs_strings_with_selection_options
Create a Transform from two CRS strings using explicit selection options.

Type Aliases§

Result