Projet

Général

Profil

Paste
Télécharger (1019 octets) Statistiques
| Branche: | Révision:

root / ajax / all_points.php @ fe12dd81

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

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

    
14

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

    
25

    
26
$json = array(
27
              "type" => "FeatureCollection",
28
              "features"=> array()
29
              );
30

    
31
foreach (get_ref_points() as $name => $vals) {
32
        $json['features'][] = ref_point_to_geoJSONFeature($name, $vals);
33
}
34

    
35

    
36
foreach(site_point::get_all(true) as $site_point) {
37
        $json['features'][] = $site_point->to_geoJSON();
38
}
39

    
40
echo json_encode($json);
41
?>