-
Notifications
You must be signed in to change notification settings - Fork 752
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
Horisontal and vertical gridshift drivers #492
Conversation
fc911e6
to
bd951b9
Compare
Until now gridshifts has not been working with the new API in proj.h since parsing of +nadgrids and +geoidgrids is build into pj_transform(). This commit introduces the possibility to do vertical gridshift with the pipeline API. The vgridshift kernel is a simple wrapper for pj_apply_vgridshift() that is also used by pj_transform().
Until now gridshifts has not been working with the new API in proj.h since parsing of +nadgrids and +geoidgrids is build into pj_transform(). This commit introduces the possibility to do horizontal gridshift with the pipeline API. The hgridshift driver is a simple wrapper for the funtions in pj_apply_gridshift.c that is also used by pj_transform().
…nsistent with +nadgrids in cs2cs
I am now happy with this. @busstoptaktik would you please have a look and see if it makes sense to you? At the moment the forward operation of |
Actually, my main use case is the reverse ;-) when orthorectifying images with RPC, the transform (long, lat, elev) -> (x, y) expects elevations to be relative to the WGS84 elliposoid, so you will go from orthometric to ellipsoidal. I think it might be a good idea to keep the same conventions in the old and new API. |
I agree. And that's how I've set it up so far, as demonstrated with the |
I agree with @rouault that keeping the sign convention consistent is preferable. I also agree with @kbevers that the convention is confusing for the vgridshift case. But it may become slightly less confusing if we assume that the convention has been established in pre-GNSS times, which really is not that long ago, historically speaking. Prior to GNSS, you could hardly measure anything but orthometric heights ("elevations"), so when needing to go from geodetic/polar to geocentric/cartesian coordinates, you would need a geoid model and convert your elevations to geometric ("ellipsoidal") heights. Hence, going from the natural height system to the synthetic/geometrical would be seen as the forward direction. This is in fine accordance with the convention of map projections: Forward is when projecting FROM the "natural" latitude/longitude system, TO the "synthetic" planar, rectangular map coordinates. So the way to remember the sign conventions in Proj.4 may be that when you go from a (somewhat) natural system to a more planar geometrical, it is a step forward. Which makes sense if you're a cartographer, and probably somewhat less sense if you are a geophysicist :-) |
src/PJ_hgridshift.c
Outdated
PJ_OBS expect, a, b; | ||
double dist; | ||
|
||
/* fail on purpose: +grids parameter it mandatory*/ |
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.
it -> is
src/PJ_hgridshift.c
Outdated
|
||
P = pj_create ("+proj=hgridshift +grids=nzgd2kgrid0005.gsb +ellps=GRS80"); | ||
if (0==P) | ||
/* very likely the grid is missing */ |
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.
A comment makes more sense at the block level. Consider:
/* Failure most likely means that the grid is missing */
if (0==P)
return 10
src/PJ_vgridshift.c
Outdated
|
||
P = pj_create ("+proj=vgridshift +grids=egm96_15.gtx +ellps=GRS80"); | ||
if (0==P) | ||
/* most likely the grid wasn't found */ |
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.
cf comment in hgridshift about block level comments
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.
Looks good to me. I only have a few comments on comment structure, which you abviously may ignore if you disagree.
I believe this is a highly valuable contribution, much improving the utility of the pipeline functionality.
You point out a potential oops in your initial presentation of the work (the one about needing to input radians in cs2cs). I believe this should be corrected in cs2cs, if at all.
I have updated the comments in the code, and otherwise taken note of your comments about conventions. Could be useful at a later stage when writing proper documentation for this. Thanks for the review.
I can pretend to be a cartographer for a moment :-)
So how about adding a |
So now curl is not available on AppVeyor!? I wonder what has changed... worked fine a few days ago. |
According to appveyor/ci#1426 |
Until now gridshifts has not been working with the new API in
proj.h
since parsing of+nadgrids
and+geoidgrids
is build intopj_transform()
. This PR introduces the possibility to do horizontal and vertical gridshifting with the pipeline API.The
vgridshift
driver is a simple wrapper forpj_apply_vgridshift()
andhgridshift
is a wrapper for the functionality inpj_apply_gridshift.c
. Horizontal gridshifting has historically been done by adding the+nadgrids
parameter to the projection initializer string. With the changes in this PR it can now also be done in a projection pipeline by adding+proj=hgridshift +grids=grid1.gdb,grid2.gsb,gridN.gsb
. Similarly vertical gridshifts can be done by using+proj=vgridshift +grids=grid1.gtx,grid2.gtx,gridN.gtx
. With the old API you would use the+geoidgrids
parameter.I have deliberately used very generic names for the drivers since it can be expected to be used for more than just geoids and the North American Datum. With the generic names it is more obvious that the drivers can be used in many different cases, for instance transforming the vertical component from ellipsoidal heights to a chart datum like LAT.
A few examples comparing the old gridshifts style with the new: