3v4l.org

run code in 300+ PHP versions simultaneously
<?php function UTMtoGeog($Easting,$Northing,$UtmZone,$SouthofEquator=false) //Convert UTM Coordinates to Geographic { //Declarations //Symbols as used in USGS PP 1395: Map Projections - A Working Manual $k0 = 0.9996;//scale on central meridian $a = 6378137.0;//equatorial radius, meters. $f = 1/298.2572236;//polar flattening. $b = $a*(1-$f);//polar axis. $e = sqrt(1 - $b*$b/$a*$a);//eccentricity $drad = pi()/180;//Convert degrees to radians) $phi = 0;//latitude (north +, south -), but uses phi in reference $e0 = $e/sqrt(1 - $e*$e);//e prime in reference $lng = 0;//Longitude (e = +, w = -) $lng0 = 0;//longitude of central meridian $lngd = 0;//longitude in degrees $M = 0;//M requires calculation $x = 0;//x coordinate $y = 0;//y coordinate $k = 1;//local scale $zcm = 0;//zone central meridian //End declarations //Convert UTM Coordinates to Geographic $k0 = 0.9996;//scale on central meridian $b = $a*(1-$f);//polar axis. $e = sqrt(1 - ($b/$a)*($b/$a));//eccentricity $e0 = $e/sqrt(1 - $e*$e);//Called e prime in reference $esq =(1 - ($b/$a)*($b/$a));//e squared for use in expansions $e0sq =$e*$e/(1-$e*$e);// e0 squared - always even powers $x = $Easting; if ($x<160000 || $x>840000) echo "Outside permissible range of easting values \n Results may be unreliable \n Use with caution\n"; $y = $Northing; if ($y<0) echo "Negative values not allowed \n Results may be unreliable \n Use with caution\n"; if ($y>10000000) echo "Northing may not exceed 10,000,000 \n Results may be unreliable \n Use with caution\n"; $zcm =3 + 6*($UtmZone-1) - 180;//Central meridian of zone $e1 =(1 - sqrt(1 - $e*$e))/(1 + sqrt(1 - $e*$e));//Called e1 in USGS PP 1395 also $M0 =0;//In case origin other than zero lat - not needed for standard UTM $M =$M0 + $y/$k0;//Arc length along standard meridian. if ($SouthofEquator === true) $M=$M0+($y-10000000)/$k; $mu =$M/($a*(1 - $esq*(1/4 + $esq*(3/64 + 5*$esq/256)))); $phi1 =$mu + $e1*(3/2 - 27*$e1*$e1/32)*sin(2*$mu) + $e1*$e1*(21/16 -55*$e1*$e1/32)*sin(4*$mu);//Footprint Latitude $phi1 =$phi1 + $e1*$e1*$e1*(sin(6*$mu)*151/96 + $e1*sin(8*$mu)*1097/512); $C1 =$e0sq*pow(cos($phi1),2); $T1 =pow(tan($phi1),2); $N1 =$a/sqrt(1-pow($e*sin($phi1),2)); $R1 =$N1*(1-$e*$e)/(1-pow($e*sin($phi1),2)); $D =($x-500000)/($N1*$k0); $phi =($D*$D)*(1/2 - $D*$D*(5 + 3*$T1 + 10*$C1 - 4*$C1*$C1 - 9*$e0sq)/24); $phi =$phi + pow($D,6)*(61 + 90*$T1 + 298*$C1 + 45*$T1*$T1 -252*$e0sq - 3*$C1*$C1)/720; $phi =$phi1 - ($N1*tan($phi1)/$R1)*$phi; //Longitude $lng =$D*(1 + $D*$D*((-1 -2*$T1 -$C1)/6 + $D*$D*(5 - 2*$C1 + 28*$T1 - 3*$C1*$C1 +8*$e0sq + 24*$T1*$T1)/120))/cos($phi1); $lngd = $zcm+$lng/$drad; return array(floor(1000000*$phi/$drad)/1000000,floor(1000000*$lngd)/1000000); //Latitude,Longitude } $r = array(); for ($a = 0; $a < 1; $a = $a + 0.00001) { $utm = UTMtoGeog(377298.745+$a, 1483034.794+$a, 48); $r[] = $utm; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 3
Branch analysis from position: 17
Branch analysis from position: 3
filename:       /in/9gDcR
function name:  (null)
number of ops:  18
compiled vars:  !0 = $r, !1 = $a, !2 = $utm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   ASSIGN                                                   !0, <array>
   65     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->15
   66     3    >   INIT_FCALL                                               'utmtogeog'
          4        ADD                                              ~5      377299, !1
          5        SEND_VAL                                                 ~5
          6        ADD                                              ~6      1.48303e+6, !1
          7        SEND_VAL                                                 ~6
          8        SEND_VAL                                                 48
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
   67    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  !2
   65    13        ADD                                              ~10     !1, 1.0e-5
         14        ASSIGN                                                   !1, ~10
         15    >   IS_SMALLER                                               !1, 1
         16      > JMPNZ                                                    ~12, ->3
   68    17    > > RETURN                                                   1

Function utmtogeog:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 70, Position 2 = 72
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 74
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 78
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 81
Branch analysis from position: 80
2 jumps found. (Code = 43) Position 1 = 106, Position 2 = 110
Branch analysis from position: 106
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 110
Branch analysis from position: 81
Branch analysis from position: 78
Branch analysis from position: 74
Branch analysis from position: 72
filename:       /in/9gDcR
function name:  UTMtoGeog
number of ops:  303
compiled vars:  !0 = $Easting, !1 = $Northing, !2 = $UtmZone, !3 = $SouthofEquator, !4 = $k0, !5 = $a, !6 = $f, !7 = $b, !8 = $e, !9 = $drad, !10 = $phi, !11 = $e0, !12 = $lng, !13 = $lng0, !14 = $lngd, !15 = $M, !16 = $x, !17 = $y, !18 = $k, !19 = $zcm, !20 = $esq, !21 = $e0sq, !22 = $e1, !23 = $M0, !24 = $mu, !25 = $phi1, !26 = $C1, !27 = $T1, !28 = $N1, !29 = $R1, !30 = $D
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <false>
    7     4        ASSIGN                                                   !4, 0.9996
    8     5        ASSIGN                                                   !5, 6.37814e+6
    9     6        ASSIGN                                                   !6, 0.00335281
   10     7        SUB                                              ~34     1, !6
          8        MUL                                              ~35     !5, ~34
          9        ASSIGN                                                   !7, ~35
   11    10        INIT_FCALL                                               'sqrt'
         11        MUL                                              ~37     !7, !7
         12        DIV                                              ~38     ~37, !5
         13        MUL                                              ~39     !5, ~38
         14        SUB                                              ~40     1, ~39
         15        SEND_VAL                                                 ~40
         16        DO_ICALL                                         $41     
         17        ASSIGN                                                   !8, $41
   12    18        INIT_FCALL                                               'pi'
         19        DO_ICALL                                         $43     
         20        DIV                                              ~44     $43, 180
         21        ASSIGN                                                   !9, ~44
   13    22        ASSIGN                                                   !10, 0
   14    23        INIT_FCALL                                               'sqrt'
         24        MUL                                              ~47     !8, !8
         25        SUB                                              ~48     1, ~47
         26        SEND_VAL                                                 ~48
         27        DO_ICALL                                         $49     
         28        DIV                                              ~50     !8, $49
         29        ASSIGN                                                   !11, ~50
   15    30        ASSIGN                                                   !12, 0
   16    31        ASSIGN                                                   !13, 0
   17    32        ASSIGN                                                   !14, 0
   18    33        ASSIGN                                                   !15, 0
   19    34        ASSIGN                                                   !16, 0
   20    35        ASSIGN                                                   !17, 0
   21    36        ASSIGN                                                   !18, 1
   22    37        ASSIGN                                                   !19, 0
   25    38        ASSIGN                                                   !4, 0.9996
   26    39        SUB                                              ~61     1, !6
         40        MUL                                              ~62     !5, ~61
         41        ASSIGN                                                   !7, ~62
   27    42        INIT_FCALL                                               'sqrt'
         43        DIV                                              ~64     !7, !5
         44        DIV                                              ~65     !7, !5
         45        MUL                                              ~66     ~64, ~65
         46        SUB                                              ~67     1, ~66
         47        SEND_VAL                                                 ~67
         48        DO_ICALL                                         $68     
         49        ASSIGN                                                   !8, $68
   28    50        INIT_FCALL                                               'sqrt'
         51        MUL                                              ~70     !8, !8
         52        SUB                                              ~71     1, ~70
         53        SEND_VAL                                                 ~71
         54        DO_ICALL                                         $72     
         55        DIV                                              ~73     !8, $72
         56        ASSIGN                                                   !11, ~73
   29    57        DIV                                              ~75     !7, !5
         58        DIV                                              ~76     !7, !5
         59        MUL                                              ~77     ~75, ~76
         60        SUB                                              ~78     1, ~77
         61        ASSIGN                                                   !20, ~78
   30    62        MUL                                              ~80     !8, !8
         63        MUL                                              ~81     !8, !8
         64        SUB                                              ~82     1, ~81
         65        DIV                                              ~83     ~80, ~82
         66        ASSIGN                                                   !21, ~83
   31    67        ASSIGN                                                   !16, !0
   32    68        IS_SMALLER                                       ~86     !16, 160000
         69      > JMPNZ_EX                                         ~86     ~86, ->72
         70    >   IS_SMALLER                                       ~87     840000, !16
         71        BOOL                                             ~86     ~87
         72    > > JMPZ                                                     ~86, ->74
   33    73    >   ECHO                                                     'Outside+permissible+range+of+easting+values+%0A+Results+may+be+unreliable+%0A+Use+with+caution%0A'
   34    74    >   ASSIGN                                                   !17, !1
   35    75        IS_SMALLER                                               !17, 0
         76      > JMPZ                                                     ~89, ->78
   36    77    >   ECHO                                                     'Negative+values+not+allowed+%0A+Results+may+be+unreliable+%0A+Use+with+caution%0A'
   37    78    >   IS_SMALLER                                               10000000, !17
         79      > JMPZ                                                     ~90, ->81
   38    80    >   ECHO                                                     'Northing+may+not+exceed+10%2C000%2C000+%0A+Results+may+be+unreliable+%0A+Use+with+caution%0A'
   39    81    >   SUB                                              ~91     !2, 1
         82        MUL                                              ~92     ~91, 6
         83        ADD                                              ~93     3, ~92
         84        SUB                                              ~94     ~93, 180
         85        ASSIGN                                                   !19, ~94
   40    86        INIT_FCALL                                               'sqrt'
         87        MUL                                              ~96     !8, !8
         88        SUB                                              ~97     1, ~96
         89        SEND_VAL                                                 ~97
         90        DO_ICALL                                         $98     
         91        SUB                                              ~99     1, $98
         92        INIT_FCALL                                               'sqrt'
         93        MUL                                              ~100    !8, !8
         94        SUB                                              ~101    1, ~100
         95        SEND_VAL                                                 ~101
         96        DO_ICALL                                         $102    
         97        ADD                                              ~103    1, $102
         98        DIV                                              ~104    ~99, ~103
         99        ASSIGN                                                   !22, ~104
   41   100        ASSIGN                                                   !23, 0
   42   101        DIV                                              ~107    !17, !4
        102        ADD                                              ~108    !23, ~107
        103        ASSIGN                                                   !15, ~108
   43   104        TYPE_CHECK                                    8          !3
        105      > JMPZ                                                     ~110, ->110
   44   106    >   SUB                                              ~111    !17, 10000000
        107        DIV                                              ~112    ~111, !18
        108        ADD                                              ~113    !23, ~112
        109        ASSIGN                                                   !15, ~113
   45   110    >   MUL                                              ~115    !20, 5
        111        DIV                                              ~116    ~115, 256
        112        ADD                                              ~117    0.046875, ~116
        113        MUL                                              ~118    !20, ~117
        114        ADD                                              ~119    0.25, ~118
        115        MUL                                              ~120    !20, ~119
        116        SUB                                              ~121    1, ~120
        117        MUL                                              ~122    !5, ~121
        118        DIV                                              ~123    !15, ~122
        119        ASSIGN                                                   !24, ~123
   46   120        MUL                                              ~125    !22, 27
        121        MUL                                              ~126    !22, ~125
        122        DIV                                              ~127    ~126, 32
        123        SUB                                              ~128    1.5, ~127
        124        MUL                                              ~129    !22, ~128
        125        INIT_FCALL                                               'sin'
        126        MUL                                              ~130    !24, 2
        127        SEND_VAL                                                 ~130
        128        DO_ICALL                                         $131    
        129        MUL                                              ~132    $131, ~129
        130        ADD                                              ~133    !24, ~132
        131        MUL                                              ~134    !22, !22
        132        MUL                                              ~135    !22, 55
        133        MUL                                              ~136    !22, ~135
        134        DIV                                              ~137    ~136, 32
        135        SUB                                              ~138    1.3125, ~137
        136        MUL                                              ~139    ~134, ~138
        137        INIT_FCALL                                               'sin'
        138        MUL                                              ~140    !24, 4
        139        SEND_VAL                                                 ~140
        140        DO_ICALL                                         $141    
        141        MUL                                              ~142    $141, ~139
        142        ADD                                              ~143    ~133, ~142
        143        ASSIGN                                                   !25, ~143
   47   144        MUL                                              ~145    !22, !22
        145        MUL                                              ~146    !22, ~145
        146        INIT_FCALL                                               'sin'
        147        MUL                                              ~147    !24, 6
        148        SEND_VAL                                                 ~147
        149        DO_ICALL                                         $148    
        150        MUL                                              ~149    $148, 151
        151        DIV                                              ~150    ~149, 96
        152        INIT_FCALL                                               'sin'
        153        MUL                                              ~151    !24, 8
        154        SEND_VAL                                                 ~151
        155        DO_ICALL                                         $152    
        156        MUL                                              ~153    !22, $152
        157        MUL                                              ~154    ~153, 1097
        158        DIV                                              ~155    ~154, 512
        159        ADD                                              ~156    ~150, ~155
        160        MUL                                              ~157    ~146, ~156
        161        ADD                                              ~158    !25, ~157
        162        ASSIGN                                                   !25, ~158
   48   163        INIT_FCALL                                               'pow'
        164        INIT_FCALL                                               'cos'
        165        SEND_VAR                                                 !25
        166        DO_ICALL                                         $160    
        167        SEND_VAR                                                 $160
        168        SEND_VAL                                                 2
        169        DO_ICALL                                         $161    
        170        MUL                                              ~162    !21, $161
        171        ASSIGN                                                   !26, ~162
   49   172        INIT_FCALL                                               'pow'
        173        INIT_FCALL                                               'tan'
        174        SEND_VAR                                                 !25
        175        DO_ICALL                                         $164    
        176        SEND_VAR                                                 $164
        177        SEND_VAL                                                 2
        178        DO_ICALL                                         $165    
        179        ASSIGN                                                   !27, $165
   50   180        INIT_FCALL                                               'sqrt'
        181        INIT_FCALL                                               'pow'
        182        INIT_FCALL                                               'sin'
        183        SEND_VAR                                                 !25
        184        DO_ICALL                                         $167    
        185        MUL                                              ~168    !8, $167
        186        SEND_VAL                                                 ~168
        187        SEND_VAL                                                 2
        188        DO_ICALL                                         $169    
        189        SUB                                              ~170    1, $169
        190        SEND_VAL                                                 ~170
        191        DO_ICALL                                         $171    
        192        DIV                                              ~172    !5, $171
        193        ASSIGN                                                   !28, ~172
   51   194        MUL                                              ~174    !8, !8
        195        SUB                                              ~175    1, ~174
        196        MUL                                              ~176    !28, ~175
        197        INIT_FCALL                                               'pow'
        198        INIT_FCALL                                               'sin'
        199        SEND_VAR                                                 !25
        200        DO_ICALL                                         $177    
        201        MUL                                              ~178    !8, $177
        202        SEND_VAL                                                 ~178
        203        SEND_VAL                                                 2
        204        DO_ICALL                                         $179    
        205        SUB                                              ~180    1, $179
        206        DIV                                              ~181    ~176, ~180
        207        ASSIGN                                                   !29, ~181
   52   208        SUB                                              ~183    !16, 500000
        209        MUL                                              ~184    !28, !4
        210        DIV                                              ~185    ~183, ~184
        211        ASSIGN                                                   !30, ~185
   53   212        MUL                                              ~187    !30, !30
        213        MUL                                              ~188    !30, !30
        214        MUL                                              ~189    !27, 3
        215        ADD                                              ~190    5, ~189
        216        MUL                                              ~191    !26, 10
        217        ADD                                              ~192    ~190, ~191
        218        MUL                                              ~193    !26, 4
        219        MUL                                              ~194    !26, ~193
        220        SUB                                              ~195    ~192, ~194
        221        MUL                                              ~196    !21, 9
        222        SUB                                              ~197    ~195, ~196
        223        MUL                                              ~198    ~188, ~197
        224        DIV                                              ~199    ~198, 24
        225        SUB                                              ~200    0.5, ~199
        226        MUL                                              ~201    ~187, ~200
        227        ASSIGN                                                   !10, ~201
   54   228        INIT_FCALL                                               'pow'
        229        SEND_VAR                                                 !30
        230        SEND_VAL                                                 6
        231        DO_ICALL                                         $203    
        232        MUL                                              ~204    !27, 90
        233        ADD                                              ~205    61, ~204
        234        MUL                                              ~206    !26, 298
        235        ADD                                              ~207    ~205, ~206
        236        MUL                                              ~208    !27, 45
        237        MUL                                              ~209    !27, ~208
        238        ADD                                              ~210    ~207, ~209
        239        MUL                                              ~211    !21, 252
        240        SUB                                              ~212    ~210, ~211
        241        MUL                                              ~213    !26, 3
        242        MUL                                              ~214    !26, ~213
        243        SUB                                              ~215    ~212, ~214
        244        MUL                                              ~216    $203, ~215
        245        DIV                                              ~217    ~216, 720
        246        ADD                                              ~218    !10, ~217
        247        ASSIGN                                                   !10, ~218
   55   248        INIT_FCALL                                               'tan'
        249        SEND_VAR                                                 !25
        250        DO_ICALL                                         $220    
        251        MUL                                              ~221    !28, $220
        252        DIV                                              ~222    ~221, !29
        253        MUL                                              ~223    !10, ~222
        254        SUB                                              ~224    !25, ~223
        255        ASSIGN                                                   !10, ~224
   58   256        MUL                                              ~226    !30, !30
        257        MUL                                              ~227    !27, 2
        258        SUB                                              ~228    -1, ~227
        259        SUB                                              ~229    ~228, !26
        260        DIV                                              ~230    ~229, 6
        261        MUL                                              ~231    !30, !30
        262        MUL                                              ~232    !26, 2
        263        SUB                                              ~233    5, ~232
        264        MUL                                              ~234    !27, 28
        265        ADD                                              ~235    ~233, ~234
        266        MUL                                              ~236    !26, 3
        267        MUL                                              ~237    !26, ~236
        268        SUB                                              ~238    ~235, ~237
        269        MUL                                              ~239    !21, 8
        270        ADD                                              ~240    ~238, ~239
        271        MUL                                              ~241    !27, 24
        272        MUL                                              ~242    !27, ~241
        273        ADD                                              ~243    ~240, ~242
        274        MUL                                              ~244    ~231, ~243
        275        DIV                                              ~245    ~244, 120
        276        ADD                                              ~246    ~230, ~245
        277        MUL                                              ~247    ~226, ~246
        278        ADD                                              ~248    1, ~247
        279        MUL                                              ~249    !30, ~248
        280        INIT_FCALL                                               'cos'
        281        SEND_VAR                                                 !25
        282        DO_ICALL                                         $250    
        283        DIV                                              ~251    ~249, $250
        284        ASSIGN                                                   !12, ~251
   59   285        DIV                                              ~253    !12, !9
        286        ADD                                              ~254    !19, ~253
        287        ASSIGN                                                   !14, ~254
   61   288        INIT_FCALL                                               'floor'
        289        MUL                                              ~256    !10, 1000000
        290        DIV                                              ~257    ~256, !9
        291        SEND_VAL                                                 ~257
        292        DO_ICALL                                         $258    
        293        DIV                                              ~259    $258, 1000000
        294        INIT_ARRAY                                       ~260    ~259
        295        INIT_FCALL                                               'floor'
        296        MUL                                              ~261    !14, 1000000
        297        SEND_VAL                                                 ~261
        298        DO_ICALL                                         $262    
        299        DIV                                              ~263    $262, 1000000
        300        ADD_ARRAY_ELEMENT                                ~260    ~263
        301      > RETURN                                                   ~260
   62   302*     > RETURN                                                   null

End of function utmtogeog

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
264.6 ms | 1048 KiB | 22 Q