-
Notifications
You must be signed in to change notification settings - Fork 1
/
panorama.php
190 lines (171 loc) · 7.36 KB
/
panorama.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<?php
require 'class/utils.class.php';
require_once 'constants.inc.php';
$fields_spec = array(
'panorama' => array('basename'),
'dir' => array(),//fixme
'to_cap' => array('numeric'),
'to_ele' => array('numeric'),
'to_zoom' => array('numeric')
);
$validator = new FormValidator($fields_spec);
$is_valid = $validator->validate($_GET);
if ($is_valid) {
$input = $validator->sane_values();
} else {
$validator->print_errors();
die();//fixme, could be cleaner
}
$form_extpoint = file_get_contents('html/form_extpoint.html');
$form_param = file_get_contents('html/form_param.html');
if (isset($input['dir']) && isset($input['panorama'])) {
$dir = $input['dir'];
$name = $input['panorama'];
} else {
$dir = PANORAMA_PATH;
$name = 'ttn_mediatheque';
}
$opt_vals = array();
foreach(array('to_cap', 'to_ele', 'to_zoom') as $val) {
if (!empty($input[$val])) $opt_vals[$val] = $input[$val];
}
$pt = site_point::get($input['panorama']);
$base_dir = $pt->tiles_url_prefix();
if(!$pt) die("impossible d'accéder à ".$base_dir." !\n");
$params = $pt->get_params();
$prefix = $pt->get_prefix();
?>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<?php
$titre = 'panorama';
if ($params && isset($params['titre'])) $titre .= ' : '.$params['titre'];
printf ("<title>%s</title>\n", $titre);
?>
<script>
<?php
printf ("var title = \"%s\";\n", $titre);
printf ("var img_prefix = '%s/%s';\n", $base_dir, $prefix);
if (is_array($params)) $opt_vals = array_merge($params, $opt_vals);
foreach(array('to_cap', 'to_ele', 'to_zoom', 'image_loop') as $val) {
if (isset($opt_vals[$val]))
printf ('var '.$val.' = '.utils::php2ini($opt_vals[$val]).";\n"); // correction du décalage angulaire par rapport au Nord
}
?>
</script>
<script src="js/pano.js"></script>
<script>window.onload = load_pano</script>
<script>
<?php
$zoom_array = $pt->get_magnifications();
foreach($zoom_array as $zoom => $val) {
echo "zooms[$zoom] = new tzoom($zoom);\n";
echo "zooms[$zoom].ntiles.x = ".$val['nx'].";\n";
echo "zooms[$zoom].ntiles.y = ".$val['ny'].";\n";
$size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, 0, 0));
echo "zooms[$zoom].tile.width = ".$size[0].";\n";
echo "zooms[$zoom].tile.height = ".$size[1].";\n";
$size = getimagesize(sprintf($base_dir.'/'.$prefix.'_%03d_%03d_%03d.jpg', $zoom, $val['nx']-1, $val['ny']-1));
echo "zooms[$zoom].last_tile.width = ".$size[0].";\n";
echo "zooms[$zoom].last_tile.height = ".$size[1].";\n";
}
$dir_list = new sites_dir($dir);
$ipt = 0;
foreach(site_point::get_all() as $opt) {
$prm = $opt->get_params();
$oname = $opt->get_name();
if (($oname != $name) && $opt->has_params()) {
list($dist, $cap, $ele) = $pt->coordsToCap($prm['latitude'], $prm['longitude'], $prm['altitude']);
// Looks back at the point from which we come.
$lnk = $opt->get_url($cap + 180, -$ele);
printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "%s");'."\n", $ipt++, $prm['titre'], $dist, $cap, $ele, $lnk);
}
}
$ref_points = array ();
$ref_points_filename = 'ref_points.local.php';
if (file_exists($ref_points_filename)) {
include $ref_points_filename;
}
$extra_names = array();
$ref_names = array();
if (is_array($ref_points)) {
foreach ($ref_points as $name => $vals) {
$extra_names[] = $name;
list($dist, $cap, $ele) = $pt->coordsToCap($vals[0], $vals[1], $vals[2]);
$ref_names[$name] = array($dist, $cap, $ele);
printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "");'."\n", $ipt++, $name, $dist, $cap, $ele);
}
}
if (isset($params['reference'])) {
echo "ref_points = new Array();\n";
foreach ($params['reference'] as $nm => $val) {
if (isset($ref_names[$nm])) {
list($dist, $cap, $ele) = $ref_names[$nm];
list($px, $py) = $val;
printf("ref_points[\"%s\"] = {x:%.5f, cap:%.5f, y:%.5f, ele:%.5f};\n", $nm, $px, $cap, $py, $ele);
}
}
}
$localLat = (isset($_POST["loca_latitude"])) ? $_POST["loca_latitude"] : NULL;
$localLon = (isset($_POST["loca_longitude"])) ? $_POST["loca_longitude"] : NULL;
$localAlt = (isset($_POST["loca_altitude"])) ? $_POST["loca_altitude"] : NULL;
if ($localLat && $localLon && $localAlt) {
list($localDistance, $localCap, $localEle) = $pt->coordsToCap($localLat, $localLon, $localAlt);
$n = "point temporaire";
printf('point_list[%d] = new Array("%s", %03lf, %03lf, %03lf, "temporary");'."\n",$ipt++, $n, $localDistance, $localCap, $localEle);
}
?>
</script>
<link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/>
<link rel="stylesheet" media="screen" href="css/map.css" />
<script src="js/hide_n_showForm.js"></script>
</head>
<body>
<canvas id="mon-canvas">
Ce message indique que ce navigateur est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
</canvas>
<fieldset id="control"><legend>contrôle</legend>
<label>Zoom : <input type="range" min="0" max="2" value="2" id="zoom_ctrl"/></label>
<label>Cap : <input type="number" min="0" max="360" step="10" value="0" autofocus="" id="angle_ctrl"/></label>
<label>Élévation : <input type="number" min="-90" max="90" step="1" value="0" autofocus="" id="elvtn_ctrl"/></label>
</fieldset>
<?php
if ($params && isset($params['latitude']) && isset($params['longitude'])) {
print("<div id=\"params\">\n");
printf ("<p>latitude : <em><span id=\"pos_lat\">%.5f</span>°</em></p>\n", $params['latitude']);
printf ("<p>longitude : <em><span id=\"pos_lon\">%.5f</span>°</em></p>\n", $params['longitude']);
if (isset($params['altitude'])) printf ("<p>altitude : <em><span id=\"pos_alt\">%d</span> m</em></p>\n", $params['altitude']);
print("</div>\n");
echo $form_extpoint;
} elseif ($params == false ) {
$dir = $input['dir'];
$name = $input['panorama'];
printf($form_param, $name, $name);
}
echo '<p id="info"></p>'."\n";
echo "<p id=\"insert\">";
if (count($extra_names) > 1) {
echo "<select id=\"sel_point\" name=\"known_points\">\n";
foreach ($extra_names as $nm) {
echo '<option>'.$nm."</option>\n";
}
echo "</select>\n";
echo "<input type=\"button\" id=\"do-insert\" value=\"insérer\"/>\n";
echo "<input type=\"button\" id=\"do-delete\" value=\"suppimer\"/>\n";
echo "<input type=\"button\" id=\"show-cap\" value=\"visualiser cet axe sur OSM\"/>\n";
} else {
echo "Pas de point de reférénce connu, lisez le <em>README.md</em> pour en ajouter. \n";
}
echo "<input type=\"button\" id=\"do-cancel\" value=\"annuler\"/>\n";
echo "</p>\n";
?>
<p id="res"></p>
<div class="validators">
page validée par
<a href="http://validator.w3.org/check?uri=referer"><img src="images/valid_xhtml.svg" alt="Valid XHTML" title="xHTML validé !"/></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="images/valid_css.svg" alt="CSS validé !" title="CSS validé !"/></a>
</div>
</body>
</html>