Projet

Général

Profil

Paste
Télécharger (6,94 ko) Statistiques
| Branche: | Révision:

root / panorama.php @ 4841125e

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 = file_get_contents('html/form_extpoint.html');
9

    
10
   $form_param = file_get_contents('html/form_param.html');
11

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

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

    
62
   $dir_list = new sites_dir($dir);
63

    
64
   $ipt = 0;
65
   $scrname = getenv('SCRIPT_NAME');
66
   foreach($dir_list->get_sites() as $opt) {
67
     $prm = $opt->get_params();
68
     $oname = $opt->get_name();
69
     if ($oname != $name && isset($prm['latitude']) && isset($prm['longitude']) && isset($prm['altitude']) && isset($prm['titre'])) {
70
       list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
71
       $lnk = sprintf("%s?dir=%s&panorama=%s&to_cap=%.3f&to_ele=%.3f", $scrname, $dir, $oname, $cap + 180, -$ele);
72
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);
73
     }
74
   }
75
   $ref_points = array ();
76
   $ref_points_filename = 'ref_points.local.php';
77
   if (file_exists($ref_points_filename)) {
78
     include $ref_points_filename;
79
   }
80
   $extra_names = array();
81
   $ref_names = array();
82
   if (is_array($ref_points)) {
83
     foreach ($ref_points as $name => $vals) {
84
       $extra_names[] = $name;
85
       list($dist, $cap, $ele) = $pt->coordsToCap($vals[0], $vals[1], $vals[2]);
86
       $ref_names[$name] = array($dist, $cap, $ele);
87
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "");'."\n", $ipt++, $name, $dist, $cap, $ele);
88
     }
89
   }
90

    
91

    
92
   if (isset($params['reference'])) {
93
     echo "ref_points = new Array();\n";
94
     foreach ($params['reference'] as $nm => $val) {
95
       if (isset($ref_names[$nm])) {
96
         list($dist, $cap, $ele) = $ref_names[$nm];
97
         list($px, $py) = explode(',', $val);
98
         printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
99
       }
100
     }
101
   }
102

    
103
   $localLat = (isset($_POST["loca_latitude"])) ? $_POST["loca_latitude"] : NULL;
104
   $localLon = (isset($_POST["loca_longitude"])) ? $_POST["loca_longitude"] : NULL;
105
   $localAlt = (isset($_POST["loca_altitude"])) ? $_POST["loca_altitude"] : NULL;
106

    
107
   if ($localLat && $localLon && $localAlt) {
108
     list($localDistance, $localCap, $localEle) = $pt->coordsToCap($localLat, $localLon, $localAlt);
109
     $n = "point temporaire";
110
     printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "temporary");'."\n",$ipt++, $n, $localDistance, $localCap, $localEle);
111
   }
112
  ?>
113
  </script>
114
  <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
115
  <link rel="stylesheet" media="screen" href="css/map.css" />
116
  <script src="js/hide_n_showForm.js"></script>
117
</head>
118
<body>
119
  <canvas id="mon-canvas">
120
    Ce message indique que ce navigateur est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
121
  </canvas>
122

    
123
  <fieldset id="control"><legend>contrôle</legend>
124
      <label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
125
      <label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl"/></label>
126
      <label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl"/></label>
127
  </fieldset>
128

    
129
  <?php
130

    
131
     if ($params && isset($params['latitude']) && isset($params['longitude'])) {
132
       print("<div id=\"params\">\n");
133
       printf ("<p>latitude :   <em><span id=\"pos_lat\">%.5f</span>°</em></p>\n", $params['latitude']);
134
       printf ("<p>longitude : <em><span id=\"pos_lon\">%.5f</span>°</em></p>\n", $params['longitude']);
135
       if (isset($params['altitude'])) printf ("<p>altitude : <em><span id=\"pos_alt\">%d</span> m</em></p>\n", $params['altitude']);
136
       print("</div>\n");
137
       echo $form_extpoint;
138
     } elseif ($params == false ) {
139
             $dir   = $_GET['dir'];
140
        $name  = $_GET['panorama'];
141
        printf($form_param, $dir, $name, $name);
142
     }
143
     echo '<p id="info"></p>'."\n";
144

    
145
     echo "<p id=\"insert\">";
146
     if (count($extra_names) > 1) {
147
       echo "<select id=\"sel_point\" name=\"known_points\">\n";
148
       foreach ($extra_names as $nm) {
149
             echo '<option>'.$nm."</option>\n";
150
       }
151
       echo "</select>\n";
152
       echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
153
       echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
154
       echo "<input type=\"button\" id=\"show-cap\" value=\"visualiser cet axe sur OSM\"/>\n";
155
     } else {
156
       echo "Pas de point de reférénce connu, lisez le <em>README.md</em> pour en ajouter. \n";
157
     }
158
     echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
159
     echo "</p>\n";
160
  ?>
161
  <p id="res"></p>
162
  <div class="validators">
163
    page validée par
164
       <a href="http://validator.w3.org/check?uri=referer"><img src="images/valid_xhtml.svg" alt="Valid XHTML" title="xHTML validé !"/></a>
165
       <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="images/valid_css.svg" alt="CSS validé !" title="CSS validé !"/></a>
166
  </div>
167
</body>
168
</html>