Projet

Général

Profil

Paste
Télécharger (8,76 ko) Statistiques
| Branche: | Révision:

root / panorama.php @ 0bd646e4

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

    
8
   $form_extpoint = <<<'EO_FORM_EXTPOINT'
9
<img src="images/locapoint.svg" id="loca_show" alt="localiser un point" title="pour localiser un point..."/>
10
<fieldset id="locadraw"><legend id="loca_hide">Localiser un point</legend>
11
  <label class="form_col" title="La latitude ϵ [-90°, 90°]. Ex: 12.55257">Latitude :
12
    <input  name="loca_latitude" type="number" min="-90" max="90"  id="loca_latitude"/></label>
13
  <label class="form_col" title="La longitude ϵ [-180°, 180°]. Ex: 144.14723">Longitude :
14
    <input name="loca_longitude" type="number" min="-180" max="180" id="loca_longitude"/></label>
15
  <label class="form_col" title="L'altitude positive Ex: 170">Altitude :
16
    <input  name="loca_altitude" type="number" min="-400" id="loca_altitude"/></label>
17
  <div class="answer">
18
    <input type="button" value="Localiser" id="loca_button"/> 
19
    <input type="button" value="Effacer" id="loca_erase"/>
20
  </div>
21
</fieldset>
22
EO_FORM_EXTPOINT;
23

    
24
   $form_param = <<<'EO_FORM_PARAM'
25
<div id="addParams">                
26
  <label id="paramFormShow">Paramétrer le panorama</label>        
27
</div>
28
     <form action="addParams.php?param_dir=%s&amp;param_panorama=%s" id="form_param" method="post">
29
  <fieldset id="adding"><legend id="paramFormHide">Paramétrage du panorama</legend>
30
    <label title="Au moins 4 caractères">Titre :
31
      <input type="text" pattern="^.{1,40}$" name="param_title" placeholder="%s" 
32
             title="ne doit pas contenir pus de 40 caractères" required=""/></label>
33
    <label title="La latitude ϵ [-90°, 90°]. Ex : 46.55257">Latitude :
34
      <input name="param_latitude" type="number" min="-90" max="90" placeholder="43.56" required="" step="any"/></label>
35
    <label title="La longitude ϵ [-180°, 180°]. Ex : 1.45">Longitude :
36
      <input name="param_longitude" type="number" min="-180" max="180" placeholder="1.45" required="" step="any"/></label>
37
    <label title="L'altitude exprmée en mètres et &gt; -400. Ex : 170">Altitude :
38
      <input name="param_altitude" type="number" min="-400" required="" placeholder="170" step="any"/></label>
39
    <label title="L'image fait-elle 360° ?">Rebouclage :
40
      <input type="checkbox" name="param_loop" value="true"></label>
41
    
42
    <div>
43
      <input type="submit" value="Submit"/> 
44
      <input type="reset" value="Reset"/>
45
    </div>
46
  </fieldset>
47
</form>
48
EO_FORM_PARAM;
49

    
50
   if (isset($_GET['dir']) && isset($_GET['panorama'])) {
51
     $dir   = $_GET['dir'];
52
     $name  = $_GET['panorama'];
53
   } else {
54
     $dir   = 'tiles';
55
     $name  = 'ttn_mediatheque';
56
   }
57
   $opt_vals = array();
58
   foreach(array('to_cap', 'to_ele', 'to_zoom') as $val) {
59
     if (!empty($_GET[$val])) $opt_vals[$val] = $_GET[$val];
60
   }
61

    
62
   $base_dir = $dir.'/'.$name;
63
   $pt = new site_point($base_dir);
64
   if(!$pt) die("impossible d'accéder à ".$base_dir." !\n");
65
   $params = $pt->get_params();
66
   $prefix = $pt->get_prefix();
67
  ?>
68
  <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
69
  <?php
70
     $titre = 'panorama';
71
     if ($params && isset($params['titre'])) $titre .= ' : '.$params['titre'];
72
     printf ("<title>%s</title>\n", $titre);
73
  ?>
74
  <script>
75
   <?php
76
     printf ("var img_prefix = '%s/%s'\n", $base_dir, $prefix);
77
     if (is_array($params)) $opt_vals = array_merge($params, $opt_vals);
78
     foreach(array('to_cap', 'to_ele', 'to_zoom', 'image_loop') as $val) {
79
        if (isset($opt_vals[$val])) printf ('var '.$val.' = '.$opt_vals[$val].";\n"); // correction du décalage angulaire par rapport au Nord
80
     }
81
  ?>
82
  </script>
83
  <script src="js/pano.js"></script>
84
  <script>
85
  <?php
86
     $zoom_array = $pt->get_magnifications();
87
     foreach($zoom_array as $zoom => $val) {
88
       echo "zooms[$zoom] = new tzoom($zoom);\n";
89
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
90
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
91
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
92
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
93
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
94
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
95
       echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
96
       echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
97
     }
98

    
99
   $dir_list = new sites_dir($dir);
100

    
101
   $ipt = 0;
102
   $scrname = getenv('SCRIPT_NAME');
103
   foreach($dir_list->get_sites() as $opt) {
104
     $prm = $opt->get_params();
105
     $oname = $opt->get_name();
106
     if ($oname != $name && isset($prm['latitude']) && isset($prm['longitude']) && isset($prm['altitude']) && isset($prm['titre'])) {
107
       list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
108
       $lnk = sprintf("%s?dir=%s&panorama=%s&to_cap=%.3f&to_ele=%.3f", $scrname, $dir, $oname, $cap + 180, -$ele);
109
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);
110
     }
111
   }
112

    
113
   include 'ref_points.php';
114
   $extra_names = array();
115
   $ref_names = array();
116
   if (is_array($ref_points)) {
117
     foreach ($ref_points as $name => $vals) {
118
       $extra_names[] = $name;
119
       list($dist, $cap, $ele) = $pt->coordsToCap($vals[0], $vals[1], $vals[2]);
120
       $ref_names[$name] = array($dist, $cap, $ele);
121
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "");'."\n", $ipt++, $name, $dist, $cap, $ele);
122
     }
123
   }
124
 
125

    
126
   if (isset($params['reference'])) {
127
     echo "ref_points = new Array();\n";
128
     foreach ($params['reference'] as $nm => $val) {
129
       if (isset($ref_names[$nm])) {
130
         list($dist, $cap, $ele) = $ref_names[$nm];
131
         list($px, $py) = explode(',', $val);
132
         printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
133
       }
134
     }
135
   }
136
  
137
   $localLat = (isset($_POST["loca_latitude"])) ? $_POST["loca_latitude"] : NULL;
138
   $localLon = (isset($_POST["loca_longitude"])) ? $_POST["loca_longitude"] : NULL;
139
   $localAlt = (isset($_POST["loca_altitude"])) ? $_POST["loca_altitude"] : NULL;
140
 
141
   if ($localLat && $localLon && $localAlt) {
142
     list($localDistance, $localCap, $localEle) = $pt->coordsToCap($localLat, $localLon, $localAlt);
143
     $n = "point temporaire";
144
     printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "temporary");'."\n",$ipt++, $n, $localDistance, $localCap, $localEle);
145
   } 
146
  ?>
147
  </script>
148
  <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
149
  <link rel="stylesheet" media="screen" href="css/map.css" />
150
  <script src="js/hide_n_showForm.js"></script> 
151
</head>
152
<body>
153
  <canvas id="mon-canvas">
154
    Ce message indique que ce navigateur est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
155
  </canvas>
156
  
157
  <fieldset id="control"><legend>contrôle</legend>
158
      <label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
159
      <label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl" step="any"/></label>
160
      <label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl" step="any"/></label>
161
  </fieldset>
162

    
163
  <?php
164
      
165
     if ($params && isset($params['latitude']) && isset($params['longitude'])) {
166
       print("<div id=\"params\">\n");
167
       printf ("<p>latitude :   <em><span id=\"pos_lat\">%.5f</span>°</em></p>\n", $params['latitude']);
168
       printf ("<p>longitude : <em><span id=\"pos_lon\">%.5f</span>°</em></p>\n", $params['longitude']);
169
       if (isset($params['altitude'])) printf ("<p>altitude : <em><span id=\"pos_alt\">%d</span> m</em></p>\n", $params['altitude']); 
170
       print("</div>\n");
171
       echo $form_extpoint;
172
     } elseif ($params == false ) {
173
             $dir   = $_GET['dir'];
174
        $name  = $_GET['panorama'];
175
        printf($form_param, $dir, $name, $name);
176
     }
177
     echo '<p id="info"></p>'."\n";
178
     if (count($extra_names) > 1) {
179
       echo "<p id=\"insert\">\n<select id=\"sel_point\" name=\"known_points\">\n";
180
       foreach ($extra_names as $nm) {
181
         echo '<option>'.$nm."</option>\n";
182
       }
183
       echo "</select>\n";
184
       echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
185
       echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
186
       echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
187
       echo "</p>\n";
188
     }
189
     
190
  ?>
191
  <p id="res"></p>
192
  <div class="validators">
193
    pages validées par
194
    <a href="http://validator.w3.org/check?uri=referer"><img src="images/valid_xhtml.svg" alt="Valid XHTML 1.1" title="xHTML 1.1 validé !"/></a>
195
    <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="images/valid_css.svg" alt="CSS validé !" title="CSS validé !"/></a>
196
  </div>
197
</body>
198
</html>