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
added new projection function for Navionics Mercator #391
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7346734
adding PJ_nav_merc for Navionics Mercator
mpasquini ecf3f5c
removed unused pj_nav_tsfn embeded in PJ_nav_merc
mpasquini 8a5bd61
updated src/lib_proj.cmake passed all travis tests locally. TODO:add …
mpasquini 9295f89
PJ_nav_merc.c: added 3 extra points as test, all test passed, recheck…
mpasquini 4b67ca7
added comments to function, NOT adding MSword document
mpasquini 100a2d9
added references to makefile.vc, missing MS envirounment to test on m…
mpasquini 5df7d0b
updated proj parameters to +ellps=intl instead of +a=6378388.0 +rf=29…
mpasquini File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
***** Navionics Mercator **************** | ||
* | ||
* (co)author pasquini.matteo@gmail.com, mpasquini@navionics.com | ||
* | ||
* datum(barely speaking): | ||
* based on Hayford 1909 ellipsoid but geocentered. | ||
* | ||
* attributes: | ||
* - geocentered | ||
* - a = 6378388 | ||
* - b = 6356912 | ||
* - (a/b)/a = 1/297.0 | ||
* - eccentricity = 0.081991889977 | ||
* - KC = 1.00676429271698 | ||
* | ||
* orignal functions are in decimal degrees(instead radians) | ||
* this implementation is(should be) the most precise in radians, | ||
* the first outside proprietary Navionics S.p.A. SDK | ||
* | ||
* note the KC is a CONST value that substitute the P->e | ||
* it have some similarity with PJ_merc and PJ_tsfn | ||
* , all maths help are wellcome ... | ||
* | ||
* This few lines represent a "small docs" | ||
* complete documentation is in .docx format, to not pollute this beautiful project | ||
* i prefer that you bother me throught email request. | ||
* | ||
* this is my first piece of C in the real world. | ||
* | ||
*/ | ||
|
||
|
||
|
||
#define PJ_LIB__ | ||
#include <projects.h> | ||
|
||
PROJ_HEAD(nav_merc, "Navionics Mercator") "\n\tEll\n\tlat_ts="; | ||
|
||
#define EPS10 1.e-10 | ||
#define KC 1.00676429271698 | ||
|
||
|
||
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ | ||
XY xy = {0.0,0.0}; | ||
if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) | ||
F_ERROR; | ||
|
||
xy.y = log(tan( .5 * atan (tan(lp.phi)/KC) + M_FORTPI) ) ; | ||
xy.x = P->k0 * lp.lam; | ||
return (xy); | ||
} | ||
|
||
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ | ||
LP lp = {0.0,0.0}; | ||
if ((lp.phi = pj_phi2(P->ctx, exp(- xy.y / P->k0), P->e)) == HUGE_VAL) | ||
I_ERROR; | ||
|
||
lp.phi = atan2((tan((atan(exp(xy.y)) * 2.) - M_HALFPI) * KC), 1); | ||
lp.lam = xy.x / P->k0; | ||
return lp; | ||
} | ||
|
||
static void freeup(PJ *P) { /* Destructor */ | ||
pj_dealloc(P); | ||
} | ||
|
||
|
||
PJ *PROJECTION(nav_merc) { | ||
double phits=0.0; | ||
int is_phits; | ||
|
||
if( (is_phits = pj_param(P->ctx, P->params, "tlat_ts").i) ) { | ||
phits = fabs(pj_param(P->ctx, P->params, "rlat_ts").f); | ||
if (phits >= M_HALFPI) E_ERROR(-24); | ||
} | ||
|
||
if (P->es) { /* ellipsoid */ | ||
if (is_phits) | ||
P->k0 = pj_msfn(sin(phits), cos(phits), P->es); | ||
P->inv = e_inverse; | ||
P->fwd = e_forward; | ||
} | ||
|
||
return P; | ||
} | ||
|
||
|
||
#ifdef PJ_OMIT_SELFTEST | ||
int pj_nav_merc_selftest (void) {return 0;} | ||
#else | ||
|
||
int pj_nav_merc_selftest (void) { | ||
double tolerance_lp = 1e-10; | ||
double tolerance_xy = 1e-7; | ||
|
||
char e_args[] = {" -w6 +proj=nav_merc +a=6378388.0 +rf=297"}; | ||
|
||
LP fwd_in[] = { | ||
{ 950594.539, 5968306.230 }, | ||
{ 1178796.03, 5276463.78 }, | ||
{ 18671158.340, -5945578.371 }, | ||
{ 20038296.88, -18765191.35 } | ||
}; | ||
|
||
XY e_fwd_expect[] = { | ||
{ 8.5390000000, 47.3515666667 }, | ||
{ 10.5888881683, 42.9574966432 }, | ||
{ 167.7192687988, -47.2126350403 }, | ||
{ 179.9998888889, -84.0 }, | ||
}; | ||
|
||
XY inv_in[] = { | ||
{ 8.5390000000, 47.3515666667 }, | ||
{ 10.5888881683, 42.9574966432 }, | ||
{ 167.7192687988, -47.2126350403 }, | ||
{ 180.0, -84.0 } | ||
}; | ||
|
||
LP e_inv_expect[] = { | ||
{ 950594.539, 5968306.230 }, | ||
{ 1178796.03, 5276463.78 }, | ||
{ 18671158.340, -5945578.371 }, | ||
{ 20038296.883, -18765191.347 }, | ||
}; | ||
|
||
|
||
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, e_fwd_expect, inv_in, 0, e_inv_expect ); | ||
} | ||
|
||
|
||
#endif |
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
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.
+a=6378388.0 +rf=297
could be replaced with the shorthand+ellps=intl
. This is a slight preference.Here is how I looked that up from the command line.