Projet

Général

Profil

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

root / ajax / all_points.php @ b6a05986

1
<?php
2
header("Content-type: application/json");
3

    
4
require_once('../class/site_point.class.php');
5

    
6
function get_ref_points() {
7
        if (file_exists(REF_POINTS_PATH)) {
8
                $ref_points = array();
9
                include REF_POINTS_PATH;
10
                return $ref_points;
11
        } else {
12
                return array();
13
        }
14
}
15

    
16

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

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

    
32
foreach (get_ref_points() as $name => $vals) {
33
        $json['features'][] = ref_point_to_geoJSONFeature($name, $vals);
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
?>