Projet

Général

Profil

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

root / panorama.php @ efce4ca2

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

    
129

    
130
   if (isset($params['reference'])) {
131
     echo "ref_points = new Array();\n";
132
     foreach ($params['reference'] as $nm => $val) {
133
       if (isset($ref_names[$nm])) {
134
         list($dist, $cap, $ele) = $ref_names[$nm];
135
         list($px, $py) = explode(',', $val);
136
         printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
137
       }
138
     }
139
   }
140

    
141
   $localLat = (isset($_POST["loca_latitude"])) ? $_POST["loca_latitude"] : NULL;
142
   $localLon = (isset($_POST["loca_longitude"])) ? $_POST["loca_longitude"] : NULL;
143
   $localAlt = (isset($_POST["loca_altitude"])) ? $_POST["loca_altitude"] : NULL;
144

    
145
   if ($localLat && $localLon && $localAlt) {
146
     list($localDistance, $localCap, $localEle) = $pt->coordsToCap($localLat, $localLon, $localAlt);
147
     $n = "point temporaire";
148
     printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "temporary");'."\n",$ipt++, $n, $localDistance, $localCap, $localEle);
149
   }
150
  ?>
151
  </script>
152
  <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
153
  <link rel="stylesheet" media="screen" href="css/map.css" />
154
  <script src="js/hide_n_showForm.js"></script>
155
</head>
156
<body>
157
  <canvas id="mon-canvas">
158
    Ce message indique que ce navigateur est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
159
  </canvas>
160

    
161
  <fieldset id="control"><legend>contrôle</legend>
162
      <label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
163
      <label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl"/></label>
164
      <label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl"/></label>
165
  </fieldset>
166

    
167
  <?php
168

    
169
     if ($params && isset($params['latitude']) && isset($params['longitude'])) {
170
       print("<div id=\"params\">\n");
171
       printf ("<p>latitude :   <em><span id=\"pos_lat\">%.5f</span>°</em></p>\n", $params['latitude']);
172
       printf ("<p>longitude : <em><span id=\"pos_lon\">%.5f</span>°</em></p>\n", $params['longitude']);
173
       if (isset($params['altitude'])) printf ("<p>altitude : <em><span id=\"pos_alt\">%d</span> m</em></p>\n", $params['altitude']);
174
       print("</div>\n");
175
       echo $form_extpoint;
176
     } elseif ($params == false ) {
177
             $dir   = $_GET['dir'];
178
        $name  = $_GET['panorama'];
179
        printf($form_param, $dir, $name, $name);
180
     }
181
     echo '<p id="info"></p>'."\n";
182

    
183
     echo "<p id=\"insert\">";
184
     if (count($extra_names) > 1) {
185
       echo "<select id=\"sel_point\" name=\"known_points\">\n";
186
       foreach ($extra_names as $nm) {
187
             echo '<option>'.$nm."</option>\n";
188
       }
189
       echo "</select>\n";
190
       echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
191
       echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
192
       echo "<input type=\"button\" id=\"show-cap\" value=\"visualiser cet axe sur OSM\"/>\n";
193
     } else {
194
       echo "Pas de point de reférénce connu, lisez le <em>README.md</em> pour en ajouter. \n";
195
     }
196
     echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
197
     echo "</p>\n";
198
  ?>
199
  <p id="res"></p>
200
  <div class="validators">
201
    page validée par
202
       <a href="http://validator.w3.org/check?uri=referer"><img src="images/valid_xhtml.svg" alt="Valid XHTML" title="xHTML validé !"/></a>
203
       <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="images/valid_css.svg" alt="CSS validé !" title="CSS validé !"/></a>
204
  </div>
205
</body>
206
</html>