Project

General

Profile

Paste
Download (1018 Bytes) Statistics
| Branch: | Revision:

root / ajax / all_points.php @ f0cea9c4

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" => [$values[1],$values[0]]
20
                                         ),
21
                     "properties" => array("name" => $name, "type" => 'loc_point')
22
                     );
23
}
24

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

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

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

    
38
echo json_encode($json);
39
?>