Advertisement
Guest User

LTE frekvencia vadászat

a guest
Nov 8th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.27 KB | None | 0 0
  1. <?php
  2. function convert($input) {
  3.     $deg = " " ;
  4.     $min = " " ;
  5.     $sec = " " ;  
  6.     $inputM = " " ;
  7.  
  8.     for ($i=0; $i < strlen($input); $i++)
  9.     {                    
  10.         $tempD = $input[$i];
  11.         if ($tempD == iconv("UTF-8", "ISO-8859-1//TRANSLIT", '°') )
  12.         {
  13.             $newI = $i + 1 ;
  14.             $inputM =  substr($input, $newI, -1) ;
  15.             break;
  16.         }//close if degree
  17.         $deg .= $tempD ;                    
  18.     }//close for degree
  19.  
  20.     for ($j=0; $j < strlen($inputM); $j++)
  21.     {
  22.         $tempM = $inputM[$j];
  23.         if ($tempM == "'")  
  24.         {                    
  25.             $newI = $j + 1 ;
  26.             $sec =  substr($inputM, $newI, -1) ;
  27.             break;
  28.         }//close if minute
  29.         $min .= $tempM ;                    
  30.     }//close for min
  31.     $result =  $deg+( (( $min*60) + ($sec) ) / 3600 );
  32.     return $result;
  33. }
  34. $mit = array("Latitude:", "Longitude:", "N", "É", "E", "K", "/", ";", " ", "45,", "46,", "47,", "48,", "15,", "16,", "17,", "18,", "19,", "20,", "21,", "22,", "23,", ", ,", ",,");
  35. $mire = array("", ",", ",", ",", ",", ",", ",", ",", ",", "45.", "46.", "47.", "48.", "15.", "16.", "17.", "18.", "19.", "20.", "21.", "22.", "23.", ",", ",");
  36.  
  37.  
  38. $sorok = file('https://docs.google.com/spreadsheets/d/1U96l1NgLH0HI_xT_nnCPZX0fAqRoMVhCZUcl18qyLdY/export?gid=1057796338&format=csv');
  39. $cnt = 0;
  40. $id = 0;
  41. $string = '{
  42.    "type": "FeatureCollection",
  43.    "features": [';
  44. foreach ($sorok as $sor) {
  45.     $cnt ++;
  46.     if ($cnt == 1) continue;
  47.     $mezok = str_getcsv($sor, ",");
  48.     if (count($mezok) < 5) continue;
  49.     if (trim($mezok[5]) == '') continue;
  50.     $tm = $mezok[5];
  51.     $tm = str_replace($mit, $mire, $tm);
  52.     $tm = trim($tm, ",");
  53.     if (strpos($tm, ",") > 0) {
  54.         //echo "<br>-" . $tm . "-<br>";
  55.         list($h1, $s1) = explode(",", $tm);
  56.         $h2 = convert($h1);
  57.         $s2 = convert($s1);
  58.         $mezok[8] = $h2 . ", ". $s2;
  59.         //print_r($mezok);
  60.         //echo "---<br>";
  61.         switch ($mezok[3]) {
  62.             case 'Telekom':
  63.                 $fillcolor = "#e20074";
  64.                 $color = "#e20074";
  65.                 break;
  66.             case 'Telenor':
  67.                 $fillcolor = "#0091d2";
  68.                 $color = "#0091d2";
  69.                 break;
  70.             case 'Vodafone':
  71.                 $fillcolor = "#e50100";
  72.                 $color = "#e50100";
  73.                 break;
  74.         }
  75.         if ( (strpos($mezok[2], 'B3') !== FALSE) || (strpos($mezok[2], 'b3') !== FALSE) || (strpos($mezok[2], 'Band3') !== FALSE) || (strpos($mezok[2], 'band3') !== FALSE) ) {
  76.             $id ++;
  77.             $string .= '
  78.        {
  79.            "id": "' . $id . '",
  80.            "type": "Feature",
  81.            "properties": {
  82.                "band": "B3",
  83.                "mag": 1,
  84.                "operator": "' . strtolower($mezok[3]) . '",
  85.                "fillcolor": "' . $fillcolor . '",
  86.                "color": "' . $color . '",
  87.                "opacity": 0.35,
  88.                "info": "' . $mezok[2] . '</br>' . $mezok[1] . '</br>Rögzítette: ' . $mezok[4] . '</br>' . $mezok[3] . '"
  89.            },
  90.            "geometry": {
  91.                "type": "Point",
  92.                "coordinates": [
  93.                    ' . $h2 . ',
  94.                    ' . $s2 . '
  95.                ]
  96.            }
  97.        },';
  98.         }// if    
  99.         if ( (strpos($mezok[2], 'B7') !== FALSE) || (strpos($mezok[2], 'b7') !== FALSE) || (strpos($mezok[2], 'Band7') !== FALSE) || (strpos($mezok[2], 'band7') !== FALSE) ) {
  100.             $id ++;
  101.             $string .= '
  102.        {
  103.            "id": "' . $id . '",
  104.            "type": "Feature",
  105.            "properties": {
  106.                "band": "B7",
  107.                "mag": 1,
  108.                "operator": "' . strtolower($mezok[3]) . '",
  109.                "fillcolor": "' . $fillcolor . '",
  110.                "color": "' . $color . '",
  111.                "opacity": 0.35,
  112.                "info": "' . $mezok[2] . '</br>' . $mezok[1] . '</br>Rögzítette: ' . $mezok[4] . '</br>' . $mezok[3] . '"
  113.            },
  114.            "geometry": {
  115.                "type": "Point",
  116.                "coordinates": [
  117.                    ' . $h2 . ',
  118.                    ' . $s2 . '
  119.                ]
  120.            }
  121.        },';
  122.         }// if    
  123.         if ( (strpos($mezok[2], 'B20') !== FALSE) || (strpos($mezok[2], 'b20') !== FALSE) || (strpos($mezok[2], 'Band20') !== FALSE) || (strpos($mezok[2], 'band20') !== FALSE) ) {
  124.             $id ++;
  125.             $string .= '
  126.        {
  127.            "id": "' . $id . '",
  128.            "type": "Feature",
  129.            "properties": {
  130.                "band": "B20",
  131.                "mag": 1,
  132.                "operator": "' . strtolower($mezok[3]) . '",
  133.                "fillcolor": "' . $fillcolor . '",
  134.                "color": "' . $color . '",
  135.                "opacity": 0.35,
  136.                "info": "' . $mezok[2] . '</br>' . $mezok[1] . '</br>Rögzítette: ' . $mezok[4] . '</br>' . $mezok[3] . '"
  137.            },
  138.            "geometry": {
  139.                "type": "Point",
  140.                "coordinates": [
  141.                    ' . $h2 . ',
  142.                    ' . $s2 . '
  143.                ]
  144.            }
  145.        },';
  146.         }// if    
  147.     }
  148. }
  149. $string .= '
  150.    ]
  151. }';
  152. echo $string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement