Projet

Général

Profil

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

root / panorama.php @ 598caaec

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>window.onload = load_pano</script>
48
  <script>
49
  <?php
50
     $zoom_array = $pt->get_magnifications();
51
     foreach($zoom_array as $zoom => $val) {
52
       echo "zooms[$zoom] = new tzoom($zoom);\n";
53
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
54
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
55
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
56
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
57
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
58
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
59
       echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
60
       echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
61
     }
62

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

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

    
92

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

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

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

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

    
130
  <?php
131

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

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