-
Notifications
You must be signed in to change notification settings - Fork 6
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
67 handle optional grids #68
Merged
busstoptaktik
merged 5 commits into
busstoptaktik:main
from
Rennzie:67-handle-optional-grids
Nov 3, 2023
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1b949bc
gridshift operator handles optional grids
Rennzie 0446ed1
use match for optionality checking
Rennzie 0de8994
update rumination with additional grid features
Rennzie 6032d39
some improvements and additional tests
busstoptaktik e29457f
Merge pull request #3 from busstoptaktik/67-handle-optional-grids
Rennzie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
Thomas Knudsen <[email protected]> | ||
Sean Rennie <[email protected]> | ||
|
||
2021-08-20. Last [revision](#document-history) 2023-10-19 | ||
2021-08-20. Last [revision](#document-history) 2023-11-02 | ||
|
||
### Abstract | ||
|
||
|
@@ -304,7 +304,7 @@ The `gridshift` operator implements datum shifts by interpolation in correction | |
| Parameter | Description | | ||
|-----------|-------------| | ||
| `inv` | Inverse operation: output-to-input datum. For 2-D and 3-D cases, this involves an iterative refinement, typically converging after less than 5 iterations | | ||
| `grids` | Name of the grid file to use. RG supports only one file for each operation, but maintains the plural form of the `grids` option for alignment with the PROJ precedent | | ||
| `grids` | Name of the grid files to use. RG supports multiple comma separated grids where the first one to contain the point is the one used. Grids are considered optional if they are prefixed with `@` and do not error the operator if they aren't available. Additionally the `@null` parameter can be specified as the last grid which will prevent errors in shifts from stomping on the coordinate. That is to say the coordinate passes through unchanged. | | ||
|
||
The `gridshift` operator has built in support for the **Gravsoft** grid format. Support for additional file formats depends on the `Context` in use. | ||
|
||
|
@@ -315,6 +315,10 @@ For grids with angular (geographical) spatial units, the corrections are suppose | |
|
||
```term | ||
geo:in | gridshift grids=ed50.datum | geo:out | ||
|
||
geo:in | gridshift grids=ed50.datum,@null | geo:out | ||
|
||
geo:in | gridshift [email protected],ed50.datum | geo:out | ||
``` | ||
|
||
**See also:** PROJ documentation, [`hgridshift`](https://proj.org/operations/transformations/hgridshift.html) and [`vgridshift`](https://proj.org/operations/transformations/vgridshift.html). RG combines the functionality of the two: The dimensionality of the grid determines whether a plane or a vertical transformation is carried out. | ||
|
@@ -738,4 +742,5 @@ Major revisions and additions: | |
registered update on 2022-05-08. a large number of new operators | ||
have been included and described | ||
- 2023-07-09: dm and dms liberated from their NMEA overlord | ||
- 2023-10-19: Add `somerc` operator description | ||
- 2023-10-19: Add `somerc` operator description | ||
- 2023-11-02: Update `gridshift` operator description with multi, optional and null grid support |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,10 +134,15 @@ pub fn new(parameters: &RawParameters, ctx: &dyn Context) -> Result<Op, Error> { | |
continue; | ||
} | ||
|
||
// TODO: Handle @optional grids | ||
|
||
let grid = ctx.get_grid(&grid_name)?; | ||
params.grids.push(grid); | ||
match ctx.get_grid(&grid_name) { | ||
Ok(grid) => params.grids.push(grid), | ||
Err(e) => { | ||
if grid_name.contains("@") { | ||
continue; | ||
} | ||
return Err(e); | ||
} | ||
} | ||
} | ||
|
||
let fwd = InnerOp(fwd); | ||
|
@@ -237,6 +242,34 @@ mod tests { | |
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn optional_grid() -> Result<(), Error> { | ||
let mut ctx = Plain::default(); | ||
let op = ctx.op("gridshift [email protected],../../geodesy/datum/test.datum")?; | ||
let cph = Coor4D::geo(55., 12., 0., 0.); | ||
let mut data = [cph]; | ||
|
||
ctx.apply(op, Fwd, &mut data)?; | ||
let res = data[0].to_geo(); | ||
assert!((res[0] - 55.015278).abs() < 1e-6); | ||
assert!((res[1] - 12.003333).abs() < 1e-6); | ||
|
||
ctx.apply(op, Inv, &mut data)?; | ||
assert!((data[0][0] - cph[0]).abs() < 1e-10); | ||
assert!((data[0][1] - cph[1]).abs() < 1e-10); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn missing_grid() -> Result<(), Error> { | ||
let mut ctx = Plain::default(); | ||
let op = ctx.op("gridshift grids=missing.gsb"); | ||
assert!(op.is_err()); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
// See additional tests in src/grid/mod.rs |
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.
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.
Some help with adding tests here would be appreciated. I couldn't figure out what a minimal passing test should be.