cls
defdbl a-z
print "
print "              TRANSFORMACIJA DXF DATOTEKA            "
print "           IZ PROJEKCIJE GAUSS-KRUEGER 16ø30'     "
print "         U PROJEKCIJU GAUSS-KRUEGER 5. I 6. ZONA"
PRINT
25
PRINT "      DA LI ZELITE TRANSFORMIRATI PODATKE:
PRINT "         1  -  OBADVIJE ZONE U JEDAN CRTEZ  "
PRINT "         2  -  CIJELI CRTEZ U JEDNU ZONU  "
INPUT "               upisi 1 ILI 2  --->  ";NAC
IF NAC < 1 OR NAC > 2 THEN 25
IF NAC=2 THEN
35  PRINT
    INPUT "          U KOJU ZONU ? ( 5 ili 6 )  ---> ";ZZNA
    IF ZZNA<5 OR ZZNA>6 THEN BEEP:GOTO 35
END IF
PRINT
' konstante
    pi=4*atn(1)
    ro=180/pi
    a=6377397.155
    b=6356078.96325
    emi=0
    if b=0 then b=a*(1-emi)
    e=sqr((a^2-b^2)/a^2)
    e1=sqr((a^2-b^2)/b^2)
    a0=1+3*e^2/4+45*e^4/64+175*e^6/256+11025*e^8/16384
    b0=3*e^2/4+15*e^4/16+525*e^6/512+2205*e^8/2048
    c0=15*e^4/64+105*e^6/256+2205*e^8/4096
    d0=35*e^6/512+315*e^8/2048
input "Upisi DXF datoteku za ulaz ";ula$
on error goto 999
open ula$ for input as#2
on error goto 0
input "Upisi DXF datoteku za izlaz ";izl$
open izl$ for output as#3
while not ll$="ENTITIES"
   locate 16,44:print time$
   line input#2,ll$
   print#3,ll$
wend
while not eof(2)
   locate 16,44:print time$
   line input#2,ll$
   if ll$=" 10" or ll$=" 11" then
         print#3,ll$
         input#2,y
         line input#2,ll$
         input#2,x
         if y=0 then 96
'  transformacija Y,X iz 16ø30' zone u FI,LAMBDA
    y1=y
    YY=INT(Y1/1000000)
    Y=Y1-YY*1000000-500000
    Y=Y/0.9997
    X=X/0.9997
'   IF YY=5 THEN JS=15 ELSE IF YY=6 THEN JS=18 ELSE IF YY=7 THEN JS=21
    JS=16:JM=30:SJ=0       'srednji meridijan projekcije 16-30
    FI1=2*X/(A+B)
51  BX=A*(1-E^2)*(A0*FI1-B0*SIN(2*FI1)/2+C0*SIN(4*FI1)/4-D0*SIN(6*FI1)/6)
    D=X-BX
    IF ABS(D)<0.0001 THEN 53
    FI1=FI1+2*D/(A+B)
    GOTO 51
53  T=TAN(FI1)
    ETA=E1*COS(FI1)
    EN=A/SQR(1-E^2*(SIN(FI1))^2)
    FIF1=-T*(1+ETA^2)/(2*EN^2)
    FIF2=T*(5+3*T^2+6*ETA^2-6*T^2*ETA^2)/(24*EN^4)
    ELF1=1/(EN*COS(FI1))
    ELF2=-(1+2*T^2+ETA^2)/(6*EN^3*COS(FI1))
    ELF3=(5+28*T^2+24*T^4)/(120*EN^5*COS(FI1))
    FI=FI1+FIF1*Y^2+FIF2*Y^4          ' geogr. sirina
    EL=ELF1*Y+ELF2*Y^3+ELF3*Y^5       '
    ALO=(JS+JM/60+SJ/3600)/RO         ' meridijan 16ø30
    AL=ALO+EL                         ' geogr. duljina (radijan)

' transformacija iz FI,LAMBDA u projekciju 5. i 6. zone
    SRMED=AL*RO
    IF SRMED <= 16.5 THEN GALO=15
    IF SRMED > 16.5 THEN GALO=18
    IF ZZNA=5 THEN GALO=15
    IF ZZNA=6 THEN GALO=18
    LINM=0.9999                      ' linearno mjerilo
    ALO=GALO*PI/180
    EL=AL-ALO
    BX=A*(1-E^2)*(A0*FI-B0*SIN(2*FI)/2+C0*SIN(4*FI)/4-D0*SIN(6*FI)/6)
    T=TAN(FI)
    ETA=E1*COS(FI)
    EN=A/SQR(1-E^2*(SIN(FI))^2)
    YF1=EN*COS(FI)
    YF2=EN*(COS(FI))^3*(1-T^2+ETA^2)/6
    YF3=EN*(COS(FI))^5*(5-18*T^2+T^4+14*ETA^2-58*T^2*ETA^2)/120
    XF1=EN*SIN(FI)*COS(FI)/2
    XF2=EN*SIN(FI)*(COS(FI))^3*(5-T^2+9*ETA^2+4*ETA^4)/24
    Y=YF1*EL+YF2*EL^3+YF3*EL^5
    Y=Y*LINM
    IF GALO=15 THEN KKO=5500000
    IF GALO=18 THEN KKO=6500000
    Y=Y+KKO
    X=BX+XF1*EL^2+XF2*EL^4
    X=X*LINM
96       print#3,y
         print#3,ll$
         print#3,x
     else
         print#3,ll$
    end if
wend
close
BEEP:PRINT "KRAJ"
end

      '                 poruke u slucaju pogresnih upisa imena datoteka
999  IF ERR=53 OR ERR=75 OR ERR=64 THEN RESUME 8990
8990  PRINT "          !!!!! NE POSTOJI DXF - DATOTEKA OVOG CRTEZA !!!!!"
      PRINT "                            PONOVI POSTUPAK":INPUT IQQQ
      CLOSE : END
