Move to proj-sys and proj.4 v5#6
Merged
Merged
Conversation
Member
Author
|
Update: error handling works now. |
Member
Author
|
Ugh bindgen is choking on multiple definitions after I |
Projections are currently broken
TODO: error handling
Need a better way to handle conversions
frewsxcv
approved these changes
Mar 12, 2018
| # 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: |
Member
There was a problem hiding this comment.
proj.5 uses the
should this be:
proj.4 uses the
| #[should_panic] | ||
| // Test that instantiation fails wth bad proj string input | ||
| fn test_init_error() { | ||
| let _ = Proj::new("ugh").unwrap(); |
Member
There was a problem hiding this comment.
alternatively
assert!(Proj::new("ugh").is_none());
Member
Author
|
bors r+ |
Contributor
|
🔒 Permission denied Existing reviewers: click here to make urschrei a reviewer |
Member
|
@urschrei just gave you review permissions for the repo |
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>
Contributor
Build succeeded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-syscrate (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 offromandtoprojections.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
Projstruct. 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 theconversionexample). The conversion function also returns aResultnow, and errors are implemented usingFailure.Anyway, this is currently WIP until I figure out how to detect errors using the new API.