Project

General

Profile

Revision 1c16578c

Added by Jocelyn Delande over 9 years ago

added site_point->get_url() method

View differences:

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
}

Also available in: Unified diff