Projet

Général

Profil

Paste
Télécharger (1,68 ko) Statistiques
| Branche: | Révision:

root / ajax / all_points.php @ 812f173f

1
<?php
2
require_once('../class/sites_dir.class.php');
3
require_once('../class/site_point.class.php');
4

    
5
function get_ref_points() {
6
        $ref_points_filename = '../ref_points.local.php';
7
        if (file_exists($ref_points_filename)) {
8
                include $ref_points_filename;
9
                return $ref_points;
10
        } else {
11
                return array();
12
        }
13
}
14

    
15

    
16
function ref_point_to_geoJSONFeature($name, $values) {
17
        return array("type" => "Feature",
18
                     "geometry" => array(
19
                                         "type" => "Point",
20
                                         "coordinates" => [$values[1],$values[0]]
21
                                         ),
22
                     "properties" => array("name" => $name, "type" => 'loc_point')
23
                     );
24
}
25

    
26

    
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
$json = array(
48
              "type" => "FeatureCollection",
49
              "features"=> array()
50
              );
51

    
52
foreach (get_ref_points() as $name => $vals) {
53
        $json['features'][] = ref_point_to_geoJSONFeature($name, $vals);
54
}
55

    
56

    
57
foreach(site_point::get_all() as $site_point) {
58
        $json['features'][] = site_point_to_geoJSONFeature($site_point);
59
}
60

    
61
echo json_encode($json);
62
?>