2 releases
| 0.1.1 | Sep 19, 2025 |
|---|---|
| 0.1.0 | Jun 8, 2023 |
#289 in Geospatial
1,394 downloads per month
69KB
2K
SLoC
WKT CRS parser
Convert WKT CRS to proj string
Support both WKT1 and WKT2 formats.
This is a companion crate for proj4rs because of this conversions are limited
to projection supported by proj4rs. As more projection will be supported
in proj4rs, more conversions will be supported in proj4wt.
This crate may be built as WASM package
Example:
use proj4wkt::wkt_to_projstring;
const nad83: &str = concat!(
r#"PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83","#,
r#"DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,"#,
r#"AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,"#,
r#"AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,"#,
r#"AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,"#,
r#"AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_2SP"],"#,
r#"PARAMETER["standard_parallel_1",42.68333333333333],"#,
r#"PARAMETER["standard_parallel_2",41.71666666666667],"#,
r#"PARAMETER["latitude_of_origin", -41],PARAMETER["central_meridian",-71.5],"#,
r#"PARAMETER["false_easting",200000],PARAMETER["false_northing",750000],"#,
r#"AUTHORITY["EPSG","26986"],AXIS["X",EAST],AXIS["Y",NORTH]]"#,
);
let projstr = wkt_to_projstring(nad83).unwrap();
assert_eq!(
projstr,
concat!(
"+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667",
" +lat_0=-41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +units=m +a=6378137",
" +rf=298.257222101 +towgs84=0,0,0,0,0,0,0",
)
);
Proj4wkt
Convert WKT strings to proj4 strings.
Support both WKT1 and WKT2 formats.
This is a companion crate for proj4rs: because of this conversions are limited
to projection supported by proj4rs. As more projection will be supported in proj4rs, more conversions will be supported in `proj4wt.
Documentation on doc.rs
Compiling for WASM
Install wasm-pack
wasm-pack build --target web --no-default-features
Or if you have installed cargo-make, use the following command:
cargo make wasm
Running the WASM example
There is a index.html file for testing the WASM module in a navigator.
For security reason you need to run it from a server; you can pop up a server from python with the following command:
python3 -m http.server
The server will automatically serve the index.html file in the current directory.
Dependencies
~0.9–3.5MB
~70K SLoC