Projet

Général

Profil

Paste
Télécharger (5,4 ko) Statistiques
| Branche: | Révision:

root / panorama.php @ 1f5db711

1
<!DOCTYPE html>
2
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
3
<head>
4
  <?php
5
   require 'class/site_point.class.php';
6
   require 'class/sites_dir.class.php';
7

    
8
   if (isset($_GET['dir']) && isset($_GET['panorama'])) {
9
     $dir   = $_GET['dir'];
10
     $name  = $_GET['panorama'];
11
   } else {
12
     $dir   = 'tiles';
13
     $name  = 'ttn_mediatheque';
14
   }
15
   $opt_vals = array();
16
   foreach(array('to_cap', 'to_ele', 'to_zoom') as $val) {
17
     if (!empty($_GET[$val])) $opt_vals[$val] = $_GET[$val];
18
   }
19

    
20
   $base_dir = $dir.'/'.$name;
21
   $pt = new site_point($base_dir);
22
   if(!$pt) die("impossible d'accéder à ".$base_dir." !\n");
23
   $params = $pt->get_params();
24
   $prefix = $pt->get_prefix();
25
  ?>
26
  <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
27
   <?php
28
     $titre = 'panorama';
29
     if ($params && isset($params['titre'])) $titre .= ' ; '.$params['titre'];
30
     printf ("<title>%s</title>\n", $params['titre']);
31
  ?>
32
  <script>
33
   <?php
34
     printf ("var img_prefix = '%s/%s'\n", $base_dir, $prefix);
35
     if (is_array($params)) $opt_vals = array_merge($params, $opt_vals);
36
     foreach(array('to_cap', 'to_ele', 'to_zoom', 'image_loop') as $val) {
37
       if (isset($opt_vals[$val])) printf ('var '.$val.' = '.$opt_vals[$val].";\n"); // correction du décalage angulaire par rapport au Nord
38
     }
39
  ?>
40
  </script>
41
  <script src="js/pano.js"></script>
42
  <script>
43
  <?php
44
     $zoom_array = $pt->get_magnifications();
45
     foreach($zoom_array as $zoom => $val) {
46
       echo "zooms[$zoom] = new tzoom($zoom);\n";
47
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
48
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
49
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
50
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
51
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
52
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
53
       echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
54
       echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
55
     }
56

    
57
   $dir_list = new sites_dir($dir);
58

    
59
   $ipt = 0;
60
   $scrname = getenv('SCRIPT_NAME');
61
   foreach($dir_list->get_sites() as $opt) {
62
     $prm = $opt->get_params();
63
     $oname = $opt->get_name();
64
     if ($oname != $name && isset($prm['latitude']) && isset($prm['longitude']) && isset($prm['altitude']) && isset($prm['titre'])) {
65
       list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
66
       $lnk = sprintf("%s?dir=%s&panorama=%s&to_cap=%.3f&to_ele=%.3f", $scrname, $dir, $oname, $cap + 180, -$ele);
67
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);
68
     }
69
   }
70

    
71
   include 'ref_points.php';
72
   $extra_names = array();
73
   $ref_names = array();
74
   if (is_array($ref_points)) {
75
     foreach ($ref_points as $name => $vals) {
76
       $extra_names[] = $name;
77
       list($dist, $cap, $ele) = $pt->coordsToCap($vals[0], $vals[1], $vals[2]);
78
       $ref_names[$name] = array($dist, $cap, $ele);
79
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "");'."\n", $ipt++, $name, $dist, $cap, $ele);
80
     }
81
   }
82

    
83
   if (isset($params['reference'])) {
84
     echo "ref_points = new Array();\n";
85
     foreach ($params['reference'] as $nm => $val) {
86
       if (isset($ref_names[$nm])) {
87
         list($dist, $cap, $ele) = $ref_names[$nm];
88
         list($px, $py) = explode(',', $val);
89
         printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
90
       }
91
     }
92
   }
93
  ?>
94
  </script>
95
  <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
96
  <link rel="stylesheet" media="screen" href="css/all.css" />
97
</head>
98
<body>
99
  <canvas id="mon-canvas">
100
    Ce message indique que ce navigateurs est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
101
  </canvas>
102
  <fieldset id="control"><legend>contrôle</legend>
103
      <label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
104
      <label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl"/></label>
105
      <label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl"/></label>
106
  </fieldset>
107

    
108
  <?php
109
      //phpinfo();exit;
110
     if ($params && isset($params['latitude']) && isset($params['longitude'])) {
111
       print("<div id=\"params\">\n");
112
       printf ("<p>latitude :   <em>%.3f°</em></p>\n", $params['latitude']);
113
       printf ("<p>longitude : <em>%.3f°</em></p>\n", $params['longitude']);
114
       if (isset($params['altitude'])) printf ("<p>altitude : <em>%d m</em></p>\n", $params['altitude']);
115
       print("</div>\n");
116
     }
117
     echo '<p id="info"></p>'."\n";
118
     if (count($extra_names) > 1) {
119
       echo "<p id=\"insert\">\n<select id=\"sel_point\" name=\"known_points\">\n";
120
       foreach ($extra_names as $nm) {
121
         echo '<option>'.$nm."</option>\n";
122
       }
123
       echo "</select>\n<br/>";
124
       echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
125
       echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
126
       echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
127
       echo "</p>\n";
128
     }
129
  ?> 
130
  <p class="validators"><a href="http://validator.w3.org/check?uri=referer">page xHTML validé !</a></p>
131
  <p id="res"></p>
132
</body>
133
</html>