home *** CD-ROM | disk | FTP | other *** search
EPOC OPL Source | 2001-10-18 | 1.3 KB | 64 lines |
-
-
- REM Rough OSGB Grid to Lat/Long Conversion
- REM Example UserInput.OPO Source Code
- REM By Kevin Millican
-
- PROC userinp$:(os$)
- LOCAL t$(20),e1,n1,t1,t2
- LOCAL E,N,res$(40),c%,d
-
- ONERR handerr
- t$=UPPER$(os$)
-
- REM Get the eastings and northings allowing for the
- REM possibility that the grid reference may be entered
- REM as AAnnnnnn AAnnnnnnnn etc
- c%=(LEN(t$)-2)/2
- d=10**(c%-2)
- e1=VAL(MID$(t$,3,c%))/d
- n1=VAL(MID$(t$,3+c%,c%))/d
-
- REM calculate grid square offsets
- t1=ASC(LEFT$(t$,1))-ASC("A")
- IF t1>8
- t1=t1-1
- ENDIF
- t2=INT(t1/5)
- n1=n1+500*(3-t2)
- e1=e1+500*(t1-5*t2-2)
- t1=ASC(MID$(t$,2,1))-ASC("A")
- IF t1>8
- t1=t1-1
- ENDIF
- t2=INT(t1/5)
- n1=n1+100*(4-t2)
- e1=e1+100*(t1-5*t2)
-
- REM Do the grid conversion
- t1=(n1+5548.79)/6371.28
- t2=2*(ATAN(EXP((e1-400)/6389.7)))
- E=ATAN(-COS(t2)/(COS(t1)*SIN(t2)))-0.0349066
- N=SIN(t2)*SIN(t1)
- N=ATAN(N/(SQR(1-N*N)))
-
- REM return the result as a tab-delimited string
-
- res$=GEN$(DEG(N),14)+CHR$(9)+GEN$(DEG(E),15)
-
- RETURN res$
-
- REM or return Error if a problem occurs
- handerr::
- ONERR OFF
- RETURN "Error"
- ENDP
-
- PROC UserDesc$:
- RETURN "OS Grid Ref"
- ENDP
-
-
-
-
-