Révision 812f173f
Ajouté par Jocelyn Delande il y a presque 11 ans
addParams.php | ||
---|---|---|
1 |
<?php |
|
2 |
require_once('class/site_point.class.php'); |
|
3 |
?> |
|
4 |
|
|
1 | 5 |
<!DOCTYPE html> |
2 | 6 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> |
3 | 7 |
<head> |
... | ... | |
6 | 10 |
<title>Positionnerment dun panoramique</title> |
7 | 11 |
<?php |
8 | 12 |
// tableau de vérification de conformité |
9 |
$params = array('title' => array('name' => 'titre',
|
|
13 |
$params = array('title' => array('name' => 'titre', |
|
10 | 14 |
'pattern' => '^.{1,50}$', |
11 | 15 |
'required' => true), |
12 |
'latitude' => array('name' => 'latitude',
|
|
16 |
'latitude' => array('name' => 'latitude', |
|
13 | 17 |
'type' => 'numeric', |
14 | 18 |
'min' => -180, |
15 | 19 |
'max' => 180, |
16 | 20 |
'required' => true), |
17 |
'longitude' => array('name' => 'longitude',
|
|
21 |
'longitude' => array('name' => 'longitude', |
|
18 | 22 |
'type' => 'numeric', |
19 | 23 |
'min' => -180, |
20 | 24 |
'max' => 180, |
21 | 25 |
'required' => true), |
22 |
'altitude' => array('name' => 'altitude',
|
|
26 |
'altitude' => array('name' => 'altitude', |
|
23 | 27 |
'type' => 'numeric', |
24 | 28 |
'min' => -400, |
25 | 29 |
'required' => true), |
26 |
'loop' => array('name' => 'image_loop',
|
|
30 |
'loop' => array('name' => 'image_loop', |
|
27 | 31 |
'type' => 'boolean', |
28 | 32 |
'required' => false), |
29 | 33 |
'dir' => array('required' => true), |
... | ... | |
52 | 56 |
} |
53 | 57 |
|
54 | 58 |
if (count($wrong) == 0) { |
55 |
// On recherche le dossier correspondant au panorama en question |
|
56 |
$dir_file = "./".$values['dir']."/".$values['panorama']; |
|
57 |
$dir_open = opendir($dir_file); |
|
58 |
while (false !== ($file = readdir($dir_open))) { |
|
59 |
// Si on trouve bien des tuiles |
|
60 |
if (preg_match('/(.*)_[0-9]+_[0-9]+_[0-9]+\.jpg$/', $file, $reg)) { |
|
61 |
$prefix = $reg[1]; |
|
62 |
$new_param_file = $prefix.".params"; |
|
63 |
break; // On sort à la première tuile trouvée |
|
64 |
} |
|
65 |
} |
|
66 |
closedir($dir_open); |
|
67 |
|
|
59 |
$pano = site_point::get($values['panorama']); |
|
60 |
|
|
68 | 61 |
// On vérifie qu'on a bien créée un nouveau fichier .params et on écrit dedans. |
69 |
if(isset($new_param_file)){ |
|
70 |
$fid = fopen($dir_file."/".$new_param_file,'a+'); |
|
71 |
echo '<p>Les valeurs suivantes sont utilisées.</p>'."\n"; |
|
72 |
echo "<dl>\n"; |
|
73 |
foreach ($values as $k => $v) { |
|
74 |
echo "$k -$v<br/>\n"; |
|
75 |
if (isset($params[$k]['name'])) { |
|
76 |
$nm = $params[$k]['name']; |
|
77 |
if (isset($params[$k]['type']) && $params[$k]['type'] == 'numeric') { |
|
78 |
$vf = $v; |
|
79 |
} else if (isset($params[$k]['type']) && $params[$k]['type'] == 'boolean') { |
|
80 |
$vf = $v ? "true" : "false"; |
|
81 |
} else { |
|
82 |
$vf = "\"$v\""; |
|
62 |
echo '<p>Les valeurs suivantes sont utilisées.</p>'."\n"; |
|
63 |
echo "<dl>\n"; |
|
64 |
foreach ($values as $k => $v) { |
|
65 |
if (isset($params[$k]['name'])) { |
|
66 |
$nm = $params[$k]['name']; |
|
67 |
if (isset($params[$k]['type']) && $params[$k]['type'] == 'numeric') { |
|
68 |
$vf = $v; |
|
69 |
} else if (isset($params[$k]['type']) && $params[$k]['type'] == 'boolean') { |
|
70 |
$vf = $v ? "true" : "false"; |
|
71 |
} else { |
|
72 |
$vf = "\"$v\""; |
|
73 |
} |
|
74 |
$pano->set_param($nm, $vf); |
|
75 |
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $nm, $vf); |
|
76 |
} |
|
83 | 77 |
} |
84 |
fputs($fid, "$nm = $vf\n"); |
|
85 |
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $nm, $vf); |
|
86 |
} |
|
87 |
} |
|
88 |
echo "</dl>\n"; |
|
89 |
fclose($fid); |
|
90 |
echo '<p class="succes">Paramétrage terminé.</p>'."\n"; |
|
91 |
} else { |
|
92 |
printf("<p class=\"error\">impossible d'écrire dans le fichier '%s'</p>\n", $dir_file); |
|
93 |
} |
|
78 |
$pano->save_params(); |
|
79 |
|
|
80 |
echo "</dl>\n"; |
|
81 |
echo '<p class="succes">Paramétrage terminé.</p>'."\n"; |
|
94 | 82 |
} else { |
95 |
echo '<p class="error">Les valeurs suivantes sont incorrectes.</p>'."\n";
|
|
96 |
echo "<dl>\n";
|
|
97 |
foreach ($wrong as $k => $v) {
|
|
98 |
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $k, $v);
|
|
99 |
}
|
|
100 |
echo "</dl>\n";
|
|
83 |
echo '<p class="error">Les valeurs suivantes sont incorrectes.</p>'."\n";
|
|
84 |
echo "<dl>\n";
|
|
85 |
foreach ($wrong as $k => $v) {
|
|
86 |
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $k, $v);
|
|
87 |
}
|
|
88 |
echo "</dl>\n";
|
|
101 | 89 |
} |
102 | 90 |
printf('<a href="%s">Retour au panorama</a></p>'."\n", $back_url); |
103 | 91 |
|
ajax/all_points.php | ||
---|---|---|
24 | 24 |
} |
25 | 25 |
|
26 | 26 |
|
27 |
function get_site_points() { |
|
28 |
$dir = "../tiles";//FIXME |
|
29 |
return (new sites_dir($dir))->get_sites(); |
|
30 |
} |
|
31 |
|
|
32 |
|
|
33 | 27 |
function site_point_to_geoJSONFeature($sp) { |
34 | 28 |
$prm = $sp->get_params(); |
35 | 29 |
$name = $sp->get_name(); |
... | ... | |
60 | 54 |
} |
61 | 55 |
|
62 | 56 |
|
63 |
foreach(get_site_points() as $site_point) {
|
|
57 |
foreach(site_point::get_all() as $site_point) {
|
|
64 | 58 |
$json['features'][] = site_point_to_geoJSONFeature($site_point); |
65 | 59 |
} |
66 | 60 |
|
class/site_point.class.php | ||
---|---|---|
25 | 25 |
} |
26 | 26 |
closedir($dir_fd); |
27 | 27 |
if ($this->prefix === false) return false; |
28 |
$this->parse_and_store_params();
|
|
28 |
$this->parse_and_cache_params();
|
|
29 | 29 |
} |
30 | 30 |
|
31 |
private function params_path() {
|
|
31 |
public function params_path() {
|
|
32 | 32 |
return $this->base_dir.'/'.$this->prefix.'.params'; |
33 | 33 |
} |
34 | 34 |
|
35 |
private function parse_and_store_params() {
|
|
35 |
private function parse_and_cache_params() {
|
|
36 | 36 |
if (is_file($this->params_path())) { |
37 | 37 |
$this->params = @parse_ini_file($this->params_path()); |
38 | 38 |
} |
... | ... | |
43 | 43 |
if (isset($this->params)) { |
44 | 44 |
return $this->params; |
45 | 45 |
} else { |
46 |
return parse_and_store_params();
|
|
46 |
return parse_and_cache_params();
|
|
47 | 47 |
} |
48 | 48 |
} |
49 | 49 |
|
50 |
public function has_params(){ |
|
50 |
public function save_params() { |
|
51 |
$o = ''; |
|
52 |
$p = $this->get_params(); |
|
53 |
foreach ($this->get_params() as $k => $v) { |
|
54 |
$o.= "$k = $v\n"; |
|
55 |
} |
|
56 |
file_put_contents($this->params_path(), $o); |
|
57 |
} |
|
58 |
|
|
59 |
public function set_param($key, $value) { |
|
51 | 60 |
$p = $this->get_params(); |
52 |
return (isset($prm['latitude'], $prm['longitude'], |
|
53 |
$prm['altitude'], $prm['titre'])) |
|
61 |
$this->params[$key] = $value; |
|
62 |
if ($key == 'titre') { |
|
63 |
$this->name = $value; |
|
64 |
} |
|
54 | 65 |
} |
55 |
if ($oname != $name && ) { |
|
56 | 66 |
|
67 |
public function has_params(){ |
|
68 |
$p = $this->get_params(); |
|
69 |
return (isset($p['latitude'], $p['longitude'], |
|
70 |
$p['altitude'], $p['titre'])); |
|
71 |
} |
|
57 | 72 |
|
58 | 73 |
public function get_name() { |
59 | 74 |
return basename($this->base_dir); |
... | ... | |
109 | 124 |
return array($d, $cap*180/M_PI, $e*180/M_PI); // les résultats sont en degrés |
110 | 125 |
} |
111 | 126 |
|
112 |
public function get_url() { |
|
113 |
return sprintf('panorama.php?dir=%s&panorama=%s', |
|
114 |
'tiles', $this->get_name()); |
|
127 |
public function get_url($cap=false, $ele=false) { |
|
128 |
$o = sprintf('panorama.php?dir=%s&panorama=%s', |
|
129 |
PANORAMA_FOLDER, $this->get_name()); |
|
130 |
if ($cap && $ele) { |
|
131 |
$o .= sprintf("&to_cap=%.3f&to_ele=%.3f", $cap, $ele); |
|
132 |
} |
|
133 |
return $o; |
|
115 | 134 |
} |
116 | 135 |
|
117 | 136 |
public static function get($name) { |
constants.inc.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
define('CELUTZ_PATH', realpath(dirname(__FILE__))); |
3 |
define('PANORAMA_PATH', CELUTZ_PATH.'/tiles' ); |
|
3 |
define('PANORAMA_FOLDER', 'tiles' ); |
|
4 |
define('PANORAMA_PATH', CELUTZ_PATH.'/'.PANORAMA_FOLDER ); |
|
4 | 5 |
define('UPLOAD_PATH', CELUTZ_PATH.'/upload' ); |
5 | 6 |
?> |
genererPano.php | ||
---|---|---|
7 | 7 |
</head> |
8 | 8 |
|
9 | 9 |
<?php |
10 |
require 'class/utils.class.php'; |
|
10 |
require_once 'class/utils.class.php'; |
|
11 |
require_once 'constants.inc.php'; |
|
11 | 12 |
utils::init(); |
12 | 13 |
if (isset($_GET['name'])) { |
13 | 14 |
$pano_name = $_GET['name']; |
14 | 15 |
$pano_basename = preg_replace('/\.[^.]+$/', '', $pano_name); |
15 | 16 |
|
16 | 17 |
//Partie exécutante du script gen_tiles qui gènere les tuiles à partir d'une image. |
17 |
$panos_dir = 'tiles'; |
|
18 |
$pano_dest = $panos_dir.'/'.$pano_basename; |
|
19 |
if (! is_dir($panos_dir)) { |
|
20 |
if (! mkdir($panos_dir)) { |
|
21 |
echo "<p class=\"error\">le répertoire \"$panos_dir\" n'est pas accessible et ne peut être créé</p>\n"; |
|
18 |
$pano_dest = PANORAMA_PATH.'/'.$pano_basename; |
|
19 |
if (! is_dir(PANORAMA_PATH)) { |
|
20 |
if (! mkdir(PANORAMA_PATH)) { |
|
21 |
echo "<p class=\"error\">le répertoire \"PANORAMA_PATH\" n'est pas accessible et ne peut être créé</p>\n"; |
|
22 | 22 |
} |
23 | 23 |
} else if (file_exists($pano_dest)) { |
24 | 24 |
echo "<p class=\"error\">le nom de répertoire \"$pano_dest\" est déjà pris</p>\n"; |
... | ... | |
47 | 47 |
if (pclose($fp) === 0) { |
48 | 48 |
print("<h4><span class=\"success\">Opération réussie</span></h4>\n"); |
49 | 49 |
printf("<p>Pour acceder directement au panorama <a href=\"panorama.php?dir=%s&panorama=%s\">cliquer ici</a></p>\n", |
50 |
$panos_dir, $pano_basename);
|
|
50 |
PANORAMA_PATH, $pano_basename);
|
|
51 | 51 |
} else { |
52 | 52 |
print("<h4><span class=\"error\">Opération en échec durant l'exécution du script !</span></h4>\n"); |
53 | 53 |
} |
index.php | ||
---|---|---|
12 | 12 |
<section id="main"> |
13 | 13 |
<h2>Liste des panoramas</h2> |
14 | 14 |
<?php |
15 |
require 'class/utils.class.php'; |
|
15 |
require_once 'class/utils.class.php'; |
|
16 |
require_once 'constants.inc.php'; |
|
16 | 17 |
utils::init(); |
17 | 18 |
|
18 | 19 |
if(isset($_GET['dir']) && is_dir($_GET['dir'])) { |
19 | 20 |
$base_dir = $_GET['dir']; |
20 | 21 |
} else { |
21 |
$base_dir='tiles';
|
|
22 |
$base_dir=PANORAMA_PATH;
|
|
22 | 23 |
} |
23 | 24 |
|
24 | 25 |
$dir = new sites_dir($base_dir); |
panorama.php | ||
---|---|---|
3 | 3 |
<head> |
4 | 4 |
<?php |
5 | 5 |
require 'class/utils.class.php'; |
6 |
require_once 'constants.inc.php'; |
|
6 | 7 |
utils::init(); |
7 | 8 |
|
8 | 9 |
$form_extpoint = file_get_contents('html/form_extpoint.html'); |
... | ... | |
13 | 14 |
$dir = $_GET['dir']; |
14 | 15 |
$name = $_GET['panorama']; |
15 | 16 |
} else { |
16 |
$dir = 'tiles';
|
|
17 |
$dir = PANORAMA_PATH;
|
|
17 | 18 |
$name = 'ttn_mediatheque'; |
18 | 19 |
} |
19 | 20 |
$opt_vals = array(); |
... | ... | |
48 | 49 |
<script> |
49 | 50 |
<?php |
50 | 51 |
$zoom_array = $pt->get_magnifications(); |
52 |
|
|
51 | 53 |
foreach($zoom_array as $zoom => $val) { |
52 | 54 |
echo "zooms[$zoom] = new tzoom($zoom);\n"; |
53 | 55 |
echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n"; |
... | ... | |
63 | 65 |
$dir_list = new sites_dir($dir); |
64 | 66 |
|
65 | 67 |
$ipt = 0; |
66 |
$scrname = getenv('SCRIPT_NAME'); |
|
67 |
foreach($dir_list->get_sites() as $opt) { |
|
68 |
foreach(site_point::get_all() as $opt) { |
|
68 | 69 |
$prm = $opt->get_params(); |
69 | 70 |
$oname = $opt->get_name(); |
70 |
if ($oname != $name && $opt->has_params()) {
|
|
71 |
if (($oname != $name) && $opt->has_params()) {
|
|
71 | 72 |
list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']); |
72 |
$lnk = sprintf("%s?dir=%s&panorama=%s&to_cap=%.3f&to_ele=%.3f", $scrname, $dir, $oname, $cap + 180, -$ele); |
|
73 |
// Looks back at the point from which we come. |
|
74 |
$lnk = $opt->get_url($cap + 180, -$ele); |
|
73 | 75 |
printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk); |
74 | 76 |
} |
75 | 77 |
} |
78 |
|
|
76 | 79 |
$ref_points = array (); |
77 | 80 |
$ref_points_filename = 'ref_points.local.php'; |
78 | 81 |
if (file_exists($ref_points_filename)) { |
Formats disponibles : Unified diff
make use of constants