Projet

Général

Profil

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

root / panorama.php @ d4e538ff

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
   require_once 'constants.inc.php';
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   = PANORAMA_PATH;
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

    
52
     foreach($zoom_array as $zoom => $val) {
53
       echo "zooms[$zoom] = new tzoom($zoom);\n";
54
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
55
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
56
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
57
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
58
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
59
       $size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
60
       echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
61
       echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
62
     }
63

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

    
66
   $ipt = 0;
67
  foreach(site_point::get_all() as $opt) {
68
     $prm = $opt->get_params();
69
     $oname = $opt->get_name();
70
     if (($oname != $name) && $opt->has_params()) {
71
       list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
72
       // Looks back at the point from which we come.
73
       $lnk = $opt->get_url($cap + 180, -$ele);
74
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);
75
     }
76
   }
77

    
78
   $ref_points = array ();
79
   $ref_points_filename = 'ref_points.local.php';
80
   if (file_exists($ref_points_filename)) {
81
     include $ref_points_filename;
82
   }
83
   $extra_names = array();
84
   $ref_names = array();
85
   if (is_array($ref_points)) {
86
     foreach ($ref_points as $name => $vals) {
87
       $extra_names[] = $name;
88
       list($dist, $cap, $ele) = $pt->coordsToCap($vals[0], $vals[1], $vals[2]);
89
       $ref_names[$name] = array($dist, $cap, $ele);
90
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "");'."\n", $ipt++, $name, $dist, $cap, $ele);
91
     }
92
   }
93

    
94

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

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

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

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

    
132
  <?php
133

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

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