Skip to content

Instantly share code, notes, and snippets.

@Balsalobre
Last active October 21, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Balsalobre/8fe2b37155c8cc7e761ac171483a3315 to your computer and use it in GitHub Desktop.
Save Balsalobre/8fe2b37155c8cc7e761ac171483a3315 to your computer and use it in GitHub Desktop.
<?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