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

Some suggestions for code cleanup #2387

Closed
cffk opened this issue Oct 21, 2020 · 4 comments · Fixed by #2388 or #3516
Closed

Some suggestions for code cleanup #2387

cffk opened this issue Oct 21, 2020 · 4 comments · Fixed by #2388 or #3516
Assignees
Labels

Comments

@cffk
Copy link
Contributor

cffk commented Oct 21, 2020

My recent update to the tmerc documentation #2379 was prompted by queries from NGA (the US National Geospatial Intelligence Agency) figuring what it should do with PROJ. Along the way there was talk of NGA doing a code review of PROJ. Of course, we should welcome this. However, there are many parts of PROJ which are showing their age. Some of these are ripe for updating to improve:

(a) clarity of the code
(b) accuracy
(c) speed

I've identified the following sections that I'm interested in updating:

  1. documentation for Mercator, merc.rst (currently incomplete)
  2. implementation of Mercator, merc.cpp (inaccurate, slow, odd parity violated)
  3. meridian distance, mlfn.[hc]pp (inaccurate, clumsy inverse)
  4. ellipsoid parameters, ell_set.cpp (inaccurate conversions with trig functions)

I realize that this is a somewhat Sisyphean undertaking. For example, other conformal projections share the defects of the Mercator projection. However, I figure I'd start chipping away at the parts of PROJ that annoy me the most. Even if my changes are reckoned to be too piecemeal, it will be good to capture possible code changes for a future more systematic housecleaning.

I will make separate pull requests for these 4 items and these can be discussed in full at that time. However, holler if you want to know my intentions before I get around to making the changes.

@cffk cffk added C: Core Documentation Issues relating to documentation For discussion labels Oct 21, 2020
@cffk cffk self-assigned this Oct 21, 2020
@busstoptaktik
Copy link
Member

I figure I'd start chipping away at the parts of PROJ that annoy me the most.

This is awesome, @cffk - scratching your own itch, but leaving the universe in better overall shape as a side effect - a classic driver for open source/free software progress. With a bit of luck and promotion, it will even inspire others to take up the challenge and expand on your work.

cffk added a commit to cffk/proj.4 that referenced this issue Oct 22, 2020
This addresses item 1 in issue OSGeo#2387

Things to note:

* I made "editorial" changes to the text.  The virtues and vices of
  Mercator are a hot topic.  So check these out.  (I judged that the
  text I replaced to be pretty misleading.)

* I include the radius of the sphere/ellipsoid in the formulas (and I
  did this also for my mods for tmerc documentation).  Surely this is
  better than leaving the reader to figure out how this is introduced.

* I include the "old-style" (ca 18th century) formulas and the newer
  ones in terms of hyperbolic functions.  The former may be the familiar
  ones, but the latter are better for computation (more succinct, more
  accurate, faster, preserve parity).

* For the inverse ellipsoidal transformation, I just say that the
  formula for psi is inverted iteratively.  This is probably sufficient,
  but it could be expanded later.
@kbevers
Copy link
Member

kbevers commented Oct 23, 2020

Reopened as #2388 is only a partial fix to this.

@kbevers kbevers reopened this Oct 23, 2020
@billyauhk
Copy link

I found tmerc.cpp was tuned for performance and speed regression on this popular projection will cause concerns at the end users. My suggestion at #2437 might be good for clarity but might be a performance killer (I guess probability is low, but the only way to know is experimentation).

Is there any benchmark and speed which we should try to maintain? Would like to know if that is also included in the CI, and, if there is a to-do list of functions which we may go hunting for performance?

@stale
Copy link

stale bot commented Jun 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants