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

Adding ellipsoidal equations for the Equal Earth #1101

Merged
merged 5 commits into from
Aug 22, 2018
Merged

Adding ellipsoidal equations for the Equal Earth #1101

merged 5 commits into from
Aug 22, 2018

Conversation

beuan
Copy link
Contributor

@beuan beuan commented Aug 22, 2018

This changes is for #1097.

@beuan beuan changed the title Adding Ellipsoidal Equations for the Equal Earth Adding ellipsoidal equations for the Equal Earth Aug 22, 2018
Copy link
Member

@kbevers kbevers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems fine to be, apart from my inlined comments.

The docs needs updating to reflect that the projection also exist in an ellipsoidal form.

src/PJ_eqearth.c Outdated
#include <math.h>

#include "projects.h"

PROJ_HEAD(eqearth, "Equal Earth") "\n\tPCyl., Sph.";
PROJ_HEAD(eqearth, "Equal Earth") "\n\tPCyl., Sph&Ell\n\th=";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with the \n\th= at the end here? As far as I can tell there's no +h parameter present in this projection. Bad cut & paste job?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, bad cut & paste.

sbeta = pj_qsfn(sin(lp.phi), P->e, 1.0 - P->es) / Q->qp;
if (fabs(sbeta) > 1) {
/* Rounding error. */
sbeta = sbeta > 0 ? 1 : -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a test case that exercises this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I can hit this test case. The best testing case is probably phi = +/-90. In this case pj_qsfn() function returns +/-Q->qp and for some rounding error it might hit this case. Those tests are already in and looked they are passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using phi > 90 would not help, because sin function would already "fix" this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, we'll live without a test for that

@kbevers
Copy link
Member

kbevers commented Aug 22, 2018

We also need +ellps listed under parameters.

@beuan
Copy link
Contributor Author

beuan commented Aug 22, 2018

@kbevers: I added +ellps parameter. I hope this is what you had in mind...

@kbevers
Copy link
Member

kbevers commented Aug 22, 2018

I added +ellps parameter. I hope this is what you had in mind...

Indeed it was. Thanks!

@beuan
Copy link
Contributor Author

beuan commented Aug 22, 2018

@kbevers @rouault, thank you for your comments, review and assistance!
Once all checks pass, should I merge or you prefer to be the one who merges?

@kbevers kbevers merged commit b2fe227 into OSGeo:master Aug 22, 2018
@kbevers
Copy link
Member

kbevers commented Aug 22, 2018

Once all checks pass, should I merge or you prefer to be the one who merges?

I just did. You shouldn't be able to do it. Thanks for adding this.

@beuan
Copy link
Contributor Author

beuan commented Aug 22, 2018

Thanks!

double sbeta;
double psi, psi2, psi6;

if (P->es != 0.0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bit of nitpicking here: For clarity, I would prefer to have block-scoped comments precede the block they refer to:

/* Ellipsoidal case, converting to authalic latitude */
if (P->es != 0.0) {
    sbeta = pj_qsfn(sin(lp.phi), P->e, 1.0 - P->es) / Q->qp;

    /* Rounding error. */
    if (fabs(sbeta) > 1) 
        sbeta = sbeta > 0 ? 1 : -1;
}

/* Spheroidal case, using latitude */
else 
    sbeta = sin(lp.phi);

Or with even less branching:

sbeta = sin(lp.phi);

/* In the ellipsoidal case, we convert sbeta to authalic latitude */
if (P->es != 0.0) {
    sbeta = pj_qsfn(sbeta, P->e, 1.0 - P->es) / Q->qp;

    /* Rounding error. */
    if (fabs(sbeta) > 1) 
        sbeta = sbeta > 0 ? 1 : -1;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Thomas, I merged this while you were writing...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry - although I think my suggestion has some merit in terms of clarity, it also is mostly cosmetical and may be simply a matter of personal preference

Copy link
Contributor Author

@beuan beuan Aug 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I happy to do the change and another PR if you would like to...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beuan: Well - I wrote the comment because I would prefer to minimize branching and have block-scope comments precede the block.

But it's your code, and it's already merged, so please only make the change if you personally find my (cosmetical) arguments highly convincing, and would like to see the change - in which case I will obviously feel honoured, that you found the comment convincing and/or useful :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@busstoptaktik No problem. Any additional inputs are welcome.
I have changes on the way. I just need to figure out how to make a pull request without any "merge conflicts"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

None yet

4 participants