Projet

Général

Profil

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

root / ajax / all_points.php @ 83478686

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
                include REF_POINTS_PATH;
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
$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
foreach(site_point::get_all(true) as $site_point) {
36
       $json['features'][] = $site_point->to_geoJSON();
37
}
38

    
39
echo json_encode($json);
40
?>