pub struct ProjBuilder { /* private fields */ }
Expand description
A PROJ
Context instance, used to create a transformation object.
Create a transformation object by calling proj
or proj_known_crs
.
Implementations§
Source§impl ProjBuilder
impl ProjBuilder
Sourcepub fn lib_info(&self) -> Result<Info, ProjError>
pub fn lib_info(&self) -> Result<Info, ProjError>
Return information about the current instance of the PROJ libary.
See: https://proj.org/development/reference/datatypes.html#c.PJ_INFO
If instead you are looking for information about the current projection / conversion, see
Proj::proj_info
.
§Safety
This method contains unsafe code.
Sourcepub fn network_enabled(&self) -> bool
pub fn network_enabled(&self) -> bool
Check whether network access for resource file download is currently enabled or disabled.
§Safety
This method contains unsafe code.
Sourcepub fn get_url_endpoint(&self) -> Result<String, ProjError>
pub fn get_url_endpoint(&self) -> Result<String, ProjError>
Sourcepub fn enable_network(&mut self, enable: bool) -> Result<u8, ProjError>
Available on crate feature network
only.
pub fn enable_network(&mut self, enable: bool) -> Result<u8, ProjError>
network
only.Enable or disable network access for resource file download.
§Safety
This method contains unsafe code.
Sourcepub fn set_search_paths<P: AsRef<Path>>(
&mut self,
newpath: P,
) -> Result<(), ProjError>
pub fn set_search_paths<P: AsRef<Path>>( &mut self, newpath: P, ) -> Result<(), ProjError>
Add a resource file search path, maintaining existing entries.
§Safety
This method contains unsafe code.
Sourcepub fn grid_cache_enable(&mut self, enable: bool)
pub fn grid_cache_enable(&mut self, enable: bool)
Enable or disable the local cache of grid chunks
To avoid repeated network access, a local cache of downloaded chunks of grids is implemented as SQLite3 database, cache.db, stored in the PROJ user writable directory. This local caching is enabled by default. The default maximum size of the cache is 300 MB, which is more than half of the total size of grids available, at time of writing.
§Safety
This method contains unsafe code.
Source§impl ProjBuilder
impl ProjBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ProjBuilder
, allowing grid downloads and other customisation.
Sourcepub fn proj(self, definition: &str) -> Result<Proj, ProjCreateError>
pub fn proj(self, definition: &str) -> Result<Proj, ProjCreateError>
Try to create a coordinate transformation object
Note: for projection operations, definition
specifies
the output projection; input coordinates
are assumed to be geodetic in radians, unless an inverse projection is intended.
For conversion operations, definition
defines input, output, and
any intermediate steps that are required. See the convert
example for more details.
§Safety
This method contains unsafe code.
Sourcepub fn proj_known_crs(
self,
from: &str,
to: &str,
area: Option<Area>,
) -> Result<Proj, ProjCreateError>
pub fn proj_known_crs( self, from: &str, to: &str, area: Option<Area>, ) -> Result<Proj, ProjCreateError>
Try to create a transformation object that is a pipeline between two known coordinate reference systems.
from
and to
can be:
- an
"AUTHORITY:CODE"
, like"EPSG:25832"
. - a PROJ string, like
"+proj=longlat +datum=WGS84"
. When using that syntax, the unit is expected to be degrees. - the name of a CRS as found in the PROJ database, e.g
"WGS84"
,"NAD27"
, etc. - more generally, any string accepted by
new()
If you wish to alter the particular area of use, you may do so using area_set_bbox()
§A Note on Coordinate Order
The required input and output coordinate order is normalised to Longitude, Latitude
/ Easting, Northing
.
This overrides the expected order of the specified input and / or output CRS if necessary. See the PROJ API
For example: per its definition, EPSG:4326 has an axis order of Latitude, Longitude. Without
normalisation, crate users would have to
remember
to reverse the coordinates of Point
or Coordinate
structs in order for a conversion operation to
return correct results.
use proj::{Proj, Coord};
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((4760096.421921f64, 3744293.729449f64))
.unwrap();
assert_relative_eq!(result.x(), 1450880.29, epsilon = 1.0e-2);
assert_relative_eq!(result.y(), 1141263.01, epsilon = 1.0e-2);
§Safety
This method contains unsafe code.