1
|
<?php
|
2
|
require_once(dirname(__FILE__).'/../constants.inc.php');
|
3
|
require_once(dirname(__FILE__).'/GeoPoint.class.php');
|
4
|
|
5
|
class RefPoint extends GeoPoint {
|
6
|
static $all_ref_points_cache;
|
7
|
public $name;
|
8
|
public $lon;
|
9
|
public $lat;
|
10
|
public $ele;
|
11
|
|
12
|
public function __construct($name, $values) {
|
13
|
$this->name = $name;
|
14
|
$this->lat = $values[0];
|
15
|
$this->lon = $values[1];
|
16
|
$this->ele = $values[2];
|
17
|
}
|
18
|
|
19
|
public function get_lat() {
|
20
|
return $this->lat;
|
21
|
}
|
22
|
|
23
|
public function get_name() {
|
24
|
return $this->name;
|
25
|
}
|
26
|
|
27
|
public function get_lon() {
|
28
|
return $this->lon;
|
29
|
}
|
30
|
|
31
|
public static function load_if_needed() {
|
32
|
if (!isset(self::$all_ref_points_cache)) {
|
33
|
if (file_exists(REF_POINTS_PATH)) {
|
34
|
require(REF_POINTS_PATH);
|
35
|
self::$all_ref_points_cache = $ref_points;
|
36
|
return $ref_points;
|
37
|
} else {
|
38
|
return array();
|
39
|
}
|
40
|
}
|
41
|
return self::$all_ref_points_cache;
|
42
|
}
|
43
|
|
44
|
public static function get_all() {
|
45
|
self::load_if_needed();
|
46
|
$ref_points_objs = array();
|
47
|
foreach (self::$all_ref_points_cache as $name => $vals) {
|
48
|
$ref_points_objs[] = new RefPoint($name, $vals);
|
49
|
}
|
50
|
return $ref_points_objs;
|
51
|
}
|
52
|
|
53
|
public static function get($name) {
|
54
|
self::load_if_needed();
|
55
|
$values = self::$all_ref_points_cache[$name];
|
56
|
return new RefPoint($name, $values);
|
57
|
}
|
58
|
|
59
|
}
|
60
|
?>
|