Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function convert($input) {
- $deg = " " ;
- $min = " " ;
- $sec = " " ;
- $inputM = " " ;
- for ($i=0; $i < strlen($input); $i++)
- {
- $tempD = $input[$i];
- if ($tempD == iconv("UTF-8", "ISO-8859-1//TRANSLIT", '°') )
- {
- $newI = $i + 1 ;
- $inputM = substr($input, $newI, -1) ;
- break;
- }//close if degree
- $deg .= $tempD ;
- }//close for degree
- for ($j=0; $j < strlen($inputM); $j++)
- {
- $tempM = $inputM[$j];
- if ($tempM == "'")
- {
- $newI = $j + 1 ;
- $sec = substr($inputM, $newI, -1) ;
- break;
- }//close if minute
- $min .= $tempM ;
- }//close for min
- $result = $deg+( (( $min*60) + ($sec) ) / 3600 );
- return $result;
- }
- $mit = array("Latitude:", "Longitude:", "N", "É", "E", "K", "/", ";", " ", "45,", "46,", "47,", "48,", "15,", "16,", "17,", "18,", "19,", "20,", "21,", "22,", "23,", ", ,", ",,");
- $mire = array("", ",", ",", ",", ",", ",", ",", ",", ",", "45.", "46.", "47.", "48.", "15.", "16.", "17.", "18.", "19.", "20.", "21.", "22.", "23.", ",", ",");
- $sorok = file('https://docs.google.com/spreadsheets/d/1U96l1NgLH0HI_xT_nnCPZX0fAqRoMVhCZUcl18qyLdY/export?gid=1057796338&format=csv');
- $cnt = 0;
- $id = 0;
- $string = '{
- "type": "FeatureCollection",
- "features": [';
- foreach ($sorok as $sor) {
- $cnt ++;
- if ($cnt == 1) continue;
- $mezok = str_getcsv($sor, ",");
- if (count($mezok) < 5) continue;
- if (trim($mezok[5]) == '') continue;
- $tm = $mezok[5];
- $tm = str_replace($mit, $mire, $tm);
- $tm = trim($tm, ",");
- if (strpos($tm, ",") > 0) {
- //echo "<br>-" . $tm . "-<br>";
- list($h1, $s1) = explode(",", $tm);
- $h2 = convert($h1);
- $s2 = convert($s1);
- $mezok[8] = $h2 . ", ". $s2;
- //print_r($mezok);
- //echo "---<br>";
- switch ($mezok[3]) {
- case 'Telekom':
- $fillcolor = "#e20074";
- $color = "#e20074";
- break;
- case 'Telenor':
- $fillcolor = "#0091d2";
- $color = "#0091d2";
- break;
- case 'Vodafone':
- $fillcolor = "#e50100";
- $color = "#e50100";
- break;
- }
- if ( (strpos($mezok[2], 'B3') !== FALSE) || (strpos($mezok[2], 'b3') !== FALSE) || (strpos($mezok[2], 'Band3') !== FALSE) || (strpos($mezok[2], 'band3') !== FALSE) ) {
- $id ++;
- $string .= '
- {
- "id": "' . $id . '",
- "type": "Feature",
- "properties": {
- "band": "B3",
- "mag": 1,
- "operator": "' . strtolower($mezok[3]) . '",
- "fillcolor": "' . $fillcolor . '",
- "color": "' . $color . '",
- "opacity": 0.35,
- "info": "' . $mezok[2] . '</br>' . $mezok[1] . '</br>Rögzítette: ' . $mezok[4] . '</br>' . $mezok[3] . '"
- },
- "geometry": {
- "type": "Point",
- "coordinates": [
- ' . $h2 . ',
- ' . $s2 . '
- ]
- }
- },';
- }// if
- if ( (strpos($mezok[2], 'B7') !== FALSE) || (strpos($mezok[2], 'b7') !== FALSE) || (strpos($mezok[2], 'Band7') !== FALSE) || (strpos($mezok[2], 'band7') !== FALSE) ) {
- $id ++;
- $string .= '
- {
- "id": "' . $id . '",
- "type": "Feature",
- "properties": {
- "band": "B7",
- "mag": 1,
- "operator": "' . strtolower($mezok[3]) . '",
- "fillcolor": "' . $fillcolor . '",
- "color": "' . $color . '",
- "opacity": 0.35,
- "info": "' . $mezok[2] . '</br>' . $mezok[1] . '</br>Rögzítette: ' . $mezok[4] . '</br>' . $mezok[3] . '"
- },
- "geometry": {
- "type": "Point",
- "coordinates": [
- ' . $h2 . ',
- ' . $s2 . '
- ]
- }
- },';
- }// if
- if ( (strpos($mezok[2], 'B20') !== FALSE) || (strpos($mezok[2], 'b20') !== FALSE) || (strpos($mezok[2], 'Band20') !== FALSE) || (strpos($mezok[2], 'band20') !== FALSE) ) {
- $id ++;
- $string .= '
- {
- "id": "' . $id . '",
- "type": "Feature",
- "properties": {
- "band": "B20",
- "mag": 1,
- "operator": "' . strtolower($mezok[3]) . '",
- "fillcolor": "' . $fillcolor . '",
- "color": "' . $color . '",
- "opacity": 0.35,
- "info": "' . $mezok[2] . '</br>' . $mezok[1] . '</br>Rögzítette: ' . $mezok[4] . '</br>' . $mezok[3] . '"
- },
- "geometry": {
- "type": "Point",
- "coordinates": [
- ' . $h2 . ',
- ' . $s2 . '
- ]
- }
- },';
- }// if
- }
- }
- $string .= '
- ]
- }';
- echo $string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement