Skip to main content
Solved

How DecimalDegreesCalculator is calculating the coordinates?

  • April 17, 2020
  • 2 replies
  • 52 views

skime
Contributor
  • Contributor
  • 14 replies

Hello, is it possible that someone share with me the knowledge how DecimalDegreesCalculator transformer exactly is calculating the decimal degrees from Degrees Minutes Seconds (DMS)? Is this the formula for it?

 Decimal Deg = Deg + Min / 60 + sec / 3600

Best answer by takashi

I think so, if the Deg is positive value. Why not confirm that with a workspace like this?

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • 7843 replies
  • Best Answer
  • April 17, 2020

I think so, if the Deg is positive value. Why not confirm that with a workspace like this?

 


mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • April 17, 2020

If you copy the transformer and paste it into a text editor, you can see the code (including typo in the comment!) that runs the conversion:

# Comvert to decimal and set the attribute
Tcl2 proc DecimalDegreesCalculator_dms2decimal {} {                    \
  set deg [DecimalDegreesCalculator_fetchAndTrimOffLeading0s {ParkId}]; \
  set min [DecimalDegreesCalculator_fetchAndTrimOffLeading0s {ParkId}]; \
  set sec [DecimalDegreesCalculator_fetchAndTrimOffLeading0s {ParkName}]; \
  if { [string index $deg 0] == {-} } {                                \
      set decimalValue [expr $deg - $min/60.0 - $sec/3600.0];          \
  } else {                                                             \
     set decimalValue [expr $deg + $min/60.0 + $sec/3600.0];           \
  };                                                                   \
  FME_SetAttribute [FME_DecodeText {_decimal_degrees}] $decimalValue;  \}

So, yes, it's as you say, depending on whether it's positive or negative coordinates.