Projet

Général

Profil

Paste
Télécharger (7,36 ko) Statistiques
| Branche: | Révision:

root / panorama.php @ 7096d2f9

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('class/Tile.class.php');
7

    
8
   require_once 'constants.inc.php';
9

    
10
  $fields_spec = array(
11
    'panorama'   => array('basename'),
12
    'dir'        => array(),//fixme
13
    'to_cap'     => array('numeric'),
14
    'to_ele'     => array('numeric'),
15
    'to_zoom'     => array('numeric')
16
  );
17

    
18
  $validator = new FormValidator($fields_spec);
19
  $is_valid = $validator->validate($_GET);
20

    
21
  if ($is_valid) {
22
    $input = $validator->sane_values();
23
  } else {
24
    $validator->print_errors();
25
    die();//fixme, could be cleaner
26
  }
27

    
28
   $form_extpoint = file_get_contents('html/form_extpoint.html');
29

    
30
   $form_param = file_get_contents('html/form_param.html');
31

    
32
   if (isset($input['dir']) && isset($input['panorama'])) {
33
     $dir   = $input['dir'];
34
     $name  = $input['panorama'];
35
   } else {
36
     $dir   = PANORAMA_PATH;
37
     $name  = 'ttn_mediatheque';
38
   }
39
   $opt_vals = array();
40
   foreach(array('to_cap', 'to_ele', 'to_zoom') as $val) {
41
     if (!empty($input[$val])) $opt_vals[$val] = $input[$val];
42
   }
43

    
44
   $pt = site_point::get($input['panorama']);
45
   $base_dir = $pt->tiles_url_prefix();
46
   if(!$pt) die("impossible d'accéder à ".$base_dir." !\n");
47
   $params = $pt->get_params();
48
   $prefix = $pt->get_prefix();
49
  ?>
50
  <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
51
  <?php
52
     $titre = 'panorama';
53
     if ($params && isset($params['titre'])) $titre .= ' : '.$params['titre'];
54
     printf ("<title>%s</title>\n", $titre);
55
  ?>
56
  <script>
57
   <?php
58
     printf ("var title = \"%s\";\n", $titre);
59
     printf ("var img_prefix = '%s/%s';\n", $base_dir, $prefix);
60
     if (is_array($params)) $opt_vals = array_merge($params, $opt_vals);
61
     foreach(array('to_cap', 'to_ele', 'to_zoom', 'image_loop') as $val) {
62
        if (isset($opt_vals[$val]))
63
        printf ('var '.$val.' = '.utils::php2ini($opt_vals[$val]).";\n"); // correction du décalage angulaire par rapport au Nord
64
     }
65
  ?>
66
  </script>
67
  <script src="js/pano.js"></script>
68
  <script>window.onload = load_pano</script>
69
  <script>
70
  <?php
71
     $zoom_array = $pt->get_magnifications();
72
     foreach($zoom_array as $zoom => $val) {
73
       $first_tile = new Tile($pt, $zoom, 0, 0);
74
       $last_tile = new Tile($pt, $zoom, $val['nx']-1, $val['ny']-1);
75

    
76
       echo "zooms[$zoom] = new tzoom($zoom);\n";
77
       echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
78
       echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
79
       $size = $first_tile->dimensions();
80
       echo "zooms[$zoom].tile.width = ".$size[0].";\n";
81
       echo "zooms[$zoom].tile.height = ".$size[1].";\n";
82
       // Last tile usually have a "remainder" size
83
       $last_size = $last_tile->dimensions();
84
       echo "zooms[$zoom].last_tile.width = ".$last_size[0].";\n";
85
       echo "zooms[$zoom].last_tile.height = ".$last_size[1].";\n";
86
     }
87
   $dir_list = new sites_dir($dir);
88

    
89
   $ipt = 0;
90
   foreach(site_point::near_points($pt, MAX_SEEING_DISTANCE) as $opt) {
91
     $prm = $opt->get_params();
92
     $oname = $opt->get_name();
93
     if (($oname != $name) && $opt->has_params()) {
94
       list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
95
       // Looks back at the point from which we come.
96
       $lnk = $opt->get_url($cap + 180, -$ele);
97
       printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);
98
     }
99
   }
100

    
101
   $extra_names = array();
102
   $ref_names = array();
103
   foreach (RefPoint::near_points($pt, MAX_SEEING_DISTANCE) as $ref) {
104
     $extra_names[] = $ref->name;
105
     list($dist, $cap, $ele) = $pt->coordsToCap($ref->lon, $ref->lat,
106
                                                $ref->ele);
107
     $ref_names[$name] = array($dist, $cap, $ele);
108
     printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "");'."\n", $ipt++, $ref->name, $dist, $cap, $ele);
109
     }
110

    
111
   if (isset($params['reference'])) {
112
     echo "ref_points = new Array();\n";
113
     foreach ($params['reference'] as $nm => $val) {
114
       if (isset($ref_names[$nm])) {
115
         list($dist, $cap, $ele) = $ref_names[$nm];
116
         list($px, $py) = $val;
117
         printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
118
       }
119
     }
120
   }
121

    
122
   $localLat = (isset($_POST["loca_latitude"])) ? $_POST["loca_latitude"] : NULL;
123
   $localLon = (isset($_POST["loca_longitude"])) ? $_POST["loca_longitude"] : NULL;
124
   $localAlt = (isset($_POST["loca_altitude"])) ? $_POST["loca_altitude"] : NULL;
125

    
126
   if ($localLat && $localLon && $localAlt) {
127
     list($localDistance, $localCap, $localEle) = $pt->coordsToCap($localLat, $localLon, $localAlt);
128
     $n = "point temporaire";
129
     printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "temporary");'."\n",$ipt++, $n, $localDistance, $localCap, $localEle);
130
   }
131
  ?>
132
  </script>
133
  <link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
134
  <link rel="stylesheet" media="screen" href="css/map.css" />
135
  <script src="js/hide_n_showForm.js"></script>
136
</head>
137
<body>
138
  <canvas id="mon-canvas">
139
    Ce message indique que ce navigateur est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
140
  </canvas>
141

    
142
  <fieldset id="control"><legend>contrôle</legend>
143
      <label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
144
      <label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl"/></label>
145
      <label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl"/></label>
146
  </fieldset>
147

    
148
  <?php
149

    
150
     if ($params && isset($params['latitude']) && isset($params['longitude'])) {
151
       print("<div id=\"params\">\n");
152
       printf ("<p>latitude :   <em><span id=\"pos_lat\">%.5f</span>°</em></p>\n", $params['latitude']);
153
       printf ("<p>longitude : <em><span id=\"pos_lon\">%.5f</span>°</em></p>\n", $params['longitude']);
154
       if (isset($params['altitude'])) printf ("<p>altitude : <em><span id=\"pos_alt\">%d</span> m</em></p>\n", $params['altitude']);
155
       print("</div>\n");
156
       echo $form_extpoint;
157
     } elseif ($params == false ) {
158
             $dir   = $input['dir'];
159
        $name  = $input['panorama'];
160
        printf($form_param, $name, $name);
161
     }
162
     echo '<p id="info"></p>'."\n";
163

    
164
     echo "<p id=\"insert\">";
165
     if (count($extra_names) > 0) {
166
       echo "<select id=\"sel_point\" name=\"known_points\">\n";
167
       foreach ($extra_names as $nm) {
168
             echo '<option>'.$nm."</option>\n";
169
       }
170
       echo "</select>\n";
171
       echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
172
       echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
173
       echo "<input type=\"button\" id=\"show-cap\" value=\"visualiser cet axe sur OSM\"/>\n";
174
     } else {
175
       echo "Pas de point de reférénce connu, lisez le <em>README.md</em> pour en ajouter. \n";
176
     }
177
     echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
178
     echo "</p>\n";
179
  ?>
180
  <p id="res"></p>
181
  <div class="validators">
182
    page validée par
183
       <a href="http://validator.w3.org/check?uri=referer"><img src="images/valid_xhtml.svg" alt="Valid XHTML" title="xHTML validé !"/></a>
184
       <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="images/valid_css.svg" alt="CSS validé !" title="CSS validé !"/></a>
185
  </div>
186
</body>
187
</html>