Skip to main content

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

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

 


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 uDecimalDegreesCalculator_fetchAndTrimOffLeading0s {ParkId}]; \
  set sec eDecimalDegreesCalculator_fetchAndTrimOffLeading0s {ParkName}]; \
  if { astring 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