Last active
October 21, 2018 09:52
-
-
Save Balsalobre/8fe2b37155c8cc7e761ac171483a3315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*********************************************************************************/ | |
/* FUNCIÓN PARA DESCARGAR ARCHIVO CSV DONDE RECIBIMOS LOS DATOS DEL SATÉLITE */ | |
/*********************************************************************************/ | |
if($download) { | |
$file = file('https://firms.modaps.eosdis.nasa.gov/data/active_fire/viirs/csv/VNP14IMGTDL_NRT_Europe_24h.csv'); | |
foreach($file as $k) | |
$csv[]=explode(',',$k); | |
$arrlength = count($csv); | |
$fuegos = array(); | |
for($x = 0; $x < $arrlength; $x++) { | |
if($x>0){ | |
$data = array( | |
"latitud" => $csv[$x][0], //latitud | |
"longitud" => $csv[$x][1], //longitud | |
"hora" => substr($csv[$x][6], 0, 2).':'.substr($csv[$x][6], -2).':00', //time | |
"fecha" => $csv[$x][5], //date | |
"comentario" => "Fuego detectado por los satélites de la NASA" | |
); | |
array_push($fuegos, $data); | |
} | |
} | |
if(createFuegoFromNasa($fuegos)){ | |
if($fecha != "") { | |
$sql2 = "UPDATE nasaData SET ultimaConsulta = '$actualDate'"; | |
$db->update($sql2); | |
} else { | |
$sql2 = "INSERT INTO nasaData VALUES('$actualDate')"; | |
$db->insert($sql2); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment