Projet

Général

Profil

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

root / ajax / all_points.php @ 9f05628b

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

    
4
function get_ref_points() {
5
        if (file_exists(REF_POINTS_PATH)) {
6
                include REF_POINTS_PATH;
7
                return $ref_points;
8
        } else {
9
                return array();
10
        }
11
}
12

    
13

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

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

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

    
33
foreach(site_point::get_all(true) as $site_point) {
34
       $json['features'][] = $site_point->to_geoJSON();
35
}
36

    
37
echo json_encode($json);
38
?>