Skip to content
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

Merged
merged 31 commits into from
Mar 12, 2018
Merged

Move to proj-sys and proj.4 v5 #6

merged 31 commits into from
Mar 12, 2018

Conversation

urschrei
Copy link
Member

@urschrei urschrei commented Mar 8, 2018

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 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, 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.
Anyway, this is currently WIP until I figure out how to detect errors using the new API.

@urschrei
Copy link
Member Author

urschrei commented Mar 8, 2018

Update: error handling works now.

@urschrei urschrei changed the title [WIP] Move to proj-sys and proj.4 v5 Move to proj-sys and proj.4 v5 Mar 8, 2018
@urschrei
Copy link
Member Author

urschrei commented Mar 8, 2018

Ugh bindgen is choking on multiple definitions after I included the legacy API so I could look up errors. Hrmm.

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:
Copy link
Member

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();
Copy link
Member

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());

@urschrei
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 12, 2018

🔒 Permission denied

Existing reviewers: click here to make urschrei a reviewer

@frewsxcv
Copy link
Member

@urschrei just gave you review permissions for the repo

@urschrei
Copy link
Member Author

bors r=frewsxcv

bors bot added a commit that referenced this pull request Mar 12, 2018
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>
@bors
Copy link
Contributor

bors bot commented Mar 12, 2018

Build succeeded

@bors bors bot merged commit 9284f7d into georust:master Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants