1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//!
//! Coordinate transformation library
//!
//! Based on Proj4 implementation
//!
//! References:
//! * <http://docs.opengeospatial.org/as/18-005r5/18-005r5.html>
//! * <https://proj.org/development/reference/cpp/cpp_general.html>
//!
//! The aim of Proj4rs is to provide at short term the same functionality as the original
//! proj4 library.
//!
//! The long term project is to integrate feature from the proj library in its latest
//! version.
//!
//! The goal of proj4rs is not to be a remplacement of proj, but instead being a light
//! weight implementation of transformations from crs to crs that could be used
//! in WASM environment
//!
//! ## Usage
//!
//! Note that angular units are in radians, not degrees !
//!
//! Radian is natural unit for trigonometric opérations, like proj, proj4rs use radians
//! for its operation while degrees are mostly used as end user input/output.
//!
//! Example:
//! ```
//! 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();
//!
//! // XXX Note that angular unit is 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
//! ```
//!
//! ## Optional features
//!
//! * **geo-types**: [geo-types](<https://docs.rs/geo-types/latest/geo_types/>) support
//! * **logging**: support for logging with [log](https://docs.rs/log/latest/log/) crate.
//! If activated for WASM, it will use the [console-log](https://docs.rs/console_log/latest/console_log/)
//! adaptor.
//! * **wasm-strict**: used with WASM; Transformation operation will return exception as soon as we
//! have invalid coordinates or that the reprojection failed.
//! The default is to use a relaxed-mode that return NaN in case of projection failure: this is expected
//! mostly from js app (at least with OpenLayer).
//! * **multi-thread**: Support for multi-thread with NAD Grid processing, this is activated by
//! default and disabled when compiling for WASM.
//! * **crs-definitions**: Support for initializing projections from EPSG codes with the
//! [crs_definitions](https://docs.rs/crs-definitions/latest/crs_definitions/) crate.
//!
//! ## WKT Support
//!
//! There is no actual default support for WKT in proj4rs
//! If you are looking for WTK/Proje string conversion support in Rust,
//! then have a look at:
//!
//! - <https://github.com/3liz/proj4wkt-rs>
//! - <https://github.com/frewsxcv/crs-definitions>
//!
//! Note that the proj library provides a great implementation of the standard.
//!
//! ## Grid shift supports
//!
//! Nadgrid support is still experimental.
//! Currently, only Ntv2 multi grids are supported for native build and WASM.
//!
// Reexport
pub use Proj;
// Include wasm entry point for wasm32-unknown-unknown
// log for logging (optional).
use log;