Skip to content

Leading zeros#7655

Merged
remkos merged 8 commits intomasterfrom
leading-zeros
Jul 20, 2023
Merged

Leading zeros#7655
remkos merged 8 commits intomasterfrom
leading-zeros

Conversation

@remkos
Copy link
Contributor

@remkos remkos commented Jul 19, 2023

Description of proposed changes

This implements the capability to have leading zeros on the geographical coordinates on the map frame, by extending the syntax for FORMAT_GEO_MAP and FORMAT_GEO_OUT to have:

  • ddd for integer degrees
  • DDD for fixed format integer degrees (3 digits of longitude, 2 digits for latitude)

Example:
gmt basemap -R-1/1/-1/1 -Baf --FORMAT_GEO_MAP=DDD:mm:ss -JM15c -pdf map

It also fixes what was effectively a bug (#7475). Longitudes are now properly written with 3 digits for the degrees in longitude.
Example:
echo 7.54353543 9.1342 | gmt convert -fg --FORMAT_GEO_OUT=DDD:mm.xxxF
now properly results in
007:32.612E 09:08.52N
while
echo 7.54353543 9.1342 | gmt convert -fg --FORMAT_GEO_OUT=ddd:mm.xxxF
now results (equivalently to maps) in
7:32.612E 9:08.52N

Fixes #7475

Reminders

  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

@remkos remkos changed the title WIP: Leading zeros Leading zeros Jul 19, 2023
@remkos remkos requested review from PaulWessel and anbj July 19, 2023 20:09
@remkos remkos added this to the 6.5.0 milestone Jul 19, 2023
@remkos remkos added bug Something isn't working enhancement Improving an existing feature labels Jul 19, 2023
@anbj
Copy link
Contributor

anbj commented Jul 20, 2023

Looks very good to me:

$ echo 7.54353543 9.1342 | gmt convert -fg --FORMAT_GEO_OUT=ddd:mm.xxxF
7:32.612E	9:08.52N

$ echo 7.54353543 9.1342 | gmt convert -fg --FORMAT_GEO_OUT=DDD:mm.xxxF
007:32.612E	09:08.52N

@anbj
Copy link
Contributor

anbj commented Jul 20, 2023

Too much C-code for me to approve. I think it's best if Paul pushes the button.
Looks good as far as I can tell.

Copy link
Member

@PaulWessel PaulWessel left a comment

Choose a reason for hiding this comment

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

Looks good.

@remkos remkos merged commit 4d392a4 into master Jul 20, 2023
@remkos remkos deleted the leading-zeros branch July 20, 2023 18:31
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog bug Something isn't working enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leading zeros with FORMAT_GEO_OUT=ddd:mm.ss.xx

5 participants