-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to proj-sys and proj.4 v5 #6
Conversation
Update: error handling works now. |
Ugh bindgen is choking on multiple definitions after I |
Projections are currently broken
TODO: error handling
Need a better way to handle conversions
README.md
Outdated
# Example | ||
## Reproject from [Stereo70](https://epsg.io/3844) to [WGS84](https://epsg.io/4326) | ||
# Examples | ||
Note that as of v5.0.0, proj.5 uses the [`pipeline`](http://proj4.org/operations/pipeline.html) operator, which allows an arbitrary number of steps in a conversion. The first example below works as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proj.5 uses the
should this be:
proj.4 uses the
src/proj.rs
Outdated
#[should_panic] | ||
// Test that instantiation fails wth bad proj string input | ||
fn test_init_error() { | ||
let _ = Proj::new("ugh").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively
assert!(Proj::new("ugh").is_none());
bors r+ |
🔒 Permission denied Existing reviewers: click here to make urschrei a reviewer |
@urschrei just gave you review permissions for the repo |
bors r=frewsxcv |
6: Move to proj-sys and proj.4 v5 r=frewsxcv a=urschrei With the surprising release (after about 23 years) of proj.4 v5, and my blowing-the-cobwebs-off PR from yesterday (#5), I thought I'd publish a [`proj-sys`](https://crates.io/crates/proj-sys) crate (generated using `bindgen`), and use it as the basis for this. Currently, the API contains a very breaking change, because proj.4 performs operations differently now: it distinguishes between _projection_ (conversions from geodetic to projected coordinates) and _conversion_ (conversions between projected coordinate systems, usually within the same datum / reference frame). The latter uses a concept proj.4 calls the [`pipeline`](http://proj4.org/operations/pipeline.html), which allows for multi-step operations to achieve almost any kind of conversion, as opposed to the old system, which only allowed the specification of `from` and `to` projections. This change is mirrored in the rust-proj API: for simple (inverse) projection from/to geodetic coordinates, there's `project`, and for conversions and transformations there's `convert`. I'm not 100% sold on the API, because it feels a bit less flexible than the old one: you could specify different destination projections, and re-use the `Proj` struct. Using the new API, you have to specify everything up front, but you have a great deal more flexibility in terms of what you can do with it (see the `conversion` example). The conversion function also returns a `Result` now, and errors are implemented using `Failure`. <s>Anyway, this is currently WIP until I figure out how to detect errors using the new API.</s>
Build succeeded |
With the surprising release (after about 23 years) of proj.4 v5, and my blowing-the-cobwebs-off PR from yesterday (#5), I thought I'd publish a
proj-sys
crate (generated usingbindgen
), and use it as the basis for this.Currently, the API contains a very breaking change, because proj.4 performs operations differently now: it distinguishes between projection (conversions from geodetic to projected coordinates) and conversion (conversions between projected coordinate systems, usually within the same datum / reference frame). The latter uses a concept proj.4 calls the
pipeline
, which allows for multi-step operations to achieve almost any kind of conversion, as opposed to the old system, which only allowed the specification offrom
andto
projections.This change is mirrored in the rust-proj API: for simple (inverse) projection from/to geodetic coordinates, there's
project
, and for conversions and transformations there'sconvert
.I'm not 100% sold on the API, because it feels a bit less flexible than the old one: you could specify different destination projections, and re-use the
Proj
struct. Using the new API, you have to specify everything up front, but you have a great deal more flexibility in terms of what you can do with it (see theconversion
example). The conversion function also returns aResult
now, and errors are implemented usingFailure
.Anyway, this is currently WIP until I figure out how to detect errors using the new API.