Projet

Général

Profil

Révision 1c16578c

Ajouté par Jocelyn Delande il y a environ 11 ans

added site_point->get_url() method

Voir les différences:

class/site_point.class.php
11 11
    if (!is_dir($dir)) return;
12 12
    $this->base_dir = $dir;
13 13
    $dir_fd = opendir($this->base_dir);
14
  
14

  
15 15
    while (false !== ($file = readdir($dir_fd))) {
16
    	
16

  
17 17
       if (preg_match('/(.*)_[0-9]+_[0-9]+_[0-9]+\.jpg$/', $file, $reg)) {
18 18
	 $this->prefix = $reg[1];
19
	 
19

  
20 20
	 break;
21 21
       }
22 22
    }
......
25 25
    $pfname = $this->base_dir.'/'.$this->prefix.'.params';
26 26
    if (is_file($pfname)) {
27 27
      $this->params = @parse_ini_file($pfname);
28
    } 
28
    }
29 29
  }
30
  
30

  
31 31
  public function get_params() {
32 32
    return $this->params;
33 33
  }
34
  
34

  
35 35
  public function get_name() {
36 36
    return basename($this->base_dir);
37 37
  }
......
39 39
  public function get_prefix() {
40 40
    return $this->prefix;
41 41
  }
42
  
42

  
43 43
  public function get_magnifications() {
44 44
    $dir_fd = opendir($this->base_dir);
45 45
    while (false !== ($file = readdir($dir_fd))) {                // extraction des paramètres de grossissement par le serveur
......
70 70
    $lon2 = $lon * M_PI/180;
71 71

  
72 72
    $dLat = $lat2-$lat1;
73
    $dLon = $lon2-$lon1; 
74
    
75
    $a = sin($dLat/2) * sin($dLat/2) + sin($dLon/2) * sin($dLon/2) * cos($lat1) * cos($lat2);  // 
73
    $dLon = $lon2-$lon1;
74

  
75
    $a = sin($dLat/2) * sin($dLat/2) + sin($dLon/2) * sin($dLon/2) * cos($lat1) * cos($lat2);  //
76 76
    $angle = 2 * atan2(sqrt($a), sqrt(1-$a));
77 77
    $d = $angle * $rt;                    // distance du point en Kms
78
    
78

  
79 79
    $y = sin($dLon)*cos($lat2);
80 80
    $x = cos($lat1)*sin($lat2) - sin($lat1)*cos($lat2)*cos($dLon);
81 81
    $cap = atan2($y, $x);                 // cap pour atteindre le point en radians
82
    
82

  
83 83
    $e = atan2(($alt2 - $alt1)/1000 - $d*$d/(2*$rt), $d);  // angle de l'élévation en radians
84 84
    //    printf("%s, %s, %s, %s\n",$lat1, $this->params['latitude'], $lat, $dLat);
85 85
    return array($d, $cap*180/M_PI, $e*180/M_PI);   // les résultats sont en degrés
86 86
  }
87
  
87

  
88
  public function get_url() {
89
	  return sprintf('panorama.php?dir=%s&panorama=%s',
90
	                 dirname($this->base_dir), $this->get_name());
91
  }
88 92
}
index.php
16 16
utils::init();
17 17

  
18 18
if(isset($_GET['dir']) && is_dir($_GET['dir'])) {
19
  $base_dir = $_GET['dir']; 
19
  $base_dir = $_GET['dir'];
20 20
} else {
21 21
  $base_dir='tiles';
22 22
}
......
26 26
  $sites_list = $dir->get_sites();
27 27

  
28 28
  echo "<ul id=\"pano-list\">\n";
29
	
29

  
30 30
  foreach($sites_list as $pt) {
31 31
    $params = $pt->get_params();
32 32
    $pos_file = sprintf('%s/%s', $pt->get_name(), $pt->get_prefix());
......
35 35
      $title = sprintf(' title="fichier : %s"', $pos_file);
36 36
    } else {
37 37
      $cmt = sprintf('<samp>%s</samp>', $pos_file);
38
      $title = ''; 
38
      $title = '';
39 39
    }
40
    printf ('<li%s><a href="panorama.php?dir=%s&amp;panorama=%s">%s</a></li>'."\n", $title, $base_dir, $pt->get_name(), $cmt);
40
    printf ('<li%s><a href="%s">%s</a></li>'."\n", $title, $pt->get_url(), $cmt);
41 41
  }
42 42
  echo "</ul>\n";
43
} catch (Exception $e) {
43
  } catch (Exception $e) {
44 44
  printf("<h3 class=\"warning\">désolé mais aucun site n'est disponible...</h3>\n");
45 45
}
46 46
?>

Formats disponibles : Unified diff