我需要一个FileMaker"计算"脚本将DMS latlong(例如:37°55'43.6"S, 145°11'26.1"E
)转换为十进制格式(例如:-37.928778,145.190583
)。
答案 0 :(得分:2)
这是一种有趣的方法:将其转换为FileMaker计算并在其上调用Evaluate()
。
Evaluate(
"Round( (" &
Substitute (
dms ;
[" ";""] ;
["°";" + "] ;
["'";"/60 + "] ;
["\"";"/3600"] ;
["S";") *-1"] ;
["W";") *-1"] ;
["N";")"] ;
["E";")"] ;
[","; " ; 6 ) & \",\" & Round( ("]
) &
" ; 6 )"
)
以上内容会将输入转换为计算结果:
Round( (37 + 55/60 + 43.6/3600) *-1 ; 6 ) & "," & Round( (145 + 11/60 + 26.1/3600) ; 6 )
然后将其传递给Evaluate
,这会为您提供-37.928778,145.190583
答案 1 :(得分:0)
这是一个使用split()
custom function by David Snyder:
If ( IsEmpty(DMSLatlong);"";
"-" &
Truncate(
(
Trim(split(
Trim(split( DMSLatlong; 1; "," ))
; 1; "°" ))
) +
(
(
Trim(split(
Trim(split(
Trim(split( DMSLatlong; 1; "," ))
; 1; "'" ))
; 2; "°" ))
) / 60
) +
(
(
Trim(split(
Trim(split(
Trim(split( DMSLatlong; 1; "," ))
; 2; "'" ))
; 1; "\"" ))
) / 3600
)
;7)
& "," &
Truncate(
(
Trim(split(
Trim(split( DMSLatlong; 2; "," ))
; 1; "°" ))
) +
(
(
Trim(split(
Trim(split(
Trim(split( DMSLatlong; 2; "," ))
; 1; "'" ))
; 2; "°" ))
) / 60
) +
(
(
Trim(split(
Trim(split(
Trim(split( DMSLatlong; 2; "," ))
; 2; "'" ))
; 1; "\"" ))
) / 3600
)
;7)
)
注意:此脚本不是防弹,如果DMS值为S或W,您可能需要调整它以在前面放置-
符号(如上所述)。请参阅:Wikipedia: Conversion from Decimal Degree to DMS。
答案 2 :(得分:0)
它可能很简单== p
Let ( [
v = Substitute ( DMS ; [ "°" ; ¶ ] ; [ "'" ; ¶ ] ; [ "\"" ; ¶ ] ) ;
t = Time ( GetValue ( v ; 1 ) ; GetValue ( v ; 2 ) ; GetValue ( v ; 3 ) ) ;
h = GetValue ( v ; 4 )
] ;
If ( h = "S" or h = "W" ; -t ; t ) / 3600
)