Révision c4802754
ID | c48027543bd05a2d13068349d1f431e2158d6d65 |
Parent | 812f173f |
Enfant | eb537a36 |
moved all_points webservice to use methods from site_point
Fichiers
- ajouté
- modifié
- copié
- renommé
- supprimé
Révisions
ajax/all_points.php | ||
---|---|---|
1 | 1 |
<?php |
2 |
require_once('../class/sites_dir.class.php'); |
|
3 | 2 |
require_once('../class/site_point.class.php'); |
4 | 3 |
|
5 | 4 |
function get_ref_points() { |
... | ... | |
24 | 23 |
} |
25 | 24 |
|
26 | 25 |
|
27 |
function site_point_to_geoJSONFeature($sp) { |
|
28 |
$prm = $sp->get_params(); |
|
29 |
$name = $sp->get_name(); |
|
30 |
$lat = floatval($prm['latitude']); |
|
31 |
$lon = floatval($prm['longitude']); |
|
32 |
//$alt = $prm['altitude']; |
|
33 |
//$title = $prm['titre']; |
|
34 |
|
|
35 |
return array("type" => "Feature", |
|
36 |
"geometry" => array( |
|
37 |
"type" => "Point", |
|
38 |
"coordinates" => [$lon, $lat] |
|
39 |
), |
|
40 |
"properties" => array("name" => $name, |
|
41 |
"type" => 'pano_point', |
|
42 |
"view_url" => $sp->get_url()) |
|
43 |
); |
|
44 |
} |
|
45 |
|
|
46 |
|
|
47 | 26 |
$json = array( |
48 | 27 |
"type" => "FeatureCollection", |
49 | 28 |
"features"=> array() |
... | ... | |
55 | 34 |
|
56 | 35 |
|
57 | 36 |
foreach(site_point::get_all() as $site_point) { |
58 |
$json['features'][] = site_point_to_geoJSONFeature($site_point);
|
|
37 |
$json['features'][] = $site_point->to_geoJSON();
|
|
59 | 38 |
} |
60 | 39 |
|
61 | 40 |
echo json_encode($json); |
class/site_point.class.php | ||
---|---|---|
140 | 140 |
return new site_point($pano_dir); |
141 | 141 |
} |
142 | 142 |
|
143 |
|
|
144 |
public function to_geoJSON() { |
|
145 |
$prm = $this->get_params(); |
|
146 |
$name = $this->get_name(); |
|
147 |
$lat = floatval($prm['latitude']); |
|
148 |
$lon = floatval($prm['longitude']); |
|
149 |
//$alt = $prm['altitude']; |
|
150 |
//$title = $prm['titre']; |
|
151 |
|
|
152 |
return array("type" => "Feature", |
|
153 |
"geometry" => array( |
|
154 |
"type" => "Point", |
|
155 |
"coordinates" => [$lon, $lat] |
|
156 |
), |
|
157 |
"properties" => array("name" => $name, |
|
158 |
"type" => 'pano_point', |
|
159 |
"view_url" => $this->get_url()) |
|
160 |
); |
|
161 |
} |
|
162 |
|
|
163 |
|
|
143 | 164 |
public static function get_all() { |
144 | 165 |
$panos = array_diff(scandir(PANORAMA_PATH), array('..', '.')); |
145 | 166 |
$pano_instances = array(); |
... | ... | |
148 | 169 |
} |
149 | 170 |
return $pano_instances; |
150 | 171 |
} |
172 |
|
|
151 | 173 |
} |