1

我需要一个 FileMaker“计算”脚本来将 DMS latlong(例如:)转换37°55'43.6"S, 145°11'26.1"E为十进制格式(例如:) -37.928778,145.190583

4

3 回答 3

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

于 2012-12-19T18:16:50.007 回答
0

这是使用split()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,您可能需要调整它以-在前面放置一个符号(正如我在上面所做的那样)。参考:维基百科:从十进制度到 DMS 的转换

于 2012-12-19T05:38:25.453 回答
0

它可以像 =

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
)
于 2020-02-22T10:39:30.540 回答