22 |
22 |
}
|
23 |
23 |
closedir($dir_fd);
|
24 |
24 |
if ($this->prefix === false) return false;
|
25 |
|
$pfname = $this->base_dir.'/'.$this->prefix.'.params';
|
26 |
|
if (is_file($pfname)) {
|
27 |
|
$this->params = @parse_ini_file($pfname);
|
|
25 |
$this->parse_and_store_params();
|
|
26 |
}
|
|
27 |
|
|
28 |
private function params_path() {
|
|
29 |
return $this->base_dir.'/'.$this->prefix.'.params';
|
|
30 |
}
|
|
31 |
|
|
32 |
private function parse_and_store_params() {
|
|
33 |
if (is_file($this->params_path())) {
|
|
34 |
$this->params = @parse_ini_file($this->params_path());
|
28 |
35 |
}
|
29 |
36 |
}
|
30 |
37 |
|
31 |
38 |
public function get_params() {
|
32 |
|
return $this->params;
|
|
39 |
// the params are cached
|
|
40 |
if (isset($this->params)) {
|
|
41 |
return $this->params;
|
|
42 |
} else {
|
|
43 |
return parse_and_store_params();
|
|
44 |
}
|
33 |
45 |
}
|
34 |
46 |
|
35 |
47 |
public function get_name() {
|
... | ... | |
60 |
72 |
}
|
61 |
73 |
|
62 |
74 |
public function coordsToCap($lat, $lon, $alt) {
|
63 |
|
if (!isset($this->params['latitude']) || !isset($this->params['longitude'])) return false;
|
|
75 |
$params = $this->get_params();
|
|
76 |
if (!isset($params['latitude']) || !isset($params['longitude'])) return false;
|
64 |
77 |
$rt = 6371; // Rayon de la terre
|
65 |
|
$alt1 = isset($this->params['altitude']) ? $this->params['altitude'] : $alt;
|
66 |
|
$lat1 = $this->params['latitude']*M_PI/180;
|
67 |
|
$lon1 = $this->params['longitude']*M_PI/180;
|
|
78 |
$alt1 = isset($params['altitude']) ? $params['altitude'] : $alt;
|
|
79 |
$lat1 = $params['latitude']*M_PI/180;
|
|
80 |
$lon1 = $params['longitude']*M_PI/180;
|
68 |
81 |
$alt2 = $alt;
|
69 |
82 |
$lat2 = $lat * M_PI/180;
|
70 |
83 |
$lon2 = $lon * M_PI/180;
|
... | ... | |
81 |
94 |
$cap = atan2($y, $x); // cap pour atteindre le point en radians
|
82 |
95 |
|
83 |
96 |
$e = atan2(($alt2 - $alt1)/1000 - $d*$d/(2*$rt), $d); // angle de l'élévation en radians
|
84 |
|
// printf("%s, %s, %s, %s\n",$lat1, $this->params['latitude'], $lat, $dLat);
|
|
97 |
// printf("%s, %s, %s, %s\n",$lat1, $params['latitude'], $lat, $dLat);
|
85 |
98 |
return array($d, $cap*180/M_PI, $e*180/M_PI); // les résultats sont en degrés
|
86 |
99 |
}
|
87 |
100 |
|
handle a params cache