Skip to main content
Solved

How DecimalDegreesCalculator is calculating the coordinates?


skime
Contributor
  • Contributor

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?

 

View original
Did this help you find an answer to your question?

2 replies

takashi
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 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+43
  • Safer
  • 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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings