No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

76 líneas
2.8 KiB

  1. <?php
  2. class Conn {
  3. private $con;
  4. public function __construct() {
  5. $this->con = new SQLite3("/home/pi/raspberry-noaa/panel.db");
  6. }
  7. public function getPasses() {
  8. $today = strtotime(date('Y-m-d', time()));
  9. $query = $this->con->query("SELECT sat_name, is_active,
  10. pass_start, pass_end,
  11. max_elev FROM predict_passes
  12. WHERE (pass_start > $today) ORDER BY
  13. pass_start ASC;");
  14. $passes = [];
  15. $i = 0;
  16. while($row = $query->fetchArray()){
  17. $passes[$i] = $row;
  18. $i++;
  19. }
  20. return $passes;
  21. }
  22. public function totalPages($img_per_page) {
  23. $total_pages = $this->con->querySingle("SELECT count() from decoded_passes;");
  24. return ceil($total_pages/$img_per_page);
  25. }
  26. public function getImages($page, $img_per_page) {
  27. $query = $this->con->prepare("SELECT decoded_passes.id, predict_passes.pass_start,
  28. file_path, sat_type, predict_passes.sat_name, predict_passes.max_elev
  29. FROM decoded_passes INNER JOIN predict_passes
  30. ON predict_passes.pass_start = decoded_passes.pass_start
  31. ORDER BY decoded_passes.pass_start DESC LIMIT ? OFFSET ?;");
  32. $query->bindValue(1, $img_per_page);
  33. $query->bindValue(2, $img_per_page * ($page-1));
  34. $result = $query->execute();
  35. $images = [];
  36. $i = 0;
  37. while($row = $result->fetchArray()){
  38. $images[$i] = $row;
  39. $i++;
  40. }
  41. return $images;
  42. }
  43. public function getEnhacements($id) {
  44. $query = $this->con->prepare('SELECT daylight_pass, sat_type
  45. FROM decoded_passes WHERE id = ?;');
  46. $query->bindValue(1, $id);
  47. $result = $query->execute();
  48. $pass = $result->fetchArray();
  49. switch($pass['sat_type']) {
  50. case 0:
  51. $ending = "-122-rectified.jpg";
  52. case 1:
  53. if ($pass['daylight_pass'] == 1) {
  54. $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg','-MSA.jpg','-MSA-precip.jpg','-HVC.jpg','-HVC-precip.jpg','-HVCT.jpg','-HVCT-precip.jpg'];
  55. } else {
  56. $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg'];
  57. }
  58. }
  59. return $enhacements;
  60. }
  61. public function getPath($id) {
  62. $query = $this->con->prepare('SELECT file_path FROM decoded_passes
  63. WHERE id = ?;');
  64. $query->bindValue(1, $id);
  65. $result = $query->execute();
  66. $image = $result->fetchArray();
  67. return $image['file_path'];
  68. }
  69. }
  70. ?>