Struct proj::ProjBuilder
source · [−]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
sourceimpl ProjBuilder
impl ProjBuilder
sourcepub fn enable_network(&mut self, enable: bool) -> Result<u8, ProjError>
This is supported 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.
sourceimpl 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.
extern crate proj;
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.
Trait Implementations
sourceimpl Default for ProjBuilder
impl Default for ProjBuilder
sourceimpl Drop for ProjBuilder
impl Drop for ProjBuilder
sourceimpl Info for ProjBuilder
impl Info for ProjBuilder
sourcefn info(&self) -> Result<Projinfo, ProjError>
fn info(&self) -> Result<Projinfo, ProjError>
Return Information about the current PROJ context Read more
sourcefn network_enabled(&self) -> bool
fn network_enabled(&self) -> bool
Check whether network access for resource file download is currently enabled or disabled. Read more
Auto Trait Implementations
impl RefUnwindSafe for ProjBuilder
impl !Send for ProjBuilder
impl !Sync for ProjBuilder
impl Unpin for ProjBuilder
impl UnwindSafe for ProjBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more