Projet

Général

Profil

Paste
Télécharger (9,39 ko) Statistiques
| Branche: | Révision:

root / panorama.php @ 7f9aab46

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

    
84
   if (isset($params['reference'])) {
85
     echo "ref_points = new Array();\n";
86
     foreach ($params['reference'] as $nm => $val) {
87
       if (isset($ref_names[$nm])) {
88
         list($dist, $cap, $ele) = $ref_names[$nm];
89
         list($px, $py) = explode(',', $val);
90
         printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
91
       }
92
     }
93
   }
94
  
95
  $localLat = (isset($_POST["loca_latitude"])) ? $_POST["loca_latitude"] : NULL;
96
  $localLon = (isset($_POST["loca_longitude"])) ? $_POST["loca_longitude"] : NULL;
97
  $localAlt = (isset($_POST["loca_altitude"])) ? $_POST["loca_altitude"] : NULL;
98
 
99
  if ($localLat && $localLon && $localAlt) {
100
            list($localDistance, $localCap, $localEle) = $pt->coordsToCap($localLat, $localLon, $localAlt);
101
            $n = "point temporaire";
102
      printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "temporary");'."\n",$ipt++, $n, $localDistance, $localCap, $localEle);
103
  } 
104
  ?>
105
  </script>
106
  
107
 
108

    
109
  
110
  <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
111
  <link rel="stylesheet" media="screen" href="css/all.css" />
112
  <script src="js/hide_n_showForm.js"></script> 
113
</head>
114
<body>
115
  <canvas id="mon-canvas">
116
    Ce message indique que ce navigateurs est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
117
  </canvas>
118
  
119
  <fieldset id="control"><legend>contrôle</legend>
120
      <label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
121
      <label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl"/></label>
122
      <label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl"/></label>
123
  </fieldset>
124

    
125
  <?php
126
      
127
     if ($params && isset($params['latitude']) && isset($params['longitude'])) {
128
       print("<div id=\"params\">\n");
129
       printf ("<p>latitude :   <em><span id=\"pos_lat\">%.5f</span>°</em></p>\n", $params['latitude']);
130
       printf ("<p>longitude : <em><span id=\"pos_lon\">%.5f</span>°</em></p>\n", $params['longitude']);
131
       if (isset($params['altitude'])) printf ("<p>altitude : <em><span id=\"pos_alt\">%d</span> m</em></p>\n", $params['altitude']); 
132
       print("</div>\n");
133
       ?>
134
       <span id="loca"><img src="images/locapoint.svg" id="icone" onclick="showLoca()"/></span>
135
  <fieldset id="locadraw"><legend id="" onclick="hideLoca()">Localiser un point</legend>
136
    <form id="form_loca" method="post" name="form_localate" action="panorama.php?dir=<?php echo $_GET['dir'];?>&amp;panorama=<?php echo $_GET['panorama'];?>">
137
      <label class="form_col" title="La latitude ϵ [-90°, 90°]. Ex: 12.55257">Latitude :
138
        <input  name="loca_latitude" type="number" min="-90" max="90"  id="loca_latitude"/></label>
139
                 
140
      <label class="form_col" title="La longitude ϵ [-180°, 180°]. Ex: 144.14723">Longitude :
141
        <input name="loca_longitude" type="number" min="-180" max="180" id="loca_longitude"/></label>
142
              
143
      <label class="form_col" title="L'altitude positive Ex: 170">Altitude :
144
        <input  name="loca_altitude" type="number" min="-400" id="loca_altitude"/></label>
145
               
146
      <div class="answer">
147
        <input type="button" value="Localiser" id="loca_button" class="form_button"/> 
148
        <input type="reset" value="Reset" class="form_button"/>
149
        <input type="button" value="Effacer" class="form_button" id="loca_erase"/>
150
      </div>
151
              
152
    </form>
153
  </fieldset>
154
       <?php
155
     } elseif ($params == false ){
156
             $dir   = $_GET['dir'];
157
        $name  = $_GET['panorama'];
158
             ?>
159
       <div id="addParams">                
160
               <label onclick="showForm()" value="Hide label">Paramétrer le panorama</label>        
161
       </div>
162
       <fieldset id="adding"><legend id="lgd" onclick="hideForm()">Paramètrer le panorama</legend>
163
         <form action="addParams.php?dir=<?php echo $dir;?>&amp;panorama=<?php echo $name;?>" id="form_param" method="post">
164
                     
165
           <label class="form_col" for="param_title" title="Au moins 4 caractères">Titre: </label>
166
           <input type="text" id="param_title" name="param_title"/>
167
           
168
           <label class="form_col" for="param_latitude" title="La latitude ϵ [-90°, 90°]. Ex: 12.55257">Latitude: </label>
169
           <input  name="param_latitude" type="text" id="param_latitude" />
170
                 
171
           <label class="form_col" for="param_longitude" title="La longitude ϵ [-180°, 180°]. Ex: 144.14723">Longitude: </label>
172
           <input name="param_longitude" type="text" id="param_longitude" />
173
           
174
           <label class="form_col" for="param_altitude" title="L'altitude positive Ex: 170">Altitude: </label>
175
           <input  name="param_altitude" type="text" id="param_altitude" />
176
          
177
           <label class="form_col" for="param_elevation" title="élévation ϵ [-10,10] ( valeur par défaut : 0)">Elévation: </label>
178
           <input  name="param_elevation" type="text" id="param_elevation" />
179
           
180
           <label class="form_col" for="param_loop" title="L'image fait elle 360° ? ">Rebouclage: </label>
181
           <input class="radio" type="radio" name="param_loop" value="true" checked="checked"> Oui
182
           <input class="radio" type="radio" name="param_loop" value="false"> Non
183
           
184
           <input type="hidden" value="Localiser" id="loca_button" class="form_button" style="width:70px" /> 
185
           <input type="hidden" value="Effacer" class="form_button" id="loca_erase"/>
186
          
187
           <div class="answer">
188
             <input type="submit" value="Submit" class="form_button"/> 
189
             <input type="reset" value="Reset" class="form_button"/>
190
           </div>
191
              
192
           </form>
193
       </fieldset>
194
  
195
 
196
       <script src="js/pano_deroulant.js"></script> 
197
      
198
             <?php
199
     }
200
     echo '<p id="info"></p>'."\n";
201
     if (count($extra_names) > 1) {
202
       echo "<p id=\"insert\">\n<select id=\"sel_point\" name=\"known_points\">\n";
203
       foreach ($extra_names as $nm) {
204
         echo '<option>'.$nm."</option>\n";
205
       }
206
       echo "</select>\n<br/>";
207
       echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
208
       echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
209
       echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
210
       echo "</p>\n";
211
     }
212
     
213
     ?>
214
  <p class="validators"><a href="http://validator.w3.org/check?uri=referer">page xHTML validé !</a></p>
215
  <p id="res"></p>
216
</body>
217
</html>