Projet

Général

Profil

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

root / panorama.php @ 2e2ebcb8

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 title = \"%s\"\n", $titre);
77
     printf ("var img_prefix = '%s/%s'\n", $base_dir, $prefix);
78
     if (is_array($params)) $opt_vals = array_merge($params, $opt_vals);
79
     foreach(array('to_cap', 'to_ele', 'to_zoom', 'image_loop') as $val) {
80
        if (isset($opt_vals[$val])) printf ('var '.$val.' = '.$opt_vals[$val].";\n"); // correction du décalage angulaire par rapport au Nord
81
     }
82
  ?>
83
  </script>
84
  <script src="js/pano.js"></script>
85
  <script>
86
  <?php
87
     $zoom_array = $pt->get_magnifications();
88
     foreach($zoom_array as $zoom => $val) {
89
       echo "zooms[$zoom] = new tzoom($zoom);\n";
90
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
91
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
92
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
93
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
94
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
95
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
96
       echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
97
       echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
98
     }
99

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

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

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

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

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