 # JIRA CLOUD - CONVERT LONGITUDE AND LATITUDE FIELD DATA TO DMS (degrees, minutes, seconds)

I have 2 free text custom fields called Longitude and Latitude. Users enter text info with decimal numbers. I want to convert that data to DMS numbers in a new respective text fields example “Longitude (DMS)”. Using JWME and automation for JIRA. Example if user enters “Latitude - 40.75” it would be converted to “40 45 0”.

Formula for this is :

Example: Convert decimal degrees 156.742 to degrees minutes seconds
The whole number is degrees. So 156.742 gives you 156 degrees.
Multiply the remaining decimal by 60.
0.74260 = 44.52, so the whole number 44 equals minutes.
Multiply the remaining decimal by 60.
0.52
60 = 31.2, so the whole number 31 equals seconds.
Decimal degrees

Using JMWE for Jira Cloud, you’ll only be able to do this conversion during a transition, which is fine if the user inputs this data during issue creation or transition, not so much if they can edit the free text custom fields directly on the issue view.
Is that acceptable for your use case?

Using JMWE for Jira Cloud, yo could do something like this for the Latitude:

``````{% set val = issue.fields.Latitude | float %}
{% set hemisphere = "N" if val >= 0 else "S" %}
{% set val = val | abs %}
{% set deg = val | round(0, 'floor') %}
{% set min = ((val - deg) * 60) | round(0, 'floor') %}
{% set sec = ((val - deg - min / 60) * 3600 * 1000) | round(0, 'round') / 1000 %}
{{deg}}°{{min}}'{{sec}}" {{hemisphere}}
``````

The Longitude would be calculated similarly, except of course negative numbers would be W and positive E

Thank you this worked perfectly.